Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -644,18 +644,19 @@ class _Poll extends \IPS\Patterns\ActiveRecord implements \SplSubject
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string title Title
|
||||
* @apiresponse int votes Number of votes
|
||||
* @apiresponse [\IPS\Poll\Question] questions The questions
|
||||
*/
|
||||
public function apiOutput()
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
$questions = array();
|
||||
foreach ( $this->choices as $choice )
|
||||
{
|
||||
$questions[] = ( new \IPS\Poll\Question( $choice ) )->apiOutput();
|
||||
$questions[] = ( new \IPS\Poll\Question( $choice ) )->apiOutput( $authorizedMember );
|
||||
}
|
||||
|
||||
return array(
|
||||
|
||||
@@ -41,11 +41,12 @@ class _Question
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse string question The question
|
||||
* @apiresponse object options Each of the options and how many votes they have had
|
||||
*/
|
||||
public function apiOutput()
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
return array(
|
||||
'question' => $this->data['question'],
|
||||
|
||||
+14
-12
@@ -150,24 +150,26 @@ class _Vote extends \IPS\Patterns\ActiveRecord
|
||||
$choices = $this->poll->choices;
|
||||
foreach ( $this->member_choices as $k => $v )
|
||||
{
|
||||
if ( is_array( $v ) )
|
||||
if ( isset( $choices[ $k ] ) ) // If the question has been deleted since this vote was cast, this won't be set
|
||||
{
|
||||
foreach ( $v as $key => $memberValues )
|
||||
if ( is_array( $v ) )
|
||||
{
|
||||
if ( $choices[ $k ]['votes'][ $memberValues ] > 0 )
|
||||
foreach ( $v as $key => $memberValues )
|
||||
{
|
||||
$choices[ $k ]['votes'][ $memberValues ]--;
|
||||
if ( $choices[ $k ]['votes'][ $memberValues ] > 0 )
|
||||
{
|
||||
$choices[ $k ]['votes'][ $memberValues ]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $choices[ $k ]['votes'][ $v ] > 0 )
|
||||
{
|
||||
$choices[ $k ]['votes'][ $v ]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $choices[ $k ]['votes'][ $v ] > 0 )
|
||||
{
|
||||
$choices[ $k ]['votes'][ $v ]--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$this->poll->choices = $choices;
|
||||
|
||||
Reference in new issue
Block a user