Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Popular things
|
||||
* @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 21 Oct 2016
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\front\discover;
|
||||
@@ -83,120 +82,44 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function members()
|
||||
{
|
||||
$filters = array(
|
||||
'reputation' => array( 'pp_reputation_points', \IPS\Member::loggedIn()->language()->addToStack('leaderboard_tab_reputation') ),
|
||||
'posts' => array( 'member_posts', \IPS\Member::loggedIn()->language()->addToStack('leaderboard_tab_posts') )
|
||||
);
|
||||
|
||||
$classes = array();
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'ContentRouter', TRUE ) as $object )
|
||||
/* Get filters */
|
||||
$filters = array_merge( array( 'overview' => \IPS\Member::loggedIn()->language()->addToStack('overview') ), \IPS\Member::topMembersOptions( \IPS\Member::TOP_MEMBERS_FILTERS ) );
|
||||
$activeFilter = 'overview';
|
||||
if ( isset( \IPS\Request::i()->filter ) )
|
||||
{
|
||||
$classes = array_merge( $object->classes, $classes );
|
||||
}
|
||||
|
||||
foreach( $classes as $item )
|
||||
{
|
||||
$commentClass = NULL;
|
||||
|
||||
if ( isset( $item::$commentClass ) )
|
||||
if ( array_key_exists( \IPS\Request::i()->filter, $filters ) )
|
||||
{
|
||||
$commentClass = $item::$commentClass;
|
||||
$activeFilter = \IPS\Request::i()->filter;
|
||||
}
|
||||
|
||||
if ( $item::$firstCommentRequired and isset( $commentClass::$databaseColumnMap['author'] ) )
|
||||
else
|
||||
{
|
||||
$filters[ 'app_' . $item::$application . '_' . $item::$module ] = array(
|
||||
$commentClass,
|
||||
\IPS\Member::loggedIn()->language()->addToStack('leaderboard_tab_x', NULL, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack("{$commentClass::$title}_pl_lc") ) ) ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack("{$commentClass::$title}_pl")
|
||||
);
|
||||
}
|
||||
else if ( isset( $item::$databaseColumnMap['author'] ) )
|
||||
{
|
||||
$filters[ 'app_' . $item::$application . '_' . $item::$module ] = array(
|
||||
$item,
|
||||
\IPS\Member::loggedIn()->language()->addToStack('leaderboard_tab_x', NULL, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack("{$item::$title}_pl_lc") ) ) ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack("{$item::$title}_pl")
|
||||
);
|
||||
$possibleFilter = 'IPS\\' . str_replace( '_', '\\', \IPS\Request::i()->filter );
|
||||
if ( array_key_exists( $possibleFilter, $filters ) )
|
||||
{
|
||||
$activeFilter = $possibleFilter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$activeFilter = ( isset( \IPS\Request::i()->filter ) and isset( $filters[ \IPS\Request::i()->filter ] ) ) ? \IPS\Request::i()->filter : 'reputation';
|
||||
$members = array();
|
||||
|
||||
/* Get the members */
|
||||
if ( mb_substr( $activeFilter, 0, 4 ) == 'app_' )
|
||||
/* Get results */
|
||||
if ( $activeFilter == 'overview' )
|
||||
{
|
||||
$storeKey = 'store_' . $activeFilter;
|
||||
$recache = true;
|
||||
$memberIds = NULL;
|
||||
|
||||
if ( isset( \IPS\Data\Store::i()->$storeKey ) )
|
||||
{
|
||||
$cache = \IPS\Data\Store::i()->$storeKey;
|
||||
|
||||
if ( isset( $cache['time'] ) and isset( $cache['memberIds'] ) and ( time() - $cache['time'] < 300 ) )
|
||||
{
|
||||
$memberIds = $cache['memberIds'];
|
||||
}
|
||||
}
|
||||
|
||||
/* Nothing returned from the cache, so fetch and store */
|
||||
if ( $memberIds === NULL )
|
||||
{
|
||||
$class = $filters[ $activeFilter ][0];
|
||||
$authorField = $class::$databasePrefix . $class::$databaseColumnMap['author'];
|
||||
$memberIds = array();
|
||||
$where = NULL;
|
||||
|
||||
if ( isset( $class::$databaseColumnMap['hidden'] ) )
|
||||
{
|
||||
$where = array( $class::$databasePrefix . $class::$databaseColumnMap['hidden'] . '=0' );
|
||||
}
|
||||
else if ( isset( $class::$databaseColumnMap['approved'] ) )
|
||||
{
|
||||
$where = array( $class::$databasePrefix . $class::$databaseColumnMap['approved'] . '=1' );
|
||||
}
|
||||
|
||||
/* Get member IDS */
|
||||
foreach( \IPS\Db::i()->select( 'COUNT(*) as count, ' . $class::$databaseTable . '.' . $authorField, $class::$databaseTable, $where, 'count DESC', array( 0, \IPS\Settings::i()->reputation_max_members ), $authorField ) as $row )
|
||||
{
|
||||
$memberIds[ $row[ $authorField ] ] = array( $row['count'] . '.' . $row[ $authorField ], $row['count'] );
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->$storeKey = array( 'time' => time(), 'memberIds' => $memberIds );
|
||||
}
|
||||
|
||||
if ( count( $memberIds ) )
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_members', array( \IPS\Db::i()->in( 'member_id', array_keys( $memberIds ) ) ) ) as $member )
|
||||
{
|
||||
$members[ $memberIds[ $member['member_id'] ][0] ] = \IPS\Member::constructFromData( array_merge( $member, array( 'custom_count' => $memberIds[ $member['member_id'] ][1] ) ) );
|
||||
}
|
||||
|
||||
krsort( $members );
|
||||
}
|
||||
$output = \IPS\Theme::i()->getTemplate('popular')->topMembersOverview( \IPS\Member::topMembersOptions( \IPS\Member::TOP_MEMBERS_OVERVIEW ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$members = iterator_to_array( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_members', array( "name IS NOT NULL AND name != '' AND temp_ban != -1 AND email != '' AND " . $filters[ $activeFilter ][0] . " > 0" ), $filters[ $activeFilter ][0] . ' DESC', array( 0, \IPS\Settings::i()->reputation_max_members ) ), '\IPS\Member' ) );
|
||||
$output = \IPS\Theme::i()->getTemplate('popular')->topMembersResults( $activeFilter, NULL, \IPS\Member::topMembers( $activeFilter, \IPS\Settings::i()->reputation_max_members ) );
|
||||
}
|
||||
|
||||
$contentLabel = 'members_member_posts';
|
||||
$contentCount = 'member_posts';
|
||||
if ( isset( $filters[ $activeFilter ][2] ) )
|
||||
{
|
||||
$contentLabel = $filters[ $activeFilter ][2];
|
||||
$contentCount = 'custom_count';
|
||||
}
|
||||
|
||||
|
||||
/* Output */
|
||||
\IPS\Output::i()->linkTags['canonical'] = (string) \IPS\Http\Url::internal( "app=core&module=discover&controller=popular&tab=members", 'front', 'leaderboard_members' );
|
||||
if ( \IPS\Request::i()->isAjax() and \IPS\Request::i()->topMembers )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'rows' => \IPS\Theme::i()->getTemplate('popular')->membersWrapper( $members, $contentLabel, $contentCount ), 'extraHtml' => $filters[ $activeFilter ][1] ) );
|
||||
\IPS\Output::i()->json( array( 'rows' => $output, 'extraHtml' => $filters[ $activeFilter ] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('popular')->members( $members, $filters, $activeFilter, \IPS\Http\Url::internal( "app=core&module=discover&controller=popular&tab=members", 'front', 'leaderboard_members' ), $contentLabel, $contentCount );
|
||||
return \IPS\Theme::i()->getTemplate('popular')->topMembers( \IPS\Http\Url::internal( 'app=core&module=discover&controller=popular&tab=members', 'front', 'leaderboard_members' ), $filters, $activeFilter, $output );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +167,7 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
return \IPS\DateTime::ts( $val )->setTimezone( new \DateTimeZone( \IPS\Settings::i()->reputation_timezone ) );
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->blankTemplate( $table ), 200, 'text/html', \IPS\Output::i()->httpHeaders );
|
||||
@@ -277,111 +200,111 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
$dates = array();
|
||||
$timezone = new \DateTimeZone( \IPS\Settings::i()->reputation_timezone );
|
||||
$endDate = \IPS\DateTime::ts( time() )->setTimezone( $timezone );
|
||||
|
||||
|
||||
$firstRepDate = \IPS\Db::i()->select( 'MIN(rep_date)', 'core_reputation_index' )->first();
|
||||
$firstIndexDate = \IPS\Db::i()->select( 'MIN(index_date_updated)', 'core_search_index' )->first();
|
||||
$appWhere = null;
|
||||
$descApp = \IPS\Member::loggedIn()->language()->addToStack('leaderboard_in_all_apps');
|
||||
|
||||
$dates['oldest'] = \IPS\DateTime::ts( ( $firstRepDate > $firstIndexDate ) ? $firstRepDate : $firstIndexDate );
|
||||
$oldestStamp = $dates['oldest']->getTimeStamp();
|
||||
$date = $dates['oldest'];
|
||||
|
||||
$descApp = \IPS\Member::loggedIn()->language()->addToStack( 'leaderboard_in_all_apps' );
|
||||
|
||||
$dates[ 'oldest' ] = \IPS\DateTime::ts( ( $firstRepDate > $firstIndexDate ) ? $firstRepDate : $firstIndexDate );
|
||||
$oldestStamp = $dates[ 'oldest' ]->getTimeStamp();
|
||||
$date = $dates[ 'oldest' ];
|
||||
|
||||
$aYearAgo = \IPS\DateTime::create()->setTimezone( $timezone )->sub( new \DateInterval( 'P1Y' ) );
|
||||
$month = \IPS\DateTime::create()->setTimezone( $timezone )->sub( new \DateInterval( 'P1M' ) )->setTime( 0, 0 );
|
||||
$week = \IPS\DateTime::create()->setTimezone( $timezone )->sub( new \DateInterval( 'P7D' ) )->setTime( 0, 0 );
|
||||
$today = \IPS\DateTime::create()->setTimezone( $timezone )->setTime( 0, 0 );
|
||||
|
||||
|
||||
if ( $aYearAgo->getTimeStamp() > $oldestStamp )
|
||||
{
|
||||
$dates['year'] = $aYearAgo;
|
||||
$dates[ 'year' ] = $aYearAgo;
|
||||
}
|
||||
|
||||
|
||||
if ( $month->getTimeStamp() > $oldestStamp )
|
||||
{
|
||||
$dates['month'] = $month;
|
||||
$dates[ 'month' ] = $month;
|
||||
}
|
||||
|
||||
|
||||
if ( $week->getTimeStamp() > $oldestStamp )
|
||||
{
|
||||
$dates['week'] = $week;
|
||||
$dates[ 'week' ] = $week;
|
||||
}
|
||||
|
||||
|
||||
if ( $today->getTimeStamp() > $oldestStamp )
|
||||
{
|
||||
$dates['today'] = $today;
|
||||
$dates[ 'today' ] = $today;
|
||||
}
|
||||
|
||||
|
||||
/* Got a date? */
|
||||
if ( isset( \IPS\Request::i()->time ) and isset( $dates[ \IPS\Request::i()->time ] ) )
|
||||
{
|
||||
$date = $dates[ \IPS\Request::i()->time ];
|
||||
}
|
||||
else if ( isset( $dates['month'] ) )
|
||||
else if ( isset( $dates[ 'month' ] ) )
|
||||
{
|
||||
/* Set the default to month */
|
||||
\IPS\Request::i()->time = 'month';
|
||||
$date = $dates['month'];
|
||||
$date = $dates[ 'month' ];
|
||||
}
|
||||
|
||||
|
||||
/* Applications */
|
||||
$classes = array();
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'ContentRouter', TRUE ) as $object )
|
||||
{
|
||||
$classes = array_merge( $object->classes, $classes );
|
||||
}
|
||||
|
||||
|
||||
$areas = array();
|
||||
foreach( $classes as $item )
|
||||
foreach ( $classes as $item )
|
||||
{
|
||||
$commentClass = NULL;
|
||||
$reviewClass = NULL;
|
||||
|
||||
if ( in_array( 'IPS\Content\Reputation', class_implements( $item ) ) and isset( $item::$reputationType ) )
|
||||
|
||||
if ( \IPS\IPS::classUsesTrait( $item, 'IPS\Content\Reactable' ) )
|
||||
{
|
||||
$areas[ $item::$application . '-' . $item::$reputationType ] = array( $item, \IPS\Member::loggedIn()->language()->addToStack("{$item::$title}_pl") );
|
||||
$areas[ $item::$application . '-' . $item::reactionType() ] = array( $item, \IPS\Member::loggedIn()->language()->addToStack( "{$item::$title}_pl" ) );
|
||||
}
|
||||
|
||||
if ( isset( $item::$commentClass ) )
|
||||
{
|
||||
$commentClass = $item::$commentClass;
|
||||
if ( in_array( 'IPS\Content\Reputation', class_implements( $commentClass ) ) and isset( $commentClass::$reputationType ) )
|
||||
if ( \IPS\IPS::classUsesTrait( $commentClass, 'IPS\Content\Reactable' ) )
|
||||
{
|
||||
$areas[ $item::$application . '-' . $commentClass::$reputationType ] = array( $commentClass, \IPS\Member::loggedIn()->language()->addToStack("{$commentClass::$title}_pl") );
|
||||
$areas[ $item::$application . '-' . $commentClass::reactionType() ] = array( $commentClass, \IPS\Member::loggedIn()->language()->addToStack( "{$commentClass::$title}_pl" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $item::$reviewClass ) )
|
||||
{
|
||||
$reviewClass = $item::$reviewClass;
|
||||
if ( in_array( 'IPS\Content\Reputation', class_implements( $reviewClass ) ) and isset( $reviewClass::$reputationType ) )
|
||||
if ( \IPS\IPS::classUsesTrait( $reviewClass, 'IPS\Content\Reactable' ) )
|
||||
{
|
||||
$areas[ $item::$application . '-' . $reviewClass::$reputationType ] = array( $reviewClass, \IPS\Member::loggedIn()->language()->addToStack("{$reviewClass::$title}_pl") );
|
||||
$areas[ $item::$application . '-' . $reviewClass::reactionType() ] = array( $reviewClass, \IPS\Member::loggedIn()->language()->addToStack( "{$reviewClass::$title}_pl" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form('popular_date', 'continue');
|
||||
$form = new \IPS\Helpers\Form( 'popular_date', 'continue' );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$customStart = isset( \IPS\Request::i()->custom_date_start ) ? \IPS\Request::i()->custom_date_start : NULL;
|
||||
$customEnd = isset( \IPS\Request::i()->custom_date_end ) ? \IPS\Request::i()->custom_date_end : NULL;
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'custom_date', array( 'start' => $customStart, 'end' => $customEnd ), FALSE, array( 'start' => array( 'min' => $dates['oldest'], 'time' => false ) ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'custom_date', array( 'start' => $customStart, 'end' => $customEnd ), FALSE, array( 'start' => array( 'min' => $dates[ 'oldest' ], 'time' => false ) ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$url = \IPS\Request::i()->url()->stripQueryString('time');
|
||||
|
||||
if ( isset( $values['custom_date']['start'] ) and $values['custom_date']['start'] instanceof \IPS\DateTime )
|
||||
$url = \IPS\Request::i()->url()->stripQueryString( 'time' );
|
||||
|
||||
if ( isset( $values[ 'custom_date' ][ 'start' ] ) and $values[ 'custom_date' ][ 'start' ] instanceof \IPS\DateTime )
|
||||
{
|
||||
$url = $url->setQueryString( 'custom_date_start', $values['custom_date']['start']->getTimeStamp() );
|
||||
$url = $url->setQueryString( 'custom_date_start', $values[ 'custom_date' ][ 'start' ]->getTimeStamp() );
|
||||
}
|
||||
|
||||
if ( isset( $values['custom_date']['end'] ) and $values['custom_date']['end'] instanceof \IPS\DateTime )
|
||||
|
||||
if ( isset( $values[ 'custom_date' ][ 'end' ] ) and $values[ 'custom_date' ][ 'end' ] instanceof \IPS\DateTime )
|
||||
{
|
||||
$url = $url->setQueryString( 'custom_date_end', $values['custom_date']['end']->getTimeStamp() );
|
||||
$url = $url->setQueryString( 'custom_date_end', $values[ 'custom_date' ][ 'end' ]->getTimeStamp() );
|
||||
}
|
||||
|
||||
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
else
|
||||
@@ -390,20 +313,30 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$date = \IPS\DateTime::ts( $customStart )->setTimezone( $timezone )->setTime( 0, 0, 1 );
|
||||
}
|
||||
|
||||
|
||||
if ( $customEnd )
|
||||
{
|
||||
$endDate = \IPS\DateTime::ts( $customEnd )->setTimezone( $timezone )->setTime( 23, 59, 59 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Got an app? */
|
||||
$appWhere = '';
|
||||
|
||||
if ( isset( \IPS\Request::i()->in ) and isset( $areas[ \IPS\Request::i()->in ] ) )
|
||||
{
|
||||
$appWhere = " AND rep_class='" . \IPS\Db::i()->escape_string( $areas[ \IPS\Request::i()->in ][0] ) . "'";
|
||||
$descApp = \IPS\Member::loggedIn()->language()->addToStack('leaderboard_in_app', NULL, array( 'sprintf' => array( $areas[ \IPS\Request::i()->in ][1] ) ) );
|
||||
$appWhere = " AND rep_class='" . \IPS\Db::i()->escape_string( $areas[ \IPS\Request::i()->in ][ 0 ] ) . "'";
|
||||
$descApp = \IPS\Member::loggedIn()->language()->addToStack( 'leaderboard_in_app', NULL, array( 'sprintf' => array( $areas[ \IPS\Request::i()->in ][ 1 ] ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$repAreas = array();
|
||||
foreach( $areas as $area )
|
||||
{
|
||||
$repAreas[] = $area[0] ;
|
||||
}
|
||||
|
||||
$appWhere = " AND " . \IPS\Db::i()->in( 'rep_class', $repAreas );
|
||||
}
|
||||
|
||||
$storeKey = NULL;
|
||||
@@ -432,27 +365,16 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
\IPS\Data\Store::i()->$storeKey = array( 'time' => time(), 'hashes' => array() );
|
||||
}
|
||||
|
||||
$testFirst = iterator_to_array( \IPS\Db::i()->select( 'class_type_id_hash', 'core_reputation_index', array( 'rep_date BETWEEN ' . $date->getTimeStamp() . ' AND ' . $endDate->getTimeStamp() . $appWhere ), NULL, NULL, 'class_type_id_hash' ) );
|
||||
$searchWhere = array( array( "( si.index_permissions = '*' OR " . \IPS\Db::i()->findInSet( 'si.index_permissions', \IPS\Member::loggedIn()->groups ) . ' AND si.index_hidden=0 )' ) );
|
||||
/* Get rep hashes */
|
||||
$inner = \IPS\Db::i()->select( 'class_type_id_hash, SUM(rep_rating) as total_rep', array( 'core_reputation_index', 'x' ), array( 'rep_date BETWEEN ' . $date->getTimeStamp() . ' AND ' . $endDate->getTimeStamp() . $appWhere ), NULL, NULL, 'class_type_id_hash' );
|
||||
$repHashes = iterator_to_array( \IPS\Db::i()->select( 'class_type_id_hash, total_rep', $inner, NULL, 'x.total_rep desc', array( 0, 500 ) )->setKeyField('class_type_id_hash') );
|
||||
|
||||
/* Now filter through permissions */
|
||||
$searchHashes = iterator_to_array( \IPS\Db::i()->select( 'index_class_type_id_hash', array( 'core_search_index', 'si' ), array( array( "( si.index_permissions = '*' OR " . \IPS\Db::i()->findInSet( 'si.index_permissions', \IPS\Member::loggedIn()->groups ) . ' AND si.index_hidden=0 )' ), array( \IPS\Db::i()->in( 'si.index_class_type_id_hash', array_keys( $repHashes ) ) ) ) )->setKeyField('index_class_type_id_hash') );
|
||||
|
||||
if ( count( $testFirst ) < 501 )
|
||||
{
|
||||
/* We can use an IN() to make this a bit more efficient */
|
||||
$repQuery = \IPS\Db::i()->select( 'class_type_id_hash, SUM(rep_rating) as total_rep', 'core_reputation_index', \IPS\Db::i()->in( 'class_type_id_hash', array_values( $testFirst ) ), NULL, NULL, 'class_type_id_hash' );
|
||||
|
||||
$searchWhere[] = array( \IPS\Db::i()->in( 'si.index_class_type_id_hash', array_values( $testFirst ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$repQuery = \IPS\Db::i()->select( 'class_type_id_hash, SUM(rep_rating) as total_rep', 'core_reputation_index', array( 'rep_date BETWEEN ' . $date->getTimeStamp() . ' AND ' . $endDate->getTimeStamp() . $appWhere ), NULL, NULL, 'class_type_id_hash' );
|
||||
}
|
||||
/* Filter out rep hashes not in search results */
|
||||
$hashes = array_slice( array_intersect_key( $repHashes, $searchHashes ), 0, 50 );
|
||||
|
||||
$searchQuery = \IPS\Db::i()->select( 'index_class_type_id_hash', array( 'core_search_index', 'si' ), $searchWhere );
|
||||
|
||||
$hashes = iterator_to_array(
|
||||
\IPS\Db::i()->select( 'class_type_id_hash, total_rep', array( $repQuery, 'ri' ), array( 'class_type_id_hash IN(?)', $searchQuery ), 'total_rep DESC', array( 0, 50 ) )->setKeyField('class_type_id_hash')
|
||||
);
|
||||
|
||||
if ( $storeKey )
|
||||
{
|
||||
\IPS\Data\Store::i()->$storeKey = array( 'time' => time(), 'hashes' => $hashes );
|
||||
@@ -557,6 +479,8 @@ class _popular extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
|
||||
\IPS\Output::i()->linkTags['canonical'] = (string) \IPS\Http\Url::internal( "app=core&module=discover&controller=popular&tab=leaderboard", 'front', 'leaderboard_leaderboard' );
|
||||
|
||||
/* Display */
|
||||
return \IPS\Theme::i()->getTemplate('popular')->popularWrapper( $results, $areas, $topContributors, $dates, $description, $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) ), $tzOffsetDifference );
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief rss
|
||||
* @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 13 Oct 2016
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\front\discover;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief streams
|
||||
* @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 02 Jul 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\front\discover;
|
||||
@@ -178,6 +177,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Start with a blank stream */
|
||||
$stream = \IPS\core\Stream::allActivityStream();
|
||||
$stream->default_view = "expanded";
|
||||
|
||||
/* Set the title to "All Activity" */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('all_activity');
|
||||
@@ -187,7 +187,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
/* but only if we haven't submitted the form on this request */
|
||||
if( !\IPS\Request::i()->stream_submitted )
|
||||
{
|
||||
$streamFields = array( 'include_comments', 'classes', 'ownership', 'custom_members', 'read', 'follow', 'followed_types', 'date_type', 'date_start', 'date_end', 'date_relative_days', 'sort', 'tags', 'unread_links' );
|
||||
$streamFields = array( 'include_comments', 'classes', 'clubs', 'ownership', 'custom_members', 'read', 'follow', 'followed_types', 'date_type', 'date_start', 'date_end', 'date_relative_days', 'sort', 'tags', 'unread_links' );
|
||||
|
||||
/* Build and format field values */
|
||||
$_values = array();
|
||||
@@ -220,6 +220,11 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $_values['stream_club_filter'] ) and !isset( $_values['stream_club_select'] ) )
|
||||
{
|
||||
$_values['stream_club_select'] = 'select';
|
||||
}
|
||||
|
||||
$formattedValues = $stream->formatFormValues( $_values );
|
||||
|
||||
/* Overwrite stream config if present in the request */
|
||||
@@ -227,7 +232,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$requestKey = 'stream_' . $k;
|
||||
|
||||
if ( isset( \IPS\Request::i()->$requestKey ) )
|
||||
if ( isset( \IPS\Request::i()->$requestKey ) or ( $k === 'clubs' and ( isset( \IPS\Request::i()->stream_club_select ) or isset( \IPS\Request::i()->stream_club_filter ) ) ) )
|
||||
{
|
||||
if ( $stream->$k != $formattedValues[ $k ] )
|
||||
{
|
||||
@@ -341,7 +346,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/* Is anything turned on? */
|
||||
$extra = array();
|
||||
foreach ( array( 'register', 'follow_member', 'follow_content', 'photo', 'like', 'rep_neg' ) as $k )
|
||||
foreach ( array( 'register', 'follow_member', 'follow_content', 'photo', 'like', 'react', 'clubs' ) as $k )
|
||||
{
|
||||
$key = "all_activity_{$k}";
|
||||
if ( \IPS\Settings::i()->$key )
|
||||
@@ -594,7 +599,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$url = $stream ? $stream->baseUrl->setQueryString( 'className', $class ) : \IPS\Request::i()->url()->setQueryString( 'className', $class );
|
||||
$containerClass = $class::$containerNodeClass;
|
||||
$field = new \IPS\Helpers\Form\Node( 'stream_containers_' . $class::$title, isset( $currentContainers[ $class ] ) ? $currentContainers[ $class ] : array(), NULL, array( 'url' => $url, 'class' => $class::$containerNodeClass, 'multiple' => TRUE, 'permissionCheck' => $containerClass::searchableNodesPermission() ), NULL, NULL, NULL, 'stream_containers_' . $class::$title );
|
||||
$field = new \IPS\Helpers\Form\Node( 'stream_containers_' . $class::$title, isset( $currentContainers[ $class ] ) ? $currentContainers[ $class ] : array(), NULL, array( 'url' => $url, 'class' => $class::$containerNodeClass, 'multiple' => TRUE, 'permissionCheck' => $containerClass::searchableNodesPermission(), 'clubs' => \IPS\IPS::classUsesTrait( $containerClass, 'IPS\Content\ClubContainer' ) ), NULL, NULL, NULL, 'stream_containers_' . $class::$title );
|
||||
$field->label = \IPS\Member::loggedIn()->language()->addToStack( 'stream_narrow_by_container_label', NULL, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $containerClass::$nodeTitle ) ) ) );
|
||||
|
||||
return \IPS\Output::i()->json( array( 'node' => \IPS\Theme::i()->getTemplate('streams')->filterFormContentTypeContent( $field, $class, \IPS\Request::i()->key ) ) );
|
||||
@@ -604,6 +609,47 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the club selector form element HTML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getClubElement()
|
||||
{
|
||||
$clubOptions = array();
|
||||
foreach ( \IPS\Member\Club::clubs( \IPS\Member::loggedIn(), NULL, 'name', TRUE ) as $club )
|
||||
{
|
||||
$clubOptions[ "c{$club->id}" ] = $club->name;
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->stream_club_select ) )
|
||||
{
|
||||
switch ( \IPS\Request::i()->stream_club_select )
|
||||
{
|
||||
case 'all':
|
||||
$value = 0;
|
||||
break;
|
||||
|
||||
case 'none':
|
||||
$value = array();
|
||||
break;
|
||||
|
||||
default:
|
||||
$value = explode( ',', \IPS\Request::i()->stream_club_filter );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
$field = new \IPS\Helpers\Form\Select( 'stream_club_filter_dummy', $value, FALSE, array( 'options' => $clubOptions, 'parse' => 'normal', 'multiple' => TRUE, 'noDefault' => TRUE, 'unlimited' => 0, 'unlimitedLang' => 'stream_club_select_all' ), NULL, NULL, NULL, 'stream_club_filter' );
|
||||
$field->label = \IPS\Member::loggedIn()->language()->addToStack('stream_club_filter');
|
||||
|
||||
return \IPS\Output::i()->json( array( 'field' => \IPS\Theme::i()->getTemplate('streams')->filterFormClubs( $field ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build form
|
||||
*
|
||||
@@ -650,7 +696,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$formattedValues = $stream->formatFormValues( $values );
|
||||
|
||||
foreach ( array( 'include_comments', 'classes', 'containers', 'ownership', 'custom_members', 'read', 'follow', 'followed_types', 'date_type', 'date_start', 'date_end', 'date_relative_days', 'sort', 'tags', 'unread_links' ) as $k )
|
||||
foreach ( array( 'include_comments', 'classes', 'containers', 'clubs', 'ownership', 'custom_members', 'read', 'follow', 'followed_types', 'date_type', 'date_start', 'date_end', 'date_relative_days', 'sort', 'tags', 'unread_links' ) as $k )
|
||||
{
|
||||
$requestKey = 'stream_' . $k;
|
||||
if ( isset( $formattedValues[ $k ] ) AND $stream->$k != $formattedValues[ $k ] )
|
||||
|
||||
Reference in new issue
Block a user