+ // TRANS: Application title.
+ return _m('APPTITLE','Poll');
+ }
+
+ function onStartAddNoticeReply($nli, $parent, $child)
+ {
+ // Filter out any poll responses
+ if ($parent->object_type == self::POLL_OBJECT &&
+ $child->object_type == self::POLL_RESPONSE_OBJECT) {
+ return false;
+ }
+ return true;
+ }
+
+ // Hide poll responses for @chuck
+
+ function onEndNoticeWhoGets($notice, &$ni) {
+ if ($notice->object_type == self::POLL_RESPONSE_OBJECT) {
+ foreach ($ni as $id => $source) {
+ $user = User::getKV('id', $id);
+ if (!empty($user)) {
+ $pollPrefs = User_poll_prefs::getKV('user_id', $user->id);
+ if (!empty($pollPrefs) && ($pollPrefs->hide_responses)) {
+ unset($ni[$id]);
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Menu item for personal subscriptions/groups area
+ *
+ * @param Action $action action being executed
+ *
+ * @return boolean hook return
+ */
+
+ function onEndAccountSettingsNav($action)
+ {
+ $action_name = $action->trimmed('action');
+
+ $action->menuItem(common_local_url('pollsettings'),
+ // TRANS: Poll plugin menu item on user settings page.
+ _m('MENU', 'Polls'),
+ // TRANS: Poll plugin tooltip for user settings menu item.
+ _m('Configure poll behavior'),
+ $action_name === 'pollsettings');
+
+ 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'));
+ }