diff --git a/swad_changelog.h b/swad_changelog.h index 62aa777c3..61e108d62 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -111,11 +111,12 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.42.3 (2015/11/21)" +#define Log_PLATFORM_VERSION "SWAD 15.42.4 (2015/11/21)" // 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 15.42.4: Nov 21, 2015 Fixed bug when getting first day of week from IP preferences. (187535 lines) Version 15.42.3: Nov 21, 2015 Stats of hits distributed by week depend on user's preference about first day of the week. (187528 lines) Version 15.42.2: Nov 21, 2015 Fixed bug in JavaScript code to draw months. (187524 lines) Version 15.42.1: Nov 21, 2015 Calendar is drawn depending on user's preference about first day of the week. (187523 lines) diff --git a/swad_preference.c b/swad_preference.c index 9117c7441..783f7bd54 100644 --- a/swad_preference.c +++ b/swad_preference.c @@ -125,6 +125,7 @@ void Pre_EditPrefs (void) void Pre_GetPrefsFromIP (void) { + extern const bool Cal_DayIsValidAsFirstDayOfWeek[7]; char Query[1024]; unsigned long NumRows; MYSQL_RES *mysql_res; @@ -134,7 +135,7 @@ void Pre_GetPrefsFromIP (void) if (Gbl.IP[0]) { /***** Get preferences from database *****/ - sprintf (Query,"SELECT Layout,Theme,IconSet,Menu,SideCols" + sprintf (Query,"SELECT FirstDayOfWeek,Layout,Theme,IconSet,Menu,SideCols" " FROM IP_prefs WHERE IP='%s'", Gbl.IP); if ((NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get preferences"))) @@ -145,26 +146,32 @@ void Pre_GetPrefsFromIP (void) /***** Get preferences from database *****/ row = mysql_fetch_row (mysql_res); - /* Get layout (row[0]) */ - Gbl.Prefs.Layout = Lay_LAYOUT_DEFAULT; + /* Get first day of week (row[0]) */ + Gbl.Prefs.FirstDayOfWeek = Cal_FIRST_DAY_OF_WEEK_DEFAULT; if (sscanf (row[0],"%u",&UnsignedNum) == 1) + if (Cal_DayIsValidAsFirstDayOfWeek[UnsignedNum]) + Gbl.Prefs.FirstDayOfWeek = UnsignedNum; + + /* Get layout (row[1]) */ + Gbl.Prefs.Layout = Lay_LAYOUT_DEFAULT; + if (sscanf (row[1],"%u",&UnsignedNum) == 1) if (UnsignedNum < Lay_NUM_LAYOUTS) Gbl.Prefs.Layout = (Lay_Layout_t) UnsignedNum; - /* Get theme (row[1]) */ - Gbl.Prefs.Theme = The_GetThemeFromStr (row[1]); + /* Get theme (row[2]) */ + Gbl.Prefs.Theme = The_GetThemeFromStr (row[2]); - /* Get icon set (row[2]) */ - Gbl.Prefs.IconSet = Ico_GetIconSetFromStr (row[2]); + /* Get icon set (row[3]) */ + Gbl.Prefs.IconSet = Ico_GetIconSetFromStr (row[3]); - /* Get menu (row[3]) */ + /* Get menu (row[4]) */ Gbl.Prefs.Menu = Mnu_MENU_DEFAULT; - if (sscanf (row[3],"%u",&UnsignedNum) == 1) + if (sscanf (row[4],"%u",&UnsignedNum) == 1) if (UnsignedNum < Mnu_NUM_MENUS) Gbl.Prefs.Menu = (Lay_Layout_t) UnsignedNum; - /* Get if user wants to show side columns (row[4]) */ - if (sscanf (row[4],"%u",&Gbl.Prefs.SideCols) == 1) + /* Get if user wants to show side columns (row[5]) */ + if (sscanf (row[5],"%u",&Gbl.Prefs.SideCols) == 1) { if (Gbl.Prefs.SideCols > Lay_SHOW_BOTH_COLUMNS) Gbl.Prefs.SideCols = Cfg_DEFAULT_COLUMNS;