[module.professor] PUT can now remove CAS_LOGIN (argument @remCas = TRUE)

This commit is contained in:
xdrm-brackets 2018-03-13 11:13:03 +01:00
parent f7a63a503d
commit 3e0ccea7df
3 changed files with 9 additions and 3 deletions

View File

@ -145,6 +145,7 @@ class professorController{
* @initials<int> [OPT] The professor's initials * @initials<int> [OPT] The professor's initials
* @isAdmin<bool> [OPT] Whether the professor is an admin * @isAdmin<bool> [OPT] Whether the professor is an admin
* @casLogin<String> [OPT] The professor's CAS username * @casLogin<String> [OPT] The professor's CAS username
* @remCas<bool> [OPT] Whether to remove the CAS login (only works if @casLogin is NULL)
* *
* @return updated<bool> Whether it has been updated * @return updated<bool> Whether it has been updated
* *
@ -158,6 +159,7 @@ class professorController{
$initials = null; $initials = null;
$isAdmin = null; $isAdmin = null;
$casLogin = null; $casLogin = null;
$remCas = false;
extract($args); extract($args);
/* Get the professor repo */ /* Get the professor repo */
@ -173,7 +175,7 @@ class professorController{
$hoursToDo, $hoursToDo,
$initials, $initials,
$isAdmin, $isAdmin,
$casLogin $remCas === true && is_null($casLogin) ? '' : $casLogin
)]; )];
} }

View File

@ -143,7 +143,8 @@
"hoursToDo": { "des": "Number of hours professor have to do", "typ": "id", "opt": true }, "hoursToDo": { "des": "Number of hours professor have to do", "typ": "id", "opt": true },
"initials": { "des": "Professor initials", "typ": "varchar(2,8,letters)", "opt": true }, "initials": { "des": "Professor initials", "typ": "varchar(2,8,letters)", "opt": true },
"isAdmin": { "des": "Whether professor is an admin", "typ": "boolean", "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": { "out": {
"updated": { "des": "Whether the professor has been updated", "typ": "boolean" } "updated": { "des": "Whether the professor has been updated", "typ": "boolean" }

View File

@ -543,11 +543,14 @@ gstore.add('ie_handler', function(prof_i){
/* (5.7) Création de la requête */ /* (5.7) Création de la requête */
var rq = {}; var rq = {};
( name[0] != prof.firstName ) && ( rq.firstName = name[0] ); ( name[0] != prof.firstName ) && ( rq.firstName = name[0] );
( name[1] != prof.lastName ) && ( rq.lastName = name[1] ); ( name[1] != prof.lastName ) && ( rq.lastName = name[1] );
( cat != prof.idCat ) && ( rq.category = cat ); ( cat != prof.idCat ) && ( rq.category = cat );
( hour != prof.hoursToDo ) && ( rq.hoursToDo = hour ); ( 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) // 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); rq.initials = name[0].substr(0,2) + name[1].substr(0,2);