From 7db2a41027c582fd1d9df8534160b4bcd994e257 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 20 Mar 2018 18:49:00 +0100 Subject: [PATCH] [repo.meta] fixed 'create_prof' return type to 'bool' [repo.professor] removed getLinkedDepartments --- build/database/repo/meta.php | 2 +- build/database/repo/professor.php | 52 ++++--------------------------- 2 files changed, 7 insertions(+), 47 deletions(-) diff --git a/build/database/repo/meta.php b/build/database/repo/meta.php index 01fedc4..720e704 100644 --- a/build/database/repo/meta.php +++ b/build/database/repo/meta.php @@ -18,7 +18,7 @@ class meta extends Repo_i { * @return created 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 diff --git a/build/database/repo/professor.php b/build/database/repo/professor.php index 2c07090..0dc845b 100644 --- a/build/database/repo/professor.php +++ b/build/database/repo/professor.php @@ -139,49 +139,9 @@ class professor extends Repo_i { - /* (3) Get available departments for a CAS login - * - * @casLogin The professor's CAS username - * - * @return departments 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 The professor's UID * @lastName [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 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 [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 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 [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 Whether the professor have been deleeted successfully *