/** * 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(); }
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(); }