Version 20.87.1: Jun 01, 2021 Database function moved from swad_calendar to swad_setting.

This commit is contained in:
acanas 2021-06-01 23:37:23 +02:00
parent 535385c27f
commit 9ea5a0eeec
5 changed files with 93 additions and 78 deletions

View File

@ -87,10 +87,10 @@ void Cal_PutIconsToSelectFirstDayOfWeek (void)
Box_BoxBegin (NULL,Txt_Calendar, Box_BoxBegin (NULL,Txt_Calendar,
Cal_PutIconsFirstDayOfWeek,NULL, Cal_PutIconsFirstDayOfWeek,NULL,
Hlp_PROFILE_Settings_calendar,Box_NOT_CLOSABLE); Hlp_PROFILE_Settings_calendar,Box_NOT_CLOSABLE);
Set_BeginSettingsHead (); Set_BeginSettingsHead ();
Cal_ShowFormToSelFirstDayOfWeek (ActChg1stDay, Cal_ShowFormToSelFirstDayOfWeek (ActChg1stDay,
NULL,NULL); NULL,NULL);
Set_EndSettingsHead (); Set_EndSettingsHead ();
Box_BoxEnd (); Box_BoxEnd ();
} }
@ -117,26 +117,26 @@ void Cal_ShowFormToSelFirstDayOfWeek (Act_Action_t Action,
char Icon[32 + 1]; char Icon[32 + 1];
Set_BeginOneSettingSelector (); Set_BeginOneSettingSelector ();
for (FirstDayOfWeek = 0; // Monday for (FirstDayOfWeek = 0; // Monday
FirstDayOfWeek <= 6; // Sunday FirstDayOfWeek <= 6; // Sunday
FirstDayOfWeek++) FirstDayOfWeek++)
if (Cal_DayIsValidAsFirstDayOfWeek[FirstDayOfWeek]) if (Cal_DayIsValidAsFirstDayOfWeek[FirstDayOfWeek])
{ {
HTM_DIV_Begin ("class=\"%s\"", HTM_DIV_Begin ("class=\"%s\"",
FirstDayOfWeek == Gbl.Prefs.FirstDayOfWeek ? "PREF_ON" : FirstDayOfWeek == Gbl.Prefs.FirstDayOfWeek ? "PREF_ON" :
"PREF_OFF"); "PREF_OFF");
Frm_BeginForm (Action); Frm_BeginForm (Action);
Par_PutHiddenParamUnsigned (NULL,"FirstDayOfWeek",FirstDayOfWeek); Par_PutHiddenParamUnsigned (NULL,"FirstDayOfWeek",FirstDayOfWeek);
if (FuncParams) // Extra parameters depending on the action if (FuncParams) // Extra parameters depending on the action
FuncParams (Args); FuncParams (Args);
snprintf (Icon,sizeof (Icon),"first-day-of-week-%u.png",FirstDayOfWeek); snprintf (Icon,sizeof (Icon),"first-day-of-week-%u.png",FirstDayOfWeek);
Ico_PutSettingIconLink (Icon, Ico_PutSettingIconLink (Icon,
Str_BuildStringStr (Txt_First_day_of_the_week_X, Str_BuildStringStr (Txt_First_day_of_the_week_X,
Txt_DAYS_SMALL[FirstDayOfWeek])); Txt_DAYS_SMALL[FirstDayOfWeek]));
Str_FreeString (); Str_FreeString ();
Frm_EndForm (); Frm_EndForm ();
HTM_DIV_End (); HTM_DIV_End ();
} }
Set_EndOneSettingSelector (); Set_EndOneSettingSelector ();
} }
@ -151,12 +151,7 @@ void Cal_ChangeFirstDayOfWeek (void)
/***** Store icon first day of week database *****/ /***** Store icon first day of week database *****/
if (Gbl.Usrs.Me.Logged) if (Gbl.Usrs.Me.Logged)
DB_QueryUPDATE ("can not update your setting about first day of week", Set_DB_ChangeFirstDayOfWeek (Gbl.Prefs.FirstDayOfWeek);
"UPDATE usr_data"
" SET FirstDayOfWeek=%u"
" WHERE UsrCod=%ld",
Gbl.Prefs.FirstDayOfWeek,
Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Set settings from current IP *****/ /***** Set settings from current IP *****/
Set_SetSettingsFromIP (); Set_SetSettingsFromIP ();
@ -212,17 +207,17 @@ void Cal_DrawCurrentMonth (void)
/* Write script to draw the month */ /* Write script to draw the month */
HTM_SCRIPT_Begin (NULL,NULL); HTM_SCRIPT_Begin (NULL,NULL);
HTM_Txt ("\tGbl_HTMLContent = '';"); HTM_Txt ("\tGbl_HTMLContent = '';");
HTM_TxtF ("\tDrawCurrentMonth ('CurrentMonth',%u,%ld,%ld,'%s/%s',", HTM_TxtF ("\tDrawCurrentMonth ('CurrentMonth',%u,%ld,%ld,'%s/%s',",
Gbl.Prefs.FirstDayOfWeek, Gbl.Prefs.FirstDayOfWeek,
(long) Gbl.StartExecutionTimeUTC, (long) Gbl.StartExecutionTimeUTC,
Gbl.Hierarchy.Ctr.PlcCod, Gbl.Hierarchy.Ctr.PlcCod,
Cfg_URL_SWAD_CGI, Cfg_URL_SWAD_CGI,
Lan_STR_LANG_ID[Gbl.Prefs.Language]); Lan_STR_LANG_ID[Gbl.Prefs.Language]);
Frm_SetParamsForm (ParamsStr,ActSeeCal,true); Frm_SetParamsForm (ParamsStr,ActSeeCal,true);
HTM_TxtF ("'%s',",ParamsStr); HTM_TxtF ("'%s',",ParamsStr);
Frm_SetParamsForm (ParamsStr,ActSeeDatCfe,true); Frm_SetParamsForm (ParamsStr,ActSeeDatCfe,true);
HTM_TxtF ("'%s');",ParamsStr); HTM_TxtF ("'%s');",ParamsStr);
HTM_SCRIPT_End (); HTM_SCRIPT_End ();
} }
@ -258,41 +253,43 @@ static void Cal_DrawCalendar (Act_Action_t ActionSeeCalendar,
FunctionToDrawContextualIcons,Args, FunctionToDrawContextualIcons,Args,
PrintView ? NULL : PrintView ? NULL :
Hlp_START_Calendar,Box_NOT_CLOSABLE); Hlp_START_Calendar,Box_NOT_CLOSABLE);
Lay_WriteHeaderClassPhoto (PrintView,false,
Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Deg.DegCod,
Gbl.Hierarchy.Crs.CrsCod);
/***** Preference selector to change first day of week *****/ /***** Write header *****/
if (!PrintView) Lay_WriteHeaderClassPhoto (PrintView,false,
{ Gbl.Hierarchy.Ins.InsCod,
Set_BeginSettingsHead (); Gbl.Hierarchy.Deg.DegCod,
Cal_ShowFormToSelFirstDayOfWeek (ActionChangeCalendar1stDay, Gbl.Hierarchy.Crs.CrsCod);
NULL,NULL);
Set_EndSettingsHead ();
}
/***** Draw several months *****/ /***** Preference selector to change first day of week *****/
/* JavaScript will write HTML here */ if (!PrintView)
HTM_DIV_Begin ("id=\"calendar\""); {
HTM_DIV_End (); Set_BeginSettingsHead ();
Cal_ShowFormToSelFirstDayOfWeek (ActionChangeCalendar1stDay,
NULL,NULL);
Set_EndSettingsHead ();
}
/* Write script to draw the month */ /***** Draw several months *****/
HTM_SCRIPT_Begin (NULL,NULL); /* JavaScript will write HTML here */
HTM_Txt ("\tGbl_HTMLContent = '';"); HTM_DIV_Begin ("id=\"calendar\"");
HTM_TxtF ("\tCal_DrawCalendar('calendar',%u,%ld,%ld,%s,'%s/%s',", HTM_DIV_End ();
Gbl.Prefs.FirstDayOfWeek,
(long) Gbl.StartExecutionTimeUTC, /* Write script to draw the month */
Gbl.Hierarchy.Ctr.PlcCod, HTM_SCRIPT_Begin (NULL,NULL);
PrintView ? "true" : HTM_Txt ("\tGbl_HTMLContent = '';");
"false", HTM_TxtF ("\tCal_DrawCalendar('calendar',%u,%ld,%ld,%s,'%s/%s',",
Cfg_URL_SWAD_CGI, Gbl.Prefs.FirstDayOfWeek,
Lan_STR_LANG_ID[Gbl.Prefs.Language]); (long) Gbl.StartExecutionTimeUTC,
Frm_SetParamsForm (ParamsStr,ActionSeeCalendar,true); Gbl.Hierarchy.Ctr.PlcCod,
HTM_TxtF ("'%s',",ParamsStr); PrintView ? "true" :
Frm_SetParamsForm (ParamsStr,ActSeeDatCfe,true); "false",
HTM_TxtF ("'%s');",ParamsStr); Cfg_URL_SWAD_CGI,
HTM_SCRIPT_End (); Lan_STR_LANG_ID[Gbl.Prefs.Language]);
Frm_SetParamsForm (ParamsStr,ActionSeeCalendar,true);
HTM_TxtF ("'%s',",ParamsStr);
Frm_SetParamsForm (ParamsStr,ActSeeDatCfe,true);
HTM_TxtF ("'%s');",ParamsStr);
HTM_SCRIPT_End ();
/***** End box *****/ /***** End box *****/
Box_BoxEnd (); Box_BoxEnd ();

View File

@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
*/ */
#define Log_PLATFORM_VERSION "SWAD 20.87 (2021-06-01)" #define Log_PLATFORM_VERSION "SWAD 20.87.1 (2021-06-01)"
#define CSS_FILE "swad20.45.css" #define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js" #define JS_FILE "swad20.69.1.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 20.87.1: Jun 01, 2021 Database function moved from swad_calendar to swad_setting. (312549 lines)
Version 20.87: Jun 01, 2021 New module swad_building_database for database queries related to buildings. (312538 lines) Version 20.87: Jun 01, 2021 New module swad_building_database for database queries related to buildings. (312538 lines)
Version 20.86.1: May 31, 2021 Queries moved to module swad_call_for_exam_database. (312420 lines) Version 20.86.1: May 31, 2021 Queries moved to module swad_call_for_exam_database. (312420 lines)
Version 20.86: May 31, 2021 New module swad_call_for_exam_database for database queries related to calls for exams. (312415 lines) Version 20.86: May 31, 2021 New module swad_call_for_exam_database for database queries related to calls for exams. (312415 lines)

View File

@ -208,7 +208,7 @@ void Dat_ChangeDateFormat (void)
/***** Store date format in database *****/ /***** Store date format in database *****/
if (Gbl.Usrs.Me.Logged) if (Gbl.Usrs.Me.Logged)
Set_DB_UpdateMySettingsAboutDateFormat (); Set_DB_UpdateMySettingsAboutDateFormat (Gbl.Prefs.DateFormat);
/***** Set settings from current IP *****/ /***** Set settings from current IP *****/
Set_SetSettingsFromIP (); Set_SetSettingsFromIP ();

View File

@ -343,13 +343,27 @@ unsigned Set_GetParamSideCols (void)
/******************** Update my settings about date format *******************/ /******************** Update my settings about date format *******************/
/*****************************************************************************/ /*****************************************************************************/
void Set_DB_UpdateMySettingsAboutDateFormat (void) void Set_DB_UpdateMySettingsAboutDateFormat (Dat_Format_t DateFormat)
{ {
DB_QueryUPDATE ("can not update your setting about date format", DB_QueryUPDATE ("can not update your setting about date format",
"UPDATE usr_data" "UPDATE usr_data"
" SET DateFormat=%u" " SET DateFormat=%u"
" WHERE UsrCod=%ld", " WHERE UsrCod=%ld",
(unsigned) Gbl.Prefs.DateFormat, (unsigned) DateFormat,
Gbl.Usrs.Me.UsrDat.UsrCod);
}
/*****************************************************************************/
/***************** Update my settings about first day of week ****************/
/*****************************************************************************/
void Set_DB_ChangeFirstDayOfWeek (unsigned FirstDayOfWeek)
{
DB_QueryUPDATE ("can not update your setting about first day of week",
"UPDATE usr_data"
" SET FirstDayOfWeek=%u"
" WHERE UsrCod=%ld",
Gbl.Prefs.FirstDayOfWeek,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod);
} }

View File

@ -27,6 +27,8 @@
/********************************* Headers ***********************************/ /********************************* Headers ***********************************/
/*****************************************************************************/ /*****************************************************************************/
#include "swad_date.h"
/*****************************************************************************/ /*****************************************************************************/
/***************************** Public constants ******************************/ /***************************** Public constants ******************************/
/*****************************************************************************/ /*****************************************************************************/
@ -48,7 +50,8 @@ void Set_RemoveOldSettingsFromIP (void);
void Set_ChangeSideCols (void); void Set_ChangeSideCols (void);
unsigned Set_GetParamSideCols (void); unsigned Set_GetParamSideCols (void);
void Set_DB_UpdateMySettingsAboutDateFormat (void); void Set_DB_UpdateMySettingsAboutDateFormat (Dat_Format_t DateFormat);
void Set_DB_ChangeFirstDayOfWeek (unsigned FirstDayOfWeek);
void Set_BeginSettingsHead (void); void Set_BeginSettingsHead (void);
void Set_EndSettingsHead (void); void Set_EndSettingsHead (void);