/** * Get the login time for on e or all users in the specified time interval * * This function returns the login time for the specified user in the specified interval * <br/>Example: * <code> * $interval['from'] = "00000000"; * $interval['to'] = time(); * $time = EfrontUser :: getLoginTime('jdoe', $interval); //$time['jdoe'] now holds his times * $times = EfrontUser :: getLoginTime($interval); //$times now holds an array of times for all users * </code> * * @param mixed $login The user to calulate times for, or false for all users * @param mixed An array of the form (from =>'', to=>'') or false (return the total login time) * @return the total login time as an array of hours, minutes, seconds * @since 3.5.0 * @access public */ public static function getLoginTime($login = false, $interval = array()) { $times = new EfrontTimes($interval); if ($login) { $result = $times->getUserTotalSessionTime($login); return $times->formatTimeForReporting($result); } else { foreach ($times->getSystemSessionTimesForUsers() as $login => $result) { $userTimes[$login] = $times->formatTimeForReporting($result); return $userTimes; } } }
$testNames = array_combine($testNames['id'], $testNames['name']); $result = eF_getTableData("logs", "*", "timestamp between {$from} and {$to} order by timestamp"); foreach ($result as $key => $value) { $value['lessons_ID'] ? $result[$key]['lesson_name'] = $lessonNames[$value['lessons_ID']] : null; if ($value['action'] == 'content' || $value['action'] == 'tests' || $value['action'] == 'test_begin') { $result[$key]['content_name'] = $contentNames[$value['comments']]; } } $analytic_log = $result; $smarty->assign("T_SYSTEM_LOG", $analytic_log); } $users = array(); $result = eF_getTableData("logs, users", "users.name, users.surname, users.active, users_LOGIN, count(logs.id) as cnt ", "users.login=users_LOGIN and action = 'login' and logs.timestamp between {$from} and {$to} group by users_LOGIN order by count(logs.id) desc"); // $userTimes = EfrontUser :: getLoginTime(false, array('from' => $from, 'to' => $to)); $timesReport = new EfrontTimes(array($from, $to)); $userTimes = $timesReport->getSystemSessionTimesForUsers(); foreach ($result as $value) { $users[$value['users_LOGIN']]['name'] = $value['name']; $users[$value['users_LOGIN']]['surname'] = $value['surname']; $users[$value['users_LOGIN']]['active'] = $value['active']; $users[$value['users_LOGIN']]['accesses'] = $value['cnt']; $users[$value['users_LOGIN']]['seconds'] = $userTimes[$value['users_LOGIN']]; } $lessons = array(); $result = eF_getTableData("logs", "*", "timestamp between {$from} and {$to}"); foreach ($result as $value) { if ($value['lessons_ID']) { $lessons[$value['lessons_ID']] = array(); } } $totalUserAccesses = $totalUserTime = 0;