From fd6fbdd664c516d9d87c506dd32212272a8b0ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sat, 23 Apr 2016 19:59:45 +0200 Subject: [PATCH] Version 15.203.1 --- swad_ID.c | 94 ++++++++++++++++++++++++++++-------------------- swad_ID.h | 2 -- swad_changelog.h | 4 +-- 3 files changed, 57 insertions(+), 43 deletions(-) diff --git a/swad_ID.c b/swad_ID.c index 2f0a42a97..d4a1e4ba9 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -64,6 +64,8 @@ extern struct Globals Gbl; static bool ID_CheckIfUsrIDIsValidUsingMinDigits (const char *UsrID,unsigned MinDigits); +static bool ID_ICanSeeAnotherUsrID (struct UsrData *UsrDat); + static void ID_RemoveUsrID (const struct UsrData *UsrDat,bool ItsMe); static bool ID_CheckIfConfirmed (long UsrCod,const char *UsrID); static void ID_RemoveUsrIDFromDB (long UsrCod,const char *UsrID); @@ -348,7 +350,21 @@ static bool ID_CheckIfUsrIDIsValidUsingMinDigits (const char *UsrID,unsigned Min void ID_WriteUsrIDs (struct UsrData *UsrDat) { unsigned NumID; - bool ICanSeeUsrID = ID_ICanSeeUsrID (UsrDat); + bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod); + bool ICanSeeUsrID; + bool ICanConfirmUsrID; + + if (ItsMe) + { + ICanSeeUsrID = true; + ICanConfirmUsrID = false; + } + else // A user distinct than me + { + ICanSeeUsrID = ID_ICanSeeAnotherUsrID (UsrDat); + ICanConfirmUsrID = ICanSeeUsrID && + !Gbl.Form.Inside; // Not inside a form + } for (NumID = 0; NumID < UsrDat->IDs.Num; @@ -365,6 +381,44 @@ void ID_WriteUsrIDs (struct UsrData *UsrDat) else fprintf (Gbl.F.Out,"********"); fprintf (Gbl.F.Out,""); + + if (ICanConfirmUsrID && + !UsrDat->IDs.List[NumID].Confirmed) + fprintf (Gbl.F.Out," Confirmar ID"); // TODO: Need translation!!!! + } + } + +/*****************************************************************************/ +/***************** Check if I can see another user's IDs *********************/ +/*****************************************************************************/ +// This function should not be called when UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod + +static bool ID_ICanSeeAnotherUsrID (struct UsrData *UsrDat) + { + /***** Check if I have permission to see another user's IDs *****/ + switch (Gbl.Usrs.Me.LoggedRole) + { + case Rol_TEACHER: + /* If I am a teacher of current course, + I only can see the user's IDs of students from current course */ + return (UsrDat->Accepted && + UsrDat->RoleInCurrentCrsDB == Rol_STUDENT); + case Rol_DEG_ADM: + /* If I am an administrator of current degree, + I only can see the user's IDs of users from current degree */ + return Usr_CheckIfUsrBelongsToDeg (UsrDat->UsrCod,Gbl.CurrentDeg.Deg.DegCod,true); + case Rol_CTR_ADM: + /* If I am an administrator of current centre, + I only can see the user's IDs of users from current centre */ + return Usr_CheckIfUsrBelongsToCtr (UsrDat->UsrCod,Gbl.CurrentCtr.Ctr.CtrCod,true); + case Rol_INS_ADM: + /* If I am an administrator of current institution, + I only can see the user's IDs of users from current institution */ + return Usr_CheckIfUsrBelongsToIns (UsrDat->UsrCod,Gbl.CurrentIns.Ins.InsCod,true); + case Rol_SYS_ADM: + return true; + default: + return false; } } @@ -826,41 +880,3 @@ void ID_ConfirmUsrID (long UsrCod,const char *UsrID) UsrCod,UsrID); DB_QueryINSERT (Query,"can not confirm a user's ID"); } - -/*****************************************************************************/ -/***************** Check if I can see another user's ID **********************/ -/*****************************************************************************/ - -bool ID_ICanSeeUsrID (struct UsrData *UsrDat) - { - bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod); - - if (ItsMe) - return true; - - /* Check if I have permission to see another user's ID */ - switch (Gbl.Usrs.Me.LoggedRole) - { - case Rol_TEACHER: - /* If I am a teacher of current course, - I only can see the user's ID of students from current course */ - return (UsrDat->Accepted && - UsrDat->RoleInCurrentCrsDB == Rol_STUDENT); - case Rol_DEG_ADM: - /* If I am an administrator of current degree, - I only can see the user's ID of users from current degree */ - return Usr_CheckIfUsrBelongsToDeg (UsrDat->UsrCod,Gbl.CurrentDeg.Deg.DegCod,true); - case Rol_CTR_ADM: - /* If I am an administrator of current centre, - I only can see the user's ID of users from current centre */ - return Usr_CheckIfUsrBelongsToCtr (UsrDat->UsrCod,Gbl.CurrentCtr.Ctr.CtrCod,true); - case Rol_INS_ADM: - /* If I am an administrator of current institution, - I only can see the user's ID of users from current institution */ - return Usr_CheckIfUsrBelongsToIns (UsrDat->UsrCod,Gbl.CurrentIns.Ins.InsCod,true); - case Rol_SYS_ADM: - return true; - default: - return false; - } - } diff --git a/swad_ID.h b/swad_ID.h index f971e49d9..dfc041a0b 100644 --- a/swad_ID.h +++ b/swad_ID.h @@ -75,6 +75,4 @@ void ID_NewMyUsrID (void); void ID_NewOtherUsrID (void); void ID_ConfirmUsrID (long UsrCod,const char *UsrID); -bool ID_ICanSeeUsrID (struct UsrData *UsrDat); - #endif diff --git a/swad_changelog.h b/swad_changelog.h index 07d52afd5..6a417b6c7 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -134,14 +134,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.203 (2016-04-23)" +#define Log_PLATFORM_VERSION "SWAD 15.203.1 (2016-04-23)" #define CSS_FILE "swad15.203.css" #define JS_FILE "swad15.197.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 /* - Version 15.204: Apr 23, 2016 New form to confirm another user's ID. (? lines) + Version 15.203.1: Apr 23, 2016 New form to confirm another user's ID. Not finished. (201090 lines) Version 15.203: Apr 23, 2016 Changes in layout and CSS related to record card. (201076 lines) Version 15.202.19:Apr 23, 2016 User's ID is shown in green or red in user's account. (201120 lines) Version 15.202.18:Apr 23, 2016 Change of message about ID in user's account. (201092 lines)