|
@@ -6,26 +6,21 @@
|
|
|
* @license see /license.txt
|
|
|
* @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva
|
|
|
*/
|
|
|
-class Redirect
|
|
|
-{
|
|
|
+class Redirect {
|
|
|
|
|
|
- static function www()
|
|
|
- {
|
|
|
+ static function www() {
|
|
|
return Uri::www();
|
|
|
}
|
|
|
|
|
|
- static function go($url = '')
|
|
|
- {
|
|
|
- if (empty($url))
|
|
|
- {
|
|
|
+ static function go($url = '') {
|
|
|
+ if (empty($url)) {
|
|
|
Redirect::session_request_uri();
|
|
|
$www = self::www();
|
|
|
self::navigate($www);
|
|
|
}
|
|
|
|
|
|
$is_full_uri = (strpos($url, 'http') === 0);
|
|
|
- if ($is_full_uri)
|
|
|
- {
|
|
|
+ if ($is_full_uri) {
|
|
|
self::navigate($url);
|
|
|
}
|
|
|
|
|
@@ -35,25 +30,20 @@ class Redirect
|
|
|
|
|
|
/**
|
|
|
* Redirect to the session "request uri" if it exists.
|
|
|
- * @param bool Whether the user ha just logged in (in this case, use page_after_login rules)
|
|
|
+ * @param bool Whether the user just logged in (in this case, use page_after_login rules)
|
|
|
*/
|
|
|
- static function session_request_uri($logging_in = false, $user_id = null)
|
|
|
- {
|
|
|
-// if (api_is_anonymous())
|
|
|
-// {
|
|
|
-// return;
|
|
|
-// }
|
|
|
+ static function session_request_uri($logging_in = false, $user_id = null) {
|
|
|
$no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false;
|
|
|
-
|
|
|
- if($no_redirection){
|
|
|
+
|
|
|
+ if ($no_redirection) {
|
|
|
unset($_SESSION['noredirection']);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$url = isset($_SESSION['request_uri']) ? $_SESSION['request_uri'] : '';
|
|
|
unset($_SESSION['request_uri']);
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
if (!empty($url)) {
|
|
|
self::navigate($url);
|
|
|
} elseif ($logging_in) {
|
|
@@ -65,52 +55,49 @@ class Redirect
|
|
|
case COURSEMANAGER:
|
|
|
$redir = api_get_setting('teacher_page_after_login');
|
|
|
if (!empty($redir)) {
|
|
|
- self::navigate(api_get_path(WEB_PATH).$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);
|
|
|
+ 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);
|
|
|
+ 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);
|
|
|
+ self::navigate(api_get_path(WEB_PATH) . $redir);
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- $pal = api_get_setting('page_after_login');
|
|
|
- if (!empty($pal)) {
|
|
|
- self::navigate(api_get_path(WEB_PATH).$pal);
|
|
|
+ $page_after_login = api_get_setting('page_after_login');
|
|
|
+ if (!empty($page_after_login)) {
|
|
|
+ self::navigate(api_get_path(WEB_PATH) . $page_after_login);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- static function home()
|
|
|
- {
|
|
|
+ static function home() {
|
|
|
$www = self::www();
|
|
|
self::navigate($www);
|
|
|
}
|
|
|
|
|
|
- static function user_home()
|
|
|
- {
|
|
|
+ static function user_home() {
|
|
|
$www = self::www();
|
|
|
self::navigate("$www/user_portal.php");
|
|
|
}
|
|
|
|
|
|
- protected static function navigate($url)
|
|
|
- {
|
|
|
+ protected static function navigate($url) {
|
|
|
session_write_close(); //should not be neeeded
|
|
|
header("Location: $url");
|
|
|
exit;
|