From 3e0ccea7df78e4b8f2724880a0b04ecc4891e514 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 13 Mar 2018 11:13:03 +0100 Subject: [PATCH] [module.professor] PUT can now remove CAS_LOGIN (argument @remCas = TRUE) --- build/api/module/professorController.php | 4 +++- config/modules.json | 3 ++- webpack/data/teacher.js | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/build/api/module/professorController.php b/build/api/module/professorController.php index 823e99e..43e2e02 100644 --- a/build/api/module/professorController.php +++ b/build/api/module/professorController.php @@ -145,6 +145,7 @@ class professorController{ * @initials [OPT] The professor's initials * @isAdmin [OPT] Whether the professor is an admin * @casLogin [OPT] The professor's CAS username + * @remCas [OPT] Whether to remove the CAS login (only works if @casLogin is NULL) * * @return updated Whether it has been updated * @@ -158,6 +159,7 @@ class professorController{ $initials = null; $isAdmin = null; $casLogin = null; + $remCas = false; extract($args); /* Get the professor repo */ @@ -173,7 +175,7 @@ class professorController{ $hoursToDo, $initials, $isAdmin, - $casLogin + $remCas === true && is_null($casLogin) ? '' : $casLogin )]; } diff --git a/config/modules.json b/config/modules.json index 4f744ef..6ee1c30 100644 --- a/config/modules.json +++ b/config/modules.json @@ -143,7 +143,8 @@ "hoursToDo": { "des": "Number of hours professor have to do", "typ": "id", "opt": true }, "initials": { "des": "Professor initials", "typ": "varchar(2,8,letters)", "opt": true }, "isAdmin": { "des": "Whether professor is an admin", "typ": "boolean", "opt": true }, - "casLogin": { "des": "Optional CAS username", "typ": "varchar(6,16,letters)", "opt": true } + "casLogin": { "des": "Optional CAS username", "typ": "varchar(6,16,letters)", "opt": true }, + "remCas": { "des": "Unset CAS username", "typ": "boolean", "def": false, "opt": true } }, "out": { "updated": { "des": "Whether the professor has been updated", "typ": "boolean" } diff --git a/webpack/data/teacher.js b/webpack/data/teacher.js index 3ac306e..d735895 100644 --- a/webpack/data/teacher.js +++ b/webpack/data/teacher.js @@ -543,11 +543,14 @@ gstore.add('ie_handler', function(prof_i){ /* (5.7) Création de la requête */ var rq = {}; + ( name[0] != prof.firstName ) && ( rq.firstName = name[0] ); ( name[1] != prof.lastName ) && ( rq.lastName = name[1] ); ( cat != prof.idCat ) && ( rq.category = cat ); ( hour != prof.hoursToDo ) && ( rq.hoursToDo = hour ); - ( cas != prof.casLogin ) && ( rq.casLogin = cas ); + + // if empty cas -> request to remove cas login + ( cas != prof.casLogin ) && ( ( cas.length > 0 ) && ( rq.casLogin = cas ) || ( rq.remCas = true ) ); // update initials whatever have been modified (to avoid API error when no field given) rq.initials = name[0].substr(0,2) + name[1].substr(0,2);