]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Poll/showpoll.php
Consolidate common code in micro-apps custom notice type display actions.
[quix0rs-gnu-social.git] / plugins / Poll / showpoll.php
index d59d9e28f3489ec0f7295e879f5d5fb16ae8d7ef..edfe3fe245f8520105184c231a43ec2e40a2873d 100644 (file)
@@ -48,17 +48,8 @@ class ShowPollAction extends ShownoticeAction
 {
     protected $poll = null;
 
-    /**
-     * For initializing members of the class.
-     *
-     * @param array $argarray misc. arguments
-     *
-     * @return boolean true
-     */
-    function prepare($argarray)
+    function getNotice()
     {
-        OwnerDesignAction::prepare($argarray);
-
         $this->id = $this->trimmed('id');
 
         $this->poll = Poll::staticGet('id', $this->id);
@@ -68,43 +59,15 @@ class ShowPollAction extends ShownoticeAction
             throw new ClientException(_m('No such poll.'), 404);
         }
 
-        $this->notice = $this->poll->getNotice();
+        $notice = $this->poll->getNotice();
 
-        if (empty($this->notice)) {
+        if (empty($notice)) {
             // Did we used to have it, and it got deleted?
             // TRANS: Client exception thrown trying to view a non-existing poll notice.
             throw new ClientException(_m('No such poll notice.'), 404);
         }
 
-        $cur = common_current_user();
-
-        if (!empty($cur)) {
-            $curProfile = $cur->getProfile();
-        } else {
-            $curProfile = null;
-        }
-
-        if (!$this->notice->inScope($curProfile)) {
-            throw new ClientException(_('Not available.'), 403);
-        }
-
-        $this->user = User::staticGet('id', $this->poll->profile_id);
-
-        if (empty($this->user)) {
-            // TRANS: Client exception thrown trying to view a poll of a non-existing user.
-            throw new ClientException(_m('No such user.'), 404);
-        }
-
-        $this->profile = $this->user->getProfile();
-
-        if (empty($this->profile)) {
-            // TRANS: Server exception thrown trying to view a poll for a user for which the profile could not be loaded.
-            throw new ServerException(_m('User without a profile.'));
-        }
-
-        $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
-
-        return true;
+        return $notice;
     }
 
     /**