summaryrefslogtreecommitdiff
path: root/actions/newnotice.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-07-29 22:28:56 -0400
committerEvan Prodromou <evan@prodromou.name>2008-07-29 22:28:56 -0400
commitd79dc8344b529281dfb8a8383c529720a429472b (patch)
tree33d4914a14e62b657a426520a5844340c187059b /actions/newnotice.php
parent44fb662efb0e664287863dfe106f332a83a2f622 (diff)
refactor notice-adding code to one static method on Notice
darcs-hash:20080730022856-84dde-f19e4ff5d5ae2603b63b8aebd8f878ec90b3ce22.gz
Diffstat (limited to 'actions/newnotice.php')
-rw-r--r--actions/newnotice.php39
1 files changed, 11 insertions, 28 deletions
diff --git a/actions/newnotice.php b/actions/newnotice.php
index 5f6a22484..8de6643a0 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -38,44 +38,27 @@ class NewnoticeAction extends Action {
$user = common_current_user();
assert($user); # XXX: maybe an error instead...
- $notice = new Notice();
- assert($notice);
- $notice->profile_id = $user->id; # user id *is* profile id
- $notice->is_local = 1;
- $notice->created = DB_DataObject_Cast::dateTime();
- # Default theme uses 'content' for something else
- $notice->content = $this->trimmed('status_textarea');
-
- if (!$notice->content) {
+ $content = $this->trimmed('status_textarea');
+
+ if (!$content) {
$this->show_form(_('No content!'));
return;
- } else if (strlen($notice->content) > 140) {
+ } else if (strlen($content) > 140) {
$this->show_form(_('That\'s too long. Max notice size is 140 chars.'));
return;
}
- $notice->rendered = common_render_content($notice->content, $notice);
-
- $id = $notice->insert();
-
- if (!$id) {
- common_server_error(_('Problem saving notice.'));
+ $notice = Notice::saveNew($user->id, $content, 'web');
+
+ if (is_string($notice)) {
+ $this->show_form($notice);
return;
}
-
- $orig = clone($notice);
- $notice->uri = common_notice_uri($notice);
-
- if (!$notice->update($orig)) {
- common_server_error(_('Problem saving notice.'));
- return;
- }
-
- common_save_replies($notice);
- $notice->saveTags();
+
common_broadcast_notice($notice);
-
+
$returnto = $this->trimmed('returnto');
+
if ($returnto) {
$url = common_local_url($returnto,
array('nickname' => $user->nickname));