/** * Get user information for online users * * @return array An array of arrays describing an atom feed */ public static function get_online_users() { global $USER; // last 10 active users $users = get_onlineusers(); // now format ready for atom $results = array('id' => sha1($_SERVER['HTTP_HOST'] . 'get_online_users' . time()), 'link' => get_config('wwwroot'), 'email' => $USER->get('email'), 'uri' => get_config('wwwroot'), 'title' => 'Get Online Users by ' . $USER->username . ' at ' . webservice_rest_server::format_rfc3339_date(time()), 'name' => 'mahara_user_external_get_online_users', 'updated' => webservice_rest_server::format_rfc3339_date(time()), 'entries' => array()); foreach ($users['data'] as $user) { $user = get_record('usr', 'id', $user); if (empty($user)) { continue; } $results['entries'][] = array('id' => get_config('wwwroot') . 'user/view.php?id=' . $user->id, 'link' => get_config('wwwroot') . 'user/view.php?id=' . $user->id, 'email' => $user->email, 'name' => display_name($user), 'updated' => webservice_rest_server::format_rfc3339_date(strtotime($user->lastaccess)), 'published' => webservice_rest_server::format_rfc3339_date(time()), 'title' => 'last_access'); } return $results; }
/** * * @package mahara * @subpackage core * @author Stacey Walker * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); require dirname(dirname(__FILE__)) . '/init.php'; // OVERWRITE 1: insert define('INSTITUTIONALADMIN', 1); global $CFG; if (!$CFG->current_app->hasPrivilege('EschoolAdmin')) { $CFG->current_app->gcError('Unprivileged attempted access to /site/pages.php', 'gcpageaccessdenied'); } // END OVERWRITE 1 define('TITLE', get_string('onlineusers')); define('SECTION_PLUGINTYPE', 'core'); define('SECTION_PLUGINNAME', 'user'); define('SECTION_PAGE', 'onlineusers'); $offset = param_integer('offset', 0); $limit = 10; $data = get_onlineusers($limit, $offset); build_onlinelist_html($data, 'online'); $smarty = smarty(array('paginator')); $smarty->assign('PAGEHEADING', TITLE); $smarty->assign('lastminutes', floor(get_config('accessidletimeout') / 60)); $smarty->assign('data', $data); $smarty->display('user/online.tpl');