Version 5.0.6
This commit is contained in:
1 parent
a3a4a9ccbd
commit
b89858b2ff
1214 files changed
+92828
-14859
No files matched your search
+28
-15
@@ -15,6 +15,7 @@ namespace IPS;
|
||||
use DateTimeZone;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Events\Event;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Date;
|
||||
use IPS\Patterns\ActiveRecord;
|
||||
@@ -192,7 +193,12 @@ class Poll extends ActiveRecord implements SplSubject
|
||||
*/
|
||||
public function get_choices(): array
|
||||
{
|
||||
return json_decode( $this->_data['choices'], TRUE );
|
||||
if( isset( $this->_data['choices'] ) and $choices = json_decode( $this->_data['choices'], true ) )
|
||||
{
|
||||
return $choices;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,6 +312,9 @@ class Poll extends ActiveRecord implements SplSubject
|
||||
$this->poll_close_date = -1;
|
||||
}
|
||||
|
||||
/* Event */
|
||||
Event::fire( 'onCreateOrEdit', $this );
|
||||
|
||||
/* Set the number of voters */
|
||||
$this->recountVotes();
|
||||
}
|
||||
@@ -441,6 +450,9 @@ class Poll extends ActiveRecord implements SplSubject
|
||||
$this->recountVotes();
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/* Fire an event */
|
||||
Event::fire( 'onVote', $this, [ $vote ] );
|
||||
|
||||
/* Achievements */
|
||||
$member->achievementAction( 'core', 'VotePoll', $this );
|
||||
@@ -458,6 +470,9 @@ class Poll extends ActiveRecord implements SplSubject
|
||||
{
|
||||
/* Reset the cached count */
|
||||
$this->votes = Db::i()->select( 'COUNT(*)', 'core_voters', array( 'poll=?', $this->pid ) )->first();
|
||||
|
||||
/* Event */
|
||||
Event::fire( 'onVoteRecount', $this );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -586,25 +601,20 @@ class Poll extends ActiveRecord implements SplSubject
|
||||
}
|
||||
elseif( Member::loggedIn()->group['g_poll_results'] == 1 )
|
||||
{
|
||||
if ( isset( Request::i()->nullVote ) and Member::loggedIn()->member_id )
|
||||
{
|
||||
if ( ! $this->getVote() )
|
||||
{
|
||||
Session::i()->csrfCheck();
|
||||
$this->addVote( Vote::fromForm( NULL ) );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
elseif( Settings::i()->allow_result_view )
|
||||
/* If we already voted, let it through */
|
||||
if( $this->getVote() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
/* If we are submitting a null vote, add it and then let it through */
|
||||
if ( isset( Request::i()->nullVote ) and Member::loggedIn()->member_id )
|
||||
{
|
||||
/* If the setting is disabled, check if we have voted */
|
||||
return (bool) $this->getVote();
|
||||
Session::i()->csrfCheck();
|
||||
$this->addVote( Vote::fromForm( NULL ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@@ -762,5 +772,8 @@ class Poll extends ActiveRecord implements SplSubject
|
||||
|
||||
/* Delete records from voters table */
|
||||
Db::i()->delete( 'core_voters', array( 'poll=?', $this->pid ) );
|
||||
|
||||
/* Event */
|
||||
Event::fire( 'onDelete', $this );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user