Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
+20
-13
@@ -12,9 +12,16 @@
|
||||
namespace IPS\Poll;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use FilterIterator;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -22,45 +29,45 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
* Poll Votes Filter Iterator
|
||||
* @note When we require PHP 5.4+ this can just be replaced with a CallbackFilterIterator
|
||||
*/
|
||||
class _Iterator extends \FilterIterator
|
||||
class Iterator extends FilterIterator
|
||||
{
|
||||
/**
|
||||
* @brief Question
|
||||
*/
|
||||
protected $question;
|
||||
protected ?int $question = NULL;
|
||||
|
||||
/**
|
||||
* @brief Option
|
||||
*/
|
||||
protected $option;
|
||||
protected ?int $option = NULL;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Patterns\ActiveRecordIterator $iterator Iterator
|
||||
* @param ActiveRecordIterator $iterator Iterator
|
||||
* @param int|null $question Question
|
||||
* @param int|null $option Option
|
||||
* @param int|null $option Option
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\Patterns\ActiveRecordIterator $iterator, $question=NULL, $option=NULL )
|
||||
public function __construct(ActiveRecordIterator $iterator, int $question=NULL, int $option=NULL )
|
||||
{
|
||||
$this->question = $question;
|
||||
$this->option = $option;
|
||||
return parent::__construct( $iterator );
|
||||
parent::__construct( $iterator );
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this rule apply?
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function accept()
|
||||
public function accept() : bool
|
||||
{
|
||||
$row = $this->getInnerIterator()->current();
|
||||
|
||||
if ( \is_array( $row->member_choices[ $this->question ] ) )
|
||||
if ( is_array( $row->member_choices[ $this->question ] ) )
|
||||
{
|
||||
return (bool) \in_array( $this->option, $row->member_choices[ $this->question ] );
|
||||
return in_array( $this->option, $row->member_choices[ $this->question ] );
|
||||
}
|
||||
|
||||
return $row->member_choices[ $this->question ] == $this->option;
|
||||
|
||||
Reference in new issue
Block a user