diff --git a/css/swad15.198.css b/css/swad15.202.css similarity index 99% rename from css/swad15.198.css rename to css/swad15.202.css index f2e39f2ed..eeb4a2101 100644 --- a/css/swad15.198.css +++ b/css/swad15.202.css @@ -1679,6 +1679,10 @@ a:hover img.CENTRE_PHOTO_SHOW .DAT_SMALL_BLUE {font-family:"Arial Narrow","Nimbus Sans L","DejaVu LGC Sans Condensed",sans-serif; color:#0080FF; font-size:12pt;} .DAT_SMALL_YELLOW {font-family:"Arial Narrow","Nimbus Sans L","DejaVu LGC Sans Condensed",sans-serif; color:#C0C000; font-size:12pt;} +/******************************** User's IDs *********************************/ +.USR_ID_C {color:#408020} +.USR_ID_NC {color:#A02020} + /******************************* Record card *********************************/ .REC_SHORTCUTS { diff --git a/swad_ID.c b/swad_ID.c index 99ee46c67..031a42ecc 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -345,26 +345,27 @@ static bool ID_CheckIfUsrIDIsValidUsingMinDigits (const char *UsrID,unsigned Min /*************************** Write list of user's ID *************************/ /*****************************************************************************/ -void ID_WriteUsrIDs (struct UsrData *UsrDat,bool ICanSeeUsrID) +void ID_WriteUsrIDs (struct UsrData *UsrDat) { unsigned NumID; + bool ICanSeeUsrID = ID_ICanSeeUsrID (UsrDat); - if (ICanSeeUsrID) - for (NumID = 0; - NumID < UsrDat->IDs.Num; - NumID++) - { - if (NumID) - fprintf (Gbl.F.Out,"
"); + for (NumID = 0; + NumID < UsrDat->IDs.Num; + NumID++) + { + if (NumID) + fprintf (Gbl.F.Out,"
"); - if (!UsrDat->IDs.List[NumID].Confirmed) - fprintf (Gbl.F.Out,""); + fprintf (Gbl.F.Out,"", + UsrDat->IDs.List[NumID].Confirmed ? "USR_ID_C" : + "USR_ID_NC"); + if (ICanSeeUsrID) fprintf (Gbl.F.Out,"%s",UsrDat->IDs.List[NumID].ID); - if (!UsrDat->IDs.List[NumID].Confirmed) - fprintf (Gbl.F.Out,""); - } - else - fprintf (Gbl.F.Out,"********"); + else + fprintf (Gbl.F.Out,"********"); + fprintf (Gbl.F.Out,""); + } } /*****************************************************************************/ @@ -824,13 +825,19 @@ void ID_ConfirmUsrID (long UsrCod,const char *UsrID) 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->RoleInCurrentCrsDB == Rol_STUDENT); + 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 */ diff --git a/swad_ID.h b/swad_ID.h index d43139ab3..f971e49d9 100644 --- a/swad_ID.h +++ b/swad_ID.h @@ -64,7 +64,7 @@ void ID_GetParamOtherUsrIDPlain (void); bool ID_CheckIfUsrIDIsValid (const char *UsrID); bool ID_CheckIfUsrIDSeemsAValidID (const char *UsrID); -void ID_WriteUsrIDs (struct UsrData *UsrDat,bool ICanSeeUsrID); +void ID_WriteUsrIDs (struct UsrData *UsrDat); void ID_PutLinkToChangeUsrIDs (void); void ID_ShowFormOthIDs (void); diff --git a/swad_attendance.c b/swad_attendance.c index be401f818..1a4567991 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -2008,7 +2008,7 @@ static void Att_WriteRowStdToCallTheRoll (unsigned NumStd,struct UsrData *UsrDat UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat,true); + ID_WriteUsrIDs (UsrDat); fprintf (Gbl.F.Out,""); /***** Write student's name *****/ @@ -3217,7 +3217,7 @@ static void Att_WriteRowStdSeveralAttEvents (unsigned NumStd,struct UsrData *Usr UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat,true); + ID_WriteUsrIDs (UsrDat); fprintf (Gbl.F.Out,""); /***** Write student's name *****/ @@ -3357,7 +3357,7 @@ static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat) Gbl.RowEvenOdd, UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL"); - ID_WriteUsrIDs (UsrDat,true); + ID_WriteUsrIDs (UsrDat); fprintf (Gbl.F.Out,""); /***** Write student's name *****/ diff --git a/swad_changelog.h b/swad_changelog.h index 0a6a3df85..95a7c0d3b 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -137,13 +137,17 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.201.8 (2016-04-22)" -#define CSS_FILE "swad15.198.css" +#define Log_PLATFORM_VERSION "SWAD 15.202 (2016-04-23)" +#define CSS_FILE "swad15.202.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.202: Apr 23, 2016 User's IDs are show in green or red. + Code refactoring and bug fixing related to showing user's ID and e-mail. (200908 lines) + Version 15.201.9: Apr 22, 2016 Code refactoring in record card. + Changes in layout of record cards. (200895 lines) Version 15.201.8: Apr 22, 2016 Code refactoring in record card. Fixed bugs in record cards. (200881 lines) Version 15.201.7: Apr 22, 2016 Code refactoring in record card. diff --git a/swad_file_browser.c b/swad_file_browser.c index c0261cc83..2248b8a3d 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -3457,9 +3457,7 @@ static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat) Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); /***** Show user's ID *****/ - ID_WriteUsrIDs (UsrDat, - UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ID_ICanSeeUsrID (UsrDat) : - (Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER)); + ID_WriteUsrIDs (UsrDat); /***** Show user's name *****/ fprintf (Gbl.F.Out,"
"); diff --git a/swad_mail.c b/swad_mail.c index 739f8371b..c9a0ae14b 100644 --- a/swad_mail.c +++ b/swad_mail.c @@ -1558,3 +1558,47 @@ void Mai_WriteFootNoteEMail (Txt_Language_t Language) Cfg_PLATFORM_SHORT_NAME, Cfg_HTTPS_URL_SWAD_CGI); } + +/*****************************************************************************/ +/**************** Check if I can see another user's e-mail *******************/ +/*****************************************************************************/ + +bool Mai_ICanSeeEmail (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 e-mail */ + switch (Gbl.Usrs.Me.LoggedRole) + { + case Rol_STUDENT: + /* If I am a student of current course, + I only can see the user's e-mail of teachers from current course */ + return (UsrDat->Accepted && + UsrDat->RoleInCurrentCrsDB == Rol_TEACHER); + case Rol_TEACHER: + /* If I am a teacher of current course, + I only can see the user's e-mail of students or teachers from current course */ + return (UsrDat->Accepted && + (UsrDat->RoleInCurrentCrsDB == Rol_STUDENT || + UsrDat->RoleInCurrentCrsDB == Rol_TEACHER)); + case Rol_DEG_ADM: + /* If I am an administrator of current degree, + I only can see the user's e-mail 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 e-mail 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 e-mail 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_mail.h b/swad_mail.h index e67e17a40..3c856e560 100644 --- a/swad_mail.h +++ b/swad_mail.h @@ -85,4 +85,6 @@ void Mai_CreateFileNameMail (void); void Mai_WriteWelcomeNoteEMail (struct UsrData *UsrDat); void Mai_WriteFootNoteEMail (Txt_Language_t Language); +bool Mai_ICanSeeEmail (struct UsrData *UsrDat); + #endif diff --git a/swad_message.c b/swad_message.c index fae36dc12..355bda508 100644 --- a/swad_message.c +++ b/swad_message.c @@ -493,8 +493,7 @@ static void Msg_ShowOneUniqueRecipient (void) fprintf (Gbl.F.Out,"
", Gbl.Usrs.Other.UsrDat.Accepted ? "DAT_SMALL_NOBR_N" : "DAT_SMALL_NOBR"); - ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat, - ID_ICanSeeUsrID (&Gbl.Usrs.Other.UsrDat)); + ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat); fprintf (Gbl.F.Out,"
"); /***** Write user's name *****/ diff --git a/swad_record.c b/swad_record.c index 0ffa9db96..6fc9bb503 100644 --- a/swad_record.c +++ b/swad_record.c @@ -98,10 +98,10 @@ static void Rec_ShowEmail (struct UsrData *UsrDat, Rec_RecordViewType_t TypeOfView, bool DataForm, const char *ClassForm); -static void Rec_ShowUsrIDs (struct UsrData *UsrDat, - Rec_RecordViewType_t TypeOfView, - bool DataForm, - const char *ClassForm); +static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm); +static void Rec_ShowRole (struct UsrData *UsrDat, + Rec_RecordViewType_t TypeOfView, + const char *ClassForm); static void Rec_WriteLinkToDataProtectionClause (void); @@ -1963,12 +1963,7 @@ void Rec_ShowCommonRecordUnmodifiable (struct UsrData *UsrDat) void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView, struct UsrData *UsrDat) { - extern const char *Usr_StringsSexDB[Usr_NUM_SEXS]; extern const char *The_ClassForm[The_NUM_THEMES]; - extern const char *Txt_Sex; - extern const char *Txt_Role; - extern const char *Txt_SEX_SINGULAR_Abc[Usr_NUM_SEXS]; - extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_Surname_1; extern const char *Txt_Surname_2; extern const char *Txt_First_name; @@ -1993,10 +1988,6 @@ void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView, bool IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER); // My current role is teacher bool IAmLoggedAsSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is superuser bool CountryForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD); - bool RoleForm = (TypeOfView == Rec_FORM_SIGN_UP || - TypeOfView == Rec_FORM_NEW_RECORD_OTHER_NEW_USR || - TypeOfView == Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR); - bool SexForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD); bool DataForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD || TypeOfView == Rec_FORM_NEW_RECORD_OTHER_NEW_USR || (TypeOfView == Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR && @@ -2022,9 +2013,6 @@ void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView, ((TypeOfView == Rec_RECORD_LIST || TypeOfView == Rec_RECORD_PRINT) && UsrDat->RoleInCurrentCrsDB == Rol_TEACHER)); // He/she is a teacher in the current course - Usr_Sex_t Sex; - Rol_Role_t Role; - Rol_Role_t DefaultRoleInCurrentCrs; unsigned NumCty; struct Institution Ins; struct Centre Ctr; @@ -2118,195 +2106,10 @@ void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView, Rec_ShowEmail (UsrDat,TypeOfView,DataForm,ClassForm); /***** User's ID *****/ - Rec_ShowUsrIDs (UsrDat,TypeOfView,DataForm,ClassForm); + Rec_ShowUsrIDs (UsrDat,ClassForm); /***** User's role or sex *****/ - if (RoleForm) - { - fprintf (Gbl.F.Out,"" - "" - "%s:" - "", - ClassForm,Rec_C1_BOTTOM, - Txt_Role, - Rec_C2_BOTTOM); - switch (TypeOfView) - { - case Rec_FORM_SIGN_UP: // I want to apply for enrollment - DefaultRoleInCurrentCrs = ((UsrDat->Roles & (1 << Rol_TEACHER)) || // I am teacher in other courses - UsrDat->UsrCod == Gbl.CurrentCrs.Crs.RequesterUsrCod) ? // I am the creator of the course - Rol_TEACHER : - Rol_STUDENT; - fprintf (Gbl.F.Out,""); - break; - case Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR: // The other user already exists in the platform - fprintf (Gbl.F.Out,""); - break; - case Rec_FORM_NEW_RECORD_OTHER_NEW_USR: // The other user does not exist in platform - fprintf (Gbl.F.Out,""); - break; - default: - break; - } - fprintf (Gbl.F.Out,"" - ""); - } - else if (SexForm) - { - fprintf (Gbl.F.Out,"" - "" - "%s*:" - "", - ClassForm,Rec_C1_BOTTOM, - Txt_Sex, - Rec_C2_BOTTOM); - for (Sex = Usr_SEX_FEMALE; - Sex <= Usr_SEX_MALE; - Sex++) - { - fprintf (Gbl.F.Out,"" - "\"%s\"" - "%s", - Gbl.Prefs.IconsURL,Usr_StringsSexDB[Sex], - Txt_SEX_SINGULAR_Abc[Sex], - Txt_SEX_SINGULAR_Abc[Sex], - Txt_SEX_SINGULAR_Abc[Sex]); - } - fprintf (Gbl.F.Out,"" - ""); - } - else // RoleForm == false, SexForm == false - fprintf (Gbl.F.Out,"" - "" - "%s:" - "" - "" - "%s" - "" - "", - ClassForm,Rec_C1_BOTTOM, - TypeOfView == Rec_MY_COMMON_RECORD_CHECK ? Txt_Sex : - Txt_Role, - Rec_C2_BOTTOM, - TypeOfView == Rec_MY_COMMON_RECORD_CHECK ? Txt_SEX_SINGULAR_Abc[UsrDat->Sex] : - Txt_ROLES_SINGUL_Abc[UsrDat->RoleInCurrentCrsDB][UsrDat->Sex]); + Rec_ShowRole (UsrDat,TypeOfView,ClassForm); /***** Name *****/ /* Surname 1 */ @@ -3236,29 +3039,9 @@ static void Rec_ShowEmail (struct UsrData *UsrDat, /******************************* Show user's IDs *****************************/ /*****************************************************************************/ -static void Rec_ShowUsrIDs (struct UsrData *UsrDat, - Rec_RecordViewType_t TypeOfView, - bool DataForm, - const char *ClassForm) +static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm) { extern const char *Txt_ID; - bool ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod); - bool IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER); // My current role is teacher - bool HeIsTeacherInThisCourse = (UsrDat->RoleInCurrentCrsDB == Rol_TEACHER); // He/she is a teacher in this course - bool ShowID = (ItsMe || - Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM || - DataForm || - TypeOfView == Rec_FORM_MY_COMMON_RECORD || - TypeOfView == Rec_MY_COMMON_RECORD_CHECK || - TypeOfView == Rec_FORM_MY_COURSE_RECORD_AS_STUDENT || - TypeOfView == Rec_CHECK_MY_COURSE_RECORD_AS_STUDENT || - (UsrDat->Accepted && - (((TypeOfView == Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR || - TypeOfView == Rec_CHECK_OTHER_USR_COMMON_RECORD) && - !(IAmLoggedAsTeacher && HeIsTeacherInThisCourse)) || // A teacher can not see another teacher's ID - ((TypeOfView == Rec_RECORD_LIST || - TypeOfView == Rec_RECORD_PRINT) && - IAmLoggedAsTeacher && Gbl.Usrs.Listing.RecsUsrs == Rec_RECORD_USERS_STUDENTS)))); fprintf (Gbl.F.Out,"" "", ClassForm,Rec_C1_BOTTOM,Txt_ID, Rec_C2_BOTTOM); - ID_WriteUsrIDs (UsrDat,ShowID); + ID_WriteUsrIDs (UsrDat); fprintf (Gbl.F.Out,"" ""); } +/*****************************************************************************/ +/************************** Show user's role / sex ***************************/ +/*****************************************************************************/ + +static void Rec_ShowRole (struct UsrData *UsrDat, + Rec_RecordViewType_t TypeOfView, + const char *ClassForm) + { + extern const char *Usr_StringsSexDB[Usr_NUM_SEXS]; + extern const char *Txt_Role; + extern const char *Txt_Sex; + extern const char *Txt_SEX_SINGULAR_Abc[Usr_NUM_SEXS]; + extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; + bool RoleForm = (TypeOfView == Rec_FORM_SIGN_UP || + TypeOfView == Rec_FORM_NEW_RECORD_OTHER_NEW_USR || + TypeOfView == Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR); + bool SexForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD); + Rol_Role_t DefaultRoleInCurrentCrs; + Rol_Role_t Role; + Usr_Sex_t Sex; + + if (RoleForm) + { + fprintf (Gbl.F.Out,"" + "" + "%s:" + "", + ClassForm,Rec_C1_BOTTOM, + Txt_Role, + Rec_C2_BOTTOM); + switch (TypeOfView) + { + case Rec_FORM_SIGN_UP: // I want to apply for enrollment + DefaultRoleInCurrentCrs = ((UsrDat->Roles & (1 << Rol_TEACHER)) || // I am teacher in other courses + UsrDat->UsrCod == Gbl.CurrentCrs.Crs.RequesterUsrCod) ? // I am the creator of the course + Rol_TEACHER : + Rol_STUDENT; + fprintf (Gbl.F.Out,""); + break; + case Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR: // The other user already exists in the platform + fprintf (Gbl.F.Out,""); + break; + case Rec_FORM_NEW_RECORD_OTHER_NEW_USR: // The other user does not exist in platform + fprintf (Gbl.F.Out,""); + break; + default: + break; + } + fprintf (Gbl.F.Out,"" + ""); + } + else if (SexForm) + { + fprintf (Gbl.F.Out,"" + "" + "%s*:" + "", + ClassForm,Rec_C1_BOTTOM, + Txt_Sex, + Rec_C2_BOTTOM); + for (Sex = Usr_SEX_FEMALE; + Sex <= Usr_SEX_MALE; + Sex++) + { + fprintf (Gbl.F.Out,"" + "\"%s\"" + "%s", + Gbl.Prefs.IconsURL,Usr_StringsSexDB[Sex], + Txt_SEX_SINGULAR_Abc[Sex], + Txt_SEX_SINGULAR_Abc[Sex], + Txt_SEX_SINGULAR_Abc[Sex]); + } + fprintf (Gbl.F.Out,"" + ""); + } + else // RoleForm == false, SexForm == false + fprintf (Gbl.F.Out,"" + "" + "%s:" + "" + "" + "%s" + "" + "", + ClassForm,Rec_C1_BOTTOM, + TypeOfView == Rec_MY_COMMON_RECORD_CHECK ? Txt_Sex : + Txt_Role, + Rec_C2_BOTTOM, + TypeOfView == Rec_MY_COMMON_RECORD_CHECK ? Txt_SEX_SINGULAR_Abc[UsrDat->Sex] : + Txt_ROLES_SINGUL_Abc[UsrDat->RoleInCurrentCrsDB][UsrDat->Sex]); + } + /*****************************************************************************/ /*********************** Write a link to netiquette rules ********************/ /*****************************************************************************/ diff --git a/swad_statistic.c b/swad_statistic.c index 1f2204b9a..a2196bcb1 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -1662,7 +1662,7 @@ static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql /* Write the user's ID if user is a student */ fprintf (Gbl.F.Out,"", Gbl.RowEvenOdd); - ID_WriteUsrIDs (&UsrDat,(RoleFromLog == Rol_STUDENT)); + ID_WriteUsrIDs (&UsrDat); fprintf (Gbl.F.Out," "); /* Write the first name and the surnames */ @@ -1821,7 +1821,7 @@ static void Sta_ShowNumHitsPerUsr (unsigned long NumRows, /* Write the user's ID if user is a student in current course */ fprintf (Gbl.F.Out,"", Gbl.RowEvenOdd); - ID_WriteUsrIDs (&UsrDat,(UsrDat.RoleInCurrentCrsDB == Rol_STUDENT)); + ID_WriteUsrIDs (&UsrDat); fprintf (Gbl.F.Out," "); /* Write the name and the surnames */ diff --git a/swad_test.c b/swad_test.c index 2d048857b..4497d276a 100644 --- a/swad_test.c +++ b/swad_test.c @@ -7339,9 +7339,7 @@ static void Tst_ShowDataUsr (struct UsrData *UsrDat,unsigned NumExams) Act_LinkFormSubmit (UsrDat->FullName,"MSG_AUT"); /***** Show user's ID *****/ - ID_WriteUsrIDs (UsrDat, - (UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ID_ICanSeeUsrID (UsrDat) : - (Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER))); + ID_WriteUsrIDs (UsrDat); /***** Show user's name *****/ fprintf (Gbl.F.Out,"
%s",UsrDat->Surname1); @@ -7454,7 +7452,7 @@ void Tst_ShowOneTestExam (void) "" "", Txt_ROLES_SINGUL_Abc[Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB][Gbl.Usrs.Other.UsrDat.Sex]); - ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat,true); + ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat); fprintf (Gbl.F.Out," %s", Gbl.Usrs.Other.UsrDat.Surname1); if (Gbl.Usrs.Other.UsrDat.Surname2[0]) diff --git a/swad_user.c b/swad_user.c index a5d6620e0..8d52b3002 100644 --- a/swad_user.c +++ b/swad_user.c @@ -129,12 +129,17 @@ static void Usr_SetUsrRoleAndPrefs (void); static void Usr_InsertMyLastData (void); static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat); -static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutCheckBoxToSelectUsr); +static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat, + bool PutCheckBoxToSelectUsr); static void Usr_WriteRowGstAllData (struct UsrData *UsrDat); -static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,const char *BgColor,bool ShowEmail, - const char *MailLink, - const char *InstitutionName,const char *InstitutionLink); -static void Usr_WriteUsrData (const char *BgColor,const char *Data,const char *Link,bool NonBreak,bool Accepted); +static void Usr_RestrictLengthUsrName (struct UsrData *UsrDat); +static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat, + const char *BgColor, + const char *InstitutionName, + const char *InstitutionLink); +static void Usr_WriteUsrData (const char *BgColor, + const char *Data,const char *Link, + bool NonBreak,bool Accepted); static void Usr_BuildQueryToGetUsrsLstCrs (Rol_Role_t Role,const char *UsrQuery,bool Search,char *Query); static void Usr_GetAdmsLst (Sco_Scope_t Scope); @@ -2686,7 +2691,6 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat) { char PhotoURL[PATH_MAX+1]; bool ShowPhoto; - char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address struct Institution Ins; /***** Start row *****/ @@ -2699,7 +2703,7 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat) Usr_PutCheckboxToSelectUser (UsrDat,false); fprintf (Gbl.F.Out,""); - /***** Student has accepted enrollment in current course? *****/ + /***** Guest has accepted enrollment in current course? *****/ fprintf (Gbl.F.Out,"" "\"\"", Gbl.RowEvenOdd); ShowPhoto = Pho_ShowUsrPhotoIsAllowed (UsrDat,PhotoURL); @@ -2726,26 +2730,21 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat) fprintf (Gbl.F.Out,""); } - /***** Prepare data for brief presentation *****/ - Usr_RestrictLengthMainData (true,UsrDat,MailLink); - /****** Write user's IDs ******/ fprintf (Gbl.F.Out,"", UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat,(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER)); + ID_WriteUsrIDs (UsrDat); fprintf (Gbl.F.Out,""); - /***** Write rest of main student's data *****/ + /***** Write rest of main guest's data *****/ Ins.InsCod = UsrDat->InsCod; Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); - Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],true, - UsrDat->Email[0] ? MailLink : - NULL, - Ins.ShortName, - Ins.WWW[0] ? Ins.WWW : - NULL); + Usr_RestrictLengthUsrName (UsrDat); + Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd], + Ins.ShortName,Ins.WWW[0] ? Ins.WWW : + NULL); /***** End row *****/ fprintf (Gbl.F.Out,""); @@ -2757,7 +2756,8 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat) /************ Write a row of a table with the data of a student **************/ /*****************************************************************************/ -void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutCheckBoxToSelectUsr) +void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat, + bool PutCheckBoxToSelectUsr) { extern const char *Txt_Enrollment_confirmed; extern const char *Txt_Enrollment_not_confirmed; @@ -2765,11 +2765,7 @@ void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutChe char PhotoURL[PATH_MAX+1]; bool ShowPhoto; bool UsrIsTheMsgSender = false; - char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address struct Institution Ins; - bool ShowEmail = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER && UsrDat->Accepted) || - Gbl.Usrs.Me.LoggedRole == Rol_DEG_ADM || - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM; /***** Start row *****/ fprintf (Gbl.F.Out,""); @@ -2828,26 +2824,21 @@ void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutChe fprintf (Gbl.F.Out,""); } - /***** Prepare data for brief presentation *****/ - Usr_RestrictLengthMainData (ShowEmail,UsrDat,MailLink); - /****** Write user's ID ******/ fprintf (Gbl.F.Out,"", UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", BgColor); - ID_WriteUsrIDs (UsrDat,(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER)); + ID_WriteUsrIDs (UsrDat); fprintf (Gbl.F.Out,""); /***** Write rest of main student's data *****/ Ins.InsCod = UsrDat->InsCod; Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); - Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor,ShowEmail, - UsrDat->Email[0] ? MailLink : - NULL, - Ins.ShortName, - Ins.WWW[0] ? Ins.WWW : - NULL); + Usr_RestrictLengthUsrName (UsrDat); + Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor, + Ins.ShortName,Ins.WWW[0] ? Ins.WWW : + NULL); /***** End row *****/ fprintf (Gbl.F.Out,""); @@ -2885,14 +2876,14 @@ static void Usr_WriteRowGstAllData (struct UsrData *UsrDat) /****** Write user's ID ******/ fprintf (Gbl.F.Out,"", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat,true); + ID_WriteUsrIDs (UsrDat); fprintf (Gbl.F.Out," "); /***** Write rest of guest's main data *****/ Ins.InsCod = UsrDat->InsCod; Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); - Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],true, - NULL,Ins.ShortName,NULL); + Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd], + Ins.ShortName,NULL); /***** Write the rest of the data of the guest *****/ if (UsrDat->Tch.CtrCod > 0) @@ -2966,8 +2957,7 @@ void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) char Text[Cns_MAX_BYTES_TEXT+1]; struct Institution Ins; bool ShowData = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER && UsrDat->Accepted) || - Gbl.Usrs.Me.LoggedRole == Rol_DEG_ADM || - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM; + Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM; /***** Start row *****/ fprintf (Gbl.F.Out,""); @@ -2989,13 +2979,14 @@ void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat,(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER)); + ID_WriteUsrIDs (UsrDat); fprintf (Gbl.F.Out," "); /***** Write rest of main student's data *****/ Ins.InsCod = UsrDat->InsCod; Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); - Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],ShowData,NULL,Ins.ShortName,NULL); + Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd], + Ins.ShortName,NULL); /***** Write the rest of the data of the student *****/ Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], @@ -3073,7 +3064,8 @@ void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) /************* Write a row of a table with the data of a teacher *************/ /*****************************************************************************/ -static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutCheckBoxToSelectUsr) +static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat, + bool PutCheckBoxToSelectUsr) { extern const char *Txt_Enrollment_confirmed; extern const char *Txt_Enrollment_not_confirmed; @@ -3082,11 +3074,7 @@ static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,bool bool ShowPhoto; bool UsrIsTheMsgSender = PutCheckBoxToSelectUsr && (UsrDat->UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod); - char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address struct Institution Ins; - bool ShowEmail = UsrDat->Accepted || - Gbl.Usrs.Me.LoggedRole == Rol_DEG_ADM || - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM; /***** Start row *****/ fprintf (Gbl.F.Out,""); @@ -3139,27 +3127,22 @@ static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,bool fprintf (Gbl.F.Out,""); } - /***** Prepare data for brief presentation *****/ - Usr_RestrictLengthMainData (ShowEmail,UsrDat,MailLink); - /****** Write the user's ID ******/ fprintf (Gbl.F.Out,"", UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", BgColor); - ID_WriteUsrIDs (UsrDat,ID_ICanSeeUsrID (UsrDat)); + ID_WriteUsrIDs (UsrDat); fprintf (Gbl.F.Out," "); fprintf (Gbl.F.Out,""); /***** Write rest of main teacher's data *****/ Ins.InsCod = UsrDat->InsCod; Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); - Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor,ShowEmail, - UsrDat->Email[0] ? MailLink : - NULL, - Ins.ShortName, - Ins.WWW[0] ? Ins.WWW : - NULL); + Usr_RestrictLengthUsrName (UsrDat); + Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor, + Ins.ShortName,Ins.WWW[0] ? Ins.WWW : + NULL); fprintf (Gbl.F.Out,""); Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; @@ -3200,13 +3183,14 @@ void Usr_WriteRowTchAllData (struct UsrData *UsrDat) UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat,ID_ICanSeeUsrID (UsrDat)); + ID_WriteUsrIDs (UsrDat); fprintf (Gbl.F.Out," "); /***** Write rest of main teacher's data *****/ Ins.InsCod = UsrDat->InsCod; Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); - Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],ShowData,NULL,Ins.ShortName,NULL); + Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd], + Ins.ShortName,NULL); /***** Write the rest of teacher's data *****/ if (ShowData && UsrDat->Tch.CtrCod > 0) @@ -3242,14 +3226,13 @@ void Usr_WriteRowTchAllData (struct UsrData *UsrDat) } /*****************************************************************************/ -/*** Write a row of a table with the data of a teacher or an administrator ***/ +/********** Write a row of a table with the data of an administrator *********/ /*****************************************************************************/ void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat) { char PhotoURL[PATH_MAX+1]; bool ShowPhoto; - char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address struct Institution Ins; /***** Start row *****/ @@ -3273,26 +3256,21 @@ void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat) fprintf (Gbl.F.Out,""); } - /***** Prepare data for brief presentation *****/ - Usr_RestrictLengthMainData (true,UsrDat,MailLink); - /****** Write the user's ID ******/ fprintf (Gbl.F.Out,"", UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat,(Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)); + ID_WriteUsrIDs (UsrDat); fprintf (Gbl.F.Out," "); /***** Write rest of main administrator's data *****/ Ins.InsCod = UsrDat->InsCod; Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); - Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],true, - UsrDat->Email[0] ? MailLink : - NULL, - Ins.ShortName, - Ins.WWW[0] ? Ins.WWW : - NULL); + Usr_RestrictLengthUsrName (UsrDat); + Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd], + Ins.ShortName,Ins.WWW[0] ? Ins.WWW : + NULL); fprintf (Gbl.F.Out,""); /***** Write degrees which are administrated by this administrator *****/ @@ -3304,29 +3282,28 @@ void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat) } /*****************************************************************************/ -/************** Restrict the length of the main data of a user ***************/ +/***************** Restrict the length of the user's name ********************/ /*****************************************************************************/ -void Usr_RestrictLengthMainData (bool ShowData,struct UsrData *UsrDat,char *MailLink) +static void Usr_RestrictLengthUsrName (struct UsrData *UsrDat) { Str_LimitLengthHTMLStr (UsrDat->FirstName,10); Str_LimitLengthHTMLStr (UsrDat->Surname1,10); Str_LimitLengthHTMLStr (UsrDat->Surname2,10); - if (ShowData && UsrDat->Email[0]) - { - sprintf (MailLink,"mailto:%s",UsrDat->Email); - Str_LimitLengthHTMLStr (UsrDat->Email,10); - } } /*****************************************************************************/ /************************* Write main data of a user *************************/ /*****************************************************************************/ -static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,const char *BgColor,bool ShowEmail, - const char *MailLink, - const char *InstitutionName,const char *InstitutionLink) +static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat, + const char *BgColor, + const char *InstitutionName, + const char *InstitutionLink) { + bool ShowEmail; + char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address + Usr_WriteUsrData (BgColor, UsrDat->Surname1[0] ? UsrDat->Surname1 : " ", @@ -3339,6 +3316,14 @@ static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,const char * UsrDat->FirstName[0] ? UsrDat->FirstName : " ", NULL,true,UsrDat->Accepted); + if (UsrDat->Email[0]) + { + ShowEmail = Mai_ICanSeeEmail (UsrDat); + sprintf (MailLink,"mailto:%s",UsrDat->Email); + Str_LimitLengthHTMLStr (UsrDat->Email,10); + } + else + ShowEmail = false; Usr_WriteUsrData (BgColor, UsrDat->Email[0] ? (ShowEmail ? UsrDat->Email : "********") : @@ -3356,7 +3341,9 @@ static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,const char * /********************* Write a cell with data of a user **********************/ /*****************************************************************************/ -static void Usr_WriteUsrData (const char *BgColor,const char *Data,const char *Link,bool NonBreak,bool Accepted) +static void Usr_WriteUsrData (const char *BgColor, + const char *Data,const char *Link, + bool NonBreak,bool Accepted) { fprintf (Gbl.F.Out,"", Accepted ? (NonBreak ? "DAT_SMALL_NOBR_N" : diff --git a/swad_user.h b/swad_user.h index 1b71a3c5e..479bbfdd4 100644 --- a/swad_user.h +++ b/swad_user.h @@ -271,10 +271,10 @@ bool Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (struct UsrData *UsrDat); void Usr_UpdateMyLastData (void); void Usr_InsertMyLastCrsTabAndTime (void); -void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutCheckboxToSelectUsr); +void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat, + bool PutCheckboxToSelectUsr); void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GrpNames); void Usr_WriteRowTchAllData (struct UsrData *UsrDat); -void Usr_RestrictLengthMainData (bool ShowData,struct UsrData *UsrDat,char *MailLink); unsigned Usr_GetNumUsrsInCrs (Rol_Role_t Role,long CrsCod); unsigned Usr_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod);