X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FPoll%2FPoll_response.php;h=a4ea999933ecdd146a7a80070d17cd9f355c8217;hb=90d35885aeed68b11a80225ff255b6ac70a349b9;hp=b5204c71f0719ac651b44c80dedc2fb6072871be;hpb=e085ef5ef5c9f8f5a13877bce84bc094eb6a5a34;p=quix0rs-gnu-social.git diff --git a/plugins/Poll/Poll_response.php b/plugins/Poll/Poll_response.php index b5204c71f0..a4ea999933 100644 --- a/plugins/Poll/Poll_response.php +++ b/plugins/Poll/Poll_response.php @@ -42,7 +42,6 @@ if (!defined('STATUSNET')) { * * @see DB_DataObject */ - class Poll_response extends Managed_DataObject { public $__table = 'poll_response'; // table name @@ -63,7 +62,6 @@ class Poll_response extends Managed_DataObject * @return User_greeting_count object found, or null for no hits * */ - function staticGet($k, $v=null) { return Memcached_DataObject::staticGet('Poll_response', $k, $v); @@ -81,7 +79,6 @@ class Poll_response extends Managed_DataObject * @return Bookmark object found, or null for no hits * */ - function pkeyGet($kv) { return Memcached_DataObject::pkeyGet('Poll_response', $kv); @@ -120,7 +117,6 @@ class Poll_response extends Managed_DataObject * * @return Poll_response found response or null */ - function getByNotice($notice) { return self::staticGet('uri', $notice->uri); @@ -141,6 +137,14 @@ class Poll_response extends Managed_DataObject return $this->getNotice()->bestUrl(); } + /** + * + * @return Poll + */ + function getPoll() + { + return Poll::staticGet('id', $this->poll_id); + } /** * Save a new poll notice * @@ -151,17 +155,17 @@ class Poll_response extends Managed_DataObject * * @return Notice saved notice */ - static function saveNew($profile, $poll, $selection, $options=null) { if (empty($options)) { $options = array(); } - $opts = $poll->getOptions(); - if ($selection < 1 || $selection > count($opts)) { + if (!$poll->isValidSelection($selection)) { + // TRANS: Client exception thrown when responding to a poll with an invalid option. throw new ClientException(_m('Invalid poll selection.')); } + $opts = $poll->getOptions(); $answer = $opts[$selection - 1]; $pr = new Poll_response(); @@ -186,11 +190,14 @@ class Poll_response extends Managed_DataObject common_log(LOG_DEBUG, "Saving poll response: $pr->id $pr->uri"); $pr->insert(); + // TRANS: Notice content voting for a poll. + // TRANS: %s is the chosen option in the poll. $content = sprintf(_m('voted for "%s"'), $answer); - $rendered = sprintf(_m('voted for “%s”'), - htmlspecialchars($poll->uri), - htmlspecialchars($answer)); + $link = '' . htmlspecialchars($answer) . ''; + // TRANS: Rendered version of the notice content voting for a poll. + // TRANS: %s a link to the poll with the chosen option as link description. + $rendered = sprintf(_m('voted for "%s"'), $link); $tags = array(); $replies = array();