]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/newnotice.php
Added missing isPrivateScope().
[quix0rs-gnu-social.git] / actions / newnotice.php
index d1e47fec5c095b994240f870d296be01303a7caf..ccc3f94fd4105ce86d76140937e55aa76d6eb048 100644 (file)
@@ -30,9 +30,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Action for posting new notices
@@ -62,6 +60,9 @@ class NewnoticeAction extends FormAction
             // TRANS: Page title after sending a notice.
             return _('Notice posted');
         }
+        if ($this->int('inreplyto')) {
+            return _m('TITLE', 'New reply');
+        }
         // TRANS: Page title for sending a new notice.
         return _m('TITLE','New notice');
     }
@@ -73,10 +74,14 @@ class NewnoticeAction extends FormAction
                 $this->formOpts[$opt] = $this->trimmed($opt);
             }
         }
+
+        // Backwards compatibility for "share this" widget things.
+        // If no 'content', use 'status_textarea'
+        $this->formOpts['content'] = $this->trimmed('content') ?: $this->trimmed('status_textarea');
     }
 
     /**
-     * This handlePost saves a new notice, based on arguments
+     * This doPost saves a new notice, based on arguments
      *
      * If successful, will show the notice, or return an Ajax-y result.
      * If not, it will show an error message -- possibly Ajax-y.
@@ -86,17 +91,15 @@ class NewnoticeAction extends FormAction
      *
      * @return void
      */
-    protected function handlePost()
+    protected function doPost()
     {
-        parent::handlePost();
-
-        assert($this->scoped); // XXX: maybe an error instead...
+        assert($this->scoped instanceof Profile); // XXX: maybe an error instead...
         $user = $this->scoped->getUser();
         $content = $this->trimmed('status_textarea');
         $options = array();
         Event::handle('StartSaveNewNoticeWeb', array($this, $user, &$content, &$options));
 
-        if (!$content) {
+        if (empty($content)) {
             // TRANS: Client error displayed trying to send a notice without content.
             $this->clientError(_('No content!'));
         }
@@ -106,7 +109,7 @@ class NewnoticeAction extends FormAction
         $cmd = $inter->handle_command($user, $content);
 
         if ($cmd) {
-            if (StatusNet::isAjax()) {
+            if (GNUsocial::isAjax()) {
                 $cmd->execute(new AjaxWebChannel($this));
             } else {
                 $cmd->execute(new WebChannel($this));
@@ -124,7 +127,7 @@ class NewnoticeAction extends FormAction
                                        Notice::maxContent()));
         }
 
-        $replyto = intval($this->trimmed('inreplyto'));
+        $replyto = $this->int('inreplyto');
         if ($replyto) {
             $options['reply_to'] = $replyto;
         }
@@ -191,7 +194,7 @@ class NewnoticeAction extends FormAction
 
         Event::handle('EndSaveNewNoticeWeb', array($this, $user, &$content_shortened, &$options));
 
-        if (!StatusNet::isAjax()) {
+        if (!GNUsocial::isAjax()) {
             $url = common_local_url('shownotice', array('notice' => $this->stored->id));
             common_redirect($url, 303);
         }