diff --git a/js/swad18.114.js b/js/swad18.116.5.js similarity index 99% rename from js/swad18.114.js rename to js/swad18.116.5.js index 5642637c..00c5b179 100644 --- a/js/swad18.114.js +++ b/js/swad18.116.5.js @@ -1554,7 +1554,7 @@ function DrawMonth (id,FirstDayOfWeek,YearToDraw,MonthToDraw,CurrentMonth,Curren FormIdNum++; FormId = id + '_event_' + FormIdNum; Gbl_HTMLContent += '
' + FormEventParams + diff --git a/swad_agenda.c b/swad_agenda.c index c0ca419f..7e413c81 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -108,8 +108,6 @@ static void Agd_PutIconsOtherPublicAgenda (void); static void Agd_PutButtonToCreateNewEvent (void); static void Agd_ShowOneEvent (Agd_AgendaType_t AgendaType,long AgdCod); static void Agd_GetParamEventOrder (void); -static void Agd_SetAnchorStr (long AgdCod,char **Anchor); -static void Agd_FreeAnchorStr (char *Anchor); static void Agd_PutFormsToRemEditOneEvent (struct AgendaEvent *AgdEvent, const char *Anchor); @@ -738,7 +736,7 @@ static void Agd_ShowOneEvent (Agd_AgendaType_t AgendaType,long AgdCod) Agd_GetDataOfEventByCod (&AgdEvent); /***** Set anchor string *****/ - Agd_SetAnchorStr (AgdEvent.AgdCod,&Anchor); + Frm_SetAnchorStr (AgdEvent.AgdCod,&Anchor); /***** Write first row of data of this event *****/ /* Start date/time */ @@ -825,36 +823,11 @@ static void Agd_ShowOneEvent (Agd_AgendaType_t AgendaType,long AgdCod) Txt); /***** Free anchor string *****/ - Agd_FreeAnchorStr (Anchor); + Frm_FreeAnchorStr (Anchor); Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; } -/*****************************************************************************/ -/****************** Build/free anchor string for an event ********************/ -/*****************************************************************************/ - -static void Agd_SetAnchorStr (long AgdCod,char **Anchor) - { - if (AgdCod > 0) - { - if (asprintf (Anchor,"agd_%ld", - AgdCod) < 0) - Lay_NotEnoughMemoryExit (); - } - else - *Anchor = NULL; - } - -static void Agd_FreeAnchorStr (char *Anchor) - { - if (Anchor) - { - free ((void *) Anchor); - Anchor = NULL; - } - } - /*****************************************************************************/ /******************* Put a link (form) to edit one event *********************/ /*****************************************************************************/ diff --git a/swad_attendance.c b/swad_attendance.c index 784fcc6b..f04c2d78 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -91,7 +91,8 @@ static void Att_PutFormToListMyAttendance (void); static void Att_PutFormToListStdsAttendance (void); static void Att_PutFormToListStdsParams (void); -static void Att_PutFormsToRemEditOneAttEvent (long AttCod,bool Hidden); +static void Att_PutFormsToRemEditOneAttEvent (const struct AttendanceEvent *Att, + const char *Anchor); static void Att_PutParams (void); static void Att_GetListAttEvents (Att_OrderNewestOldest_t OrderNewestOldest); static void Att_GetDataOfAttEventByCodAndCheckCrs (struct AttendanceEvent *Att); @@ -372,6 +373,7 @@ static void Att_ShowOneAttEvent (struct AttendanceEvent *Att,bool ShowOnlyThisAt { extern const char *Txt_Today; extern const char *Txt_View_event; + char *Anchor = NULL; static unsigned UniqueId = 0; char Description[Cns_MAX_BYTES_TEXT + 1]; @@ -379,6 +381,9 @@ static void Att_ShowOneAttEvent (struct AttendanceEvent *Att,bool ShowOnlyThisAt Att_GetDataOfAttEventByCodAndCheckCrs (Att); Att_GetNumStdsTotalWhoAreInAttEvent (Att); + /***** Set anchor string *****/ + Frm_SetAnchorStr (Att->AttCod,&Anchor); + /***** Write first row of data of this attendance event *****/ /* Forms to remove/edit this attendance event */ fprintf (Gbl.F.Out,"" @@ -390,7 +395,7 @@ static void Att_ShowOneAttEvent (struct AttendanceEvent *Att,bool ShowOnlyThisAt { case Rol_TCH: case Rol_SYS_ADM: - Att_PutFormsToRemEditOneAttEvent (Att->AttCod,Att->Hidden); + Att_PutFormsToRemEditOneAttEvent (Att,Anchor); break; default: break; @@ -439,9 +444,11 @@ static void Att_ShowOneAttEvent (struct AttendanceEvent *Att,bool ShowOnlyThisAt if (!ShowOnlyThisAttEventComplete) fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"\">"); + Lay_StartArticle (Anchor); Att_PutLinkAttEvent (Att,Txt_View_event,Att->Title, Att->Hidden ? "ASG_TITLE_LIGHT" : "ASG_TITLE"); + Lay_EndArticle (); fprintf (Gbl.F.Out,""); /* Number of students in this event */ @@ -489,6 +496,9 @@ static void Att_ShowOneAttEvent (struct AttendanceEvent *Att,bool ShowOnlyThisAt fprintf (Gbl.F.Out,"" ""); + /***** Free anchor string *****/ + Frm_FreeAnchorStr (Anchor); + Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; } @@ -561,18 +571,19 @@ static void Att_PutFormToListStdsParams (void) /************** Put a link (form) to edit one attendance event ***************/ /*****************************************************************************/ -static void Att_PutFormsToRemEditOneAttEvent (long AttCod,bool Hidden) +static void Att_PutFormsToRemEditOneAttEvent (const struct AttendanceEvent *Att, + const char *Anchor) { - Gbl.AttEvents.AttCod = AttCod; // Used as parameters in contextual links + Gbl.AttEvents.AttCod = Att->AttCod; // Used as parameters in contextual links /***** Put form to remove attendance event *****/ Ico_PutContextualIconToRemove (ActReqRemAtt,Att_PutParams); /***** Put form to hide/show attendance event *****/ - if (Hidden) - Ico_PutContextualIconToUnhide (ActShoAtt,NULL,Att_PutParams); + if (Att->Hidden) + Ico_PutContextualIconToUnhide (ActShoAtt,Anchor,Att_PutParams); else - Ico_PutContextualIconToHide (ActHidAtt,NULL,Att_PutParams); + Ico_PutContextualIconToHide (ActHidAtt,Anchor,Att_PutParams); /***** Put form to edit attendance event *****/ Ico_PutContextualIconToEdit (ActEdiOneAtt,Att_PutParams); @@ -957,7 +968,6 @@ void Att_RemoveAttEventFromDB (long AttCod) void Att_HideAttEvent (void) { - extern const char *Txt_Event_X_is_now_hidden; struct AttendanceEvent Att; /***** Get attendance event code *****/ @@ -973,10 +983,6 @@ void Att_HideAttEvent (void) " WHERE AttCod=%ld AND CrsCod=%ld", Att.AttCod,Gbl.Hierarchy.Crs.CrsCod); - /***** Write message to show the change made *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_Event_X_is_now_hidden, - Att.Title); - /***** Show attendance events again *****/ Att_SeeAttEvents (); } @@ -987,7 +993,6 @@ void Att_HideAttEvent (void) void Att_ShowAttEvent (void) { - extern const char *Txt_Event_X_is_now_visible; struct AttendanceEvent Att; /***** Get attendance event code *****/ @@ -1003,10 +1008,6 @@ void Att_ShowAttEvent (void) " WHERE AttCod=%ld AND CrsCod=%ld", Att.AttCod,Gbl.Hierarchy.Crs.CrsCod); - /***** Write message to show the change made *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_Event_X_is_now_visible, - Att.Title); - /***** Show attendance events again *****/ Att_SeeAttEvents (); } diff --git a/swad_changelog.h b/swad_changelog.h index 60833014..2b9c88f5 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -448,10 +448,12 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.116.4 (2019-04-20)" +#define Log_PLATFORM_VERSION "SWAD 18.116.5 (2019-04-20)" #define CSS_FILE "swad18.112.1.css" -#define JS_FILE "swad18.114.js" +#define JS_FILE "swad18.116.5.js" /* + Version 18.116.5: Apr 20, 2019 Changed the behaviour of hiding/showing an attendance event. + Code refactoring related to anchors. (243014 lines) Version 18.116.4: Apr 20, 2019 Changed the behaviour of hiding/showing an agenda event. (243130 lines) Version 18.116.3: Apr 20, 2019 Changed the behaviour of hiding/showing a project. (243105 lines) Version 18.116.2: Apr 20, 2019 Code refactoring in announcements and notices. (243124 lines) diff --git a/swad_exam.c b/swad_exam.c index 679792cb..179ea477 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -296,13 +296,12 @@ void Exa_ReceiveExamAnnouncement1 (void) /***** Free memory of the exam announcement *****/ Exa_FreeMemExamAnnouncement (); - /***** Create alert to show the change made *****/ - Exa_SetAnchorStr (ExaCod,&Anchor); + Frm_SetAnchorStr (ExaCod,&Anchor); Ale_CreateAlert (Ale_SUCCESS,Anchor, NewExamAnnouncement ? Txt_Created_new_announcement_of_exam : Txt_The_announcement_of_exam_has_been_successfully_updated); - Exa_FreeAnchorStr (Anchor); + Frm_FreeAnchorStr (Anchor); /***** Set exam to be highlighted *****/ Gbl.ExamAnns.HighlightExaCod = ExaCod; @@ -467,10 +466,10 @@ void Exa_HideExamAnnouncement (void) Gbl.ExamAnns.HighlightExaCod = ExaCod; /***** Create alert to show the change made *****/ - Exa_SetAnchorStr (ExaCod,&Anchor); + Frm_SetAnchorStr (ExaCod,&Anchor); Ale_CreateAlert (Ale_SUCCESS,Anchor, Txt_The_announcement_of_exam_is_now_hidden); - Exa_FreeAnchorStr (Anchor); + Frm_FreeAnchorStr (Anchor); } /*****************************************************************************/ @@ -500,10 +499,10 @@ void Exa_UnhideExamAnnouncement (void) Gbl.ExamAnns.HighlightExaCod = ExaCod; /***** Create alert to show the change made *****/ - Exa_SetAnchorStr (ExaCod,&Anchor); + Frm_SetAnchorStr (ExaCod,&Anchor); Ale_CreateAlert (Ale_SUCCESS,Anchor, Txt_The_announcement_of_exam_is_now_visible); - Exa_FreeAnchorStr (Anchor); + Frm_FreeAnchorStr (Anchor); } /*****************************************************************************/ @@ -1019,7 +1018,7 @@ static void Exa_ShowExamAnnouncement (long ExaCod, } /***** Build anchor string *****/ - Exa_SetAnchorStr (ExaCod,&Anchor); + Frm_SetAnchorStr (ExaCod,&Anchor); /***** Start article *****/ if (TypeViewExamAnnouncement == Exa_NORMAL_VIEW) @@ -1506,7 +1505,7 @@ static void Exa_ShowExamAnnouncement (long ExaCod, Lay_EndArticle (); /***** Free anchor string *****/ - Exa_FreeAnchorStr (Anchor); + Frm_FreeAnchorStr (Anchor); } /*****************************************************************************/ @@ -1566,40 +1565,6 @@ static long Exa_GetParamExaCod (void) return Par_GetParToLong ("ExaCod"); } -/*****************************************************************************/ -/*********** Build/free anchor string for an announcement of exam ************/ -/*****************************************************************************/ - -void Exa_SetAnchorStr (long ExaCod,char **Anchor) - { - if (ExaCod > 0) - { - if (ExaCod == Gbl.ExamAnns.NewExaCod) // New announcement of exam - { - if (asprintf (Anchor,"exam_new") < 0) - Lay_NotEnoughMemoryExit (); - } - else // Existing announcement of exam, not a new one - { - // Existing announcement of exam, not new - if (asprintf (Anchor,"exam_%ld", - ExaCod) < 0) - Lay_NotEnoughMemoryExit (); - } - } - else // ? - *Anchor = NULL; - } - -void Exa_FreeAnchorStr (char *Anchor) - { - if (Anchor) - { - free ((void *) Anchor); - Anchor = NULL; - } - } - /*****************************************************************************/ /************ Get summary and content about an exam announcement *************/ /*****************************************************************************/ diff --git a/swad_exam.h b/swad_exam.h index 779bc0f8..5907ea1e 100644 --- a/swad_exam.h +++ b/swad_exam.h @@ -108,9 +108,6 @@ void Exa_GetDateToHighlight (void); void Exa_CreateListDatesOfExamAnnouncements (void); void Exa_PutHiddenParamExaCod (long ExaCod); -void Exa_SetAnchorStr (long ExaCod,char **Anchor); -void Exa_FreeAnchorStr (char *Anchor); - void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long ExaCod,bool GetContent); diff --git a/swad_form.c b/swad_form.c index 662d4480..d0672ccd 100644 --- a/swad_form.c +++ b/swad_form.c @@ -25,10 +25,12 @@ /*********************************** Headers *********************************/ /*****************************************************************************/ +#define _GNU_SOURCE // For asprintf +#include // For asprintf + #include "swad_form.h" #include "swad_global.h" - /*****************************************************************************/ /************** External global variables from others modules ****************/ /*****************************************************************************/ @@ -308,3 +310,28 @@ void Frm_SetUniqueId (char UniqueId[Frm_MAX_BYTES_ID + 1]) Gbl.UniqueNameEncrypted, ++CountForThisExecution); } + +/*****************************************************************************/ +/****************** Build/free anchor string given a code ********************/ +/*****************************************************************************/ + +void Frm_SetAnchorStr (long Cod,char **Anchor) + { + if (Cod > 0) + { + if (asprintf (Anchor,"cod_%ld", + Cod) < 0) + Lay_NotEnoughMemoryExit (); + } + else + *Anchor = NULL; + } + +void Frm_FreeAnchorStr (char *Anchor) + { + if (Anchor) + { + free ((void *) Anchor); + Anchor = NULL; + } + } diff --git a/swad_form.h b/swad_form.h index 47731908..0e480254 100644 --- a/swad_form.h +++ b/swad_form.h @@ -72,5 +72,7 @@ void Frm_LinkFormSubmitAnimated (const char *Title,const char *LinkClass, void Frm_SetUniqueId (char UniqueId[Frm_MAX_BYTES_ID + 1]); -#endif +void Frm_SetAnchorStr (long Cod,char **Anchor); +void Frm_FreeAnchorStr (char *Anchor); +#endif diff --git a/swad_notice.c b/swad_notice.c index 354b84e4..82374dbb 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -641,7 +641,7 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, char *Anchor = NULL; /***** Build anchor string *****/ - Not_SetAnchorStr (NotCod,&Anchor); + Frm_SetAnchorStr (NotCod,&Anchor); /***** Start article for this notice *****/ if (TypeNoticesListing == Not_LIST_FULL_NOTICES) @@ -744,32 +744,7 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, } /***** Free anchor string *****/ - Not_FreeAnchorStr (Anchor); - } - -/*****************************************************************************/ -/****************** Build/free anchor string for a notice ********************/ -/*****************************************************************************/ - -void Not_SetAnchorStr (long NotCod,char **Anchor) - { - if (NotCod > 0) // Existing announcement of exam, not a new one - { - if (asprintf (Anchor,"not_%ld", - NotCod) < 0) - Lay_NotEnoughMemoryExit (); - } - else // ? - *Anchor = NULL; - } - -void Not_FreeAnchorStr (char *Anchor) - { - if (Anchor) - { - free ((void *) Anchor); - Anchor = NULL; - } + Frm_FreeAnchorStr (Anchor); } /*****************************************************************************/ diff --git a/swad_notice.h b/swad_notice.h index 79b18922..b93fea9e 100644 --- a/swad_notice.h +++ b/swad_notice.h @@ -69,9 +69,6 @@ void Not_RemoveNotice (void); void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod); -void Not_SetAnchorStr (long NotCod,char **Anchor); -void Not_FreeAnchorStr (char *Anchor); - void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long NotCod,bool GetContent); diff --git a/swad_project.c b/swad_project.c index f94d3295..286cdabf 100644 --- a/swad_project.c +++ b/swad_project.c @@ -144,8 +144,6 @@ static void Prj_PutIconsToLockUnlockAllProjects (void); static void Prj_ShowOneProject (unsigned NumIndex,struct Project *Prj, Prj_ProjectView_t ProjectView); -static void Prj_SetAnchorStr (long PrjCod,char **Anchor); -static void Prj_FreeAnchorStr (char *Anchor); static void Prj_PutIconToToggleProject (unsigned UniqueId, const char *Icon,const char *Text); static void Prj_ShowTableAllProjectsOneRow (struct Project *Prj); @@ -980,7 +978,7 @@ static void Prj_ShowOneProject (unsigned NumIndex,struct Project *Prj, bool ICanViewProjectFiles = Prj_CheckIfICanViewProjectFiles (Prj_GetMyRolesInProject (Prj->PrjCod)); /***** Set anchor string *****/ - Prj_SetAnchorStr (Prj->PrjCod,&Anchor); + Frm_SetAnchorStr (Prj->PrjCod,&Anchor); /***** Write first row of data of this project *****/ fprintf (Gbl.F.Out,""); @@ -1247,36 +1245,11 @@ static void Prj_ShowOneProject (unsigned NumIndex,struct Project *Prj, Prj_ShowOneProjectURL (Prj,ProjectView,"prj_url_",UniqueId); /***** Free anchor string *****/ - Prj_FreeAnchorStr (Anchor); + Frm_FreeAnchorStr (Anchor); Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; } -/*****************************************************************************/ -/****************** Build/free anchor string for a project *******************/ -/*****************************************************************************/ - -static void Prj_SetAnchorStr (long PrjCod,char **Anchor) - { - if (PrjCod > 0) - { - if (asprintf (Anchor,"prj_%ld", - PrjCod) < 0) - Lay_NotEnoughMemoryExit (); - } - else - *Anchor = NULL; - } - -static void Prj_FreeAnchorStr (char *Anchor) - { - if (Anchor) - { - free ((void *) Anchor); - Anchor = NULL; - } - } - /*****************************************************************************/ /********** Put an icon to toggle on/off some fields of a project ************/ /*****************************************************************************/ diff --git a/swad_text.c b/swad_text.c index d37c401b..bd541149 100644 --- a/swad_text.c +++ b/swad_text.c @@ -10766,27 +10766,6 @@ const char *Txt_Event = "Evento"; #endif -const char *Txt_Event_X_is_now_hidden = // Warning: it is very important to include %s in the following sentences -#if L==1 // ca - "L'esdeveniment %s ara està ocult."; -#elif L==2 // de - "Der Ereignis %s ist jetzt ausgeblendet."; -#elif L==3 // en - "Event %s is now hidden."; -#elif L==4 // es - "El evento %s ahora está oculto."; -#elif L==5 // fr - "L'événement %s est maintenant caché."; -#elif L==6 // gn - "El evento %s ahora está oculto."; // Okoteve traducción -#elif L==7 // it - "L'evento %s è ora nascosto."; -#elif L==8 // pl - "Wydarzenie %s jest ukryte."; -#elif L==9 // pt - "O evento %s é agora oculto."; -#endif - const char *Txt_Event_X_is_now_private = // Warning: it is very important to include %s in the following sentences #if L==1 // ca "L'esdevenimen %s ara és privat."; @@ -10808,27 +10787,6 @@ const char *Txt_Event_X_is_now_private = // Warning: it is very important to inc "O evento %s é agora privado."; #endif -const char *Txt_Event_X_is_now_visible = // Warning: it is very important to include %s in the following sentences -#if L==1 // ca - "L'esdevenimen %s ara està visible."; -#elif L==2 // de - "Der Ereignis %s ist jetzt sichtbar."; -#elif L==3 // en - "Event %s is now visible."; -#elif L==4 // es - "El evento %s ahora está visible."; -#elif L==5 // fr - "L'événement %s est maintenant visible."; -#elif L==6 // gn - "El evento %s ahora está visible."; // Okoteve traducción -#elif L==7 // it - "L'evento %s è ora visibile."; -#elif L==8 // pl - "Wydarzenie %s jest teraz widoczny."; -#elif L==9 // pt - "O evento %s é agora visível."; -#endif - const char *Txt_Event_X_is_now_visible_to_users_of_your_courses = // Warning: it is very important to include %s in the following sentences #if L==1 // ca "L'esdevenimen %s ara és visible" diff --git a/swad_timeline.c b/swad_timeline.c index 8813cb7d..4810e837 100644 --- a/swad_timeline.c +++ b/swad_timeline.c @@ -1983,10 +1983,10 @@ static void TL_PutFormGoToAction (const struct TL_Note *SocNot) Crs_PutParamCrsCod (SocNot->HieCod); // Go to another course break; case TL_NOTE_EXAM_ANNOUNCEMENT: - Exa_SetAnchorStr (SocNot->Cod,&Anchor); + Frm_SetAnchorStr (SocNot->Cod,&Anchor); Frm_StartFormUniqueAnchor (TL_DefaultActions[SocNot->NoteType], Anchor); // Locate on this specific exam - Exa_FreeAnchorStr (Anchor); + Frm_FreeAnchorStr (Anchor); Exa_PutHiddenParamExaCod (SocNot->Cod); if (SocNot->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course Crs_PutParamCrsCod (SocNot->HieCod); // Go to another course @@ -2006,10 +2006,10 @@ static void TL_PutFormGoToAction (const struct TL_Note *SocNot) Crs_PutParamCrsCod (SocNot->HieCod); // Go to another course break; case TL_NOTE_NOTICE: - Not_SetAnchorStr (SocNot->Cod,&Anchor); + Frm_SetAnchorStr (SocNot->Cod,&Anchor); Frm_StartFormUniqueAnchor (TL_DefaultActions[SocNot->NoteType], Anchor); - Not_FreeAnchorStr (Anchor); + Frm_FreeAnchorStr (Anchor); Not_PutHiddenParamNotCod (SocNot->Cod); if (SocNot->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course Crs_PutParamCrsCod (SocNot->HieCod); // Go to another course