Total Complexity | 7 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class ConditionalLogin |
||
10 | { |
||
11 | /** |
||
12 | * Check conditions based in the $login_conditions see conditional_login.php file. |
||
13 | * |
||
14 | * @param array $user |
||
15 | */ |
||
16 | public static function check_conditions($user) |
||
17 | { |
||
18 | $file = api_get_path(SYS_CODE_PATH).'auth/conditional_login/conditional_login.php'; |
||
19 | if (file_exists($file)) { |
||
20 | include_once $file; |
||
21 | if (isset($login_conditions)) { |
||
|
|||
22 | foreach ($login_conditions as $condition) { |
||
23 | //If condition fails we redirect to the URL defined by the condition |
||
24 | if (isset($condition['conditional_function'])) { |
||
25 | $function = $condition['conditional_function']; |
||
26 | $result = $function($user); |
||
27 | if (false == $result) { |
||
28 | $_SESSION['conditional_login']['uid'] = $user['user_id']; |
||
29 | $_SESSION['conditional_login']['can_login'] = false; |
||
30 | header("Location: ".$condition['url']); |
||
31 | exit; |
||
32 | } |
||
33 | } |
||
34 | } |
||
35 | } |
||
36 | } |
||
37 | } |
||
38 | |||
39 | public static function login() |
||
43 | } |
||
44 | } |
||
45 |