- $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) {
+ 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;
+ }
+
+ $notice = Notice::saveNew($user->id, $content, 'web');
+
+ 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);