ÿØÿà JFIF    ÿÛ „  ( %!1"%)+...383-7(-.+  -%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ     ÿÄ @    !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ    ÿÄ '   1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ϗ -3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéߦ$$½—šÙÜCC¯¶è8β–Åkèwx LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2޿د­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÁ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’שT ] ªb—ÊîKC^×M“xùäñz¬zJ× {4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi [0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú Ò˜Æ}2VE•Ѐp¡Ô3Úº …h³^LJºçì¥Ánó|˜ÖˆÎˆ+« ¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<̉Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈ Àá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ ƒÜÒ? :õdsÀ –3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LǐÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl Í›G¹ÀPá¼Nc¡šÒ…ÙWͳœ±vÊáЄ×9‹P‰cEØ‘™›µŸP<×g1 º©Ø¬wiÁ^l5× I/';Ë+´Z‡ÓÄFÕp[Èð’ HÄ ó 9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ QãñQtIeórVB,ÏÂf‹4#Μc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ  ÷jsςҒKÈcø(é›;k(’#ôŒQ ™C> õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~Ȧ—’-$fe«"FâUˆÊwµPÏu w+"åÉó¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ɏdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt ·K¢ÅÅ·¥RÄÊÉbKn N­R2g$VµÕó Qr#–ÓZUÏð0ÎtÙÀœz ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Δâ‘ËØ´IˆÓ°Ë‰ÞM3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z à¾] üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.ž„æ“I[ ª+·zÐÒÚ,½Ð»¶€C›7jk$๖€Ž¾ÅÙpp¶ÍþéΤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ćf× æ¢ƱqWı[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGށ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ ƈæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„ g01¬„åEM蛇Ã\6µE›‘fÙO k÷CºnÓ1`iîÒ² áÂ!ÑLÄÿ ³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#» Ç\……ßïIœÉ$¸ÎñÍ®ÔHÇ Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡ —JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ 5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*禌Éù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnݳvðÖKE¼‚ »mà ÷f®:Ë ™–4rð¡4` ܹçž~‹C=œ…¾Ïj|VDtK.ƒ"9 Ï ­–éXá³6WÒïIL-Ї Ç PK\w db/access.phpnu[. /** * Capabilities for this report. * * @package report_usersessions * @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Petr Skoda */ defined('MOODLE_INTERNAL') || die(); $capabilities = array( 'report/usersessions:manageownsessions' => array( 'captype' => 'write', 'contextlevel' => CONTEXT_USER, 'archetypes' => array( 'user' => CAP_ALLOW, ), // NOTE: shared accounts usually do not allow changing // of own passwords, this is not very accurate but safer. 'clonepermissionsfrom' => 'moodle/user:changeownpassword' ), ); PK\ lang/en/report_usersessions.phpnu[. /** * Lang strings. * * @package report_usersessions * @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Petr Skoda */ $string['logoutothersessions'] = 'Log out all other browser sessions'; $string['logoutothersessions_help'] = 'Log out of all browser sessions, except for this one. This does not affect web apps.'; $string['logoutothersessionssuccess'] = 'You are logged out of all your other sessions.'; $string['logoutsinglesessionsuccess'] = 'You are logged out of the session at {$a}.'; $string['mysessions'] = 'My active browser sessions'; $string['navigationlink'] = 'Browser sessions'; $string['pluginname'] = 'User sessions report'; $string['thissession'] = 'Current session'; $string['usersessions:manageownsessions'] = 'Manage own browser sessions'; $string['privacy:metadata'] = 'The User sessions report plugin does not store any personal data.'; PK\>  lib.phpnu[. /** * Lib API functions. * * @package report_usersessions * @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Petr Skoda */ defined('MOODLE_INTERNAL') || die; /** * This function extends the course navigation with the report items * * @param navigation_node $navigation The navigation node to extend * @param stdClass $user * @param stdClass $course The course to object for the report */ function report_usersessions_extend_navigation_user($navigation, $user, $course) { global $USER; if (isguestuser() or !isloggedin()) { return; } if (\core\session\manager::is_loggedinas() or $USER->id != $user->id) { // No peeking at somebody else's sessions! return; } $context = context_user::instance($USER->id); if (has_capability('report/usersessions:manageownsessions', $context)) { $navigation->add(get_string('navigationlink', 'report_usersessions'), new moodle_url('/report/usersessions/user.php'), $navigation::TYPE_SETTING); } } /** * Add nodes to myprofile page. * * @param \core_user\output\myprofile\tree $tree Tree object * @param stdClass $user user object * @param bool $iscurrentuser * @param stdClass $course Course object * * @return bool */ function report_usersessions_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) { global $USER; if (isguestuser() or !isloggedin()) { return; } if (\core\session\manager::is_loggedinas() or $USER->id != $user->id) { // No peeking at somebody else's sessions! return; } $context = context_user::instance($USER->id); if (has_capability('report/usersessions:manageownsessions', $context)) { $node = new core_user\output\myprofile\node('reports', 'usersessions', get_string('navigationlink', 'report_usersessions'), null, new moodle_url('/report/usersessions/user.php')); $tree->add_node($node); } return true; } PK\lKR version.phpnu[. /** * Version info. * * @package report_usersessions * @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Petr Skoda */ defined('MOODLE_INTERNAL') || die; $plugin->version = 2025041400; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2025040800; // Requires this Moodle version. $plugin->component = 'report_usersessions'; // Full name of the plugin (used for diagnostics). PK\~Iclasses/privacy/provider.phpnu[. /** * Privacy Subsystem implementation for report_usersessions. * * @package report_usersessions * @copyright 2018 Zig Tan * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace report_usersessions\privacy; defined('MOODLE_INTERNAL') || die(); /** * Privacy Subsystem for report_usersessions implementing null_provider. * * @copyright 2018 Zig Tan * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class provider implements \core_privacy\local\metadata\null_provider { /** * Get the language string identifier with the component's language * file to explain why this plugin stores no data. * * @return string */ public static function get_reason(): string { return 'privacy:metadata'; } }PK\= locallib.phpnu[. /** * Lib API functions. * * @package report_usersessions * @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Petr Skoda */ defined('MOODLE_INTERNAL') || die; require_once(__DIR__ . '/lib.php'); /** * Show user friendly duration since last activity. * * @param int $duration in seconds * @return string */ function report_usersessions_format_duration($duration) { // NOTE: The session duration is not accurate thanks to // $CFG->session_update_timemodified_frequency setting. // Also there is no point in showing days here because // the session cleanup should purge all stale sessions // regularly. if ($duration < 60) { return get_string('now'); } if ($duration < 60 * 60 * 2) { $minutes = (int)($duration / 60); $ago = $minutes . ' ' . get_string('minutes'); return get_string('ago', 'core_message', $ago); } $hours = (int)($duration / (60 * 60)); $ago = $hours . ' ' . get_string('hours'); return get_string('ago', 'core_message', $ago); } /** * Show some user friendly IP address info. * * @param string $ip * @return string */ function report_usersessions_format_ip($ip) { if (strpos($ip, ':') !== false) { // For now ipv6 is not supported yet. return $ip; } $url = new moodle_url('/iplookup/index.php', array('ip' => $ip)); return html_writer::link($url, $ip); } /** * Kill user session. * * @param int $id * @return void */ function report_usersessions_kill_session(int $id): void { global $USER; $sessions = \core\session\manager::get_sessions_by_userid($USER->id); $filteredsessions = array_filter($sessions, fn ($session) => $session->id === $id); foreach ($filteredsessions as $session) { if ($session->sid !== session_id()) { \core\session\manager::destroy($session->sid); } } } PK\3B3?? index.phpnu[. /** * Listing of all sessions for current user. * * @package report_usersessions * @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Petr Skoda */ require(__DIR__ . '/../../config.php'); redirect(new moodle_url('/report/usersessions/user.php')); PK\h{*tests/lib_test.phpnu[. /** * Tests for report library functions. * * @package report_usersessions * @copyright 2015 onwards Ankit agarwal * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ namespace report_usersessions; defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot. '/report/usersessions/lib.php'); /** * Class report_stats_lib_testcase * * @package report_usersessions * @copyright 2014 onwards Ankit agarwal * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ final class lib_test extends \advanced_testcase { /** * @var stdClass The user. */ private $user; /** * @var stdClass The course. */ private $course; /** * @var \core_user\output\myprofile\tree The navigation tree. */ private $tree; public function setUp(): void { parent::setUp(); $this->user = $this->getDataGenerator()->create_user(); $this->course = $this->getDataGenerator()->create_course(); $this->tree = new \core_user\output\myprofile\tree(); $this->resetAfterTest(); } /** * Tests the report_userssesions_myprofile_navigation() function as an admin. */ public function test_report_usersessions_myprofile_navigation_as_admin(): void { $this->setAdminUser(); $iscurrentuser = false; // Not even admins allowed to pick at other user's sessions. report_usersessions_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course); $reflector = new \ReflectionObject($this->tree); $nodes = $reflector->getProperty('nodes'); $this->assertArrayNotHasKey('usersessions', $nodes->getValue($this->tree)); } /** * Tests the report_userssesions_myprofile_navigation() function as the currently logged in user. */ public function test_report_usersessions_myprofile_navigation_as_current_user(): void { $this->setUser($this->user); $iscurrentuser = true; report_usersessions_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course); $reflector = new \ReflectionObject($this->tree); $nodes = $reflector->getProperty('nodes'); $this->assertArrayHasKey('usersessions', $nodes->getValue($this->tree)); } /** * Tests the report_userssesions_myprofile_navigation() function as a guest. */ public function test_report_usersessions_myprofile_navigation_as_guest(): void { $this->setGuestUser(); $iscurrentuser = true; report_usersessions_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course); $reflector = new \ReflectionObject($this->tree); $nodes = $reflector->getProperty('nodes'); $this->assertArrayNotHasKey('usersessions', $nodes->getValue($this->tree)); } /** * Tests the report_userssesions_myprofile_navigation() function as a user without permission. */ public function test_report_usersessions_myprofile_navigation_without_permission(): void { // Try to see as a user without permission. $user2 = $this->getDataGenerator()->create_user(); $this->setUser($user2); $iscurrentuser = false; report_usersessions_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course); $reflector = new \ReflectionObject($this->tree); $nodes = $reflector->getProperty('nodes'); $this->assertArrayNotHasKey('usersessions', $nodes->getValue($this->tree)); } } PK\R'tests/behat/usersessions_report.featurenu[@report @report_usersessions Feature: In a report, admin can see current sessions In order see usersession data As a admin I need to view usersessions report and see if the current session is listed @javascript Scenario: Check usersessions report shows current session Given I log in as "admin" And I follow "Profile" in the user menu When I follow "Browser sessions" Then I should see "Current session" PK\??user.phpnu[. /** * Listing of all sessions for current user. * * @package report_usersessions * @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Petr Skoda */ require(__DIR__ . '/../../config.php'); require_once(__DIR__ . '/locallib.php'); require_login(null, false); if (isguestuser()) { // No guests here! redirect(new moodle_url('/')); die; } if (\core\session\manager::is_loggedinas()) { // No login-as users. redirect(new moodle_url('/user/index.php')); die; } $context = context_user::instance($USER->id); require_capability('report/usersessions:manageownsessions', $context); $delete = optional_param('delete', 0, PARAM_INT); $deleteall = optional_param('deleteall', false, PARAM_BOOL); $lastip = cleanremoteaddr(optional_param('lastip', '', PARAM_TEXT)); $PAGE->set_url('/report/usersessions/user.php'); $PAGE->set_context($context); $PAGE->set_title(get_string('navigationlink', 'report_usersessions')); $PAGE->set_heading(fullname($USER)); $PAGE->set_pagelayout('admin'); // Delete a specific session. if ($delete && confirm_sesskey()) { report_usersessions_kill_session($delete); redirect( url: $PAGE->url, message: get_string('logoutsinglesessionsuccess', 'report_usersessions', $lastip), messagetype: \core\output\notification::NOTIFY_SUCCESS, ); } // Delete all sessions except current. if ($deleteall && confirm_sesskey()) { \core\session\manager::destroy_user_sessions($USER->id, session_id()); redirect( url: $PAGE->url, message: get_string('logoutothersessionssuccess', 'report_usersessions'), messagetype: \core\output\notification::NOTIFY_SUCCESS, ); } // Create the breadcrumb. $PAGE->add_report_nodes($USER->id, array( 'name' => get_string('navigationlink', 'report_usersessions'), 'url' => new moodle_url('/report/usersessions/user.php') )); echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('mysessions', 'report_usersessions')); $data = array(); $sessions = \core\session\manager::get_sessions_by_userid($USER->id); // Order records by timemodified DESC. usort($sessions, function($a, $b){ return $b->timemodified <=> $a->timemodified; }); foreach ($sessions as $session) { if ($session->sid === session_id()) { $lastaccess = get_string('thissession', 'report_usersessions'); $deletelink = ''; } else { $lastaccess = report_usersessions_format_duration(time() - $session->timemodified); $url = new moodle_url($PAGE->url, ['delete' => $session->id, 'sesskey' => sesskey(), 'lastip' => $session->lastip]); $deletelink = html_writer::link($url, get_string('logout')); } $data[] = array(userdate($session->timecreated), $lastaccess, report_usersessions_format_ip($session->lastip), $deletelink); } $table = new html_table(); $table->head = array(get_string('login'), get_string('lastaccess'), get_string('lastip'), get_string('action')); $table->align = array('left', 'left', 'left', 'right'); $table->data = $data; echo html_writer::table($table); // Provide button to log out all other sessions. if (count($sessions) > 1) { $url = new moodle_url($PAGE->url, ['deleteall' => true]); echo $OUTPUT->single_button($url, get_string('logoutothersessions', 'report_usersessions')); } echo $OUTPUT->footer(); PK\w db/access.phpnu[PK\ lang/en/report_usersessions.phpnu[PK\>   lib.phpnu[PK\lKR !version.phpnu[PK\~I?classes/privacy/provider.phpnu[PK\= #locallib.phpnu[PK\3B3?? w.index.phpnu[PK\h{*2tests/lib_test.phpnu[PK\R' Dtests/behat/usersessions_report.featurenu[PK\??Fuser.phpnu[PK 0V