2018-03-15 11:02:28 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: lucas
|
|
|
|
* Date: 15/03/18
|
|
|
|
* Time: 11:47
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace api\module;
|
|
|
|
|
|
|
|
|
|
|
|
use database\core\Repo;
|
|
|
|
use database\repo\professor;
|
|
|
|
|
2018-03-15 16:38:06 +00:00
|
|
|
class departmentController
|
2018-03-15 11:02:28 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public function put($args){
|
|
|
|
$department = 0;
|
|
|
|
extract($args);
|
|
|
|
|
2018-03-20 09:49:53 +00:00
|
|
|
|
2018-03-15 11:02:28 +00:00
|
|
|
/** @var professor $prof_repo */
|
|
|
|
$prof_repo = Repo::getRepo('professor');
|
|
|
|
|
2018-03-20 09:49:53 +00:00
|
|
|
|
|
|
|
|
2018-03-19 18:05:19 +00:00
|
|
|
$deps = $prof_repo->getLinkedDepartments($_SESSION['CAS']['login']);
|
2018-03-15 11:02:28 +00:00
|
|
|
|
2018-03-20 09:49:53 +00:00
|
|
|
|
|
|
|
|
2018-03-19 18:05:19 +00:00
|
|
|
if( count($deps) > 0 ){
|
2018-03-20 09:49:53 +00:00
|
|
|
|
|
|
|
foreach($deps as $dep){
|
|
|
|
|
|
|
|
if( $dep['idDep'] == $department){
|
|
|
|
|
|
|
|
$_SESSION['AvailableDepartments'] = $deps;
|
|
|
|
$_SESSION['CurrentDatabase'] = $dep['dbName'];
|
|
|
|
$_SESSION['CurrentDepartmentId'] = $dep['idDep'];
|
2018-03-15 11:02:28 +00:00
|
|
|
|
2018-03-17 18:07:44 +00:00
|
|
|
return ['switched' => true];
|
2018-03-20 09:49:53 +00:00
|
|
|
|
2018-03-15 11:02:28 +00:00
|
|
|
}
|
2018-03-20 09:49:53 +00:00
|
|
|
|
2018-03-15 11:02:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-17 18:07:44 +00:00
|
|
|
return ['switched' => false];
|
2018-03-15 11:02:28 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|