[renamed] 'AvailableDepartment' -> 'AvailableDepartments' [renamed] 'CurrentDepartementId' -> 'CurrentDepartmentId'
This commit is contained in:
parent
35b0cb36fa
commit
b06b8666bc
|
@ -25,8 +25,9 @@
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
if( !isset($_SESSION['CAS']) || !is_array($_SESSION['CAS']) ) $_SESSION['CAS'] = [];
|
if( !isset($_SESSION['CAS']) || !is_array($_SESSION['CAS']) ) $_SESSION['CAS'] = [];
|
||||||
if( !isset($_SESSION['AUTH']) || !is_array($_SESSION['AUTH']) ) $_SESSION['AUTH'] = [];
|
if( !isset($_SESSION['AUTH']) || !is_array($_SESSION['AUTH']) ) $_SESSION['AUTH'] = [];
|
||||||
if( !isset($_SESSION['AvailableDepartment']) || !is_array($_SESSION['AvailableDepartment']) ) $_SESSION['AvailableDepartment'] = [];
|
if( !isset($_SESSION['AvailableDepartments']) || !is_array($_SESSION['AvailableDepartments']) ) $_SESSION['AvailableDepartments'] = [];
|
||||||
if( !isset($_SESSION['VERSION']) || !is_string($_SESSION['VERSION']) ) $_SESSION['VERSION'] = null;
|
if( !isset($_SESSION['VERSION']) || !is_string($_SESSION['VERSION']) ) $_SESSION['VERSION'] = null;
|
||||||
|
if( !isset($_SESSION['CurrentDepartmentId']) || !is_array($_SESSION['CurrentDepartmentId']) ) $_SESSION['CurrentDepartmentId'] = null;
|
||||||
|
|
||||||
|
|
||||||
/* (2) Process AUTH
|
/* (2) Process AUTH
|
||||||
|
|
|
@ -119,7 +119,7 @@ class casController{
|
||||||
return [ 'headers' => $headers, 'body' => $body_start.'-3'.$body_end ];
|
return [ 'headers' => $headers, 'body' => $body_start.'-3'.$body_end ];
|
||||||
|
|
||||||
/* (3) Set departments data */
|
/* (3) Set departments data */
|
||||||
$_SESSION['AvailableDepartment'] = $departments;
|
$_SESSION['AvailableDepartments'] = $departments;
|
||||||
|
|
||||||
/* (4) Choose first department by default */
|
/* (4) Choose first department by default */
|
||||||
$_SESSION['CurrentDatabase'] = $departments[0]['dbName'];
|
$_SESSION['CurrentDatabase'] = $departments[0]['dbName'];
|
||||||
|
|
|
@ -16,25 +16,33 @@ class departmentController
|
||||||
{
|
{
|
||||||
|
|
||||||
public function put($args){
|
public function put($args){
|
||||||
|
|
||||||
$department = 0;
|
$department = 0;
|
||||||
|
|
||||||
extract($args);
|
extract($args);
|
||||||
|
|
||||||
|
|
||||||
/** @var professor $prof_repo */
|
/** @var professor $prof_repo */
|
||||||
$prof_repo = Repo::getRepo('professor');
|
$prof_repo = Repo::getRepo('professor');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$deps = $prof_repo->getLinkedDepartments($_SESSION['CAS']['login']);
|
$deps = $prof_repo->getLinkedDepartments($_SESSION['CAS']['login']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if( count($deps) > 0 ){
|
if( count($deps) > 0 ){
|
||||||
foreach ($deps as $dep){
|
|
||||||
if($dep["idDep"] == $department){
|
foreach($deps as $dep){
|
||||||
$_SESSION["AvailableDepartment"] = $deps;
|
|
||||||
$_SESSION['CurrentDatabase'] = $dep["dbName"];
|
if( $dep['idDep'] == $department){
|
||||||
$_SESSION['CurrentDepartementId'] = $dep["idDep"];
|
|
||||||
|
$_SESSION['AvailableDepartments'] = $deps;
|
||||||
|
$_SESSION['CurrentDatabase'] = $dep['dbName'];
|
||||||
|
$_SESSION['CurrentDepartmentId'] = $dep['idDep'];
|
||||||
|
|
||||||
return ['switched' => true];
|
return ['switched' => true];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
'session' => [
|
'session' => [
|
||||||
'name' => $_SESSION['CAS']['login'],
|
'name' => $_SESSION['CAS']['login'],
|
||||||
'connected' => isset($_SESSION['AUTH']) ? count($_SESSION['AUTH']) > 0 : false,
|
'connected' => isset($_SESSION['AUTH']) ? count($_SESSION['AUTH']) > 0 : false,
|
||||||
'departments' => array_map(function($d){ return [ 'id' => $d['idDep'], 'label' => $d['labelDep']]; }, $_SESSION['AvailableDepartment']),
|
'departments' => array_map(function($d){ return [ 'id' => $d['idDep'], 'label' => $d['labelDep']]; }, $_SESSION['AvailableDepartments']),
|
||||||
'department_id' => $_SESSION['CurrentDepartementId'],
|
'department_id' => $_SESSION['CurrentDepartmentId'],
|
||||||
'version' => $_SESSION['VERSION']
|
'version' => $_SESSION['VERSION']
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue