Implemented department database switch
This commit is contained in:
parent
7c2a698733
commit
2a9e1e1474
|
@ -38,6 +38,7 @@
|
||||||
/* (2) Get professor with this login */
|
/* (2) Get professor with this login */
|
||||||
$deps = $prof_repo->getLinkedDepartment($_SESSION['CAS']['login']);
|
$deps = $prof_repo->getLinkedDepartment($_SESSION['CAS']['login']);
|
||||||
if(is_array($deps)){
|
if(is_array($deps)){
|
||||||
|
$_SESSION["AvailableDepartment"] = $deps;
|
||||||
$_SESSION['CurrentDatabase'] = $deps[0]["dbName"];
|
$_SESSION['CurrentDatabase'] = $deps[0]["dbName"];
|
||||||
$_SESSION['CurrentDepartementId'] = $deps[0]["idDep"];
|
$_SESSION['CurrentDepartementId'] = $deps[0]["idDep"];
|
||||||
|
|
||||||
|
@ -48,6 +49,9 @@
|
||||||
/* (3) If found -> store useful information */
|
/* (3) If found -> store useful information */
|
||||||
if( is_array($by_login) && isset($by_login['idProfesseur']) && isset($by_login['admin']) ){
|
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']['admin'] = (bool) $by_login['admin'];
|
||||||
$_SESSION['CAS']['id'] = (int) $by_login['idProfesseur'];
|
$_SESSION['CAS']['id'] = (int) $by_login['idProfesseur'];
|
||||||
$_SESSION["isLogged"] = true;
|
$_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":{
|
"departement":{
|
||||||
|
|
||||||
|
"PUT":{
|
||||||
|
"des": "Switch the user on another department database",
|
||||||
|
"per": [],
|
||||||
|
"par": {
|
||||||
|
"department": {"des": "Department id", "typ": "id"}
|
||||||
|
}
|
||||||
|
},
|
||||||
"errors":{
|
"errors":{
|
||||||
"GET": {
|
"GET": {
|
||||||
"des": "Get the list of incoherence of the department",
|
"des": "Get the list of incoherence of the department",
|
||||||
|
|
Loading…
Reference in New Issue