本文整理汇总了PHP中KunenaUserHelper::getOnlineUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaUserHelper::getOnlineUsers方法的具体用法?PHP KunenaUserHelper::getOnlineUsers怎么用?PHP KunenaUserHelper::getOnlineUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaUserHelper
的用法示例。
在下文中一共展示了KunenaUserHelper::getOnlineUsers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
/**
* Prepare Who is online display.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
$this->config = KunenaConfig::getInstance();
if (!$this->config->get('showwhoisonline')) {
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '404');
}
$me = KunenaUserHelper::getMyself();
$moderator = intval($me->isModerator()) + intval($me->isAdmin());
$users = KunenaUserHelper::getOnlineUsers();
KunenaUserHelper::loadUsers(array_keys($users));
$onlineusers = KunenaUserHelper::getOnlineCount();
$who = '<strong>' . $onlineusers['user'] . ' </strong>';
if ($onlineusers['user'] == 1) {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_MEMBER') . ' ';
} else {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_MEMBERS') . ' ';
}
$who .= JText::_('COM_KUNENA_WHO_AND');
$who .= '<strong> ' . $onlineusers['guest'] . ' </strong>';
if ($onlineusers['guest'] == 1) {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_GUEST') . ' ';
} else {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_GUESTS') . ' ';
}
$who .= JText::_('COM_KUNENA_WHO_ONLINE_NOW');
$this->membersOnline = $who;
$this->onlineList = array();
$this->hiddenList = array();
foreach ($users as $userid => $usertime) {
$user = KunenaUserHelper::get($userid);
if (!$user->showOnline) {
if ($moderator) {
$this->hiddenList[$user->getName()] = $user;
}
} else {
$this->onlineList[$user->getName()] = $user;
}
}
ksort($this->onlineList);
ksort($this->hiddenList);
$profile = KunenaFactory::getProfile();
$this->usersUrl = $profile->getUserListURL();
}
示例2: displayWhosonline
function displayWhosonline($tpl = null) {
$moderator = intval($this->me->isModerator());
$cache = JFactory::getCache('com_kunena', 'output');
if ($cache->start("{$this->template->name}.common.whosonline.{$moderator}", "com_kunena.template")) return;
$this->my = JFactory::getUser();
$users = KunenaUserHelper::getOnlineUsers();
KunenaUserHelper::loadUsers(array_keys($users));
$onlineusers = KunenaUserHelper::getOnlineCount();
$who = '<strong>'.$onlineusers['user'].' </strong>';
if($onlineusers['user']==1) {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_MEMBER').' ';
} else {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_MEMBERS').' ';
}
$who .= JText::_('COM_KUNENA_WHO_AND');
$who .= '<strong> '. $onlineusers['guest'].' </strong>';
if($onlineusers['guest']==1) {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_GUEST').' ';
} else {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_GUESTS').' ';
}
$who .= JText::_('COM_KUNENA_WHO_ONLINE_NOW');
$this->membersOnline = $who;
$this->onlineList = array();
$this->hiddenList = array();
foreach ($users as $userid=>$usertime) {
$user = KunenaUserHelper::get($userid);
if ( !$user->showOnline ) {
if ($this->me->isModerator()) $this->hiddenList[$user->getName()] = $user;
} else {
$this->onlineList[$user->getName()] = $user;
}
}
ksort($this->onlineList);
ksort($this->hiddenList);
$this->usersURL = KunenaRoute::_('index.php?option=com_kunena&view=user&layout=list');
$result = $this->loadTemplate($tpl);
if (JError::isError($result)) {
return $result;
}
echo $result;
$cache->end();
}