]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/shownotice.php
Consolidate common code in micro-apps custom notice type display actions.
[quix0rs-gnu-social.git] / actions / shownotice.php
index 15358fd0826b1ae916b0e369fce35e838ffece95..b6d0625e13ec0f86c43ef11138e7476c54611661 100644 (file)
@@ -77,22 +77,7 @@ class ShownoticeAction extends OwnerDesignAction
             StatusNet::setApi(true);
         }
 
-        $id = $this->arg('notice');
-
-        $this->notice = Notice::staticGet('id', $id);
-
-        if (empty($this->notice)) {
-            // Did we used to have it, and it got deleted?
-            $deleted = Deleted_notice::staticGet($id);
-            if (!empty($deleted)) {
-                // TRANS: Client error displayed trying to show a deleted notice.
-                $this->clientError(_('Notice deleted.'), 410);
-            } else {
-                // TRANS: Client error displayed trying to show a non-existing notice.
-                $this->clientError(_('No such notice.'), 404);
-            }
-            return false;
-        }
+        $this->notice = $this->getNotice();
 
         $cur = common_current_user();
 
@@ -122,6 +107,33 @@ class ShownoticeAction extends OwnerDesignAction
         return true;
     }
 
+    /**
+     * Fetch the notice to show. This may be overridden by child classes to
+     * customize what we fetch without duplicating all of the prepare() method.
+     *
+     * @return Notice
+     */
+    function getNotice()
+    {
+        $id = $this->arg('notice');
+
+        $notice = Notice::staticGet('id', $id);
+
+        if (empty($notice)) {
+            // Did we used to have it, and it got deleted?
+            $deleted = Deleted_notice::staticGet($id);
+            if (!empty($deleted)) {
+                // TRANS: Client error displayed trying to show a deleted notice.
+                $this->clientError(_('Notice deleted.'), 410);
+            } else {
+                // TRANS: Client error displayed trying to show a non-existing notice.
+                $this->clientError(_('No such notice.'), 404);
+            }
+            return false;
+        }
+        return $notice;
+    }
+
     /**
      * Is this action read-only?
      *