From d15af31fd036152640901a5e2ea4fb7cd9c7012b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 4 May 2017 02:19:23 +0200 Subject: [PATCH] Version 16.203 --- swad_action.c | 4 ++ swad_action.h | 71 +++++++++++++++--------------- swad_calendar.c | 2 +- swad_changelog.h | 8 +++- swad_date.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++ swad_date.h | 13 ++++++ swad_global.c | 1 + swad_global.h | 1 + swad_preference.c | 26 +++++++---- swad_text.c | 21 +++++++++ swad_user.c | 1 + swad_user.h | 1 + 12 files changed, 212 insertions(+), 46 deletions(-) diff --git a/swad_action.c b/swad_action.c index 55554997..cd8e594a 100644 --- a/swad_action.c +++ b/swad_action.c @@ -41,6 +41,7 @@ #include "swad_course.h" #include "swad_chat.h" #include "swad_database.h" +#include "swad_date.h" #include "swad_degree_type.h" #include "swad_duplicate.h" #include "swad_exam.h" @@ -1442,6 +1443,7 @@ Profile: 1231. ActReqChgLan Ask if change language 1232. ActChgLan Change language 1233. ActChg1stDay Change first day of the week + NEW!. ActChgDatFmt Change date format 1234. ActChgCol Change side columns 1235. ActHidLftCol Hide left side column 1236. ActHidRgtCol Hide right side column @@ -2946,6 +2948,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActReqChgLan */{ 992,-1,TabUnk,ActEdiPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Pre_AskChangeLanguage ,NULL}, /* ActChgLan */{ 654,-1,TabUnk,ActEdiPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,Pre_ChangeLanguage ,Pre_EditPrefs ,NULL}, /* ActChg1stDay */{1484,-1,TabUnk,ActEdiPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,Cal_ChangeFirstDayOfWeek ,Pre_EditPrefs ,NULL}, + /* ActChgDatFmt */{1638,-1,TabUnk,ActEdiPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,Dat_ChangeDateFormat ,Pre_EditPrefs ,NULL}, /* ActChgCol */{ 674,-1,TabUnk,ActEdiPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,Pre_ChangeSideCols ,Pre_EditPrefs ,NULL}, /* ActHidLftCol */{ 668,-1,TabUnk,ActEdiPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,Pre_HideLeftCol ,Pre_EditPrefs ,NULL}, /* ActHidRgtCol */{ 669,-1,TabUnk,ActEdiPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,Pre_HideRightCol ,Pre_EditPrefs ,NULL}, @@ -4624,6 +4627,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un ActPrnCalDeg, // #1635 ActChgCalDeg1stDay, // #1636 ActPrnOneAsg, // #1637 + ActChgDatFmt, // #1638 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index f98cc0a7..53d4ffee 100644 --- a/swad_action.h +++ b/swad_action.h @@ -57,9 +57,9 @@ typedef enum typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action -#define Act_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 32 + 24 + 115 + 72 + 416 + 159 + 172 + 42 + 14 + 96) +#define Act_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 32 + 24 + 115 + 72 + 416 + 159 + 172 + 42 + 14 + 97) -#define Act_MAX_ACTION_COD 1637 +#define Act_MAX_ACTION_COD 1638 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 12 @@ -1475,43 +1475,44 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to #define ActReqChgLan (ActSeeMyUsgRep + 61) #define ActChgLan (ActSeeMyUsgRep + 62) #define ActChg1stDay (ActSeeMyUsgRep + 63) -#define ActChgCol (ActSeeMyUsgRep + 64) -#define ActHidLftCol (ActSeeMyUsgRep + 65) -#define ActHidRgtCol (ActSeeMyUsgRep + 66) -#define ActShoLftCol (ActSeeMyUsgRep + 67) -#define ActShoRgtCol (ActSeeMyUsgRep + 68) -#define ActChgIco (ActSeeMyUsgRep + 69) -#define ActChgMnu (ActSeeMyUsgRep + 70) -#define ActChgNtfPrf (ActSeeMyUsgRep + 71) +#define ActChgDatFmt (ActSeeMyUsgRep + 64) +#define ActChgCol (ActSeeMyUsgRep + 65) +#define ActHidLftCol (ActSeeMyUsgRep + 66) +#define ActHidRgtCol (ActSeeMyUsgRep + 67) +#define ActShoLftCol (ActSeeMyUsgRep + 68) +#define ActShoRgtCol (ActSeeMyUsgRep + 69) +#define ActChgIco (ActSeeMyUsgRep + 70) +#define ActChgMnu (ActSeeMyUsgRep + 71) +#define ActChgNtfPrf (ActSeeMyUsgRep + 72) -#define ActPrnUsrQR (ActSeeMyUsgRep + 72) +#define ActPrnUsrQR (ActSeeMyUsgRep + 73) -#define ActPrnMyTT (ActSeeMyUsgRep + 73) -#define ActEdiTut (ActSeeMyUsgRep + 74) -#define ActChgTut (ActSeeMyUsgRep + 75) -#define ActChgMyTT1stDay (ActSeeMyUsgRep + 76) +#define ActPrnMyTT (ActSeeMyUsgRep + 74) +#define ActEdiTut (ActSeeMyUsgRep + 75) +#define ActChgTut (ActSeeMyUsgRep + 76) +#define ActChgMyTT1stDay (ActSeeMyUsgRep + 77) -#define ActReqRemFilBrf (ActSeeMyUsgRep + 77) -#define ActRemFilBrf (ActSeeMyUsgRep + 78) -#define ActRemFolBrf (ActSeeMyUsgRep + 79) -#define ActCopBrf (ActSeeMyUsgRep + 80) -#define ActPasBrf (ActSeeMyUsgRep + 81) -#define ActRemTreBrf (ActSeeMyUsgRep + 82) -#define ActFrmCreBrf (ActSeeMyUsgRep + 83) -#define ActCreFolBrf (ActSeeMyUsgRep + 84) -#define ActCreLnkBrf (ActSeeMyUsgRep + 85) -#define ActRenFolBrf (ActSeeMyUsgRep + 86) -#define ActRcvFilBrfDZ (ActSeeMyUsgRep + 87) -#define ActRcvFilBrfCla (ActSeeMyUsgRep + 88) -#define ActExpBrf (ActSeeMyUsgRep + 89) -#define ActConBrf (ActSeeMyUsgRep + 90) -#define ActZIPBrf (ActSeeMyUsgRep + 91) -#define ActReqDatBrf (ActSeeMyUsgRep + 92) -#define ActChgDatBrf (ActSeeMyUsgRep + 93) -#define ActDowBrf (ActSeeMyUsgRep + 94) +#define ActReqRemFilBrf (ActSeeMyUsgRep + 78) +#define ActRemFilBrf (ActSeeMyUsgRep + 79) +#define ActRemFolBrf (ActSeeMyUsgRep + 80) +#define ActCopBrf (ActSeeMyUsgRep + 81) +#define ActPasBrf (ActSeeMyUsgRep + 82) +#define ActRemTreBrf (ActSeeMyUsgRep + 83) +#define ActFrmCreBrf (ActSeeMyUsgRep + 84) +#define ActCreFolBrf (ActSeeMyUsgRep + 85) +#define ActCreLnkBrf (ActSeeMyUsgRep + 86) +#define ActRenFolBrf (ActSeeMyUsgRep + 87) +#define ActRcvFilBrfDZ (ActSeeMyUsgRep + 88) +#define ActRcvFilBrfCla (ActSeeMyUsgRep + 89) +#define ActExpBrf (ActSeeMyUsgRep + 90) +#define ActConBrf (ActSeeMyUsgRep + 91) +#define ActZIPBrf (ActSeeMyUsgRep + 92) +#define ActReqDatBrf (ActSeeMyUsgRep + 93) +#define ActChgDatBrf (ActSeeMyUsgRep + 94) +#define ActDowBrf (ActSeeMyUsgRep + 95) -#define ActReqRemOldBrf (ActSeeMyUsgRep + 95) -#define ActRemOldBrf (ActSeeMyUsgRep + 96) +#define ActReqRemOldBrf (ActSeeMyUsgRep + 96) +#define ActRemOldBrf (ActSeeMyUsgRep + 97) /*****************************************************************************/ /******************************** Public types *******************************/ diff --git a/swad_calendar.c b/swad_calendar.c index 077d21b7..f9a44008 100644 --- a/swad_calendar.c +++ b/swad_calendar.c @@ -149,7 +149,7 @@ void Cal_ChangeFirstDayOfWeek (void) /***** Get param with icon set *****/ Gbl.Prefs.FirstDayOfWeek = Cal_GetParamFirstDayOfWeek (); - /***** Store icon set in database *****/ + /***** Store icon first day of week database *****/ if (Gbl.Usrs.Me.Logged) { sprintf (Query,"UPDATE usr_data SET FirstDayOfWeek=%u" diff --git a/swad_changelog.h b/swad_changelog.h index 93d4b7c0..003d2c41 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -224,17 +224,23 @@ // 5. Informar a otros usuarios de que es el cumpleaños de otros usuarios para que los feliciten (habría que añadir una categoría de privacidad nueva para la visibilidad de la fecha de cumpleaños). // 6. La información sobre nuevas notificaciones debería aparecer también en pantallas pequeñas (móviles). Tal vez podría aparecer también en el icono de notificaciones de la pestaña MENSAJES. +// TODO: Fix bug: When a centre is associated with a place and it is moved to another institution, what happens with the place? +// TODO: Check what happens with places when a centre is removed + +// TODO: Green lock in documents is not shown when name is shortened (see OpenSWAD -> Creative Commons -> Files -> Documents) + /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.202.2 (2017-05-03)" +#define Log_PLATFORM_VERSION "SWAD 16.203 (2017-05-04)" #define CSS_FILE "swad16.202.css" #define JS_FILE "swad16.181.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 /* + Version 16.203: May 04, 2017 Form in preferences to change date format. Not finished. (218447 lines) Version 16.202.2: May 03, 2017 Fixed bug in attendance events, reported by Francisco Ocaña Lara. (218306 lines) Version 16.202.1: May 02, 2017 Changed help on surveys from STATS to ASSESSMENT. (218296 lines) Version 16.202: May 02, 2017 Changes in layout of alerts. (218295 lines) diff --git a/swad_date.c b/swad_date.c index 943f6d69..c09a9315 100644 --- a/swad_date.c +++ b/swad_date.c @@ -34,6 +34,7 @@ #include "swad_date.h" #include "swad_global.h" #include "swad_parameter.h" +#include "swad_preference.h" /*****************************************************************************/ /************** External global variables from others modules ****************/ @@ -75,6 +76,14 @@ const char *Dat_TimeStatusClassHidden[Dat_NUM_TIME_STATUS] = "DATE_BLUE_LIGHT", // Dat_FUTURE }; +/***** Date format *****/ +static const char *Dat_Format_Str[Dat_NUM_OPTIONS_FORMAT] = + { + "yyyy-mm-dd", // Dat_FORMAT_YYYY_MM_DD + "dd mmm yyyy", // Dat_FORMAT_DD_MONTH_YYYY + "mmm dd, yyyy", // Dat_FORMAT_MONTH_DD_YYYY + }; + /*****************************************************************************/ /****************************** Internal types *******************************/ /*****************************************************************************/ @@ -83,6 +92,106 @@ const char *Dat_TimeStatusClassHidden[Dat_NUM_TIME_STATUS] = /**************************** Private prototypes *****************************/ /*****************************************************************************/ +static void Dat_PutIconsDateFormat (void); +static unsigned Dat_GetParamDateFormat (void); + +/*****************************************************************************/ +/************** Put icons to select the first day of the week ****************/ +/*****************************************************************************/ + +void Dat_PutIconsToSelectDateFormat (void) + { + extern const char *Hlp_PROFILE_Preferences_calendar; + extern const char *Txt_Dates; + Dat_Format_t Format; + + /***** Start frame *****/ + Lay_StartRoundFrame (NULL,Txt_Dates, + Dat_PutIconsDateFormat, + Hlp_PROFILE_Preferences_calendar); + + /***** Form with list of options *****/ + Act_FormStart (ActChgDatFmt); + + fprintf (Gbl.F.Out,""); + + /***** End form *****/ + Act_FormEnd (); + + /***** End frame *****/ + Lay_EndRoundFrame (); + } + +/*****************************************************************************/ +/************** Put contextual icons in date-format preference ***************/ +/*****************************************************************************/ + +static void Dat_PutIconsDateFormat (void) + { + /***** Put icon to show a figure *****/ + Gbl.Stat.FigureType = Sta_FIRST_DAY_OF_WEEK; // TODO: Change!!!!!!!!!!!!!! + Sta_PutIconToShowFigure (); + } + +/*****************************************************************************/ +/***************************** Change date format ****************************/ +/*****************************************************************************/ + +void Dat_ChangeDateFormat (void) + { + char Query[512]; + + /***** Get param with date format *****/ + Gbl.Prefs.DateFormat = Dat_GetParamDateFormat (); + + /***** Store date format in database *****/ + if (Gbl.Usrs.Me.Logged) + { + sprintf (Query,"UPDATE usr_data SET DateFormat=%u" + " WHERE UsrCod=%ld", + (unsigned) Gbl.Prefs.DateFormat, + Gbl.Usrs.Me.UsrDat.UsrCod); + DB_QueryUPDATE (Query,"can not update your preference about date format"); + } + + /***** Set preferences from current IP *****/ + Pre_SetPrefsFromIP (); + } + +/*****************************************************************************/ +/********************** Get parameter with date format ***********************/ +/*****************************************************************************/ + +static unsigned Dat_GetParamDateFormat (void) + { + return (unsigned) Par_GetParToUnsignedLong ("DateFormat", + 0, + Dat_NUM_OPTIONS_FORMAT - 1, + Dat_FORMAT_DEFAULT); + } + /*****************************************************************************/ /************************** Get current time UTC *****************************/ /*****************************************************************************/ diff --git a/swad_date.h b/swad_date.h index b15706f0..276f5fee 100644 --- a/swad_date.h +++ b/swad_date.h @@ -99,10 +99,23 @@ typedef enum Dat_HMS_TO_235959 = 2, } Dat_SetHMS; +/***** Date format *****/ +#define Dat_NUM_OPTIONS_FORMAT 3 +typedef enum + { + Dat_FORMAT_YYYY_MM_DD = 0, // ISO 8601, default + Dat_FORMAT_DD_MONTH_YYYY = 1, + Dat_FORMAT_MONTH_DD_YYYY = 2, + } Dat_Format_t; +#define Dat_FORMAT_DEFAULT Dat_FORMAT_YYYY_MM_DD + /*****************************************************************************/ /***************************** Public prototypes *****************************/ /*****************************************************************************/ +void Dat_PutIconsToSelectDateFormat (void); +void Dat_ChangeDateFormat (void); + void Dat_GetStartExecutionTimeUTC (void); void Dat_GetAndConvertCurrentDateTime (void); diff --git a/swad_global.c b/swad_global.c index 64f203cb..9a578161 100644 --- a/swad_global.c +++ b/swad_global.c @@ -129,6 +129,7 @@ void Gbl_InitializeGlobals (void) Gbl.Prefs.Language = Txt_Current_CGI_SWAD_Language; Gbl.Prefs.FirstDayOfWeek = Cal_FIRST_DAY_OF_WEEK_DEFAULT; // Default first day of week + Gbl.Prefs.DateFormat = Dat_FORMAT_DEFAULT; // Default date format Gbl.Prefs.Menu = Mnu_MENU_DEFAULT; // Default menu Gbl.Prefs.Theme = The_THEME_DEFAULT; // Default theme Gbl.Prefs.IconSet = Ico_ICON_SET_DEFAULT; // Default icon set diff --git a/swad_global.h b/swad_global.h index 83fc3372..d0e9b6fd 100644 --- a/swad_global.h +++ b/swad_global.h @@ -152,6 +152,7 @@ struct Globals { Txt_Language_t Language; unsigned FirstDayOfWeek; + Dat_Format_t DateFormat; Mnu_Menu_t Menu; unsigned SideCols; The_Theme_t Theme; diff --git a/swad_preference.c b/swad_preference.c index 000d740f..e1884643 100644 --- a/swad_preference.c +++ b/swad_preference.c @@ -33,6 +33,7 @@ #include "swad_calendar.h" #include "swad_config.h" #include "swad_database.h" +#include "swad_date.h" #include "swad_global.h" #include "swad_layout.h" #include "swad_notification.h" @@ -77,26 +78,33 @@ void Pre_EditPrefs (void) Pre_PutSelectorToSelectLanguage (); // 1. Language Lay_EndRoundFrame (); - /***** Icon set, theme *****/ + /***** First day of week, date format *****/ fprintf (Gbl.F.Out,"
" "
"); - Ico_PutIconsToSelectIconSet (); // 2. Icon set + Cal_PutIconsToSelectFirstDayOfWeek (); // 2. First day of week fprintf (Gbl.F.Out,"
" "
"); - Mnu_PutIconsToSelectMenu (); // 3. Menu - fprintf (Gbl.F.Out,"
" - "
"); - Cal_PutIconsToSelectFirstDayOfWeek (); // 4. First day of week + Dat_PutIconsToSelectDateFormat (); // 3. Date format fprintf (Gbl.F.Out,"
" "
"); - /***** Menu, side columns *****/ + /***** Icon set, menu *****/ fprintf (Gbl.F.Out,"
" "
"); - The_PutIconsToSelectTheme (); // 5. Theme + Ico_PutIconsToSelectIconSet (); // 4. Icon set fprintf (Gbl.F.Out,"
" "
"); - Pre_PutIconsToSelectSideCols (); // 6. Side columns + Mnu_PutIconsToSelectMenu (); // 5. Menu + fprintf (Gbl.F.Out,"
" + "
"); + + /***** Theme, side columns *****/ + fprintf (Gbl.F.Out,"
" + "
"); + The_PutIconsToSelectTheme (); // 6. Theme + fprintf (Gbl.F.Out,"
" + "
"); + Pre_PutIconsToSelectSideCols (); // 7. Side columns fprintf (Gbl.F.Out,"
" "
"); diff --git a/swad_text.c b/swad_text.c index e389352a..d2157d7d 100644 --- a/swad_text.c +++ b/swad_text.c @@ -7394,6 +7394,27 @@ const char *Txt_Date_of_creation = "Data da criação"; #endif +const char *Txt_Dates = +#if L==1 + "Dates"; +#elif L==2 + "Datum"; +#elif L==3 + "Dates"; +#elif L==4 + "Fechas"; +#elif L==5 + "Dates"; +#elif L==6 + "Arange"; +#elif L==7 + "Date"; +#elif L==8 + "Daty"; +#elif L==9 + "Datas"; +#endif + const char *Txt_Day = #if L==1 "Día"; // Necessita traduccio diff --git a/swad_user.c b/swad_user.c index d31e9e17..14be6565 100644 --- a/swad_user.c +++ b/swad_user.c @@ -303,6 +303,7 @@ void Usr_ResetUsrDataExceptUsrCodAndIDs (struct UsrData *UsrDat) UsrDat->Prefs.Language = Txt_LANGUAGE_UNKNOWN; // Language unknown UsrDat->Prefs.FirstDayOfWeek = Cal_FIRST_DAY_OF_WEEK_DEFAULT; // Default first day of week + UsrDat->Prefs.DateFormat = Dat_FORMAT_DEFAULT ; // Default date format UsrDat->Prefs.Theme = The_THEME_DEFAULT; UsrDat->Prefs.IconSet = Ico_ICON_SET_DEFAULT; UsrDat->Prefs.Menu = Mnu_MENU_DEFAULT; diff --git a/swad_user.h b/swad_user.h index 8543cf80..2618d491 100644 --- a/swad_user.h +++ b/swad_user.h @@ -164,6 +164,7 @@ struct UsrData { Txt_Language_t Language; unsigned FirstDayOfWeek; + Dat_Format_t DateFormat; The_Theme_t Theme; Ico_IconSet_t IconSet; Mnu_Menu_t Menu;