/** * @author Sebastien Piraux <*****@*****.**> old code * @author Julio Montoya 2013 * @desc Record information for login event when an user identifies himself with username & password */ function event_login(\Entity\User $user) { $userId = $user->getUserId(); $TABLETRACK_LOGIN = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); $reallyNow = api_get_utc_datetime(); $sql = "INSERT INTO " . $TABLETRACK_LOGIN . " (login_user_id, login_ip, login_date, logout_date) VALUES\n ('" . $userId . "',\n \t\t'" . Database::escape_string(api_get_real_ip()) . "',\n \t\t'" . $reallyNow . "',\n \t\t'" . $reallyNow . "'\n \t\t)"; Database::query($sql); $roles = $user->getRolesObj(); // auto subscribe /** @var \Entity\Role $role */ foreach ($roles as $role) { $role = $role->getRole(); $userStatusParsed = 'student'; switch ($role) { case 'ROLE_SESSION_MANAGER': $userStatusParsed = 'sessionadmin'; break; case 'ROLE_TEACHER': $userStatusParsed = 'teacher'; break; case 'ROLE_RRHH': $userStatusParsed = 'DRH'; break; } $autoSubscribe = api_get_setting($userStatusParsed . '_autosubscribe'); if ($autoSubscribe) { $autoSubscribe = explode('|', $autoSubscribe); foreach ($autoSubscribe as $code) { if (CourseManager::course_exists($code)) { CourseManager::subscribe_user($userId, $code); } } } } }