From 35c7304c0e8a153a5e2e4ec74d3362ea6948f46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Wed, 25 Jan 2017 18:35:42 +0100 Subject: [PATCH] Version 16.123.2 --- swad_changelog.h | 3 ++- swad_enrollment.c | 24 +++++++++++++++++++++++- swad_enrollment.h | 3 +++ swad_record.c | 16 ++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 711d159de..f8f460eb2 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -191,13 +191,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.123.1 (2017-01-19)" +#define Log_PLATFORM_VERSION "SWAD 16.123.2 (2017-01-25)" #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.123.2: Jan 25, 2017 Teachers can edit names of students with no name. (211989 lines) Version 16.123.1: Jan 20, 2017 Minor change in text to show agenda. (211952 lines) Version 16.123: Jan 20, 2017 Link to agenda in current day (left-top date-time). (211950 lines) Version 16.122: Jan 20, 2017 Link to calendar in current month (left-top date-time). (211937 lines) diff --git a/swad_enrollment.c b/swad_enrollment.c index 8a7631732..acea07299 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -3664,7 +3664,7 @@ void Enr_ModifyUsr1 (void) if (ItsMe || Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER) { /***** Get user's name from record form *****/ - if (Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM) // Only an admin can change another user's name + if (Enr_CheckIfICanChangeAnotherUsrData (&Gbl.Usrs.Other.UsrDat)) Rec_GetUsrNameFromRecordForm (&Gbl.Usrs.Other.UsrDat); /***** Update user's data in database *****/ @@ -3822,6 +3822,28 @@ void Enr_ModifyUsr2 (void) } } +/*****************************************************************************/ +/**************** Check if I can change another user's data ******************/ +/*****************************************************************************/ + +bool Enr_CheckIfICanChangeAnotherUsrData (const struct UsrData *UsrDat) + { + switch (Gbl.Usrs.Me.LoggedRole) + { + case Rol_TEACHER: // Teachers only can edit data of new users + return !UsrDat->Email[0] || // Email empty + !UsrDat->Surname1[0] || // Surname 1 empty + !UsrDat->FirstName[0]; // First name empty + case Rol_DEG_ADM: + case Rol_CTR_ADM: + case Rol_INS_ADM: + case Rol_SYS_ADM: // Admins always can edit another user's data + return true; + default: // With other roles, I can not edit another user's data + return false; + } + } + /*****************************************************************************/ /********* Set a user's acceptation to true in the current course ************/ /*****************************************************************************/ diff --git a/swad_enrollment.h b/swad_enrollment.h index bb1961a73..30f3390e6 100644 --- a/swad_enrollment.h +++ b/swad_enrollment.h @@ -135,6 +135,9 @@ void Enr_CreateNewUsr1 (void); void Enr_CreateNewUsr2 (void); void Enr_ModifyUsr1 (void); void Enr_ModifyUsr2 (void); + +bool Enr_CheckIfICanChangeAnotherUsrData (const struct UsrData *UsrDat); + void Enr_AcceptUsrInCrs (long UsrCod); #endif diff --git a/swad_record.c b/swad_record.c index e578bd93a..b4bd8b315 100644 --- a/swad_record.c +++ b/swad_record.c @@ -2119,6 +2119,22 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, TypeOfView == Rec_SHA_RECORD_PRINT) && UsrDat->RoleInCurrentCrsDB == Rol_TEACHER)); // He/she is a teacher in the current course + /* Data form = I can edit fields like surnames and name */ + switch (TypeOfView) + { + case Rec_SHA_MY_RECORD_FORM: + case Rec_SHA_OTHER_NEW_USR_FORM: + DataForm = true; + break; + case Rec_SHA_OTHER_EXISTING_USR_FORM: + DataForm = Enr_CheckIfICanChangeAnotherUsrData (UsrDat); + break; + default: // In other options, I can not edit another user's data + DataForm = false; + break; + } + + /* Class for labels */ switch (TypeOfView) { case Rec_SHA_SIGN_UP_FORM: