Implemented department database switch
This commit is contained in:
parent
7c2a698733
commit
2a9e1e1474
|
@ -38,6 +38,7 @@
|
|||
/* (2) Get professor with this login */
|
||||
$deps = $prof_repo->getLinkedDepartment($_SESSION['CAS']['login']);
|
||||
if(is_array($deps)){
|
||||
$_SESSION["AvailableDepartment"] = $deps;
|
||||
$_SESSION['CurrentDatabase'] = $deps[0]["dbName"];
|
||||
$_SESSION['CurrentDepartementId'] = $deps[0]["idDep"];
|
||||
|
||||
|
@ -48,6 +49,9 @@
|
|||
/* (3) If found -> store useful information */
|
||||
if( is_array($by_login) && isset($by_login['idProfesseur']) && isset($by_login['admin']) ){
|
||||
|
||||
//security
|
||||
session_regenerate_id();
|
||||
|
||||
$_SESSION['CAS']['admin'] = (bool) $by_login['admin'];
|
||||
$_SESSION['CAS']['id'] = (int) $by_login['idProfesseur'];
|
||||
$_SESSION["isLogged"] = true;
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: lucas
|
||||
* Date: 15/03/18
|
||||
* Time: 11:47
|
||||
*/
|
||||
|
||||
namespace api\module;
|
||||
|
||||
|
||||
use database\core\Repo;
|
||||
use database\repo\professor;
|
||||
|
||||
class departementController
|
||||
{
|
||||
|
||||
public function put($args){
|
||||
|
||||
$department = 0;
|
||||
|
||||
extract($args);
|
||||
|
||||
/** @var professor $prof_repo */
|
||||
$prof_repo = Repo::getRepo('professor');
|
||||
|
||||
$deps = $prof_repo->getLinkedDepartment($_SESSION['CAS']['login']);
|
||||
|
||||
if(is_array($deps)){
|
||||
foreach ($deps as $dep){
|
||||
if($dep["idDep"] == $department){
|
||||
$_SESSION["AvailableDepartment"] = $deps;
|
||||
$_SESSION['CurrentDatabase'] = $dep["dbName"];
|
||||
$_SESSION['CurrentDepartementId'] = $dep["idDep"];
|
||||
|
||||
return ["success" => true];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ["success" => false];
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -72,6 +72,14 @@
|
|||
},
|
||||
|
||||
"departement":{
|
||||
|
||||
"PUT":{
|
||||
"des": "Switch the user on another department database",
|
||||
"per": [],
|
||||
"par": {
|
||||
"department": {"des": "Department id", "typ": "id"}
|
||||
}
|
||||
},
|
||||
"errors":{
|
||||
"GET": {
|
||||
"des": "Get the list of incoherence of the department",
|
||||
|
|
Loading…
Reference in New Issue