Version 4.0.13.1
This commit is contained in:
1 parent
f9e857d255
commit
c6a86f0d9b
7517 files changed
+597400
-668041
No files matched your search
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief activeUsers Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 19 Nov 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* activeUsers Widget
|
||||
*/
|
||||
class _activeUsers extends \IPS\Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'activeUsers';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
/* Do we have permission? */
|
||||
if ( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'online' ) ) )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/* Build WHERE clause */
|
||||
$parts = parse_url( (string) \IPS\Request::i()->url() );
|
||||
$url = $parts['scheme'] . "://" . $parts['host'] . $parts['path'];
|
||||
|
||||
$where = array(
|
||||
array( 'core_sessions.login_type=' . \IPS\Session\Front::LOGIN_TYPE_MEMBER ),
|
||||
array( 'core_sessions.current_appcomponent=?', \IPS\Dispatcher::i()->application->directory ),
|
||||
array( 'core_sessions.current_module=?', \IPS\Dispatcher::i()->module->key ),
|
||||
array( 'core_sessions.current_controller=?', \IPS\Dispatcher::i()->controller ),
|
||||
array( 'core_sessions.running_time>' . \IPS\DateTime::create()->sub( new \DateInterval( 'PT30M' ) )->getTimeStamp() ),
|
||||
array( 'core_sessions.location_url IS NOT NULL AND location_url LIKE ?', "{$url}%" ),
|
||||
array( 'core_sessions.member_id IS NOT NULL' ),
|
||||
array( 'core_groups.g_hide_online_list=0' )
|
||||
);
|
||||
|
||||
if( \IPS\Request::i()->id )
|
||||
{
|
||||
$where[] = array( 'core_sessions.current_id = ?', \IPS\Request::i()->id );
|
||||
}
|
||||
|
||||
/* Get members */
|
||||
if ( $this->orientation === 'vertical' )
|
||||
{
|
||||
$members = \IPS\Db::i()->select( 'core_sessions.member_id,core_sessions.member_name,core_sessions.seo_name,core_sessions.member_group', 'core_sessions', $where, 'core_sessions.running_time DESC', 60, NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS )->join( 'core_members', 'core_members.member_id=core_sessions.member_id' )->join( 'core_groups', 'core_members.member_group_id=core_groups.g_id' )->setKeyField( 'member_id' );
|
||||
$memberCount = $members->count( TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
$members = \IPS\Db::i()->select( 'core_sessions.member_id,core_sessions.member_name,core_sessions.seo_name,core_sessions.member_group', 'core_sessions', $where, 'core_sessions.running_time DESC' )->join( 'core_members', 'core_members.member_id=core_sessions.member_id' )->join( 'core_groups', 'core_members.member_group_id=core_groups.g_id' )->setKeyField( 'member_id' );
|
||||
$memberCount = $members->count();
|
||||
}
|
||||
|
||||
$members = iterator_to_array( $members );
|
||||
|
||||
if( \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
if( !\IPS\Member::loggedIn()->group['g_hide_online_list'] )
|
||||
{
|
||||
if( !isset( $members[ \IPS\Member::loggedIn()->member_id ] ) )
|
||||
{
|
||||
$memberCount++;
|
||||
}
|
||||
|
||||
$members[ \IPS\Member::loggedIn()->member_id ] = array(
|
||||
'member_id' => \IPS\Member::loggedIn()->member_id,
|
||||
'member_name' => \IPS\Member::loggedIn()->name,
|
||||
'seo_name' => \IPS\Member::loggedIn()->members_seo_name,
|
||||
'member_group' => \IPS\Member::loggedIn()->member_group_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return $this->output( $members, $memberCount );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Announcements Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 19 Nov 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Announcements Widget
|
||||
*/
|
||||
class _announcements extends \IPS\Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'announcements';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return \IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'toshow', isset( $this->configuration['toshow'] ) ? $this->configuration['toshow'] : 5, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'sort_by', isset( $this->configuration['sort_by'] ) ? $this->configuration['sort_by'] : 'asc', TRUE, array( 'options' => array( 'asc' => 'ascending', 'desc' => 'descending' ) ) ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$announcements = array();
|
||||
|
||||
$where = array();
|
||||
$where[] = array( 'announce_active=?', 1 );
|
||||
$where[] = array( 'announce_start<? AND ( announce_end=0 OR announce_end>? )', time(), time() );
|
||||
|
||||
$clauses = array();
|
||||
$params = array();
|
||||
foreach ( \IPS\Dispatcher::i()->application->extensions( 'core', 'Announcements' ) as $key => $extension )
|
||||
{
|
||||
$id = $extension::$idField;
|
||||
if ( isset( \IPS\Request::i()->$id ) )
|
||||
{
|
||||
if ( \IPS\Dispatcher::i()->dispatcherController instanceof \IPS\Content\Controller )
|
||||
{
|
||||
foreach( \IPS\Dispatcher::i()->application->extensions( 'core', 'ContentRouter' ) AS $k => $contentRouter )
|
||||
{
|
||||
foreach( $contentRouter->classes AS $class )
|
||||
{
|
||||
$clauses[] = '( announce_location=? AND ( ' . \IPS\Db::i()->findInSet( 'announce_ids', array( $class::load( \IPS\Request::i()->$id )->mapped('container') ) ) . ' OR announce_ids=? ) )';
|
||||
$params[] = $key;
|
||||
$params[] = '0';
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$clauses[] = '( announce_location=? AND ( ' . \IPS\Db::i()->findInSet( 'announce_ids', array( \IPS\Request::i()->$id ) ) . ' OR announce_ids=? ) )';
|
||||
$params[] = $key;
|
||||
$params[] = '0';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$clauses[] = '( announce_location=? AND announce_ids=? )';
|
||||
$params[] = $key;
|
||||
$params[] = '0';
|
||||
}
|
||||
}
|
||||
|
||||
$where[] = array_merge( array( '( announce_app=? OR ( announce_app=?' . ( count( $clauses ) ? ( ' AND ( ' . implode( ' OR ', $clauses ) . ' ) ' ) : '' ) . ' ) )', '*', \IPS\Dispatcher::i()->application->directory ), $params );
|
||||
|
||||
$direction = isset( $this->configuration['sort_by'] ) ? $this->configuration['sort_by'] : 'asc';
|
||||
$limit = isset( $this->configuration['toshow'] ) ? $this->configuration['toshow'] : 5;
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*' ,'core_announcements', $where, 'announce_start ' . $direction, array( 0, $limit ) ) as $row )
|
||||
{
|
||||
$announcements[] = \IPS\core\Announcements\Announcement::constructFromData($row);
|
||||
}
|
||||
|
||||
if ( !count( $announcements ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->output( $announcements );
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief recentStatusUpdates Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 04 Jun 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* recentStatusUpdates Widget
|
||||
*/
|
||||
class _recentStatusUpdates extends \IPS\Widget\PermissionCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'recentStatusUpdates';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return \IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'number_to_show', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, TRUE ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ( !\IPS\Settings::i()->profile_comments )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'status' ) ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$statuses = new \IPS\Patterns\ActiveRecordIterator(
|
||||
\IPS\Db::i()->select(
|
||||
'*',
|
||||
'core_member_status_updates',
|
||||
array( 'status_approved = 1' ),
|
||||
'status_date DESC',
|
||||
array( 0, isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5 )
|
||||
),
|
||||
'\IPS\core\Statuses\Status'
|
||||
);
|
||||
|
||||
return $this->output( $statuses );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Related Content Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 28 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
* @note This widget is designed to be enabled on a page that displays a content item (e.g. a topic) to show related content based on tags
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Related Content Widget
|
||||
*/
|
||||
class _relatedContent extends \IPS\Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'relatedContent';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return \IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'toshow', isset( $this->configuration['toshow'] ) ? $this->configuration['toshow'] : 5, TRUE ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if( !( \IPS\Dispatcher::i()->dispatcherController instanceof \IPS\Content\Controller ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$related = \IPS\Dispatcher::i()->dispatcherController->getSimilarContent();
|
||||
|
||||
if( $related === NULL or !count( $related ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->output( $related );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Stats Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 21 Nov 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stats Widget
|
||||
*/
|
||||
class _stats extends \IPS\Widget\StaticCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'stats';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$mostOnline = json_decode( \IPS\Settings::i()->most_online, TRUE );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'stats_most_online', $mostOnline['count'], TRUE ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ran before saving widget configuration
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
{
|
||||
if ( \IPS\Member::loggedIn()->isAdmin() and \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'member_recount_content' ) )
|
||||
{
|
||||
$mostOnline = array( 'count' => $values['stats_most_online'], 'time' => time() );
|
||||
\IPS\Settings::i()->most_online = json_encode( $mostOnline );
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => json_encode( $mostOnline ) ), array( 'conf_key=?', 'most_online' ) );
|
||||
|
||||
unset( $values['stats_most_online'] );
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
|
||||
\IPS\Widget::deleteCaches( 'stats', 'core' );
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$stats = array();
|
||||
$mostOnline = json_decode( \IPS\Settings::i()->most_online, TRUE );
|
||||
|
||||
/* Member count */
|
||||
$stats['member_count'] = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', array( 'name<>? AND email<>?', '', '' ) )->first();
|
||||
|
||||
/* Most online */
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', 'core_sessions', array( 'login_type<>? and running_time > ?', \IPS\Session\Front::LOGIN_TYPE_SPIDER, \IPS\DateTime::create()->sub( new \DateInterval( 'PT30M' ) )->getTimeStamp() ) )->first();
|
||||
if( $count > $mostOnline['count'] )
|
||||
{
|
||||
$mostOnline = array( 'count' => $count, 'time' => time() );
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => json_encode( $mostOnline ) ), array( 'conf_key=?', 'most_online' ) );
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
}
|
||||
$stats['most_online'] = $mostOnline;
|
||||
|
||||
/* Last Registered Member */
|
||||
$exclude = array();
|
||||
$where = array( 'name IS NOT NULL AND name != \'\' AND temp_ban != -1' );
|
||||
foreach( \IPS\Member\Group::groups() as $id => $group )
|
||||
{
|
||||
if ( $group->g_hide_online_list )
|
||||
{
|
||||
$exclude[] = $group->g_id;
|
||||
}
|
||||
}
|
||||
if ( count( $exclude ) )
|
||||
{
|
||||
$where[] = '( ! ( ' . \IPS\Db::i()->in( 'member_group_id', $exclude ) . ' ) )';
|
||||
}
|
||||
$where[] = '( ! ' . \IPS\Db::i()->bitwiseWhere( \IPS\Member::$bitOptions['members_bitoptions'], 'bw_is_spammer' ) . ' )';
|
||||
$where[] = 'core_validating.new_reg IS NULL';
|
||||
try
|
||||
{
|
||||
$stats['last_registered'] = \IPS\Member::constructFromData(
|
||||
\IPS\Db::i()->select( 'core_members.*, core_validating.new_reg', 'core_members', array( implode( ' AND ', $where ) ), 'core_members.member_id DESC', array( 0, 1 ) )->join(
|
||||
'core_validating',
|
||||
"core_validating.member_id=core_members.member_id"
|
||||
)->first() );
|
||||
}
|
||||
catch( \UnderflowException $ex )
|
||||
{
|
||||
$stats['last_registered'] = NULL;
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return $this->output( $stats );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief topContributors Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 02 Jul 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* topContributors Widget
|
||||
*/
|
||||
class _topContributors extends \IPS\Widget\StaticCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'topContributors';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return \IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'number_to_show', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, TRUE, array( 'max' => 25 ) ) );
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
/* How many? */
|
||||
$limit = isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5;
|
||||
|
||||
/* Work out who has got the most reputation this week... */
|
||||
$topContributorsThisWeek = array();
|
||||
foreach ( \IPS\Db::i()->select( array( 'member_received', 'rep_rating' ), 'core_reputation_index', array( 'member_received>0 AND rep_date>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P1W' ) )->getTimestamp() ) ) as $rep )
|
||||
{
|
||||
if ( !isset( $topContributorsThisWeek[ $rep['member_received'] ] ) )
|
||||
{
|
||||
$topContributorsThisWeek[ $rep['member_received'] ] = $rep['rep_rating'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$topContributorsThisWeek[ $rep['member_received'] ] += $rep['rep_rating'];
|
||||
}
|
||||
}
|
||||
arsort( $topContributorsThisWeek );
|
||||
$topContributorsThisWeek = array_slice( $topContributorsThisWeek, 0, $limit, TRUE );
|
||||
|
||||
/* Load their data */
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_members', \IPS\Db::i()->in( 'member_id', array_keys( $topContributorsThisWeek ) ) ) as $member )
|
||||
{
|
||||
\IPS\Member::constructFromData( $member );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return $this->output( $topContributorsThisWeek, $limit );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief whosOnline Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 28 Jul 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* whosOnline Widget
|
||||
*/
|
||||
class _whosOnline extends \IPS\Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'whosOnline';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
/* Do we have permission? */
|
||||
if ( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'online' ) ) )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
$where = array(
|
||||
array( 'core_sessions.running_time>' . \IPS\DateTime::create()->sub( new \DateInterval( 'PT30M' ) )->getTimeStamp() ),
|
||||
array( 'core_groups.g_hide_online_list=0' )
|
||||
);
|
||||
|
||||
$members = array();
|
||||
$memberCount = 0;
|
||||
$guests = 0;
|
||||
$anonymous = 0;
|
||||
|
||||
foreach( \IPS\Db::i()->select( 'core_sessions.member_id,core_sessions.member_name,core_sessions.seo_name,core_sessions.member_group,core_sessions.login_type', 'core_sessions', $where, 'core_sessions.running_time DESC', $this->orientation === 'horizontal' ? NULL : 60 )->join( 'core_groups', 'core_sessions.member_group=core_groups.g_id' ) as $row )
|
||||
{
|
||||
switch ( $row['login_type'] )
|
||||
{
|
||||
case \IPS\Session\Front::LOGIN_TYPE_MEMBER:
|
||||
$members[ $row['member_id'] ] = $row;
|
||||
break;
|
||||
case \IPS\Session\Front::LOGIN_TYPE_ANONYMOUS:
|
||||
$anonymous += 1;
|
||||
break;
|
||||
case \IPS\Session\Front::LOGIN_TYPE_GUEST:
|
||||
$guests += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$memberCount = count( $members );
|
||||
|
||||
if( \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
if( !\IPS\Member::loggedIn()->group['g_hide_online_list'] )
|
||||
{
|
||||
if( !isset( $members[ \IPS\Member::loggedIn()->member_id ] ) )
|
||||
{
|
||||
$memberCount++;
|
||||
}
|
||||
|
||||
$members[ \IPS\Member::loggedIn()->member_id ] = array(
|
||||
'member_id' => \IPS\Member::loggedIn()->member_id,
|
||||
'member_name' => \IPS\Member::loggedIn()->name,
|
||||
'seo_name' => \IPS\Member::loggedIn()->members_seo_name,
|
||||
'member_group' => \IPS\Member::loggedIn()->member_group_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return $this->output( $members, $memberCount, $guests, $anonymous );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user