]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/deletenotice.php
Merge branch 'master' of git.gnu.io:gnu/gnu-social into nightly
[quix0rs-gnu-social.git] / actions / deletenotice.php
index 8f0211f8f9e638264a1b8d9a64a16ee49341203d..f0aa767916f551caaf6e44cbe3104b012124ef03 100644 (file)
@@ -33,15 +33,13 @@ if (!defined('GNUSOCIAL')) { exit(1); }
 // @todo FIXME: documentation needed.
 class DeletenoticeAction extends FormAction
 {
-    protected $form = 'deletenotice';
-
     protected $notice = null;
 
     protected function doPreparation()
     {
-        $this->notice = Notice::getByID($this->int('notice'));
+        $this->notice = Notice::getByID($this->trimmed('notice'));
 
-        if ($this->notice->profile_id != $this->scoped->getID() &&
+        if (!$this->scoped->sameAs($this->notice->getProfile()) &&
                    !$this->scoped->hasRight(Right::DELETEOTHERSNOTICE)) {
             // TRANS: Error message displayed trying to delete a notice that was not made by the current user.
             $this->clientError(_('Cannot delete this notice.'));
@@ -67,19 +65,13 @@ class DeletenoticeAction extends FormAction
     {
         if ($this->arg('yes')) {
             if (Event::handle('StartDeleteOwnNotice', array($this->scoped->getUser(), $this->notice))) {
-                $this->notice->delete();
+                $this->notice->deleteAs($this->scoped);
                 Event::handle('EndDeleteOwnNotice', array($this->scoped->getUser(), $this->notice));
             }
-        }
-
-        $url = common_get_returnto();
-
-        if ($url) {
-            common_set_returnto(null);
         } else {
-            $url = common_local_url('public');
+            common_redirect(common_get_returnto(), 303);
         }
 
-        common_redirect($url, 303);
+        common_redirect(common_local_url('top'), 303);
     }
 }