- $notice = DB_DataObject::factory('notice');
- assert($notice);
- $notice->profile_id = $user->id; # user id *is* profile id
- $notice->content = $this->arg('content');
- $notice->created = time();
- return $notice->insert();
+ $content = $this->trimmed('status_textarea');
+
+ if (!$content) {
+ $this->show_form(_('No content!'));
+ return;
+// } else if (mb_strlen($content) > 140) {
+ } else {
+ $content = common_shorten_links($content);
+
+ if (mb_strlen($content) > 140) {
+ common_debug("Content = '$content'", __FILE__);
+ common_debug("mb_strlen(\$content) = " . mb_strlen($content), __FILE__);
+ $this->show_form(_('That\'s too long. Max notice size is 140 chars.'));
+ return;
+ }
+ }
+
+ $inter = new CommandInterpreter();
+
+ $cmd = $inter->handle_command($user, $content);
+
+ if ($cmd) {
+ $cmd->execute(new WebChannel());
+ return;
+ }
+
+ $replyto = $this->trimmed('inreplyto');
+
+ common_debug("Replyto = $replyto\n");
+
+ $notice = Notice::saveNew($user->id, $content, 'web', 1, ($replyto == 'false') ? NULL : $replyto);
+
+ if (is_string($notice)) {
+ $this->show_form($notice);
+ return;
+ }
+
+ 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' => $notice->id));
+ }
+ common_redirect($url, 303);
+ }
+
+ function show_top($content=NULL) {
+ common_notice_form(NULL, $content);