Version18.116.5

This commit is contained in:
Antonio Cañas Vargas 2019-04-20 21:11:44 +02:00
parent d7045f9f77
commit 483045a682
13 changed files with 72 additions and 202 deletions

View File

@ -1554,7 +1554,7 @@ function DrawMonth (id,FirstDayOfWeek,YearToDraw,MonthToDraw,CurrentMonth,Curren
FormIdNum++;
FormId = id + '_event_' + FormIdNum;
Gbl_HTMLContent += '<form method="post" action="' +
CGI + '#' + 'exam_' +
CGI + '#' + 'cod_' +
ExaCod +
'" id="' + FormId + '">' +
FormEventParams +

View File

@ -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 *********************/
/*****************************************************************************/

View File

@ -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,"<tr>"
@ -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,"</td>");
/* Number of students in this event */
@ -489,6 +496,9 @@ static void Att_ShowOneAttEvent (struct AttendanceEvent *Att,bool ShowOnlyThisAt
fprintf (Gbl.F.Out,"</td>"
"</tr>");
/***** 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 ();
}

View File

@ -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)

View File

@ -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 *************/
/*****************************************************************************/

View File

@ -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);

View File

@ -25,10 +25,12 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // 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;
}
}

View File

@ -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

View File

@ -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);
}
/*****************************************************************************/

View File

@ -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);

View File

@ -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,"<tr>");
@ -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 ************/
/*****************************************************************************/

View File

@ -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 <strong>%s</strong> ara est&agrave; ocult.";
#elif L==2 // de
"Der Ereignis <strong>%s</strong> ist jetzt ausgeblendet.";
#elif L==3 // en
"Event <strong>%s</strong> is now hidden.";
#elif L==4 // es
"El evento <strong>%s</strong> ahora est&aacute; oculto.";
#elif L==5 // fr
"L'&eacute;v&eacute;nement <strong>%s</strong> est maintenant cach&eacute;.";
#elif L==6 // gn
"El evento <strong>%s</strong> ahora est&aacute; oculto."; // Okoteve traducción
#elif L==7 // it
"L'evento <strong>%s</strong> &egrave; ora nascosto.";
#elif L==8 // pl
"Wydarzenie <strong>%s</strong> jest ukryte.";
#elif L==9 // pt
"O evento <strong>%s</strong> &eacute; 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 <strong>%s</strong> ara &eacute;s privat.";
@ -10808,27 +10787,6 @@ const char *Txt_Event_X_is_now_private = // Warning: it is very important to inc
"O evento <strong>%s</strong> &eacute; 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 <strong>%s</strong> ara est&agrave; visible.";
#elif L==2 // de
"Der Ereignis <strong>%s</strong> ist jetzt sichtbar.";
#elif L==3 // en
"Event <strong>%s</strong> is now visible.";
#elif L==4 // es
"El evento <strong>%s</strong> ahora est&aacute; visible.";
#elif L==5 // fr
"L'&eacute;v&eacute;nement <strong>%s</strong> est maintenant visible.";
#elif L==6 // gn
"El evento <strong>%s</strong> ahora est&aacute; visible."; // Okoteve traducción
#elif L==7 // it
"L'evento <strong>%s</strong> &egrave; ora visibile.";
#elif L==8 // pl
"Wydarzenie <strong>%s</strong> jest teraz widoczny.";
#elif L==9 // pt
"O evento <strong>%s</strong> &eacute; agora vis&iacute;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 <strong>%s</strong> ara &eacute;s visible"

View File

@ -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