/** * Display whose online * * @return void */ public function displayTask() { // get all sessions $this->view->rows = SessionHelper::getAllSessions(array('guest' => 0, 'distinct' => 1)); // Output the HTML $this->view->display(); }
/** * Display module contents for Admin * * @return void */ public function displayAdmin() { if (!\App::isAdmin()) { return; } // get active sessions (users online) $this->rows = SessionHelper::getAllSessions(array('guest' => 0, 'distinct' => 1)); // Get the view require $this->getLayoutPath('default_admin'); }
/** * Show the current user activity * * @return void */ public function activityTask() { // Set the page title Document::setTitle(Lang::txt(strtoupper($this->_option)) . ': ' . Lang::txt(strtoupper($this->_task))); // Set the pathway if (Pathway::count() <= 0) { Pathway::append(Lang::txt(strtoupper($this->_option)), 'index.php?option=' . $this->_option); } Pathway::append(Lang::txt(strtoupper($this->_task)), 'index.php?option=' . $this->_option . '&task=' . $this->_task); // Check if they're logged in if (User::isGuest()) { $rtrn = Request::getVar('REQUEST_URI', Route::url('index.php?option=' . $this->_controller . '&task=activity', false, true), 'server'); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($rtrn), false)); } // Check authorization if (!User::authorise('core.manage', $this->_option)) { App::redirect(Route::url('index.php?option=' . $this->_option)); } // Get logged-in users $prevuser = ''; $user = array(); $users = array(); $guests = array(); // get sessions $result = SessionHelper::getAllSessions(array('guest' => 0)); if ($result && count($result) > 0) { foreach ($result as $row) { $row->idle = time() - $row->time; if ($prevuser != $row->username) { if ($user) { $profile = Member::oneOrNew($prevuser); $users[$prevuser] = $user; $users[$prevuser]['uidNumber'] = $profile->get('id'); $users[$prevuser]['name'] = $profile->get('name'); $users[$prevuser]['org'] = $profile->get('organization'); $users[$prevuser]['orgtype'] = $profile->get('orgtype'); $users[$prevuser]['countryresident'] = $profile->get('countryresident'); } $prevuser = $row->username; $user = array(); } array_push($user, array('ip' => $row->ip, 'idle' => $row->idle)); } if ($user) { $profile = Member::oneOrNew($prevuser); $users[$prevuser] = $user; $users[$prevuser]['uidNumber'] = $profile->get('id'); $users[$prevuser]['name'] = $profile->get('name'); $users[$prevuser]['org'] = $profile->get('organization'); $users[$prevuser]['orgtype'] = $profile->get('orgtype'); $users[$prevuser]['countryresident'] = $profile->get('countryresident'); } } // get sessions $result = SessionHelper::getAllSessions(array('guest' => 1)); if (count($result) > 0) { foreach ($result as $row) { $row->idle = time() - $row->time; array_push($guests, array('ip' => $row->ip, 'idle' => $row->idle)); } } // Output View $this->view->set('title', Lang::txt('Active Users and Guests'))->set('users', $users)->set('guests', $guests)->setErrors($this->getErrors())->display(); }