Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -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 );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user