Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

+4 -5
View File
@@ -1,13 +1,12 @@
<?php
/**
* @brief Poll Votes Filter Iterator
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage
* @since 21 Aug 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\Poll;
+139 -8
View File
@@ -1,12 +1,11 @@
<?php
/**
* @brief Poll Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 10 Jan 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS;
@@ -79,6 +78,33 @@ class _Poll extends \IPS\Patterns\ActiveRecord implements \SplSubject
{
return \IPS\DateTime::ts( $this->_data['start_date'] );
}
/**
* Poll load - We do this so that we can close the poll in realtime when it's viewed.
*
* @see \IPS\Db::build
* @param int|string $id ID
* @param string $idField The database column that the $id parameter pertains to (NULL will use static::$databaseColumnId)
* @param mixed $extraWhereClause Additional where clause(s) (see \IPS\Db::build for details) - if used will cause multiton store to be skipped and a query always ran
* @return static
* @throws \InvalidArgumentException
* @throws \OutOfRangeException
*/
public static function load( $id, $idField=NULL, $extraWhereClause=NULL )
{
$poll = parent::load( $id, $idField, $extraWhereClause );
if( $poll->poll_close_date instanceof \IPS\DateTime )
{
if( !$poll->poll_closed and $poll->poll_close_date < \IPS\DateTime::create() )
{
$poll->poll_closed = 1;
$poll->save();
}
}
return $poll;
}
/**
* Set choices
@@ -90,6 +116,49 @@ class _Poll extends \IPS\Patterns\ActiveRecord implements \SplSubject
{
$this->_data['choices'] = json_encode( $value );
}
/**
* @brief Poll close date \IPS\DateTime object
*/
protected $_pollCloseDateObject = null;
/**
* Get Poll Close Date
*
* @return \IPS\DateTime
*/
public function get_poll_close_date()
{
if( $this->_pollCloseDateObject instanceof \IPS\DateTime )
{
return $this->_pollCloseDateObject;
}
elseif( $this->_data['poll_close_date'] == -1 )
{
return $this->_data['poll_close_date'];
}
return $this->_pollCloseDateObject = \IPS\DateTime::ts( $this->_data['poll_close_date'] );
}
/**
* Set Poll Close Date
*
* @param \IPS\DateTime|int $date
* @return void
*/
public function set_poll_close_date( $date )
{
if( $date instanceof \IPS\DateTime )
{
$this->changed['poll_close_date'] = $this->_data['poll_close_date'] = $date->getTimestamp();
$this->_pollCloseDateObject = $date;
return;
}
$this->_pollCloseDateObject = null;
$this->_data['poll_close_date'] = $date;
}
/**
* Get choices
@@ -110,7 +179,7 @@ class _Poll extends \IPS\Patterns\ActiveRecord implements \SplSubject
{
return \IPS\Member::load( $this->starter_id );
}
/**
* Set Choices
*
@@ -175,9 +244,70 @@ class _Poll extends \IPS\Patterns\ActiveRecord implements \SplSubject
}
$this->choices = $choices;
/* Poll Close Date */
if( isset( $data['poll_close_date'] ) && isset( $data['has_close_date'] ) )
{
try
{
$timezone = $this->options['timezone'] ?: ( \IPS\Member::loggedIn()->timezone ? new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) : NULL );
}
catch ( \Exception $e )
{
$timezone = NULL;
}
$time = ' 24:00';
if( isset( $data['poll_close_time'] ) and !empty( $data['poll_close_time'] ) )
{
$time = ' ' . $data['poll_close_time'];
}
$closeDate = new \IPS\DateTime( \IPS\Helpers\Form\Date::_convertDateFormat( $data['poll_close_date'] ) . $time, $timezone );
$this->poll_close_date = $closeDate;
/* Close date is in the past, make sure the poll is closed */
if( $closeDate < \IPS\DateTime::create() )
{
$this->poll_closed = 1;
}
}
else
{
/* Reset the close date, in the event the poll was edited and the close date removed */
$this->poll_close_date = -1;
}
/* Set the number of voters */
$this->recountVotes();
}
/**
* Member can close poll?
*
* @param \IPS\Member|NULL $member Member or NULL for currently logged in member
* @return void
*/
public function canClose( \IPS\Member $member = NULL )
{
$member = $member ?: \IPS\Member::loggedIn();
if( !$member->member_id )
{
return FALSE;
}
if( $member->modPermission('can_close_polls') )
{
return TRUE;
}
if( !( $member->group['g_close_polls'] and $member->member_id == $this->starter_id ) )
{
return FALSE;
}
return TRUE;
}
/**
* Member can vote?
@@ -250,7 +380,8 @@ class _Poll extends \IPS\Patterns\ActiveRecord implements \SplSubject
$vote->save();
$this->notify();
// Associate the vote with the member id in the cache
// If $vote is not associated with the member_id in the vote cache on vote submit the poll will not show until
// next page refresh. This forces the page to reload and the poll to show.
$this->_voteCache[ $member->member_id ] = $vote;
/* Log */
@@ -360,7 +491,7 @@ class _Poll extends \IPS\Patterns\ActiveRecord implements \SplSubject
{
try
{
/* Pre IPS4 data can be bad */
/* Pre 4.x data can be bad */
if ( !is_array( $this->choices ) || !count( $this->choices ) )
{
return '';
+4 -5
View File
@@ -1,12 +1,11 @@
<?php
/**
* @brief Poll Question
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 4 Dec 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\Poll;
+4 -5
View File
@@ -1,12 +1,11 @@
<?php
/**
* @brief Poll Vote Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 10 Jan 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\Poll;