Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -48,7 +48,7 @@ class _achievements extends \IPS\Widget\StaticCache
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'widget_feed_title', isset( $this->configuration['language_key'] ) ? NULL : \IPS\Member::loggedIn()->language()->addToStack( 'achievements_widget_title' ), FALSE, array( 'app' => 'core', 'key' => ( isset( $this->configuration['language_key'] ) ? $this->configuration['language_key'] : NULL ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'achievements_to_show', isset( $this->configuration['achivements_to_show'] ) ? explode( ',', $this->configuration['achivements_to_show'] ) : [ 'badges', 'ranks' ], TRUE, [ 'options' => [
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'achievements_to_show', isset( $this->configuration['achievements_to_show'] ) ? explode( ',', $this->configuration['achievements_to_show'] ) : [ 'badges', 'ranks' ], TRUE, [ 'options' => [
|
||||
'badges' => 'block_achievements_badges',
|
||||
'ranks' => 'block_achievements_rank',
|
||||
] ] ) );
|
||||
@@ -86,10 +86,27 @@ class _achievements extends \IPS\Widget\StaticCache
|
||||
$result = [];
|
||||
$toShow = explode( ',', ( $this->configuration['achievements_to_show'] ?? 'badges,ranks' ) );
|
||||
$countToShow = $this->configuration['number_to_show'] ?? 5;
|
||||
$exclude = json_decode( \IPS\Settings::i()->rules_exclude_groups, TRUE );
|
||||
|
||||
foreach( \IPS\Member\Group::groups() as $group )
|
||||
{
|
||||
if( ! $group->g_view_board )
|
||||
{
|
||||
$exclude[] = $group->g_id;
|
||||
}
|
||||
}
|
||||
|
||||
if ( \is_array( $exclude ) and \count( $exclude ) )
|
||||
{
|
||||
$subWhere[] = [ \IPS\Db::i()->in( 'member_group_id', $exclude ) . ' OR ' . \IPS\Db::i()->findInSet( 'mgroup_others', $exclude ) ];
|
||||
}
|
||||
|
||||
$subWhere[] = [ 'temp_ban != 0 OR ' . \IPS\Db::i()->bitwiseWhere( \IPS\Member::$bitOptions['members_bitoptions'], 'bw_is_spammer' ) ];
|
||||
$subQuery = \IPS\Db::i()->select( 'member_id', 'core_members', $subWhere );
|
||||
|
||||
if ( \IPS\core\Achievements\Badge::show() and \in_array( 'badges', $toShow ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_member_badges', NULL, 'datetime DESC', $countToShow )->join( 'core_badges', 'core_member_badges.badge=core_badges.id' ) as $earnedBadge )
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_member_badges', ( $subQuery ? [ \IPS\Db::i()->in( 'core_member_badges.member', $subQuery, TRUE ) ] : NULL ), 'datetime DESC', $countToShow )->join( 'core_badges', 'core_member_badges.badge=core_badges.id' ) as $earnedBadge )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -112,7 +129,14 @@ class _achievements extends \IPS\Widget\StaticCache
|
||||
|
||||
if ( \IPS\core\Achievements\Rank::show() and \in_array( 'ranks', $toShow ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_points_log', 'new_rank IS NOT NULL', 'datetime DESC', $countToShow ) as $earnedRank )
|
||||
$query = [ [ 'new_rank IS NOT NULL' ] ];
|
||||
|
||||
if ( $subQuery )
|
||||
{
|
||||
$query[] = [ \IPS\Db::i()->in( 'core_points_log.member', $subQuery, TRUE ) ];
|
||||
}
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_points_log', $query, 'datetime DESC', $countToShow ) as $earnedRank )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -58,7 +58,32 @@ class _activeUsers extends \IPS\Widget\StaticCache
|
||||
|
||||
$member = \IPS\Member::loggedIn() ?: new \IPS\Member;
|
||||
|
||||
$this->cacheKey = "widget_{$this->key}_" . $this->uniqueKey . '_' . md5( json_encode( $configuration ) . "_" . $member->language()->id . "_" . $member->skin . "_" . $orientation . '-' . (int) \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) );
|
||||
/* Build WHERE clause */
|
||||
$parts = parse_url( (string) \IPS\Request::i()->url()->setPage() );
|
||||
|
||||
/* We can't run the URL related logic if we have no dispatcher because this class could also be initialized by the CLI cron job */
|
||||
if( \IPS\Dispatcher::hasInstance() )
|
||||
{
|
||||
if ( \IPS\Settings::i()->htaccess_mod_rewrite )
|
||||
{
|
||||
$this->url = $parts['scheme'] . "://" . $parts['host'] . ( isset( $parts['port'] ) ? ':' . $parts['port'] : '' ) . $parts['path'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->url = $parts['scheme'] . "://" . $parts['host'] . ( isset( $parts['port'] ) ? ':' . $parts['port'] : '' ) . $parts['path'] . ( isset( $parts['query'] ) ? '?' . $parts['query'] : '' );
|
||||
}
|
||||
|
||||
if( $member->member_id AND !$member->isOnlineAnonymously() )
|
||||
{
|
||||
\IPS\Output::i()->jsVars['member_id'] = $member->member_id;
|
||||
\IPS\Output::i()->jsVars['member_url'] = (string) $member->url();
|
||||
\IPS\Output::i()->jsVars['member_hovercardUrl'] = (string) $member->url()->setQueryString( 'do', 'hovercard' );
|
||||
\IPS\Output::i()->jsVars['member_formattedName'] = str_replace( '"', '\\"', \IPS\Member\Group::load( $member->member_group_id )->formatName( $member->name ) );
|
||||
}
|
||||
|
||||
$theme = $member->skin ?: \IPS\Theme::defaultTheme();
|
||||
$this->cacheKey = "widget_{$this->key}_" . $this->uniqueKey . '_' . md5( $this->url . '_' . json_encode( $configuration ) . "_" . $member->language()->id . "_" . $theme . "_" . $orientation . '-' . (int) \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members', 'front' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,33 +94,13 @@ class _activeUsers extends \IPS\Widget\StaticCache
|
||||
public function render()
|
||||
{
|
||||
/* Do we have permission? */
|
||||
if ( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'online' ) ) )
|
||||
if ( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'online', 'front' ) ) )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
$members = array();
|
||||
$memberCount = 0;
|
||||
|
||||
/* Build WHERE clause */
|
||||
$parts = parse_url( (string) \IPS\Request::i()->url()->setPage() );
|
||||
|
||||
if ( \IPS\Settings::i()->htaccess_mod_rewrite )
|
||||
{
|
||||
$url = $parts['scheme'] . "://" . $parts['host'] . ( isset( $parts['port'] ) ? ':' . $parts['port'] : '' ) . $parts['path'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = $parts['scheme'] . "://" . $parts['host'] . ( isset( $parts['port'] ) ? ':' . $parts['port'] : '' ) . $parts['path'] . ( isset( $parts['query'] ) ? '?' . $parts['query'] : '' );
|
||||
}
|
||||
|
||||
$members = \IPS\Session\Store::i()->getOnlineMembersByLocation( \IPS\Dispatcher::i()->application->directory, \IPS\Dispatcher::i()->module->key, \IPS\Dispatcher::i()->controller, \IPS\Request::i()->id, $url );
|
||||
|
||||
if ( isset( $members[ \IPS\Member::loggedIn()->member_id ] ) )
|
||||
{
|
||||
unset( $members[ \IPS\Member::loggedIn()->member_id ] );
|
||||
}
|
||||
|
||||
$members = \IPS\Session\Store::i()->getOnlineMembersByLocation( \IPS\Dispatcher::i()->application->directory, \IPS\Dispatcher::i()->module->key, \IPS\Dispatcher::i()->controller, \IPS\Request::i()->id, $this->url );
|
||||
|
||||
$memberCount = \count( $members );
|
||||
|
||||
/* If it's on the sidebar (rather than at the bottom), we want to limit it to 60 so we don't take too much space */
|
||||
@@ -104,25 +109,6 @@ class _activeUsers extends \IPS\Widget\StaticCache
|
||||
$members = \array_slice( $members, 0, 60 );
|
||||
}
|
||||
|
||||
if( \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
if( !\IPS\Member::loggedIn()->isOnlineAnonymously() )
|
||||
{
|
||||
if( !isset( $members[ \IPS\Member::loggedIn()->member_id ] ) )
|
||||
{
|
||||
$memberCount++;
|
||||
}
|
||||
|
||||
$members = array_merge( array( \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,
|
||||
'in_editor' => 0
|
||||
) ), $members );
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return $this->output( $members, $memberCount );
|
||||
}
|
||||
|
||||
@@ -211,14 +211,22 @@ class _members extends \IPS\Widget\StaticCache
|
||||
}
|
||||
}
|
||||
|
||||
/* Exclude banned, validating and spammers */
|
||||
$where[] = array( "core_members.temp_ban=0" );
|
||||
$where[] = array( "core_members.email!=''" );
|
||||
$where[] = array( '( ! ' . \IPS\Db::i()->bitwiseWhere( \IPS\Member::$bitOptions['members_bitoptions'], 'bw_is_spammer' ) . ' )' );
|
||||
$where[] = array( "( core_validating.vid IS NULL ) " );
|
||||
|
||||
$select = \IPS\Db::i()->select(
|
||||
'*',
|
||||
'core_members.*',
|
||||
'core_members',
|
||||
$where,
|
||||
$sort,
|
||||
( isset( $this->configuration['widget_member_show'] ) and $this->configuration['widget_member_show'] !== -1 ) ? array( 0, $this->configuration['widget_member_show'] ) : 100
|
||||
);
|
||||
|
||||
$select->join( 'core_validating', 'core_validating.member_id=core_members.member_id AND core_validating.new_reg = 1' );
|
||||
|
||||
if ( \count( $joins ) )
|
||||
{
|
||||
foreach( $joins as $join )
|
||||
|
||||
@@ -86,7 +86,7 @@ class _recentStatusUpdates extends \IPS\Widget
|
||||
return '';
|
||||
}
|
||||
|
||||
if( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'status' ) ) )
|
||||
if( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'status', 'front' ) ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Related Content Widget
|
||||
*/
|
||||
class _relatedContent extends \IPS\Widget
|
||||
class _relatedContent extends \IPS\Widget\PermissionCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
@@ -38,6 +38,60 @@ class _relatedContent extends \IPS\Widget
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param String $uniqueKey Unique key for this specific instance
|
||||
* @param array $configuration Widget custom configuration
|
||||
* @param null|string|array $access Array/JSON string of executable apps (core=sidebar only, content=IP.Content only, etc)
|
||||
* @param null|string $orientation Orientation (top, bottom, right, left)
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $uniqueKey, array $configuration, $access=null, $orientation=null )
|
||||
{
|
||||
parent::__construct( $uniqueKey, $configuration, $access, $orientation );
|
||||
|
||||
/* We can't run the URL related logic if we have no dispatcher because this class could also be initialized by the CLI cron job */
|
||||
if( \IPS\Dispatcher::hasInstance() )
|
||||
{
|
||||
/* Cache per item, not per block */
|
||||
$parts = parse_url( (string) \IPS\Request::i()->url()->setPage() );
|
||||
|
||||
if ( \IPS\Settings::i()->htaccess_mod_rewrite )
|
||||
{
|
||||
$url = $parts['scheme'] . "://" . $parts['host'] . ( isset( $parts['port'] ) ? ':' . $parts['port'] : '' ) . $parts['path'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = $parts['scheme'] . "://" . $parts['host'] . ( isset( $parts['port'] ) ? ':' . $parts['port'] : '' ) . $parts['path'] . ( isset( $parts['query'] ) ? '?' . $parts['query'] : '' );
|
||||
}
|
||||
|
||||
$member = \IPS\Member::loggedIn() ?: new \IPS\Member;
|
||||
$theme = $member->skin ?: \IPS\Theme::defaultTheme();
|
||||
$this->cacheKey = "widget_{$this->key}_" . $this->uniqueKey . '_' . md5( $url . '_' . json_encode( $configuration ) . "_" . $member->language()->id . "_" . $theme . "_" . $orientation );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ran before saving widget configuration
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
{
|
||||
if ( !isset( $this->configuration['language_key'] ) )
|
||||
{
|
||||
$this->configuration['language_key'] = 'widget_title_' . md5( mt_rand() );
|
||||
}
|
||||
$values['language_key'] = $this->configuration['language_key'];
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', $this->configuration['language_key'], $values['widget_feed_title'] );
|
||||
unset( $values['widget_feed_title'] );
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
@@ -47,7 +101,9 @@ class _relatedContent extends \IPS\Widget
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
|
||||
/* Block title */
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'widget_feed_title', isset( $this->configuration['language_key'] ) ? NULL : \IPS\Member::loggedIn()->language()->addToStack( 'block_relatedContent' ), FALSE, array( 'app' => 'core', 'key' => ( isset( $this->configuration['language_key'] ) ? $this->configuration['language_key'] : NULL ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'toshow', isset( $this->configuration['toshow'] ) ? $this->configuration['toshow'] : 5, TRUE ) );
|
||||
|
||||
return $form;
|
||||
@@ -74,6 +130,15 @@ class _relatedContent extends \IPS\Widget
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->output( $related );
|
||||
if ( isset( $this->configuration['language_key'] ) )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $this->configuration['language_key'], FALSE, array( 'escape' => TRUE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'block_relatedContent' );
|
||||
}
|
||||
|
||||
return $this->output( $related, $title );
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,8 @@ class _stats extends \IPS\Widget\StaticCache
|
||||
$where = array( array( "completed=1 AND temp_ban != -1" ) );
|
||||
$where[] = array( '( ! ' . \IPS\Db::i()->bitwiseWhere( \IPS\Member::$bitOptions['members_bitoptions'], 'bw_is_spammer' ) . ' )' );
|
||||
$where[] = array( 'member_id NOT IN(?)', \IPS\Db::i()->select( 'member_id', 'core_validating', array( 'new_reg=1' ) ) );
|
||||
|
||||
$where[] = array( 'NOT(members_bitoptions2 & ?)', \IPS\Member::$bitOptions['members_bitoptions']['members_bitoptions2']['is_support_account'] );
|
||||
|
||||
try
|
||||
{
|
||||
$stats['last_registered'] = \IPS\Member::constructFromData( \IPS\Db::i()->select( 'core_members.*', 'core_members', $where, 'core_members.member_id DESC', array( 0, 1 ) )->first() );
|
||||
|
||||
@@ -52,7 +52,16 @@ class _whosOnline extends \IPS\Widget\StaticCache
|
||||
|
||||
$member = \IPS\Member::loggedIn() ?: new \IPS\Member;
|
||||
|
||||
$this->cacheKey = "widget_{$this->key}_" . $this->uniqueKey . '_' . md5( json_encode( $configuration ) . "_" . $member->language()->id . "_" . $member->skin . "_" . $orientation . '-' . (int) \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) );
|
||||
if( $member->member_id AND !$member->isOnlineAnonymously() )
|
||||
{
|
||||
\IPS\Output::i()->jsVars['member_id'] = $member->member_id;
|
||||
\IPS\Output::i()->jsVars['member_url'] = (string) $member->url();
|
||||
\IPS\Output::i()->jsVars['member_hovercardUrl'] = (string) $member->url()->setQueryString( 'do', 'hovercard' );
|
||||
\IPS\Output::i()->jsVars['member_formattedName'] = str_replace( '"', '\\"', \IPS\Member\Group::load( $member->member_group_id )->formatName( $member->name ) );
|
||||
}
|
||||
|
||||
$theme = $member->skin ?: \IPS\Theme::defaultTheme();
|
||||
$this->cacheKey = "widget_{$this->key}_" . $this->uniqueKey . '_' . md5( json_encode( $configuration ) . "_" . $member->language()->id . "_" . $theme . "_" . $orientation . '-' . (int) \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'online', 'front' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +72,7 @@ class _whosOnline extends \IPS\Widget\StaticCache
|
||||
public function render()
|
||||
{
|
||||
/* Do we have permission? */
|
||||
if ( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'online' ) ) )
|
||||
if ( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'online', 'front' ) ) )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
@@ -79,12 +88,9 @@ class _whosOnline extends \IPS\Widget\StaticCache
|
||||
{
|
||||
/* Not-anonymous Member */
|
||||
case \IPS\Session\Front::LOGIN_TYPE_MEMBER:
|
||||
if ( $row['member_id'] != \IPS\Member::loggedIn()->member_id ) // We add them manually to make sure they go at the top of the list
|
||||
if ( $row['member_name'] )
|
||||
{
|
||||
if ( $row['member_name'] )
|
||||
{
|
||||
$members[ $row['member_id'] ] = $row;
|
||||
}
|
||||
$members[ $row['member_id'] ] = $row;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -104,23 +110,7 @@ class _whosOnline extends \IPS\Widget\StaticCache
|
||||
{
|
||||
$members = \array_slice( $members, 0, 60 );
|
||||
}
|
||||
|
||||
/* Add ourselves at the top of the list */
|
||||
if( \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
if( !\IPS\Member::loggedIn()->isOnlineAnonymously() )
|
||||
{
|
||||
$memberCount++;
|
||||
|
||||
$members = array_merge( array( \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
|
||||
) ), $members );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Display */
|
||||
return $this->output( $members, $memberCount, $guests, $anonymous );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user