X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2FPoll%2FPoll.php;h=0c274341b2bbca204e32fed2b6c8b1cedf14690f;hb=c97048d01bea468e0cf8865b60c3c250b4515c39;hp=f5143c3e573cf60ab8393078bd33c66c5784cde3;hpb=e085ef5ef5c9f8f5a13877bce84bc094eb6a5a34;p=quix0rs-gnu-social.git
diff --git a/plugins/Poll/Poll.php b/plugins/Poll/Poll.php
index f5143c3e57..0c274341b2 100644
--- a/plugins/Poll/Poll.php
+++ b/plugins/Poll/Poll.php
@@ -64,7 +64,6 @@ class Poll extends Managed_DataObject
* @return User_greeting_count object found, or null for no hits
*
*/
-
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Poll', $k, $v);
@@ -82,7 +81,6 @@ class Poll extends Managed_DataObject
* @return Bookmark object found, or null for no hits
*
*/
-
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Poll', $kv);
@@ -117,7 +115,6 @@ class Poll extends Managed_DataObject
*
* @return Poll found poll or null
*/
-
function getByNotice($notice)
{
return self::staticGet('uri', $notice->uri);
@@ -128,6 +125,23 @@ class Poll extends Managed_DataObject
return explode("\n", $this->options);
}
+ /**
+ * Is this a valid selection index?
+ *
+ * @param numeric $selection (1-based)
+ * @return boolean
+ */
+ function isValidSelection($selection)
+ {
+ if ($selection != intval($selection)) {
+ return false;
+ }
+ if ($selection < 1 || $selection > count($this->getOptions())) {
+ return false;
+ }
+ return true;
+ }
+
function getNotice()
{
return Notice::staticGet('uri', $this->uri);
@@ -192,7 +206,6 @@ class Poll extends Managed_DataObject
*
* @return Notice saved notice
*/
-
static function saveNew($profile, $question, $opts, $options=null)
{
if (empty($options)) {
@@ -222,12 +235,15 @@ class Poll extends Managed_DataObject
common_log(LOG_DEBUG, "Saving poll: $p->id $p->uri");
$p->insert();
- $content = sprintf(_m('Poll: %s %s'),
+ // TRANS: Notice content creating a poll.
+ // TRANS: %1$s is the poll question, %2$s is a link to the poll.
+ $content = sprintf(_m('Poll: %1$s %2$s'),
$question,
$p->uri);
- $rendered = sprintf(_m('Poll: %s'),
- htmlspecialchars($p->uri),
- htmlspecialchars($question));
+ $link = '' . htmlspecialchars($question) . '';
+ // TRANS: Rendered version of the notice content creating a poll.
+ // TRANS: %s is a link to the poll with the question as link description.
+ $rendered = sprintf(_m('Poll: %s'), $link);
$tags = array('poll');
$replies = array();