Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -0,0 +1,257 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Achievement Action Extension: Answer a member in a Q&A Forum is marked as the best answer
|
||||
* @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/
|
||||
* @subpackage Forums
|
||||
* @since 18 Feb 2021
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\AchievementAction;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Achievement Action Extension: Answer a member in a Q&A Forum is marked as the best answer
|
||||
*/
|
||||
class _AnswerMarkedBest extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
{
|
||||
/**
|
||||
* Get filter form elements
|
||||
*
|
||||
* @param array|NULL $filters Current filter values (if editing)
|
||||
* @param \IPS\Http\Url $url The URL the form is being shown on
|
||||
* @return array
|
||||
*/
|
||||
public function filters( ?array $filters, \IPS\Http\Url $url ): array
|
||||
{
|
||||
return [
|
||||
'nodes' => new \IPS\Helpers\Form\Node( 'achievement_filter_AnswerMarkedBest_forum', ( $filters and isset( $filters['nodes'] ) and $filters['nodes'] ) ? $filters['nodes'] : NULL, FALSE, [
|
||||
'url' => $url,
|
||||
'class' => 'IPS\forums\Forum',
|
||||
'showAllNodes' => TRUE,
|
||||
'multiple' => TRUE,
|
||||
'permissionCheck' => function( $forum ) {
|
||||
return $forum->forums_bitoptions['bw_enable_answers'];
|
||||
}
|
||||
], NULL, \IPS\Member::loggedIn()->language()->addToStack('achievement_filter_AnswerMarkedBest_forum_prefix') ),
|
||||
'milestone' => new \IPS\Helpers\Form\Number( 'achievement_filter_AnswerMarkedBest_nth', ( $filters and isset( $filters['milestone'] ) and $filters['milestone'] ) ? $filters['milestone'] : 0, FALSE, [], NULL, \IPS\Member::loggedIn()->language()->addToStack('achievement_filter_nth_their'), \IPS\Member::loggedIn()->language()->addToStack('achievement_filter_AnswerMarkedBest_nth_suffix') )
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Format filter form values
|
||||
*
|
||||
* @param array $values The values from the form
|
||||
* @return array
|
||||
*/
|
||||
public function formatFilterValues( array $values ): array
|
||||
{
|
||||
$return = [];
|
||||
if ( isset( $values['achievement_filter_AnswerMarkedBest_forum'] ) )
|
||||
{
|
||||
$return['nodes'] = array_keys( $values['achievement_filter_AnswerMarkedBest_forum'] );
|
||||
}
|
||||
if ( isset( $values['achievement_filter_AnswerMarkedBest_nth'] ) )
|
||||
{
|
||||
$return['milestone'] = $values['achievement_filter_AnswerMarkedBest_nth'];
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Work out if the filters applies for a given action
|
||||
*
|
||||
* Important note for milestones: consider the context. This method is called by \IPS\Member::achievementAction(). If your code
|
||||
* calls that BEFORE making its change in the database (or there is read/write separation), you will need to add
|
||||
* 1 to the value being considered for milestones
|
||||
*
|
||||
* @param \IPS\Member $subject The subject member
|
||||
* @param array $filters The value returned by formatFilterValues()
|
||||
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
|
||||
* @return bool
|
||||
*/
|
||||
public function filtersMatch( \IPS\Member $subject, array $filters, $extra = NULL ): bool
|
||||
{
|
||||
if ( isset( $filters['nodes'] ) and !\in_array( $extra->container()->_id, $filters['nodes'] ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $filters['milestone'] ) )
|
||||
{
|
||||
$where = [
|
||||
[ 'member_id=? AND app=?', $extra->author()->member_id, 'forums' ],
|
||||
];
|
||||
if ( isset( $filters['nodes'] ) )
|
||||
{
|
||||
$where[] = [ \IPS\Db::i()->in( 'forum_id', $filters['nodes'] ) ];
|
||||
}
|
||||
$query = \IPS\Db::i()->select( 'COUNT(*)', 'core_solved_index', $where );
|
||||
if ( isset( $filters['nodes'] ) )
|
||||
{
|
||||
$query->join( 'forums_topics', 'core_solved_index.item_id=forums_topics.tid' );
|
||||
}
|
||||
if ( ( $query->first() + 1 ) < $filters['milestone'] )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the labels for the people this action might give awards to
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function awardOptions(): array
|
||||
{
|
||||
return [
|
||||
'subject' => 'achievement_filter_AnswerMarkedBest_poster',
|
||||
'other' => 'achievement_filter_AnswerMarkedBest_asker'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the "other" people we need to award =stuff to
|
||||
*
|
||||
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
|
||||
* @return array
|
||||
*/
|
||||
public function awardOther( $extra = NULL ): array
|
||||
{
|
||||
return [ $extra->item()->author() ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get identifier to prevent the member being awarded points for the same action twice
|
||||
* Must be unique within within of this domain, must not exceed 32 chars.
|
||||
*
|
||||
* @param \IPS\Member $subject The subject member
|
||||
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
|
||||
* @return string
|
||||
*/
|
||||
public function identifier( \IPS\Member $subject, $extra = NULL ): string
|
||||
{
|
||||
return (string) $extra->pid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a description for this action to show in the log
|
||||
*
|
||||
* @param string $identifier The identifier as returned by identifier()
|
||||
* @param array $actor If the member was the "subject", "other", or both
|
||||
* @return string
|
||||
*/
|
||||
public function logRow( string $identifier, array $actor ): string
|
||||
{
|
||||
$sprintf = [];
|
||||
try
|
||||
{
|
||||
$post = \IPS\forums\Topic\Post::load( $identifier );
|
||||
$sprintf = [ 'htmlsprintf' => [
|
||||
\IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $post->url(), TRUE, $post->item()->title, FALSE )
|
||||
] ];
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
$sprintf = [ 'sprintf' => [ \IPS\Member::loggedIn()->language()->addToStack('AchievementAction__AnswerMarkedBest_log_deleted') ] ];
|
||||
}
|
||||
|
||||
if ( \in_array( 'subject', $actor ) )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'AchievementAction__AnswerMarkedBest_log_subject', FALSE, $sprintf );
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'AchievementAction__AnswerMarkedBest_log_other', FALSE, $sprintf );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get "description" for rule
|
||||
*
|
||||
* @param \IPS\core\Achievements\Rule $rule The rule
|
||||
* @return string|null
|
||||
*/
|
||||
public function ruleDescription( \IPS\core\Achievements\Rule $rule ): ?string
|
||||
{
|
||||
$conditions = [];
|
||||
if ( isset( $rule->filters['milestone'] ) )
|
||||
{
|
||||
$conditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'achievements_title_filter_milestone', FALSE, [
|
||||
'htmlsprintf' => [
|
||||
\IPS\Theme::i()->getTemplate( 'achievements' )->ruleDescriptionBadge( 'milestone', \IPS\Member::loggedIn()->language()->addToStack( 'achievements_title_filter_milestone_nth', FALSE, [ 'pluralize' => [ $rule->filters['milestone'] ] ] ) )
|
||||
],
|
||||
'sprintf' => \IPS\Member::loggedIn()->language()->addToStack( 'best_answer_post', FALSE, [ 'strtolower' => TRUE ] )
|
||||
] );
|
||||
}
|
||||
if ( isset( $rule->filters['nodes'] ) )
|
||||
{
|
||||
$forumNames = [];
|
||||
foreach ( $rule->filters['nodes'] as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$forumNames[] = \IPS\forums\Forum::load( $id )->_title;
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
}
|
||||
if ( $forumNames )
|
||||
{
|
||||
$conditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'achievements_title_filter_location', FALSE, [
|
||||
'htmlsprintf' => [
|
||||
\IPS\Theme::i()->getTemplate( 'achievements' )->ruleDescriptionBadge( 'location',
|
||||
\count( $forumNames ) === 1 ? $forumNames[0] : \IPS\Member::loggedIn()->language()->addToStack( 'achievements_title_filter_location_val', FALSE, [ 'sprintf' => [
|
||||
\count( $forumNames ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( \IPS\forum\Forum::$nodeTitle, FALSE, [ 'strtolower' => TRUE ] )
|
||||
] ] ),
|
||||
\count( $forumNames ) === 1 ? NULL : $forumNames
|
||||
)
|
||||
],
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'achievements' )->ruleDescription(
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'AchievementAction__AnswerMarkedBest_title' ),
|
||||
$conditions
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rebuild data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function rebuildData()
|
||||
{
|
||||
return [ [
|
||||
'table' => 'core_solved_index',
|
||||
'pkey' => 'id',
|
||||
'date' => 'solved_date',
|
||||
'where' => [ [ 'app=?', 'forums' ] ],
|
||||
] ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the rebuild row
|
||||
*
|
||||
* @param array $row Row from database
|
||||
* @param array $data Data collected when starting rebuild [table, pkey...]
|
||||
* @return void
|
||||
*/
|
||||
public static function rebuildRow( $row, $data )
|
||||
{
|
||||
$post = \IPS\forums\Topic\Post::load( $row['comment_id'] );
|
||||
$post->author()->achievementAction( 'forums', 'AnswerMarkedBest', $post, \IPS\DateTime::ts( $row[ $data['date'] ] ) );
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,8 @@ class _Topics
|
||||
{
|
||||
$return['can_read_all_topics'] = 'YesNo';
|
||||
}
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'forums_forums', \IPS\Db::i()->bitwiseWhere( \IPS\forums\Forum::$bitOptions['forums_bitoptions'], 'bw_enable_answers' ) )->first() )
|
||||
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'forums_forums', '(' . \IPS\Db::i()->bitwiseWhere( \IPS\forums\Forum::$bitOptions['forums_bitoptions'], 'bw_enable_answers' ) . ') OR ( ' . \IPS\Db::i()->bitwiseWhere( \IPS\forums\Forum::$bitOptions['forums_bitoptions'], 'bw_enable_answers_moderator' ) . ' )' )->first() )
|
||||
{
|
||||
$return['can_set_best_answer'] = 'YesNo';
|
||||
}
|
||||
@@ -70,10 +71,10 @@ class _Topics
|
||||
*/
|
||||
public function onChange( $moderator, $changed )
|
||||
{
|
||||
if ( $changed === '*' or array_key_exists( 'can_read_all_topics', $changed ) )
|
||||
if ( $changed === '*' or array_key_exists( 'can_read_all_topics', $changed ) OR array_key_exists( 'forums', $changed ) )
|
||||
{
|
||||
$deleteFirst = TRUE;
|
||||
if ( $changed === '*' or $changed['can_read_all_topics'] == true )
|
||||
if ( $changed === '*' or !empty( $changed['can_read_all_topics'] ) )
|
||||
{
|
||||
$deleteFirst = FALSE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Overview statistics extension: Solved
|
||||
* @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 Forums
|
||||
* @since 01 Dec 2020
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\OverviewStatistics;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Overview statistics extension: Solved
|
||||
*/
|
||||
class _Solved
|
||||
{
|
||||
/**
|
||||
* @brief Which statistics page (activity or user)
|
||||
*/
|
||||
public $page = 'activity';
|
||||
|
||||
/**
|
||||
* Return the sub-block keys
|
||||
*
|
||||
* @note This is designed to allow one class to support multiple blocks, for instance using the ContentRouter to generate blocks.
|
||||
* @return array
|
||||
*/
|
||||
public function getBlocks()
|
||||
{
|
||||
return array( 'percentagesolved', 'averagetimesolved' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return block details (title and description)
|
||||
*
|
||||
* @param string|NULL $subBlock The subblock we are loading as returned by getBlocks()
|
||||
* @return array
|
||||
*/
|
||||
public function getBlockDetails( $subBlock = NULL )
|
||||
{
|
||||
switch( $subBlock )
|
||||
{
|
||||
case 'percentagesolved':
|
||||
return array( 'app' => 'forums', 'title' => 'stats_percentagesolved', 'description' => 'stats_percentagesolved_desc', 'refresh' => 60, 'form' => true );
|
||||
break;
|
||||
|
||||
case 'averagetimesolved':
|
||||
return array( 'app' => 'forums', 'title' => 'stats_averagetimesolved', 'description' => 'stats_averagetimesolved_desc', 'refresh' => 60, 'form' => true );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the block HTML to show
|
||||
*
|
||||
* @param array|NULL $dateRange NULL for all time, or an array with 'start' and 'end' \IPS\DateTime objects to restrict to
|
||||
* @param string|NULL $subBlock The subblock we are loading as returned by getBlocks()
|
||||
* @return string
|
||||
*/
|
||||
public function getBlock( $dateRange = NULL, $subBlock = NULL )
|
||||
{
|
||||
/* Make sure someone isn't trying to manipulate the request or do something weird */
|
||||
if( !\in_array( $subBlock, $this->getBlocks() ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$value = 0;
|
||||
$previousValue = 0;
|
||||
$nodeNames = array();
|
||||
|
||||
/* Build where clause in the event we are filtering */
|
||||
$where = array();
|
||||
$previousWhere = NULL;
|
||||
|
||||
if( $dateRange !== NULL )
|
||||
{
|
||||
if( \is_array( $dateRange ) )
|
||||
{
|
||||
$where = array(
|
||||
array( 'start_date > ?', $dateRange['start']->getTimestamp() ),
|
||||
array( 'start_date < ?', $dateRange['end']->getTimestamp() ),
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentDate = new \IPS\DateTime;
|
||||
$interval = NULL;
|
||||
|
||||
switch( $dateRange )
|
||||
{
|
||||
case '7':
|
||||
$interval = new \DateInterval( 'P7D' );
|
||||
break;
|
||||
|
||||
case '30':
|
||||
$interval = new \DateInterval( 'P1M' );
|
||||
break;
|
||||
|
||||
case '90':
|
||||
$interval = new \DateInterval( 'P3M' );
|
||||
break;
|
||||
|
||||
case '180':
|
||||
$interval = new \DateInterval( 'P6M' );
|
||||
break;
|
||||
|
||||
case '365':
|
||||
$interval = new \DateInterval( 'P1Y' );
|
||||
break;
|
||||
}
|
||||
|
||||
$initialTimestamp = $currentDate->sub( $interval )->getTimestamp();
|
||||
$where = array( array( 'start_date > ?', $initialTimestamp ) );
|
||||
$previousWhere = array( array( 'start_date BETWEEN ? AND ?', $currentDate->sub( $interval )->getTimestamp(), $initialTimestamp ) );
|
||||
}
|
||||
}
|
||||
else if ( $dateRange === NULL and isset( \IPS\Request::i()->nodes ) and \IPS\Request::i()->nodes )
|
||||
{
|
||||
$where = array( array( \IPS\Db::i()->in( 'forum_id', explode( ',', \IPS\Request::i()->nodes ) ) ) );
|
||||
}
|
||||
|
||||
$where[] = array( \IPS\Db::i()->in( 'forum_id', iterator_to_array( \IPS\Db::i()->select( 'id', 'forums_forums', '(' . \IPS\Db::i()->bitwiseWhere( \IPS\forums\Forum::$bitOptions['forums_bitoptions'], 'bw_enable_answers' ) . ') OR ( ' . \IPS\Db::i()->bitwiseWhere( \IPS\forums\Forum::$bitOptions['forums_bitoptions'], 'bw_enable_answers_moderator' ) . ' )' ) ) ) );
|
||||
|
||||
if( \IPS\Request::i()->nodes )
|
||||
{
|
||||
foreach( explode( ',', \IPS\Request::i()->nodes ) as $nodeId )
|
||||
{
|
||||
$nodeNames[] = \IPS\forums\Forum::load( $nodeId )->_title;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the current and previous values */
|
||||
switch( $subBlock )
|
||||
{
|
||||
case 'percentagesolved':
|
||||
$total = \IPS\Db::i()->select( 'COUNT(*)', 'forums_topics', $this->_modifyWhereClause( $where ) )->first();
|
||||
$solved = \IPS\Db::i()->select( 'COUNT(*)', 'forums_topics', array_merge( $this->_modifyWhereClause( $where ), array( array( 'core_solved_index.id IS NOT NULL' ) ) ) )->join( 'core_solved_index', "core_solved_index.app='forums' AND core_solved_index.item_id=forums_topics.tid")->first();
|
||||
|
||||
$value = $total ? round( $solved / $total * 100, 2 ) : 0;
|
||||
|
||||
$previousTotal = $previousSolved = NULL;
|
||||
|
||||
if( $previousWhere !== NULL )
|
||||
{
|
||||
$previousTotal = \IPS\Db::i()->select( 'COUNT(*)', 'forums_topics', $this->_modifyWhereClause( $previousWhere ) )->first();
|
||||
$previousSolved = \IPS\Db::i()->select( 'COUNT(*)', 'forums_topics', array_merge( $this->_modifyWhereClause( $previousWhere ), array( array( 'core_solved_index.id IS NOT NULL' ) ) ) )->join( 'core_solved_index', "core_solved_index.app='forums' AND core_solved_index.item_id=forums_topics.tid")->first();
|
||||
|
||||
$previousValue = $previousTotal ? round( $previousSolved / $previousTotal * 100, 2 ) : 0;
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'stats', 'forums' )->solvedPercentage( $value, $total, $solved, $previousValue, $previousTotal, $previousSolved, $nodeNames );
|
||||
break;
|
||||
|
||||
case 'averagetimesolved':
|
||||
$value = \IPS\Db::i()->select( 'AVG(core_solved_index.solved_date-forums_topics.start_date)', 'forums_topics', array_merge( $this->_modifyWhereClause( $where ), array( array( 'core_solved_index.id IS NOT NULL' ) ) ) )->join( 'core_solved_index', "core_solved_index.app='forums' AND core_solved_index.item_id=forums_topics.tid")->first();
|
||||
|
||||
if( $previousWhere !== NULL )
|
||||
{
|
||||
$previousValue = \IPS\Db::i()->select( 'AVG(core_solved_index.solved_date-forums_topics.start_date)', 'forums_topics', array_merge( $this->_modifyWhereClause( $previousWhere ), array( array( 'core_solved_index.id IS NOT NULL' ) ) ) )->join( 'core_solved_index', "core_solved_index.app='forums' AND core_solved_index.item_id=forums_topics.tid")->first();
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'stats', 'forums' )->timeToSolved( $value, $previousValue, $nodeNames );
|
||||
break;
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'stats', 'forums' )->solvedPercentage( $values, $previousValues, $nodeNames );
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the where clause to apply other filters
|
||||
*
|
||||
* @param array $where Current where clause
|
||||
* @return array
|
||||
*/
|
||||
protected function _modifyWhereClause( $where )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'approved', array( -2, -3 ), TRUE ) );
|
||||
|
||||
$where = array_merge( $where, \IPS\forums\Topic::overviewStatisticsWhere() );
|
||||
|
||||
if( \IPS\Request::i()->nodes )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'forum_id', explode( ',', \IPS\Request::i()->nodes ) ) );
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return block filter form, or the updated block result upon submit
|
||||
*
|
||||
* @param string|NULL $subBlock The subblock we are loading as returned by getBlocks()
|
||||
* @return array
|
||||
*/
|
||||
public function getBlockForm( $subBlock = NULL )
|
||||
{
|
||||
/* Make sure someone isn't trying to manipulate the request or do something weird */
|
||||
if( !\in_array( $subBlock, $this->getBlocks() ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->attributes['data-controller'] = 'core.admin.stats.nodeFilters';
|
||||
$form->attributes['data-block'] = \IPS\Request::i()->blockKey;
|
||||
$form->attributes['data-subblock'] = $subBlock;
|
||||
$form->add( new \IPS\Helpers\Form\Node( \IPS\forums\Forum::$nodeTitle, NULL, TRUE, array( 'class' => '\IPS\forums\Forum', 'multiple' => TRUE, 'clubs' => FALSE ) ) );
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
$dateFilters = NULL;
|
||||
|
||||
if( \IPS\Request::i()->range )
|
||||
{
|
||||
$dateFilters = \IPS\Request::i()->range;
|
||||
}
|
||||
elseif( \IPS\Request::i()->start )
|
||||
{
|
||||
try
|
||||
{
|
||||
$timezone = \IPS\Member::loggedIn()->timezone ? new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) : NULL;
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
$timezone = NULL;
|
||||
}
|
||||
|
||||
$dateFilters = array(
|
||||
'start' => new \IPS\DateTime( \IPS\Helpers\Form\Date::_convertDateFormat( \IPS\Request::i()->start ), $timezone ),
|
||||
'end' => new \IPS\DateTime( \IPS\Helpers\Form\Date::_convertDateFormat( \IPS\Request::i()->end ), $timezone )
|
||||
);
|
||||
}
|
||||
|
||||
return $this->getBlock( $dateFilters, $subblock );
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user