[repo.meta] fixed 'create_prof' return type to 'bool' [repo.professor] removed getLinkedDepartments

This commit is contained in:
xdrm-brackets 2018-03-20 18:49:00 +01:00
parent 12b1a29ed0
commit 7db2a41027
2 changed files with 7 additions and 47 deletions

View File

@ -18,7 +18,7 @@ class meta extends Repo_i {
* @return created<bool> Whether the professor has been created
*
---------------------------------------------------------*/
public function create_prof(String $casLogin, ?String $firstName, ?String $lastName) : ?int{
public function create_prof(String $casLogin, ?String $firstName, ?String $lastName) : bool{
/* (1) Create user in meta database

View File

@ -139,49 +139,9 @@ class professor extends Repo_i {
/* (3) Get available departments for a CAS login
*
* @casLogin<String> The professor's CAS username
*
* @return departments<array> The list of available departments (empty on error)
*
---------------------------------------------------------*/
public function getLinkedDepartments(string $casLogin) : array{
/* (1) Prepare Statement */
$st = $this->pdo->prepare("SELECT d2.iddepartement idDep, d2.label labelDep, d2.databaseName dbName
FROM meta_vhost.casUser
JOIN meta_vhost.linkedDep D ON casUser.casLogin = D.casUser_casLogin
JOIN meta_vhost.departement d2 ON D.departement_iddepartement = d2.iddepartement
WHERE casLogin = :caslogin");
/* (2) Check if statement error */
if( is_bool($st) )
return [];
/* (3) Bind params and execute statement */
$success = $st->execute([ ':caslogin' => $casLogin ]);
/* (4) Manage error */
if( !$success )
return [];
/* (5) Get data */
$fetched = $st->fetchAll();
/* (6) Return [] on no result */
if( $fetched === false )
return [];
/* (7) Return data */
return $fetched;
}
/* (4) Updates a professor's data
/* (3) Updates a professor's data
*
* @idProf<int> The professor's UID
* @lastName<String> [OPT] The professor's new lastName
@ -321,7 +281,7 @@ class professor extends Repo_i {
/* (5) Return whether a professor is an admin
/* (4) Return whether a professor is an admin
*
* @idProf<int> The professor's UID
*
@ -347,7 +307,7 @@ class professor extends Repo_i {
/* (6) Gets a professor by its UID ||| getAll
/* (5) Gets a professor by its UID ||| getAll
*
* @prof_id<int> [OPT] The professor's UID, if not set, getAll()
*
@ -386,7 +346,7 @@ class professor extends Repo_i {
/* (7) Gets a professor by its CAS login
/* (6) Gets a professor by its CAS login
*
* @cas_login<String> The professor's CAS login
*
@ -424,7 +384,7 @@ class professor extends Repo_i {
/* (8) Gets a professor by its UID ||| getAll
/* (7) Gets a professor by its UID ||| getAll
*
* @prof_id<int> [OPT] The professor's UID, if not set, getAll()
*
@ -525,7 +485,7 @@ class professor extends Repo_i {
/* (9) Deletes a professor
/* (8) Deletes a professor
*
* @return deleted<bool> Whether the professor have been deleeted successfully
*