X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FPoll%2FPollPlugin.php;h=4f74e82a359da2048b4a7578de61b752e56f8bcc;hb=2c5cba28b6a8e13a58fe7584835340aa9779b146;hp=ff98bcfb307e745050fc1bd36550f70650378281;hpb=3cdc3134290c5efaf7dfaae94b3cd12b6ffa5a10;p=quix0rs-gnu-social.git diff --git a/plugins/Poll/PollPlugin.php b/plugins/Poll/PollPlugin.php index ff98bcfb30..4f74e82a35 100644 --- a/plugins/Poll/PollPlugin.php +++ b/plugins/Poll/PollPlugin.php @@ -86,11 +86,11 @@ class PollPlugin extends MicroAppPlugin /** * Map URLs to actions * - * @param Net_URL_Mapper $m path-to-action mapper + * @param URLMapper $m path-to-action mapper * * @return boolean hook value; true means continue processing, false means stop. */ - function onRouterInitialized($m) + public function onRouterInitialized(URLMapper $m) { $m->connect('main/poll/new', array('action' => 'newpoll')); @@ -120,12 +120,12 @@ class PollPlugin extends MicroAppPlugin * * @return value */ - function onPluginVersion(&$versions) + function onPluginVersion(array &$versions) { $versions[] = array('name' => 'Poll', 'version' => self::VERSION, 'author' => 'Brion Vibber', - 'homepage' => 'http://status.net/wiki/Plugin:Poll', + 'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/Poll', 'rawdescription' => // TRANS: Plugin description. _m('Simple extension for supporting basic polls.')); @@ -137,11 +137,6 @@ class PollPlugin extends MicroAppPlugin return array(self::POLL_OBJECT, self::POLL_RESPONSE_OBJECT); } - - function adaptNoticeListItem($nli) { - return new PollListItem($nli); - } - /** * When a notice is deleted, delete the related Poll * @@ -445,4 +440,27 @@ class PollPlugin extends MicroAppPlugin return true; } + + protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped=null) + { + if ($stored->object_type == self::POLL_RESPONSE_OBJECT) { + parent::showNoticeContent($stored, $out, $scoped); + return; + } + + // If the stored notice is a POLL_OBJECT + $poll = Poll::getByNotice($stored); + if ($poll instanceof Poll) { + if (!$scoped instanceof Profile || $poll->getResponse($scoped) instanceof Poll_response) { + // Either the user is not logged in or it has already responded; show the results. + $form = new PollResultForm($poll, $out); + } else { + $form = new PollResponseForm($poll, $out); + } + $form->show(); + } else { + // TRANS: Error text displayed if no poll data could be found. + $out->text(_m('Poll data is missing')); + } + } }