forked from GibbonEdu/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roleSwitcherProcess.php
executable file
·66 lines (54 loc) · 1.95 KB
/
roleSwitcherProcess.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/*
Gibbon, Flexible & Open School System
Copyright (C) 2010, Ross Parker
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
include 'functions.php';
include 'config.php';
@session_start();
//New PDO DB connection
$pdo = new Gibbon\sqlConnection();
$connection2 = $pdo->getConnection();
$URL = './index.php';
$role = $_GET['gibbonRoleID'];
$_SESSION[$guid]['pageLoads'] = null;
//Check for parameter
if ($role == '') {
$URL .= '?return=error0';
header("Location: {$URL}");
}
//Check for access to role
else {
try {
$data = array('username' => $_SESSION[$guid]['username'], 'gibbonRoleIDAll' => "%$role%");
$sql = 'SELECT * FROM gibbonPerson WHERE (username=:username) AND (gibbonRoleIDAll LIKE :gibbonRoleIDAll)';
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
echo "<div class='error'>".$e->getMessage().'</div>';
}
if ($result->rowCount() != 1) {
$URL .= '?return=error1';
header("Location: {$URL}");
} else {
//Make the switch
$gibbon->session->set('gibbonRoleIDCurrent', $role);
// Reload cached FF actions
$gibbon->session->cacheFastFinderActions($role);
// Reload the cached menu
$mainMenu = new Gibbon\menuMain($gibbon, $pdo);
$mainMenu->setMenu();
$URL .= '?return=success0';
header("Location: {$URL}");
}
}