X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=actions%2Fshownotice.php;h=b6d0625e13ec0f86c43ef11138e7476c54611661;hb=98b3f5ea919881209692ade2a0143de72d096dfb;hp=7127a60db4c216104223f51aabd5efb6e38698e3;hpb=7b8fc701e0f27114e310dcae53c6a727ab05254b;p=quix0rs-gnu-social.git diff --git a/actions/shownotice.php b/actions/shownotice.php index 7127a60db4..b6d0625e13 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -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(); @@ -103,6 +88,7 @@ class ShownoticeAction extends OwnerDesignAction } if (!$this->notice->inScope($curProfile)) { + // TRANS: Client exception thrown when trying a view a notice the user has no access to. throw new ClientException(_('Not available.'), 403); } @@ -121,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? *