#6272 : Corrects a critical chamilo bug in local.inc.php that can lead to an icmplete session if server is loaded.
	
		
	
				
					
				
			Uses LoginRedirection library to redirect user at first loginskala
							parent
							
								
									7549864ae3
								
							
						
					
					
						commit
						a704bee93f
					
				@ -0,0 +1,66 @@ | 
				
			||||
<?php | 
				
			||||
/** | 
				
			||||
* When a user login, the function LoginRedirection::redirect is called. | 
				
			||||
* When this function is called all user info has already been registered in $_user session variable | 
				
			||||
**/ | 
				
			||||
Class LoginRedirection { | 
				
			||||
 | 
				
			||||
	//checks user status and redirect him through custom page if setting is enabled | 
				
			||||
	public function redirect(){ | 
				
			||||
 | 
				
			||||
		if ( api_is_student() && !api_get_setting('student_page_after_login') == '' ){ | 
				
			||||
			$redirect_url = html_entity_decode(api_get_setting('student_page_after_login')); | 
				
			||||
			if ($redirect_url[0] == "/") { | 
				
			||||
				$redirect_url = substr(api_get_path(WEB_PATH), 0, -1).$redirect_url; | 
				
			||||
			} | 
				
			||||
			header('Location: '.$redirect_url); | 
				
			||||
			exit(); | 
				
			||||
		} | 
				
			||||
		if ( api_is_teacher() && !api_get_setting('teacher_page_after_login') == '' ){ | 
				
			||||
			$redirect_url = html_entity_decode(api_get_setting('teacher_page_after_login')); | 
				
			||||
			if ($redirect_url[0] == "/") { | 
				
			||||
				$redirect_url = substr(api_get_path(WEB_PATH), 0, -1).$redirect_url; | 
				
			||||
			} | 
				
			||||
			header('Location: '.$redirect_url); | 
				
			||||
			exit(); | 
				
			||||
		} | 
				
			||||
		if ( api_is_drh() && !api_get_setting('DRH_page_after_login') == '' ){ | 
				
			||||
			$redirect_url = html_entity_decode(api_get_setting('DRH_page_after_login')); | 
				
			||||
			if ($redirect_url[0] == "/") { | 
				
			||||
				$redirect_url = substr(api_get_path(WEB_PATH), 0, -1).$redirect_url; | 
				
			||||
			} | 
				
			||||
			header('Location: '.$redirect_url); | 
				
			||||
			exit(); | 
				
			||||
		} | 
				
			||||
		if ( api_is_session_admin() && !api_get_setting('sessionadmin_page_after_login') == '' ){ | 
				
			||||
			$redirect_url = html_entity_decode(api_get_setting('sessionadmin_page_after_login')); | 
				
			||||
			if ($redirect_url[0] == "/") { | 
				
			||||
				$redirect_url = substr(api_get_path(WEB_PATH), 0, -1).$redirect_url; | 
				
			||||
			} | 
				
			||||
			header('Location: '.$redirect_url); | 
				
			||||
			exit(); | 
				
			||||
		} | 
				
			||||
 | 
				
			||||
 | 
				
			||||
		// Custom pages | 
				
			||||
		if (api_get_setting('use_custom_pages') == 'true') { | 
				
			||||
			if (api_get_user_id()) { | 
				
			||||
				CustomPages::displayPage('index-logged'); | 
				
			||||
			} | 
				
			||||
			else { | 
				
			||||
				CustomPages::displayPage('index-unlogged'); | 
				
			||||
			} | 
				
			||||
		} | 
				
			||||
		if (!empty($_SESSION['request_uri'])) { | 
				
			||||
			$req = $_SESSION['request_uri']; | 
				
			||||
			unset($_SESSION['request_uri']); | 
				
			||||
			header('location: '.$req); | 
				
			||||
			exit(); | 
				
			||||
		} else { | 
				
			||||
			$param = isset($param) ? $param : ''; | 
				
			||||
			header('location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login').$param); | 
				
			||||
			exit(); | 
				
			||||
		} | 
				
			||||
	} | 
				
			||||
} | 
				
			||||
?> | 
				
			||||
					Loading…
					
					
				
		Reference in new issue