123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
- class Redirect
- {
-
- public static function www()
- {
- return api_get_path(WEB_PATH);
- }
-
- public static function go($url = '')
- {
- if (empty($url)) {
- self::session_request_uri();
- $www = self::www();
- self::navigate($www);
- }
- $is_full_uri = (strpos($url, 'http') === 0);
- if ($is_full_uri) {
- self::navigate($url);
- }
- $url = self::www().$url;
- self::navigate($url);
- }
-
- public static function session_request_uri($logging_in = false, $user_id = null)
- {
- $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;
- if ($no_redirection) {
- unset($_SESSION['noredirection']);
- return;
- }
- $url = isset($_SESSION['request_uri']) ? Security::remove_XSS($_SESSION['request_uri']) : '';
- unset($_SESSION['request_uri']);
- if (!empty($url)) {
- self::navigate($url);
- } elseif ($logging_in || (isset($_REQUEST['sso_referer']) && !empty($_REQUEST['sso_referer']))) {
- if (isset($user_id)) {
-
- $user_status = api_get_user_status($user_id);
- switch ($user_status) {
- case COURSEMANAGER:
- $redir = api_get_setting('teacher_page_after_login');
- if (!empty($redir)) {
- self::navigate(api_get_path(WEB_PATH).$redir);
- }
- break;
- case STUDENT:
- $redir = api_get_setting('student_page_after_login');
- if (!empty($redir)) {
- self::navigate(api_get_path(WEB_PATH).$redir);
- }
- break;
- case DRH:
- $redir = api_get_setting('drh_page_after_login');
- if (!empty($redir)) {
- self::navigate(api_get_path(WEB_PATH).$redir);
- }
- break;
- case SESSIONADMIN:
- $redir = api_get_setting('sessionadmin_page_after_login');
- if (!empty($redir)) {
- self::navigate(api_get_path(WEB_PATH).$redir);
- }
- break;
- default:
- break;
- }
- }
- $redirect = api_get_setting('redirect_admin_to_courses_list');
- if ($redirect !== 'true') {
-
- if (api_is_multiple_url_enabled()) {
-
-
- $url = api_get_current_access_url_id();
- if (api_is_platform_admin_by_id($user_id, $url)) {
- self::navigate(api_get_path(WEB_CODE_PATH).'admin/index.php');
- }
- } else {
-
- if (api_is_platform_admin_by_id($user_id)) {
- self::navigate(api_get_path(WEB_CODE_PATH).'admin/index.php');
- }
- }
- }
- $page_after_login = api_get_setting('page_after_login');
- if (!empty($page_after_login)) {
- self::navigate(api_get_path(WEB_PATH).$page_after_login);
- }
- }
- }
-
- public static function home()
- {
- $www = self::www();
- self::navigate($www);
- }
-
- public static function user_home()
- {
- $www = self::www();
- self::navigate("$www/user_portal.php");
- }
-
- protected static function navigate($url)
- {
- session_write_close();
- header("Location: $url");
- exit;
- }
- }
|