forked from GNUsocial/gnu-social
[Poll] Store poll response to DB
This commit is contained in:
@@ -139,11 +139,29 @@ class Poll extends Entity
|
||||
return self::create(['question' => $question, 'options' => $options]);
|
||||
}
|
||||
|
||||
public function getOptionsArr()
|
||||
public function getOptionsArr(): array
|
||||
{
|
||||
return explode("\n", $this->options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a valid selection index?
|
||||
*
|
||||
* @param int $selection (1-based)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidSelection($selection): bool
|
||||
{
|
||||
if ($selection != (int) $selection) {
|
||||
return false;
|
||||
}
|
||||
if ($selection < 1 || $selection > count($this->getOptionsArr())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//from old version
|
||||
/**
|
||||
* Get a bookmark based on a notice
|
||||
@@ -159,26 +177,6 @@ class Poll extends Entity
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Is this a valid selection index?
|
||||
*
|
||||
* @param int $selection (1-based)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
/*
|
||||
public function isValidSelection($selection)
|
||||
{
|
||||
if ($selection != intval($selection)) {
|
||||
return false;
|
||||
}
|
||||
if ($selection < 1 || $selection > count($this->getOptions())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function getNotice()
|
||||
{
|
||||
|
Reference in New Issue
Block a user