diff --git a/swad_attendance.c b/swad_attendance.c index c0b5d980..2f529add 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -2070,8 +2070,6 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr, struct Att_Event *Event) { bool Present; - char PhotoURL[PATH_MAX + 1]; - bool ShowPhoto; char CommentStd[Cns_MAX_BYTES_TEXT + 1]; char CommentTch[Cns_MAX_BYTES_TEXT + 1]; bool ItsMe; @@ -2141,10 +2139,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr, if (Gbl.Usrs.Listing.WithPhotos) { HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO45x60",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO45x60",Pho_ZOOM,false); HTM_TD_End (); } @@ -3434,8 +3429,6 @@ static void Att_WriteTableHeadSeveralAttEvents (const struct Att_Events *Events) static void Att_WriteRowUsrSeveralAttEvents (const struct Att_Events *Events, unsigned NumUsr,struct UsrData *UsrDat) { - char PhotoURL[PATH_MAX + 1]; - bool ShowPhoto; unsigned NumAttEvent; bool Present; unsigned NumTimesPresent; @@ -3454,10 +3447,7 @@ static void Att_WriteRowUsrSeveralAttEvents (const struct Att_Events *Events, if (Gbl.Usrs.Listing.WithPhotos) { HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO21x28",Pho_ZOOM,false); HTM_TD_End (); } @@ -3588,8 +3578,6 @@ static void Att_ListAttEventsForAStd (const struct Att_Events *Events, { extern const char *Txt_Student_comment; extern const char *Txt_Teachers_comment; - char PhotoURL[PATH_MAX + 1]; - bool ShowPhoto; unsigned NumAttEvent; unsigned UniqueId; char *Id; @@ -3612,10 +3600,7 @@ static void Att_ListAttEventsForAStd (const struct Att_Events *Events, /***** Show student's photo *****/ HTM_TD_Begin ("colspan=\"2\" class=\"RM COLOR%u\"",Gbl.RowEvenOdd); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO21x28",Pho_ZOOM,false); HTM_TD_End (); /***** Write user's ID ******/ diff --git a/swad_changelog.h b/swad_changelog.h index dd8ddaca..91f3c217 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -598,10 +598,11 @@ TODO: DNI de un estudiante sale err TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede. TODO: Salvador Romero Cortés: @acanas opción para editar posts */ -#define Log_PLATFORM_VERSION "SWAD 20.38.1 (2021-03-02)" +#define Log_PLATFORM_VERSION "SWAD 20.39 (2021-03-02)" #define CSS_FILE "swad20.33.9.css" #define JS_FILE "swad20.6.2.js" /* + Version 20.39: Mar 02, 2021 Code refactoring in user's photo. (305610 lines) Version 20.38.1: Mar 02, 2021 Code refactoring in timeline comments. (305768 lines) Version 20.38: Mar 02, 2021 Code refactoring in timeline. (305756 lines) Version 20.37: Mar 01, 2021 Code refactoring and more error messages in timeline. (305681 lines) diff --git a/swad_connected.c b/swad_connected.c index 7ccb1ca9..cb0ed6ba 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -785,8 +785,6 @@ static void Con_ShowConnectedUsrsCurrentCrsOneByOneOnRightColumn (Rol_Role_t Rol static void Con_WriteRowConnectedUsrOnRightColumn (Rol_Role_t Role) { extern const char *Txt_View_record_for_this_course; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; const char *ClassTxt; const char *ClassLink; long UsrCod; @@ -816,10 +814,7 @@ static void Con_WriteRowConnectedUsrOnRightColumn (Rol_Role_t Role) /***** Show photo *****/ HTM_TD_Begin ("class=\"CON_PHOTO COLOR%u\"",Gbl.RowEvenOdd); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,true); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO21x28",Pho_ZOOM,true); HTM_TD_End (); /***** Write full name and link *****/ @@ -891,8 +886,6 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R unsigned NumUsr; bool ThisCrs; time_t TimeDiff; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; const char *ClassTxt; const char *ClassLink; struct UsrData UsrDat; @@ -1042,10 +1035,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R /***** Show photo *****/ HTM_TD_Begin ("class=\"CON_PHOTO COLOR%u\"",Gbl.RowEvenOdd); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (&UsrDat,"PHOTO21x28",Pho_ZOOM,false); HTM_TD_End (); /***** Write full name and link *****/ diff --git a/swad_enrolment.c b/swad_enrolment.c index bd2a74d9..ed545de7 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -2263,8 +2263,6 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) struct UsrData UsrDat; bool UsrExists; bool UsrBelongsToCrs; - bool ShowPhoto = false; - char PhotoURL[PATH_MAX + 1]; Rol_Role_t DesiredRole; Act_Action_t NextAction; @@ -2878,10 +2876,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) /***** User photo *****/ HTM_TD_Begin ("class=\"DAT CT\" style=\"width:22px;\""); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (&UsrDat,"PHOTO21x28",Pho_ZOOM,false); HTM_TD_End (); /***** User name *****/ diff --git a/swad_exam_result.c b/swad_exam_result.c index 07ef8e05..5bf1a4c2 100644 --- a/swad_exam_result.c +++ b/swad_exam_result.c @@ -1632,31 +1632,26 @@ static void ExaRes_ComputeValidPrintScore (struct ExaPrn_Print *Print) void ExaRes_ShowExamResultUser (struct UsrData *UsrDat) { extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; /***** Row begin *****/ HTM_TR_Begin (NULL); - /***** Label *****/ - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_ROLES_SINGUL_Abc[UsrDat->Roles.InCurrentCrs.Role][UsrDat->Sex]); - HTM_TD_End (); + /***** Label *****/ + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_ROLES_SINGUL_Abc[UsrDat->Roles.InCurrentCrs.Role][UsrDat->Sex]); + HTM_TD_End (); - /***** User's data *****/ - HTM_TD_Begin ("class=\"DAT LB\""); - ID_WriteUsrIDs (UsrDat,NULL); - HTM_TxtF (" %s",UsrDat->Surname1); - if (UsrDat->Surname2[0]) - HTM_TxtF (" %s",UsrDat->Surname2); - if (UsrDat->FrstName[0]) - HTM_TxtF (", %s",UsrDat->FrstName); - HTM_BR (); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO45x60",Pho_ZOOM,false); - HTM_TD_End (); + /***** User's data *****/ + HTM_TD_Begin ("class=\"DAT LB\""); + ID_WriteUsrIDs (UsrDat,NULL); + HTM_TxtF (" %s",UsrDat->Surname1); + if (UsrDat->Surname2[0]) + HTM_TxtF (" %s",UsrDat->Surname2); + if (UsrDat->FrstName[0]) + HTM_TxtF (", %s",UsrDat->FrstName); + HTM_BR (); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO45x60",Pho_ZOOM,false); + HTM_TD_End (); /***** Row end *****/ HTM_TR_End (); diff --git a/swad_file_browser.c b/swad_file_browser.c index 9261fa31..dcfe86f5 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -3369,67 +3369,63 @@ static void Brw_GetSelectedGroupData (struct GroupData *GrpDat,bool AbortOnError static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat) { extern const char *Txt_View_record_for_this_course; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; Act_Action_t NextAction; /***** Show user's photo *****/ HTM_TD_Begin ("class=\"OWNER_WORKS_PHOTO\""); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO60x80",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO60x80",Pho_ZOOM,false); HTM_TD_End (); /***** Begin form to send a message to this user *****/ HTM_TD_Begin ("class=\"LT\""); - HTM_DIV_Begin ("class=\"OWNER_WORKS_DATA AUTHOR_TXT\""); + HTM_DIV_Begin ("class=\"OWNER_WORKS_DATA AUTHOR_TXT\""); - switch (UsrDat->Roles.InCurrentCrs.Role) - { - case Rol_STD: - NextAction = ActSeeRecOneStd; - break; - case Rol_NET: - case Rol_TCH: - NextAction = ActSeeRecOneTch; - break; - default: - NextAction = ActUnk; - Rol_WrongRoleExit (); - break; - } - Frm_BeginForm (NextAction); - Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); + switch (UsrDat->Roles.InCurrentCrs.Role) + { + case Rol_STD: + NextAction = ActSeeRecOneStd; + break; + case Rol_NET: + case Rol_TCH: + NextAction = ActSeeRecOneTch; + break; + default: + NextAction = ActUnk; + Rol_WrongRoleExit (); + break; + } + Frm_BeginForm (NextAction); + Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); - /***** Show user's ID *****/ - ID_WriteUsrIDs (UsrDat,NULL); + /***** Show user's ID *****/ + ID_WriteUsrIDs (UsrDat,NULL); - /***** Show user's name *****/ - HTM_BR (); + /***** Show user's name *****/ + HTM_BR (); - HTM_BUTTON_SUBMIT_Begin (Txt_View_record_for_this_course,"BT_LINK AUTHOR_TXT",NULL); - HTM_Txt (UsrDat->Surname1); - if (UsrDat->Surname2[0]) - HTM_TxtF (" %s",UsrDat->Surname2); - if (UsrDat->FrstName[0]) - HTM_TxtF (", %s",UsrDat->FrstName); - HTM_BUTTON_End (); + HTM_BUTTON_SUBMIT_Begin (Txt_View_record_for_this_course,"BT_LINK AUTHOR_TXT",NULL); + HTM_Txt (UsrDat->Surname1); + if (UsrDat->Surname2[0]) + HTM_TxtF (" %s",UsrDat->Surname2); + if (UsrDat->FrstName[0]) + HTM_TxtF (", %s",UsrDat->FrstName); + HTM_BUTTON_End (); - /***** Show user's email *****/ - if (UsrDat->Email[0]) - { - HTM_BR (); - HTM_A_Begin ("href=\"mailto:%s\" target=\"_blank\" class=\"AUTHOR_TXT\"", - UsrDat->Email); - HTM_Txt (UsrDat->Email); - HTM_A_End (); - } - Frm_EndForm (); + /***** Show user's email *****/ + if (UsrDat->Email[0]) + { + HTM_BR (); + HTM_A_Begin ("href=\"mailto:%s\" target=\"_blank\"" + " class=\"AUTHOR_TXT\"", + UsrDat->Email); + HTM_Txt (UsrDat->Email); + HTM_A_End (); + } - HTM_DIV_End (); + Frm_EndForm (); + HTM_DIV_End (); HTM_TD_End (); } @@ -6463,8 +6459,6 @@ static void Brw_WriteFileOrFolderPublisher (unsigned Level,unsigned long UsrCod) { extern const char *Txt_Unknown_or_without_photo; bool ShowUsr = false; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; struct UsrData UsrDat; if (Level && UsrCod > 0) @@ -6479,13 +6473,8 @@ static void Brw_WriteFileOrFolderPublisher (unsigned Level,unsigned long UsrCod) HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); if (ShowUsr) - { /***** Show photo *****/ - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO15x20B",Pho_ZOOM,false); - } + Pho_ShowUsrPhotoIfAllowed (&UsrDat,"PHOTO15x20B",Pho_ZOOM,false); else Ico_PutIcon ("usr_bl.jpg",Txt_Unknown_or_without_photo,"PHOTO15x20B"); @@ -9334,8 +9323,6 @@ void Brw_ShowFileMetadata (void) bool ICanEdit; bool ICanChangePublic = false; bool FileHasPublisher; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; Brw_License_t License; unsigned LicenseUnsigned; @@ -9486,10 +9473,7 @@ void Brw_ShowFileMetadata (void) if (FileHasPublisher) { /* Show photo */ - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&PublisherUsrDat,PhotoURL); - Pho_ShowUsrPhoto (&PublisherUsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO15x20",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (&PublisherUsrDat,"PHOTO15x20",Pho_ZOOM,false); /* Write name */ HTM_NBSP (); diff --git a/swad_follow.c b/swad_follow.c index 5140b262..7f021ba9 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -823,52 +823,47 @@ static void Fol_ListFollowersUsr (struct UsrData *UsrDat) static void Fol_ShowFollowedOrFollower (struct UsrData *UsrDat) { extern const char *Txt_Another_user_s_profile; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; bool Visible = Pri_ShowingIsAllowed (UsrDat->BaPrfVisibility,UsrDat); bool ItsMe = Usr_ItsMe (UsrDat->UsrCod); /***** Show user's photo *****/ HTM_TD_Begin ("class=\"FOLLOW_PHOTO\""); - if (Visible) - { - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO60x80",Pho_ZOOM,false); - } + if (Visible) + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO60x80",Pho_ZOOM,false); HTM_TD_End (); /***** Show user's name and icon to follow/unfollow *****/ HTM_TD_Begin ("class=\"FOLLOW_USR\""); - if (Visible) - { - /* Put form to go to public profile */ - Frm_BeginForm (ActSeeOthPubPrf); - Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); - HTM_DIV_Begin ("class=\"FOLLOW_USR_NAME\""); // Limited width - HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile,"BT_LINK LT DAT",NULL); - Usr_WriteFirstNameBRSurnames (UsrDat); - HTM_BUTTON_End (); - HTM_DIV_End (); - Frm_EndForm (); - } - ItsMe = Usr_ItsMe (UsrDat->UsrCod); - if (!Gbl.Usrs.Me.Logged || // Not logged - ItsMe) // It's me - /* Inactive icon to follow/unfollow */ - Fol_PutInactiveIconToFollowUnfollow (); - else // It's not me - { - /* Put form to follow / unfollow */ - if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,UsrDat->UsrCod)) // I follow user - /* Form to unfollow */ - Fol_PutIconToUnfollow (UsrDat); - else if (Visible) // I do not follow this user and I can follow - /* Form to follow */ - Fol_PutIconToFollow (UsrDat); - } + if (Visible) + { + /* Put form to go to public profile */ + Frm_BeginForm (ActSeeOthPubPrf); + Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); + HTM_DIV_Begin ("class=\"FOLLOW_USR_NAME\""); // Limited width + HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile,"BT_LINK LT DAT",NULL); + Usr_WriteFirstNameBRSurnames (UsrDat); + HTM_BUTTON_End (); + HTM_DIV_End (); + Frm_EndForm (); + } + + ItsMe = Usr_ItsMe (UsrDat->UsrCod); + if (!Gbl.Usrs.Me.Logged || // Not logged + ItsMe) // It's me + /* Inactive icon to follow/unfollow */ + Fol_PutInactiveIconToFollowUnfollow (); + else // It's not me + { + /* Put form to follow / unfollow */ + if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,UsrDat->UsrCod)) // I follow user + /* Form to unfollow */ + Fol_PutIconToUnfollow (UsrDat); + else if (Visible) // I do not follow this user and I can follow + /* Form to follow */ + Fol_PutIconToFollow (UsrDat); + } + HTM_TD_End (); } @@ -879,56 +874,52 @@ static void Fol_ShowFollowedOrFollower (struct UsrData *UsrDat) static void Fol_WriteRowUsrToFollowOnRightColumn (struct UsrData *UsrDat) { extern const char *Txt_Another_user_s_profile; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; bool Visible = Pri_ShowingIsAllowed (UsrDat->BaPrfVisibility,UsrDat); bool ItsMe = Usr_ItsMe (UsrDat->UsrCod); /***** Show user's photo *****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"CON_PHOTO COLOR%u\"",Gbl.RowEvenOdd); - if (Visible) - { - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); - } - HTM_TD_End (); - /***** User's name *****/ - HTM_TD_Begin ("class=\"CON_NAME_FOLLOW COLOR%u\"",Gbl.RowEvenOdd); - if (Visible) - { - /* Put form to go to public profile */ - Frm_BeginForm (ActSeeOthPubPrf); - Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); - HTM_DIV_Begin ("class=\"CON_NAME_FOLLOW\""); // Limited width - HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile,"BT_LINK CON_NAME_FOLLOW CON_CRS",NULL); - Usr_WriteFirstNameBRSurnames (UsrDat); - HTM_BUTTON_End (); - HTM_DIV_End (); - Frm_EndForm (); - } - HTM_TD_End (); + HTM_TD_Begin ("class=\"CON_PHOTO COLOR%u\"",Gbl.RowEvenOdd); + if (Visible) + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO21x28",Pho_ZOOM,false); + HTM_TD_End (); + + /***** User's name *****/ + HTM_TD_Begin ("class=\"CON_NAME_FOLLOW COLOR%u\"",Gbl.RowEvenOdd); + if (Visible) + { + /* Put form to go to public profile */ + Frm_BeginForm (ActSeeOthPubPrf); + Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); + HTM_DIV_Begin ("class=\"CON_NAME_FOLLOW\""); // Limited width + HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile, + "BT_LINK CON_NAME_FOLLOW CON_CRS",NULL); + Usr_WriteFirstNameBRSurnames (UsrDat); + HTM_BUTTON_End (); + HTM_DIV_End (); + Frm_EndForm (); + } + HTM_TD_End (); + + /***** Icon to follow *****/ + HTM_TD_Begin ("class=\"CON_ICON_FOLLOW RM COLOR%u\"",Gbl.RowEvenOdd); + if (!Gbl.Usrs.Me.Logged || // Not logged + ItsMe) // It's me + /* Inactive icon to follow/unfollow */ + Fol_PutInactiveIconToFollowUnfollow (); + else // It's not me + { + /* Put form to follow / unfollow */ + if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,UsrDat->UsrCod)) // I follow user + /* Form to unfollow */ + Fol_PutIconToUnfollow (UsrDat); + else if (Visible) // I do not follow this user and I can follow + /* Form to follow */ + Fol_PutIconToFollow (UsrDat); + } + HTM_TD_End (); - /***** Icon to follow *****/ - HTM_TD_Begin ("class=\"CON_ICON_FOLLOW RM COLOR%u\"",Gbl.RowEvenOdd); - if (!Gbl.Usrs.Me.Logged || // Not logged - ItsMe) // It's me - /* Inactive icon to follow/unfollow */ - Fol_PutInactiveIconToFollowUnfollow (); - else // It's not me - { - /* Put form to follow / unfollow */ - if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,UsrDat->UsrCod)) // I follow user - /* Form to unfollow */ - Fol_PutIconToUnfollow (UsrDat); - else if (Visible) // I do not follow this user and I can follow - /* Form to follow */ - Fol_PutIconToFollow (UsrDat); - } - HTM_TD_End (); HTM_TR_End (); Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; diff --git a/swad_match_result.c b/swad_match_result.c index 648fc2a2..93d401d6 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -1159,8 +1159,6 @@ void MchRes_ShowOneMchResult (void) Dat_StartEndTime_t StartEndTime; char *Id; struct MchPrn_Print Print; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; struct MchRes_ICanView ICanView; /***** Reset games context *****/ @@ -1205,157 +1203,154 @@ void MchRes_ShowOneMchResult (void) Box_BoxBegin (NULL,Match.Title, NULL,NULL, Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE); - Lay_WriteHeaderClassPhoto (false,false, - Gbl.Hierarchy.Ins.InsCod, - Gbl.Hierarchy.Deg.DegCod, - Gbl.Hierarchy.Crs.CrsCod); + Lay_WriteHeaderClassPhoto (false,false, + Gbl.Hierarchy.Ins.InsCod, + Gbl.Hierarchy.Deg.DegCod, + Gbl.Hierarchy.Crs.CrsCod); - /***** Begin table *****/ - HTM_TABLE_BeginWideMarginPadding (10); + /***** Begin table *****/ + HTM_TABLE_BeginWideMarginPadding (10); - /***** User *****/ - /* Get data of the user who answer the match */ - if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (UsrDat,Usr_DONT_GET_PREFS)) - Lay_ShowErrorAndExit (Txt_The_user_does_not_exist); - if (!Usr_CheckIfICanViewTstExaMchResult (UsrDat)) - Lay_NoPermissionExit (); + /***** User *****/ + /* Get data of the user who answer the match */ + if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (UsrDat,Usr_DONT_GET_PREFS)) + Lay_ShowErrorAndExit (Txt_The_user_does_not_exist); + if (!Usr_CheckIfICanViewTstExaMchResult (UsrDat)) + Lay_NoPermissionExit (); - /* User */ - HTM_TR_Begin (NULL); + /* User */ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_ROLES_SINGUL_Abc[UsrDat->Roles.InCurrentCrs.Role][UsrDat->Sex]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_ROLES_SINGUL_Abc[UsrDat->Roles.InCurrentCrs.Role][UsrDat->Sex]); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LB\""); - ID_WriteUsrIDs (UsrDat,NULL); - HTM_TxtF (" %s",UsrDat->Surname1); - if (UsrDat->Surname2[0]) - HTM_TxtF (" %s",UsrDat->Surname2); - if (UsrDat->FrstName[0]) - HTM_TxtF (", %s",UsrDat->FrstName); - HTM_BR (); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO45x60",Pho_ZOOM,false); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LB\""); + ID_WriteUsrIDs (UsrDat,NULL); + HTM_TxtF (" %s",UsrDat->Surname1); + if (UsrDat->Surname2[0]) + HTM_TxtF (" %s",UsrDat->Surname2); + if (UsrDat->FrstName[0]) + HTM_TxtF (", %s",UsrDat->FrstName); + HTM_BR (); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO45x60",Pho_ZOOM,false); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Start/end time (for user in this match) *****/ - for (StartEndTime = (Dat_StartEndTime_t) 0; - StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1); - StartEndTime++) - { - HTM_TR_Begin (NULL); + /***** Start/end time (for user in this match) *****/ + for (StartEndTime = (Dat_StartEndTime_t) 0; + StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1); + StartEndTime++) + { + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_START_END_TIME[StartEndTime]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_START_END_TIME[StartEndTime]); + HTM_TD_End (); - if (asprintf (&Id,"match_%u",(unsigned) StartEndTime) < 0) - Lay_NotEnoughMemoryExit (); - HTM_TD_Begin ("id=\"%s\" class=\"DAT LB\"",Id); - Dat_WriteLocalDateHMSFromUTC (Id,Print.TimeUTC[StartEndTime], - Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, - true,true,true,0x7); - HTM_TD_End (); - free (Id); + if (asprintf (&Id,"match_%u",(unsigned) StartEndTime) < 0) + Lay_NotEnoughMemoryExit (); + HTM_TD_Begin ("id=\"%s\" class=\"DAT LB\"",Id); + Dat_WriteLocalDateHMSFromUTC (Id,Print.TimeUTC[StartEndTime], + Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, + true,true,true,0x7); + HTM_TD_End (); + free (Id); - HTM_TR_End (); - } + HTM_TR_End (); + } - /***** Number of questions *****/ - HTM_TR_Begin (NULL); + /***** Number of questions *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_Questions); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_Questions); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_Unsigned (Print.NumQsts.All); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_Unsigned (Print.NumQsts.All); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Number of answers *****/ - HTM_TR_Begin (NULL); + /***** Number of answers *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_Answers); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_Answers); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_Unsigned (Print.NumQsts.NotBlank); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_Unsigned (Print.NumQsts.NotBlank); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Score *****/ - HTM_TR_Begin (NULL); + /***** Score *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_Score); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_Score); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LB\""); - if (ICanView.Score) - { - HTM_STRONG_Begin (); - HTM_Double2Decimals (Print.Score); - HTM_Txt ("/"); - HTM_Unsigned (Print.NumQsts.All); - HTM_STRONG_End (); - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LB\""); + if (ICanView.Score) + { + HTM_STRONG_Begin (); + HTM_Double2Decimals (Print.Score); + HTM_Txt ("/"); + HTM_Unsigned (Print.NumQsts.All); + HTM_STRONG_End (); + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Grade *****/ - HTM_TR_Begin (NULL); + /***** Grade *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_Grade); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_Grade); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LB\""); - if (ICanView.Score) - { - HTM_STRONG_Begin (); - TstPrn_ComputeAndShowGrade (Print.NumQsts.All,Print.Score,Game.MaxGrade); - HTM_STRONG_End (); - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LB\""); + if (ICanView.Score) + { + HTM_STRONG_Begin (); + TstPrn_ComputeAndShowGrade (Print.NumQsts.All,Print.Score,Game.MaxGrade); + HTM_STRONG_End (); + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Tags present in this result *****/ - HTM_TR_Begin (NULL); + /***** Tags present in this result *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_Tags); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_Tags); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LB\""); - Gam_ShowTstTagsPresentInAGame (Match.GamCod); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LB\""); + Gam_ShowTstTagsPresentInAGame (Match.GamCod); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Write answers and solutions *****/ - TstPrn_ShowPrintAnswers (UsrDat, - Print.NumQsts.All, - Print.PrintedQuestions, - Print.TimeUTC, - Game.Visibility); + /***** Write answers and solutions *****/ + TstPrn_ShowPrintAnswers (UsrDat, + Print.NumQsts.All, + Print.PrintedQuestions, + Print.TimeUTC, + Game.Visibility); - /***** End table *****/ - HTM_TABLE_End (); + /***** End table *****/ + HTM_TABLE_End (); /***** End box *****/ Box_BoxEnd (); diff --git a/swad_message.c b/swad_message.c index c5e89d8a..1cbbaf30 100644 --- a/swad_message.c +++ b/swad_message.c @@ -500,27 +500,21 @@ static void Msg_PutHiddenParamsSubjectAndContent (void) static void Msg_ShowOneUniqueRecipient (void) { - char PhotoURL[PATH_MAX + 1]; - bool ShowPhoto; - /***** Show user's photo *****/ - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&Gbl.Usrs.Other.UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&Gbl.Usrs.Other.UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (&Gbl.Usrs.Other.UsrDat,"PHOTO21x28",Pho_ZOOM,false); /****** Write user's IDs ******/ HTM_DIV_Begin ("class=\"MSG_TO_ONE_RCP %s\"", Gbl.Usrs.Other.UsrDat.Accepted ? "DAT_SMALL_NOBR_N" : "DAT_SMALL_NOBR"); - ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat,NULL); + ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat,NULL); HTM_DIV_End (); /***** Write user's name *****/ HTM_DIV_Begin ("class=\"MSG_TO_ONE_RCP %s\"", Gbl.Usrs.Other.UsrDat.Accepted ? "DAT_SMALL_NOBR_N" : "DAT_SMALL_NOBR"); - HTM_Txt (Gbl.Usrs.Other.UsrDat.FullName); + HTM_Txt (Gbl.Usrs.Other.UsrDat.FullName); HTM_DIV_End (); /***** Hidden parameter with user's nickname *****/ @@ -3393,8 +3387,6 @@ static void Msg_WriteSentOrReceivedMsgSubject (struct Msg_Messages *Messages, void Msg_WriteMsgAuthor (struct UsrData *UsrDat,bool Enabled,const char *BgColor) { extern const char *Txt_Unknown_or_without_photo; - bool ShowPhoto = false; - char PhotoURL[PATH_MAX + 1]; bool WriteAuthor; /***** Write author name or don't write it? *****/ @@ -3405,51 +3397,47 @@ void Msg_WriteMsgAuthor (struct UsrData *UsrDat,bool Enabled,const char *BgColor /***** Begin table and row *****/ HTM_TABLE_BeginPadding (2); - HTM_TR_Begin (NULL); + HTM_TR_Begin (NULL); - /***** Start first column with author's photo - (if author has a web page, put a link to it) *****/ - if (BgColor) - HTM_TD_Begin ("class=\"CT %s\" style=\"width:30px;\"",BgColor); - else - HTM_TD_Begin ("class=\"CT\" style=\"width:30px;\""); + /***** Start first column with author's photo + (if author has a web page, put a link to it) *****/ + if (BgColor) + HTM_TD_Begin ("class=\"CT %s\" style=\"width:30px;\"",BgColor); + else + HTM_TD_Begin ("class=\"CT\" style=\"width:30px;\""); - if (WriteAuthor) - { - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO30x40",Pho_ZOOM,false); - } - else - Ico_PutIcon ("usr_bl.jpg",Txt_Unknown_or_without_photo,"PHOTO30x40"); - HTM_TD_End (); + if (WriteAuthor) + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO30x40",Pho_ZOOM,false); + else + Ico_PutIcon ("usr_bl.jpg",Txt_Unknown_or_without_photo,"PHOTO30x40"); - /***** Second column with user name (if author has a web page, put a link to it) *****/ - if (WriteAuthor) - { - if (BgColor) - HTM_TD_Begin ("class=\"LT %s\"",BgColor); - else - HTM_TD_Begin ("class=\"LT\""); + HTM_TD_End (); - HTM_DIV_Begin ("class=\"AUTHOR_2_LINES\""); // Limited width - Usr_WriteFirstNameBRSurnames (UsrDat); - HTM_DIV_End (); - } - else - { - if (BgColor) - HTM_TD_Begin ("class=\"LM %s\"",BgColor); - else - HTM_TD_Begin ("class=\"LM\""); - } + /***** Second column with user name (if author has a web page, put a link to it) *****/ + if (WriteAuthor) + { + if (BgColor) + HTM_TD_Begin ("class=\"LT %s\"",BgColor); + else + HTM_TD_Begin ("class=\"LT\""); - /***** End second column *****/ - HTM_TD_End (); + HTM_DIV_Begin ("class=\"AUTHOR_2_LINES\""); // Limited width + Usr_WriteFirstNameBRSurnames (UsrDat); + HTM_DIV_End (); + } + else + { + if (BgColor) + HTM_TD_Begin ("class=\"LM %s\"",BgColor); + else + HTM_TD_Begin ("class=\"LM\""); + } - /***** End row and table *****/ - HTM_TR_End (); + /***** End second column *****/ + HTM_TD_End (); + + /***** End row and table *****/ + HTM_TR_End (); HTM_TABLE_End (); } @@ -3555,50 +3543,45 @@ static void Msg_WriteMsgFrom (struct Msg_Messages *Messages, extern const char *Txt_MSG_Sent; extern const char *Txt_MSG_Sent_and_deleted; extern const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; HTM_TABLE_Begin (NULL); - HTM_TR_Begin (NULL); + HTM_TR_Begin (NULL); - /***** Put an icon to show if user has read the message *****/ - HTM_TD_Begin ("class=\"LM\" style=\"width:20px;\""); - Ico_PutIcon (Deleted ? "share-red.svg" : - "share.svg", - Deleted ? Txt_MSG_Sent_and_deleted : - Txt_MSG_Sent, - "ICO16x16"); - HTM_TD_End (); + /***** Put an icon to show if user has read the message *****/ + HTM_TD_Begin ("class=\"LM\" style=\"width:20px;\""); + Ico_PutIcon (Deleted ? "share-red.svg" : + "share.svg", + Deleted ? Txt_MSG_Sent_and_deleted : + Txt_MSG_Sent, + "ICO16x16"); + HTM_TD_End (); - /***** Put user's photo *****/ - HTM_TD_Begin ("class=\"CM\" style=\"width:30px;\""); - ShowPhoto = (Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL)); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); - HTM_TD_End (); + /***** Put user's photo *****/ + HTM_TD_Begin ("class=\"CM\" style=\"width:30px;\""); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO21x28",Pho_ZOOM,false); + HTM_TD_End (); - /***** Write user's name *****/ - HTM_TD_Begin ("class=\"AUTHOR_TXT LM\""); - if (UsrDat->UsrCod > 0) - { - HTM_Txt (UsrDat->FullName); - if (Act_GetSuperAction (Gbl.Action.Act) == ActSeeRcvMsg) - { - HTM_NBSP (); - if (Msg_CheckIfUsrIsBanned (UsrDat->UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod)) - // Sender is banned - Msg_PutFormToUnbanSender (Messages,UsrDat); - else - // Sender is not banned - Msg_PutFormToBanSender (Messages,UsrDat); - } - } - else - HTM_TxtF ("[%s]",Txt_ROLES_SINGUL_abc[Rol_UNK][Usr_SEX_UNKNOWN]); // User not found, likely an old user who has been removed - HTM_TD_End (); + /***** Write user's name *****/ + HTM_TD_Begin ("class=\"AUTHOR_TXT LM\""); + if (UsrDat->UsrCod > 0) + { + HTM_Txt (UsrDat->FullName); + if (Act_GetSuperAction (Gbl.Action.Act) == ActSeeRcvMsg) + { + HTM_NBSP (); + if (Msg_CheckIfUsrIsBanned (UsrDat->UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod)) + // Sender is banned + Msg_PutFormToUnbanSender (Messages,UsrDat); + else + // Sender is not banned + Msg_PutFormToBanSender (Messages,UsrDat); + } + } + else + HTM_TxtF ("[%s]",Txt_ROLES_SINGUL_abc[Rol_UNK][Usr_SEX_UNKNOWN]); // User not found, likely an old user who has been removed + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); HTM_TABLE_End (); } @@ -4021,8 +4004,6 @@ void Msg_ListBannedUsrs (void) MYSQL_ROW row; unsigned NumUsr,NumUsrs; struct UsrData UsrDat; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; /***** Get my banned users *****/ NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get banned users", @@ -4072,10 +4053,7 @@ void Msg_ListBannedUsrs (void) /* Show photo */ HTM_TD_Begin ("class=\"LM\" style=\"width:30px;\""); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (&UsrDat,"PHOTO21x28",Pho_ZOOM,false); HTM_TD_End (); /* Write user's full name */ diff --git a/swad_photo.c b/swad_photo.c index ad37b3d9..5f8b6eb0 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -983,13 +983,30 @@ void Pho_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod) UsrCod); } +/*****************************************************************************/ +/********************* Show a user's photo if allowed ************************/ +/*****************************************************************************/ + +void Pho_ShowUsrPhotoIfAllowed (struct UsrData *UsrDat, + const char *ClassPhoto,Pho_Zoom_t Zoom, + bool FormUnique) + { + char PhotoURL[PATH_MAX + 1]; + bool ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); + + Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : + NULL, + ClassPhoto,Zoom,FormUnique); + } + /*****************************************************************************/ /********************* Check if user's photo can be shown ********************/ /*****************************************************************************/ // Returns true if the photo can be shown and false if not. // Public photo means two different things depending on the user's type -bool Pho_ShowingUsrPhotoIsAllowed (struct UsrData *UsrDat,char PhotoURL[PATH_MAX + 1]) +bool Pho_ShowingUsrPhotoIsAllowed (struct UsrData *UsrDat, + char PhotoURL[PATH_MAX + 1]) { bool ICanSeePhoto; @@ -1058,102 +1075,7 @@ bool Pho_CheckIfPrivPhotoExists (long UsrCod,char PathPrivRelPhoto[PATH_MAX + 1] } /*****************************************************************************/ -/************************** Remove a user's photo ****************************/ -/*****************************************************************************/ -// Returns true on success, false on error - -bool Pho_RemovePhoto (struct UsrData *UsrDat) - { - extern const char *Txt_Photo_removed; - char PathPrivRelPhoto[PATH_MAX + 1]; - char PathPublPhoto[PATH_MAX + 1]; - unsigned NumErrors = 0; - - if (UsrDat->Photo[0]) - { - /***** Clear photo name in database *****/ - Pho_ClearPhotoName (UsrDat->UsrCod); - - /***** Remove public link *****/ - snprintf (PathPublPhoto,sizeof (PathPublPhoto),"%s/%s.jpg", - Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo); - if (Fil_CheckIfPathExists (PathPublPhoto)) // Public link exists - if (unlink (PathPublPhoto)) // Remove public link - NumErrors++; - - /***** Remove photo *****/ - snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto),"%s/%02u/%ld.jpg", - Cfg_PATH_PHOTO_PRIVATE, - (unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod); - if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Photo exists - { - if (unlink (PathPrivRelPhoto)) // Remove photo - NumErrors++; - } - - /***** Remove original photo *****/ - snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto), - "%s/%02u/%ld_original.jpg", - Cfg_PATH_PHOTO_PRIVATE, - (unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod); - if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Original photo exists - if (unlink (PathPrivRelPhoto)) // Remove original photo - NumErrors++; - - /***** Clear photo name in user's data *****/ - UsrDat->Photo[0] = '\0'; - } - - if (NumErrors) - { - Ale_CreateAlert (Ale_ERROR,NULL, - "Error removing photo."); - return false; - } - else - { - Ale_CreateAlert (Ale_SUCCESS,NULL, - Txt_Photo_removed); - return true; - } - } - -/*****************************************************************************/ -/****************** Clear photo name of an user in database ******************/ -/*****************************************************************************/ - -static void Pho_ClearPhotoName (long UsrCod) - { - /***** Clear photo name in user's data *****/ - DB_QueryUPDATE ("can not clear the name of a user's photo", - "UPDATE usr_data SET Photo='' WHERE UsrCod=%ld", - UsrCod); - } - -/*****************************************************************************/ -/***************** Update photo name of an user in database ******************/ -/*****************************************************************************/ - -void Pho_UpdatePhotoName (struct UsrData *UsrDat) - { - char PathPublPhoto[PATH_MAX + 1]; - - /***** Update photo name in database *****/ - DB_QueryUPDATE ("can not update the name of a user's photo", - "UPDATE usr_data SET Photo='%s' WHERE UsrCod=%ld", - Gbl.UniqueNameEncrypted,UsrDat->UsrCod); - - /***** Remove the old symbolic link to photo *****/ - snprintf (PathPublPhoto,sizeof (PathPublPhoto),"%s/%s.jpg", - Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo); - unlink (PathPublPhoto); // Remove public link - - /***** Update photo name in user's data *****/ - Str_Copy (UsrDat->Photo,Gbl.UniqueNameEncrypted,sizeof (UsrDat->Photo) - 1); - } - -/*****************************************************************************/ -/****************** Write code to show the photo of a user *******************/ +/*************************** Show a user's photo *****************************/ /*****************************************************************************/ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL, @@ -1302,6 +1224,101 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL, } } +/*****************************************************************************/ +/************************** Remove a user's photo ****************************/ +/*****************************************************************************/ +// Returns true on success, false on error + +bool Pho_RemovePhoto (struct UsrData *UsrDat) + { + extern const char *Txt_Photo_removed; + char PathPrivRelPhoto[PATH_MAX + 1]; + char PathPublPhoto[PATH_MAX + 1]; + unsigned NumErrors = 0; + + if (UsrDat->Photo[0]) + { + /***** Clear photo name in database *****/ + Pho_ClearPhotoName (UsrDat->UsrCod); + + /***** Remove public link *****/ + snprintf (PathPublPhoto,sizeof (PathPublPhoto),"%s/%s.jpg", + Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo); + if (Fil_CheckIfPathExists (PathPublPhoto)) // Public link exists + if (unlink (PathPublPhoto)) // Remove public link + NumErrors++; + + /***** Remove photo *****/ + snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto),"%s/%02u/%ld.jpg", + Cfg_PATH_PHOTO_PRIVATE, + (unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod); + if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Photo exists + { + if (unlink (PathPrivRelPhoto)) // Remove photo + NumErrors++; + } + + /***** Remove original photo *****/ + snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto), + "%s/%02u/%ld_original.jpg", + Cfg_PATH_PHOTO_PRIVATE, + (unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod); + if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Original photo exists + if (unlink (PathPrivRelPhoto)) // Remove original photo + NumErrors++; + + /***** Clear photo name in user's data *****/ + UsrDat->Photo[0] = '\0'; + } + + if (NumErrors) + { + Ale_CreateAlert (Ale_ERROR,NULL, + "Error removing photo."); + return false; + } + else + { + Ale_CreateAlert (Ale_SUCCESS,NULL, + Txt_Photo_removed); + return true; + } + } + +/*****************************************************************************/ +/****************** Clear photo name of an user in database ******************/ +/*****************************************************************************/ + +static void Pho_ClearPhotoName (long UsrCod) + { + /***** Clear photo name in user's data *****/ + DB_QueryUPDATE ("can not clear the name of a user's photo", + "UPDATE usr_data SET Photo='' WHERE UsrCod=%ld", + UsrCod); + } + +/*****************************************************************************/ +/***************** Update photo name of an user in database ******************/ +/*****************************************************************************/ + +void Pho_UpdatePhotoName (struct UsrData *UsrDat) + { + char PathPublPhoto[PATH_MAX + 1]; + + /***** Update photo name in database *****/ + DB_QueryUPDATE ("can not update the name of a user's photo", + "UPDATE usr_data SET Photo='%s' WHERE UsrCod=%ld", + Gbl.UniqueNameEncrypted,UsrDat->UsrCod); + + /***** Remove the old symbolic link to photo *****/ + snprintf (PathPublPhoto,sizeof (PathPublPhoto),"%s/%s.jpg", + Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo); + unlink (PathPublPhoto); // Remove public link + + /***** Update photo name in user's data *****/ + Str_Copy (UsrDat->Photo,Gbl.UniqueNameEncrypted,sizeof (UsrDat->Photo) - 1); + } + /*****************************************************************************/ /************************** Change photo visibility **************************/ /*****************************************************************************/ diff --git a/swad_photo.h b/swad_photo.h index f6bc67d3..2a6ea96e 100644 --- a/swad_photo.h +++ b/swad_photo.h @@ -116,15 +116,20 @@ void Pho_UpdateUsrPhoto2 (void); unsigned Pho_UpdateMyClicksWithoutPhoto (void); void Pho_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod); -bool Pho_ShowingUsrPhotoIsAllowed (struct UsrData *UsrDat,char PhotoURL[PATH_MAX + 1]); +void Pho_ShowUsrPhotoIfAllowed (struct UsrData *UsrDat, + const char *ClassPhoto,Pho_Zoom_t Zoom, + bool FormUnique); +bool Pho_ShowingUsrPhotoIsAllowed (struct UsrData *UsrDat, + char PhotoURL[PATH_MAX + 1]); bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char PhotoURL[PATH_MAX + 1]); bool Pho_CheckIfPrivPhotoExists (long UsrCod,char PathPrivRelPhoto[PATH_MAX + 1]); -bool Pho_RemovePhoto (struct UsrData *UsrDat); -void Pho_UpdatePhotoName (struct UsrData *UsrDat); void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL, const char *ClassPhoto,Pho_Zoom_t Zoom, bool FormUnique); +bool Pho_RemovePhoto (struct UsrData *UsrDat); +void Pho_UpdatePhotoName (struct UsrData *UsrDat); + void Pho_ChangePhotoVisibility (void); void Pho_CalcPhotoDegree (void); diff --git a/swad_profile.c b/swad_profile.c index 3f238519..629ecf30 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -1756,42 +1756,35 @@ void Prf_GetAndShowRankingClicksPerDay (void) static void Prf_ShowUsrInRanking (struct UsrData *UsrDat,unsigned Rank,bool ItsMe) { extern const char *Txt_Another_user_s_profile; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; bool Visible = Pri_ShowingIsAllowed (UsrDat->BaPrfVisibility,UsrDat); HTM_TD_Begin ("class=\"RM %s COLOR%u\"", ItsMe ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - HTM_TxtF ("#%u",Rank); + HTM_TxtF ("#%u",Rank); HTM_TD_End (); /***** Check if I can see the public profile *****/ HTM_TD_Begin ("class=\"RANK_PHOTO COLOR%u\"",Gbl.RowEvenOdd); - if (Visible) - { - /***** User's photo *****/ - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO30x40",Pho_ZOOM,false); - } + if (Visible) + /***** User's photo *****/ + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO30x40",Pho_ZOOM,false); HTM_TD_End (); /***** Put form to go to public profile *****/ HTM_TD_Begin ("class=\"COLOR%u\"",Gbl.RowEvenOdd); - if (Visible) - { - Frm_BeginForm (ActSeeOthPubPrf); - Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); - HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile, - ItsMe ? "BT_LINK RANK_USR DAT_SMALL_N" : - "BT_LINK RANK_USR DAT_SMALL", - NULL); // Limited width - Usr_WriteFirstNameBRSurnames (UsrDat); - HTM_BUTTON_End (); - Frm_EndForm (); - } + if (Visible) + { + Frm_BeginForm (ActSeeOthPubPrf); + Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); + HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile, + ItsMe ? "BT_LINK RANK_USR DAT_SMALL_N" : + "BT_LINK RANK_USR DAT_SMALL", + NULL); // Limited width + Usr_WriteFirstNameBRSurnames (UsrDat); + HTM_BUTTON_End (); + Frm_EndForm (); + } HTM_TD_End (); } diff --git a/swad_project.c b/swad_project.c index 6032d62f..79e73e73 100644 --- a/swad_project.c +++ b/swad_project.c @@ -2033,8 +2033,6 @@ static void Prj_ShowOneProjectMembersWithARole (struct Prj_Projects *Projects, bool WriteRow; unsigned NumUsr; unsigned NumUsrs; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; const char *ClassLabel; const char *ClassData; static const Act_Action_t ActionReqRemUsr[Prj_NUM_ROLES_IN_PROJECT] = @@ -2142,10 +2140,7 @@ static void Prj_ShowOneProjectMembersWithARole (struct Prj_Projects *Projects, /* Put user's photo */ HTM_TD_Begin ("class=\"PRJ_MEMBER_PHO\""); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&Gbl.Usrs.Other.UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&Gbl.Usrs.Other.UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (&Gbl.Usrs.Other.UsrDat,"PHOTO21x28",Pho_ZOOM,false); HTM_TD_End (); /* Write user's name */ diff --git a/swad_record.c b/swad_record.c index 007d4e7f..fc70cdd3 100644 --- a/swad_record.c +++ b/swad_record.c @@ -2710,14 +2710,9 @@ static void Rec_ShowInstitutionInHead (struct Ins_Instit *Ins,bool PutFormLinks) static void Rec_ShowPhoto (struct UsrData *UsrDat) { - char PhotoURL[PATH_MAX + 1]; - bool ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - /***** User's photo *****/ HTM_TD_Begin ("rowspan=\"3\" class=\"REC_C3_TOP CT\""); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO186x248",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO186x248",Pho_ZOOM,false); HTM_TD_End (); } diff --git a/swad_statistic.c b/swad_statistic.c index d3b9cfb9..d0c879c7 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -1742,8 +1742,6 @@ static void Sta_ShowNumHitsPerUsr (Sta_CountType_t CountType, struct Sta_Hits Hits; unsigned BarWidth; struct UsrData UsrDat; - char PhotoURL[PATH_MAX + 1]; - bool ShowPhoto; /***** Initialize user's data *****/ Usr_UsrDataConstructor (&UsrDat); @@ -1780,10 +1778,7 @@ static void Sta_ShowNumHitsPerUsr (Sta_CountType_t CountType, /* Show the photo */ HTM_TD_Begin ("class=\"CT COLOR%u\"",Gbl.RowEvenOdd); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO15x20",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (&UsrDat,"PHOTO15x20",Pho_ZOOM,false); HTM_TD_End (); /* Write the user's ID if user is a student in current course */ diff --git a/swad_test_print.c b/swad_test_print.c index 6be2315b..886cac95 100644 --- a/swad_test_print.c +++ b/swad_test_print.c @@ -2384,8 +2384,6 @@ void TstPrn_ShowOnePrint (void) extern const char *Txt_Grade; extern const char *Txt_Tags; struct TstPrn_Print Print; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; Dat_StartEndTime_t StartEndTime; char *Id; struct TstRes_ICanView ICanView; @@ -2442,10 +2440,7 @@ void TstPrn_ShowOnePrint (void) if (Gbl.Usrs.Other.UsrDat.FrstName[0]) HTM_TxtF (", %s",Gbl.Usrs.Other.UsrDat.FrstName); HTM_BR (); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&Gbl.Usrs.Other.UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&Gbl.Usrs.Other.UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO45x60",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (&Gbl.Usrs.Other.UsrDat,"PHOTO45x60",Pho_ZOOM,false); HTM_TD_End (); HTM_TR_End (); diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index 219cc41c..1d34228c 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -181,18 +181,12 @@ void TL_Com_PutPhotoAndFormToWriteNewComm (const struct TL_Timeline *Timeline, static void TL_Com_ShowAuthorPhoto (struct UsrData *UsrDat) { - bool ShowPhoto = false; - char PhotoURL[PATH_MAX + 1]; - /***** Show author's photo *****/ /* Begin container */ HTM_DIV_Begin ("class=\"TL_COM_PHOTO\""); /* Author's photo */ - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO30x40",Pho_ZOOM,true); // Use unique id + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO30x40",Pho_ZOOM,true); // Use unique id /* End container */ HTM_DIV_End (); diff --git a/swad_timeline_note.c b/swad_timeline_note.c index 205505e2..70f2b52d 100644 --- a/swad_timeline_note.c +++ b/swad_timeline_note.c @@ -310,18 +310,12 @@ static void TL_Not_WriteNote (const struct TL_Timeline *Timeline, static void TL_Not_ShowAuthorPhoto (struct UsrData *UsrDat) { - bool ShowPhoto = false; - char PhotoURL[PATH_MAX + 1]; - /***** Show author's photo *****/ /* Begin container */ HTM_DIV_Begin ("class=\"TL_LEFT_PHOTO\""); /* Photo */ - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO45x60",Pho_ZOOM,true); // Use unique id + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO45x60",Pho_ZOOM,true); // Use unique id /* End container */ HTM_DIV_End (); diff --git a/swad_timeline_post.c b/swad_timeline_post.c index ca1fdb5c..91959444 100644 --- a/swad_timeline_post.c +++ b/swad_timeline_post.c @@ -122,8 +122,6 @@ void TL_Pst_GetAndWritePost (long PstCod) void TL_Pst_PutFormToWriteNewPost (struct TL_Timeline *Timeline) { extern const char *Txt_New_TIMELINE_post; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; /***** Begin list *****/ HTM_UL_Begin ("class=\"TL_LIST\""); @@ -136,10 +134,7 @@ void TL_Pst_PutFormToWriteNewPost (struct TL_Timeline *Timeline) HTM_DIV_Begin ("class=\"TL_LEFT_PHOTO\""); /* Author's photo */ - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&Gbl.Usrs.Me.UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&Gbl.Usrs.Me.UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO45x60",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (&Gbl.Usrs.Me.UsrDat,"PHOTO45x60",Pho_ZOOM,false); /* End container */ HTM_DIV_End (); diff --git a/swad_timeline_user.c b/swad_timeline_user.c index fa4b7aba..68dbe2ab 100644 --- a/swad_timeline_user.c +++ b/swad_timeline_user.c @@ -125,8 +125,6 @@ void TL_Usr_ShowSharersOrFavers (MYSQL_RES **mysql_res, unsigned NumUsr; unsigned NumUsrsShown = 0; struct UsrData UsrDat; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; if (NumUsrs) { @@ -155,10 +153,7 @@ void TL_Usr_ShowSharersOrFavers (MYSQL_RES **mysql_res, HTM_DIV_Begin ("class=\"TL_SHARER\""); /* User's photo */ - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO12x16",Pho_ZOOM,true); // Use unique id + Pho_ShowUsrPhotoIfAllowed (&UsrDat,"PHOTO12x16",Pho_ZOOM,true); // Use unique id /* End container */ HTM_DIV_End (); diff --git a/swad_user.c b/swad_user.c index e34134f6..8b7f234e 100644 --- a/swad_user.c +++ b/swad_user.c @@ -2736,8 +2736,6 @@ void Usr_WriteLoggedUsrHead (void) extern const char *The_ClassUsr[The_NUM_THEMES]; extern const char *Txt_Role; extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; unsigned NumAvailableRoles = Rol_GetNumAvailableRoles (); HTM_DIV_Begin ("class=\"HEAD_USR %s\"",The_ClassUsr[Gbl.Prefs.Theme]); @@ -2762,10 +2760,7 @@ void Usr_WriteLoggedUsrHead (void) HTM_NBSP (); /***** Show my photo *****/ - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&Gbl.Usrs.Me.UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&Gbl.Usrs.Me.UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO18x24",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (&Gbl.Usrs.Me.UsrDat,"PHOTO18x24",Pho_ZOOM,false); /***** User's name *****/ if (Gbl.Usrs.Me.UsrDat.FrstName[0]) @@ -3558,8 +3553,6 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat, extern const char *Txt_Enrolment_confirmed; extern const char *Txt_Enrolment_not_confirmed; char BgColor[Usr_MAX_BYTES_BG_COLOR + 1]; - char PhotoURL[PATH_MAX + 1]; - bool ShowPhoto; bool UsrIsTheMsgSender = PutCheckBoxToSelectUsr && (UsrDat->UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod); struct Ins_Instit Ins; @@ -3567,73 +3560,71 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat, /***** Start row *****/ HTM_TR_Begin (NULL); - /***** Checkbox to select user *****/ - // Two colors are used alternatively to better distinguish the rows - if (UsrIsTheMsgSender) - Str_Copy (BgColor,"LIGHT_GREEN",sizeof (BgColor) - 1); - else - snprintf (BgColor,sizeof (BgColor),"COLOR%u",Gbl.RowEvenOdd); + /***** Checkbox to select user *****/ + // Two colors are used alternatively to better distinguish the rows + if (UsrIsTheMsgSender) + Str_Copy (BgColor,"LIGHT_GREEN",sizeof (BgColor) - 1); + else + snprintf (BgColor,sizeof (BgColor),"COLOR%u",Gbl.RowEvenOdd); - if (PutCheckBoxToSelectUsr) - { - HTM_TD_Begin ("class=\"CM %s\"",BgColor); - Usr_PutCheckboxToSelectUser (Role,UsrDat->EnUsrCod,UsrIsTheMsgSender, - SelectedUsrs); + if (PutCheckBoxToSelectUsr) + { + HTM_TD_Begin ("class=\"CM %s\"",BgColor); + Usr_PutCheckboxToSelectUser (Role,UsrDat->EnUsrCod,UsrIsTheMsgSender, + SelectedUsrs); + HTM_TD_End (); + } + + /***** User has accepted enrolment? *****/ + if (UsrIsTheMsgSender) + HTM_TD_Begin ("class=\"BM_SEL %s\" title=\"%s\"", + UsrDat->Accepted ? "USR_LIST_NUM_N" : + "USR_LIST_NUM", + UsrDat->Accepted ? Txt_Enrolment_confirmed : + Txt_Enrolment_not_confirmed); + else + HTM_TD_Begin ("class=\"BM%u %s\" title=\"%s\"", + Gbl.RowEvenOdd, + UsrDat->Accepted ? "USR_LIST_NUM_N" : + "USR_LIST_NUM", + UsrDat->Accepted ? Txt_Enrolment_confirmed : + Txt_Enrolment_not_confirmed); + HTM_Txt (UsrDat->Accepted ? "✓" : + "✗"); HTM_TD_End (); - } - /***** User has accepted enrolment? *****/ - if (UsrIsTheMsgSender) - HTM_TD_Begin ("class=\"BM_SEL %s\" title=\"%s\"", + /***** Write number of user in the list *****/ + HTM_TD_Begin ("class=\"%s RM %s\"", UsrDat->Accepted ? "USR_LIST_NUM_N" : "USR_LIST_NUM", - UsrDat->Accepted ? Txt_Enrolment_confirmed : - Txt_Enrolment_not_confirmed); - else - HTM_TD_Begin ("class=\"BM%u %s\" title=\"%s\"", - Gbl.RowEvenOdd, - UsrDat->Accepted ? "USR_LIST_NUM_N" : - "USR_LIST_NUM", - UsrDat->Accepted ? Txt_Enrolment_confirmed : - Txt_Enrolment_not_confirmed); - HTM_Txt (UsrDat->Accepted ? "✓" : - "✗"); - HTM_TD_End (); - - /***** Write number of user in the list *****/ - HTM_TD_Begin ("class=\"%s RM %s\"", - UsrDat->Accepted ? "USR_LIST_NUM_N" : - "USR_LIST_NUM", - BgColor); - HTM_Unsigned (NumUsr); - HTM_TD_End (); - - if (Gbl.Usrs.Listing.WithPhotos) - { - /***** Show user's photo *****/ - HTM_TD_Begin ("class=\"CM %s\"",BgColor); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); + BgColor); + HTM_Unsigned (NumUsr); HTM_TD_End (); - } - /****** Write user's IDs ******/ - HTM_TD_Begin ("class=\"%s LM %s\"", - UsrDat->Accepted ? "DAT_SMALL_N" : - "DAT_SMALL", - BgColor); - ID_WriteUsrIDs (UsrDat,NULL); - HTM_TD_End (); + if (Gbl.Usrs.Listing.WithPhotos) + { + /***** Show user's photo *****/ + HTM_TD_Begin ("class=\"CM %s\"",BgColor); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO21x28",Pho_ZOOM,false); + HTM_TD_End (); + } - /***** Write rest of main user's data *****/ - Ins.InsCod = UsrDat->InsCod; - Ins_GetDataOfInstitutionByCod (&Ins); - Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor); - HTM_TD_Begin ("class=\"LM %s\"",BgColor); - Ins_DrawInstitutionLogoWithLink (&Ins,25); - HTM_TD_End (); + /****** Write user's IDs ******/ + HTM_TD_Begin ("class=\"%s LM %s\"", + UsrDat->Accepted ? "DAT_SMALL_N" : + "DAT_SMALL", + BgColor); + ID_WriteUsrIDs (UsrDat,NULL); + HTM_TD_End (); + + /***** Write rest of main user's data *****/ + Ins.InsCod = UsrDat->InsCod; + Ins_GetDataOfInstitutionByCod (&Ins); + Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor); + + HTM_TD_Begin ("class=\"LM %s\"",BgColor); + Ins_DrawInstitutionLogoWithLink (&Ins,25); + HTM_TD_End (); /***** End row *****/ HTM_TR_End (); @@ -3645,8 +3636,6 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat, static void Usr_WriteRowGstAllData (struct UsrData *UsrDat) { - char PhotoURL[PATH_MAX + 1]; - bool ShowPhoto; struct Ins_Instit Ins; struct Ctr_Centre Ctr; struct Dpt_Department Dpt; @@ -3654,71 +3643,68 @@ static void Usr_WriteRowGstAllData (struct UsrData *UsrDat) /***** Start row *****/ HTM_TR_Begin (NULL); - if (Gbl.Usrs.Listing.WithPhotos) - { - /***** Show guest's photo *****/ - HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_NO_ZOOM,false); + if (Gbl.Usrs.Listing.WithPhotos) + { + /***** Show guest's photo *****/ + HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO21x28",Pho_NO_ZOOM,false); + HTM_TD_End (); + } + + /****** Write user's ID ******/ + HTM_TD_Begin ("class=\"DAT_SMALL LM COLOR%u\"",Gbl.RowEvenOdd); + ID_WriteUsrIDs (UsrDat,NULL); + HTM_NBSP (); HTM_TD_End (); - } - /****** Write user's ID ******/ - HTM_TD_Begin ("class=\"DAT_SMALL LM COLOR%u\"",Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat,NULL); - HTM_NBSP (); - HTM_TD_End (); + /***** Write rest of guest's main data *****/ + Ins.InsCod = UsrDat->InsCod; + Ins_GetDataOfInstitutionByCod (&Ins); + Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd]); + Usr_WriteEmail (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd]); + Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], + Ins.FullName, + NULL,true,false); - /***** Write rest of guest's main data *****/ - Ins.InsCod = UsrDat->InsCod; - Ins_GetDataOfInstitutionByCod (&Ins); - Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd]); - Usr_WriteEmail (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd]); - Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], - Ins.FullName, - NULL,true,false); - - /***** Write the rest of the data of the guest *****/ - if (UsrDat->Tch.CtrCod > 0) - { - Ctr.CtrCod = UsrDat->Tch.CtrCod; - Ctr_GetDataOfCentreByCod (&Ctr); - } - Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], - UsrDat->Tch.CtrCod > 0 ? Ctr.FullName : - " ", - NULL,true,false); - if (UsrDat->Tch.DptCod > 0) - { - Dpt.DptCod = UsrDat->Tch.DptCod; - Dpt_GetDataOfDepartmentByCod (&Dpt); - } - Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], - UsrDat->Tch.DptCod > 0 ? Dpt.FullName : - " ", - NULL,true,false); - Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], - UsrDat->Tch.Office[0] ? UsrDat->Tch.Office : - " ", - NULL,true,false); - Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], - UsrDat->Tch.OfficePhone[0] ? UsrDat->Tch.OfficePhone : - " ", - NULL,true,false); - Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], - UsrDat->Phone[0][0] ? UsrDat->Phone[0] : - " ", - NULL,true,false); - Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], - UsrDat->Phone[1][0] ? UsrDat->Phone[1] : - " ", - NULL,true,false); - Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], - UsrDat->StrBirthday[0] ? UsrDat->StrBirthday : - " ", - NULL,true,false); + /***** Write the rest of the data of the guest *****/ + if (UsrDat->Tch.CtrCod > 0) + { + Ctr.CtrCod = UsrDat->Tch.CtrCod; + Ctr_GetDataOfCentreByCod (&Ctr); + } + Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], + UsrDat->Tch.CtrCod > 0 ? Ctr.FullName : + " ", + NULL,true,false); + if (UsrDat->Tch.DptCod > 0) + { + Dpt.DptCod = UsrDat->Tch.DptCod; + Dpt_GetDataOfDepartmentByCod (&Dpt); + } + Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], + UsrDat->Tch.DptCod > 0 ? Dpt.FullName : + " ", + NULL,true,false); + Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], + UsrDat->Tch.Office[0] ? UsrDat->Tch.Office : + " ", + NULL,true,false); + Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], + UsrDat->Tch.OfficePhone[0] ? UsrDat->Tch.OfficePhone : + " ", + NULL,true,false); + Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], + UsrDat->Phone[0][0] ? UsrDat->Phone[0] : + " ", + NULL,true,false); + Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], + UsrDat->Phone[1][0] ? UsrDat->Phone[1] : + " ", + NULL,true,false); + Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], + UsrDat->StrBirthday[0] ? UsrDat->StrBirthday : + " ", + NULL,true,false); /***** End row *****/ HTM_TR_End (); @@ -3730,8 +3716,6 @@ static void Usr_WriteRowGstAllData (struct UsrData *UsrDat) static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) { - char PhotoURL[PATH_MAX + 1]; - bool ShowPhoto; unsigned NumGrpTyp,NumField; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -3747,10 +3731,7 @@ static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) { /***** Show student's photo *****/ HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_NO_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO21x28",Pho_NO_ZOOM,false); HTM_TD_End (); } @@ -3759,8 +3740,8 @@ static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat,NULL); - HTM_NBSP (); + ID_WriteUsrIDs (UsrDat,NULL); + HTM_NBSP (); HTM_TD_End (); /***** Write rest of main student's data *****/ @@ -3834,8 +3815,6 @@ static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) static void Usr_WriteRowTchAllData (struct UsrData *UsrDat) { - char PhotoURL[PATH_MAX + 1]; - bool ShowPhoto; struct Ins_Instit Ins; struct Ctr_Centre Ctr; struct Dpt_Department Dpt; @@ -3850,10 +3829,7 @@ static void Usr_WriteRowTchAllData (struct UsrData *UsrDat) { /***** Show teacher's photo *****/ HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_NO_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO21x28",Pho_NO_ZOOM,false); HTM_TD_End (); } @@ -3912,8 +3888,6 @@ static void Usr_WriteRowTchAllData (struct UsrData *UsrDat) static void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat) { - char PhotoURL[PATH_MAX + 1]; - bool ShowPhoto; struct Ins_Instit Ins; /***** Start row *****/ @@ -3928,10 +3902,7 @@ static void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat) { /***** Show administrator's photo *****/ HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO21x28",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO21x28",Pho_ZOOM,false); HTM_TD_End (); } @@ -8979,10 +8950,8 @@ static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType, { unsigned NumUsr; bool TRIsOpen = false; - bool ShowPhoto; bool UsrIsTheMsgSender; const char *ClassPhoto = "PHOTO21x28"; // Default photo size - char PhotoURL[PATH_MAX + 1]; struct UsrData UsrDat; if (Gbl.Usrs.LstUsrs[Role].NumUsrs) @@ -9043,10 +9012,7 @@ static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType, SelectedUsrs); /***** Show photo *****/ - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : - NULL, - ClassPhoto,Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (&UsrDat,ClassPhoto,Pho_ZOOM,false); /***** Photo foot *****/ HTM_DIV_Begin ("class=\"CLASSPHOTO_CAPTION\""); @@ -9906,8 +9872,6 @@ void Usr_WriteAuthor1Line (long UsrCod,bool Hidden) void Usr_ShowTableCellWithUsrData (struct UsrData *UsrDat,unsigned NumRows) { - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; Act_Action_t NextAction; /***** Show user's photo *****/ @@ -9916,10 +9880,7 @@ void Usr_ShowTableCellWithUsrData (struct UsrData *UsrDat,unsigned NumRows) NumRows + 1,Gbl.RowEvenOdd); else HTM_TD_Begin ("class=\"LT LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL); - Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO45x60",Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (UsrDat,"PHOTO45x60",Pho_ZOOM,false); HTM_TD_End (); /***** User's IDs and name *****/