+ $notice->created = DB_DataObject_Cast::dateTime();
+ # Default theme uses 'content' for something else
+ $notice->content = $this->trimmed('status_textarea');
+
+ if (!$notice->content) {
+ $this->show_form(_('No content!'));
+ return;
+ } else if (strlen($notice->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.'));
+ 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);
+ common_broadcast_notice($notice);
+
+ $returnto = $this->trimmed('returnto');
+ if ($returnto) {
+ $url = common_local_url($returnto,
+ array('nickname' => $user->nickname));
+ } else {
+ $url = common_local_url('shownotice',
+ array('notice' => $id));
+ }
+ common_redirect($url, 303);