diff --git a/swad_ID.c b/swad_ID.c index c84ba2b95..637fd1d38 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -425,45 +425,6 @@ bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat) !UsrDat->Surname1[0] && // and who has no surname 1 (nobody filled user's surname 1) !UsrDat->FirstName[0] // and who has no first name (nobody filled user's first name) ); - return (UsrDat->RoleInCurrentCrsDB == Rol_STUDENT && // A student - UsrDat->Accepted) || // who has accepted inscription in course - ( - (UsrDat->RoleInCurrentCrsDB == Rol_STUDENT || // A student - UsrDat->RoleInCurrentCrsDB == Rol_TEACHER) && // or a teacher - !UsrDat->Password[0] && // who has no password (never logged) - !UsrDat->Surname1[0] && // and who has no surname 1 (nobody filled user's surname 1) - !UsrDat->FirstName[0] // and who has no first name (nobody filled user's first name) - ); - case Rol_DEG_ADM: - case Rol_CTR_ADM: - case Rol_INS_ADM: - case Rol_SYS_ADM: - return Usr_CheckIfIAsAdminCanEditOtherUsr (UsrDat); - default: - return false; - } - } - -/*****************************************************************************/ -/***************** Check if I can change another user's IDs ******************/ -/*****************************************************************************/ - -bool ID_ICanChangeOtherUsrIDs (const struct UsrData *UsrDat) - { - if (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me - return true; - - /***** 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 change the user's IDs of empty users from current course */ - return (UsrDat->RoleInCurrentCrsDB == Rol_STUDENT || // A student - UsrDat->RoleInCurrentCrsDB == Rol_TEACHER) && // or a teacher - !UsrDat->Password[0] && // who has no password (never logged) - !UsrDat->Surname1[0] && // and who has no surname 1 (nobody filled user's surname 1) - !UsrDat->FirstName[0]; // and who has no first name (nobody filled user's first name) case Rol_DEG_ADM: case Rol_CTR_ADM: case Rol_INS_ADM: @@ -548,7 +509,7 @@ void ID_ShowFormOthIDs (void) /***** Get user whose password must be changed *****/ if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) { - if (ID_ICanChangeOtherUsrIDs (&Gbl.Usrs.Other.UsrDat)) + if (Usr_ICanChangeOtherUsrData (&Gbl.Usrs.Other.UsrDat)) { /***** Start frame *****/ Lay_StartRoundFrame (NULL,Txt_ID,NULL,NULL); @@ -752,7 +713,7 @@ static void ID_RemoveUsrID (const struct UsrData *UsrDat,bool ItsMe) char UsrID[ID_MAX_LENGTH_USR_ID+1]; bool ICanRemove; - if (ID_ICanChangeOtherUsrIDs (UsrDat)) + if (Usr_ICanChangeOtherUsrData (UsrDat)) { /***** Get user's ID from form *****/ Par_GetParToText ("UsrID",UsrID,ID_MAX_LENGTH_USR_ID); @@ -873,7 +834,7 @@ static void ID_NewUsrID (const struct UsrData *UsrDat,bool ItsMe) unsigned NumIDFound = 0; // Initialized to avoid warning bool Error = false; - if (ID_ICanChangeOtherUsrIDs (UsrDat)) + if (Usr_ICanChangeOtherUsrData (UsrDat)) { /***** Get new user's ID from form *****/ Par_GetParToText ("NewID",NewID,ID_MAX_LENGTH_USR_ID); @@ -996,7 +957,7 @@ static void ID_ReqConfOrConfOtherUsrID (ID_ReqConfOrConfID_t ReqConfOrConfID) /***** Get other user's code from form and get user's data *****/ if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) if (Gbl.Usrs.Other.UsrDat.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // Not me - if (ID_ICanChangeOtherUsrIDs (&Gbl.Usrs.Other.UsrDat)) + if (Usr_ICanChangeOtherUsrData (&Gbl.Usrs.Other.UsrDat)) ICanConfirm = true; if (ICanConfirm) diff --git a/swad_ID.h b/swad_ID.h index cb0dfc0e9..e8d8e750c 100644 --- a/swad_ID.h +++ b/swad_ID.h @@ -66,7 +66,6 @@ bool ID_CheckIfUsrIDSeemsAValidID (const char *UsrID); void ID_WriteUsrIDs (struct UsrData *UsrDat); bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat); -bool ID_ICanChangeOtherUsrIDs (const struct UsrData *UsrDat); void ID_PutLinkToChangeUsrIDs (void); void ID_ShowFormOthIDs (void); diff --git a/swad_changelog.h b/swad_changelog.h index 1ab23947b..b0571b481 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -187,17 +187,21 @@ // TODO: Fix bug when creating a new attendance event: if title is repeated, form is cleared // TODO: Fix bug: When registering an administrator, the user's name changes are ignored +// TODO: When creating a new user, the ID should be visible and the record card should not have contextual icons + /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.125 (2017-01-27)" +#define Log_PLATFORM_VERSION "SWAD 16.126 (2017-01-27)" #define CSS_FILE "swad16.123.css" #define JS_FILE "swad16.123.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 16.126.1: Jan 27, 2017 A teacher can create and register a new teacher directly in a course. (? lines) + Version 16.126: Jan 27, 2017 Code refactoring related to permissions to view/change another user's data. (212086 lines) Version 16.125: Jan 27, 2017 Code refactoring related to permissions to view/change another user's data. (212152 lines) Version 16.124: Jan 26, 2017 Code refactoring related to permissions to view/change another user's data. (212163 lines) Version 16.123.4: Jan 26, 2017 Surname1 and first name can not be deleted when editing user's data. (212000 lines) diff --git a/swad_enrollment.c b/swad_enrollment.c index ed98333d9..9e3b5f9bb 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -3051,7 +3051,7 @@ static void Enr_AskIfRegRemUsr (struct ListUsrCods *ListUsrCods,Rol_Role_t Role) extern const char *Txt_THE_USER_X_is_already_in_the_course_Y_but_has_not_yet_accepted_the_enrollment; extern const char *Txt_THE_USER_X_already_exists_in_Y_but_is_not_yet_enrolled_in_the_course_Z; extern const char *Txt_THE_USER_X_already_exists_in_Y; - extern const char *Txt_The_user_is_new_does_not_exists_yet_in_X; + extern const char *Txt_The_user_is_new_not_yet_in_X; extern const char *Txt_If_this_is_a_new_user_in_X_you_should_indicate_her_his_ID; unsigned NumUsr; bool NewUsrIDValid; @@ -3129,7 +3129,7 @@ static void Enr_AskIfRegRemUsr (struct ListUsrCods *ListUsrCods,Rol_Role_t Role) if (NewUsrIDValid) { /***** Show form to enter the data of a new user *****/ - sprintf (Gbl.Message,Txt_The_user_is_new_does_not_exists_yet_in_X, + sprintf (Gbl.Message,Txt_The_user_is_new_not_yet_in_X, Cfg_PLATFORM_SHORT_NAME); Lay_ShowAlert (Lay_INFO,Gbl.Message); Rec_ShowFormOtherNewSharedRecord (&Gbl.Usrs.Other.UsrDat); @@ -3154,14 +3154,14 @@ static void Enr_ShowFormToEditOtherUsr (void) /***** Buttons for edition *****/ fprintf (Gbl.F.Out,"