From 756ac27652526315cb38aa497a8ceb978dfac240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 4 May 2017 11:03:44 +0200 Subject: [PATCH] Version 16.204 --- sql/swad.sql | 3 + swad_account.c | 11 +- swad_calendar.c | 15 ++ swad_calendar.h | 1 + swad_changelog.h | 8 +- swad_database.c | 9 +- swad_date.c | 53 ++++-- swad_date.h | 3 +- swad_enrolment.c | 12 -- swad_global.c | 10 +- swad_menu.c | 15 ++ swad_menu.h | 1 + swad_preference.c | 43 ++--- swad_statistic.c | 427 ++++++++++++++++++++++++++++++---------------- swad_statistic.h | 5 +- swad_text.c | 81 ++++++--- swad_user.c | 59 +++---- 17 files changed, 495 insertions(+), 261 deletions(-) diff --git a/sql/swad.sql b/sql/swad.sql index 6eb44c62..27300bc8 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -8,6 +8,7 @@ CREATE TABLE IF NOT EXISTS IP_prefs ( UsrCod INT NOT NULL DEFAULT -1, LastChange DATETIME NOT NULL, FirstDayOfWeek TINYINT NOT NULL DEFAULT 0, + DateFormat TINYINT NOT NULL DEFAULT 0, Theme CHAR(16) NOT NULL, IconSet CHAR(16) NOT NULL, Menu TINYINT NOT NULL DEFAULT 0, @@ -1195,6 +1196,7 @@ CREATE TABLE IF NOT EXISTS usr_data ( IconSet CHAR(16) NOT NULL DEFAULT '', Language CHAR(2) NOT NULL DEFAULT '', FirstDayOfWeek TINYINT NOT NULL DEFAULT 0, + DateFormat TINYINT NOT NULL DEFAULT 0, Photo CHAR(43) NOT NULL DEFAULT '', PhotoVisibility ENUM('unknown','user','course','system','world') NOT NULL DEFAULT 'unknown', ProfileVisibility ENUM('unknown','user','course','system','world') NOT NULL DEFAULT 'unknown', @@ -1222,6 +1224,7 @@ CREATE TABLE IF NOT EXISTS usr_data ( INDEX(IconSet), INDEX(Language), INDEX(FirstDayOfWeek), + INDEX(DateFormat), INDEX(PhotoVisibility), INDEX(ProfileVisibility), INDEX(CtyCod), diff --git a/swad_account.c b/swad_account.c index ad6ef2bf..167fb824 100644 --- a/swad_account.c +++ b/swad_account.c @@ -719,13 +719,15 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount) Usr_CreateBirthdayStrDB (UsrDat,BirthdayStrDB); sprintf (Query,"INSERT INTO usr_data" " (EncryptedUsrCod,Password,Surname1,Surname2,FirstName,Sex," - "Theme,IconSet,Language,FirstDayOfWeek,PhotoVisibility,ProfileVisibility," + "Theme,IconSet,Language,FirstDayOfWeek,DateFormat," + "PhotoVisibility,ProfileVisibility," "CtyCod," "LocalAddress,LocalPhone,FamilyAddress,FamilyPhone,OriginPlace,Birthday,Comments," "Menu,SideCols,NotifNtfEvents,EmailNtfEvents)" " VALUES" " ('%s','%s','%s','%s','%s','%s'," - "'%s','%s','%s',%u,'%s','%s'," + "'%s','%s','%s',%u,%u," + "'%s','%s'," "%ld," "'%s','%s','%s','%s','%s',%s,'%s'," "%u,%u,-1,0)", @@ -737,6 +739,7 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount) Ico_IconSetId[UsrDat->Prefs.IconSet], Txt_STR_LANG_ID[UsrDat->Prefs.Language], Cal_FIRST_DAY_OF_WEEK_DEFAULT, + (unsigned) Dat_FORMAT_DEFAULT, Pri_VisibilityDB[UsrDat->PhotoVisibility], Pri_VisibilityDB[UsrDat->ProfileVisibility], UsrDat->CtyCod, @@ -746,8 +749,8 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount) BirthdayStrDB, UsrDat->Comments ? UsrDat->Comments : "", - Mnu_MENU_DEFAULT, - Cfg_DEFAULT_COLUMNS); + (unsigned) Mnu_MENU_DEFAULT, + (unsigned) Cfg_DEFAULT_COLUMNS); UsrDat->UsrCod = DB_QueryINSERTandReturnCode (Query,"can not create user"); /* Insert user's IDs as confirmed */ diff --git a/swad_calendar.c b/swad_calendar.c index f9a44008..bc119659 100644 --- a/swad_calendar.c +++ b/swad_calendar.c @@ -182,6 +182,21 @@ static unsigned Cal_GetParamFirstDayOfWeek (void) return FirstDayOfWeek; } +/*****************************************************************************/ +/******************** Get first day of week from string **********************/ +/*****************************************************************************/ + +unsigned Cal_GetFirstDayOfWeekFromStr (const char *Str) + { + unsigned UnsignedNum; + + if (sscanf (Str,"%u",&UnsignedNum) == 1) + if (Cal_DayIsValidAsFirstDayOfWeek[UnsignedNum]) + return (Dat_Format_t) UnsignedNum; + + return Cal_FIRST_DAY_OF_WEEK_DEFAULT; + } + /*****************************************************************************/ /***************************** Draw current month ****************************/ /*****************************************************************************/ diff --git a/swad_calendar.h b/swad_calendar.h index ae038008..079d1f84 100644 --- a/swad_calendar.h +++ b/swad_calendar.h @@ -47,6 +47,7 @@ void Cal_PutIconsToSelectFirstDayOfWeek (void); void Cal_ShowFormToSelFirstDayOfWeek (Act_Action_t Action,void (*FuncParams) (), const char *ClassIcon); void Cal_ChangeFirstDayOfWeek (void); +unsigned Cal_GetFirstDayOfWeekFromStr (const char *Str); void Cal_DrawCurrentMonth (void); Act_Action_t Cal_GetActionToSeeCalendar (); diff --git a/swad_changelog.h b/swad_changelog.h index 003d2c41..c9247abf 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -233,13 +233,19 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.203 (2017-05-04)" +#define Log_PLATFORM_VERSION "SWAD 16.204 (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.204: May 04, 2017 Form in preferences to change date format. (218656 lines) + 3 changes necessary in database: +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1638','es','N','Cambiar formato de fecha'); +ALTER TABLE usr_data ADD COLUMN DateFormat TINYINT NOT NULL DEFAULT 0 AFTER FirstDayOfWeek,ADD INDEX (DateFormat); +ALTER TABLE IP_prefs ADD COLUMN DateFormat TINYINT NOT NULL DEFAULT 0 AFTER FirstDayOfWeek; + 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) diff --git a/swad_database.c b/swad_database.c index f009e9f8..ce94ae74 100644 --- a/swad_database.c +++ b/swad_database.c @@ -95,18 +95,20 @@ mysql> DESCRIBE IP_prefs; | UsrCod | int(11) | NO | MUL | -1 | | | LastChange | datetime | NO | MUL | NULL | | | FirstDayOfWeek | tinyint(4) | NO | | 0 | | +| DateFormat | tinyint(4) | NO | | 0 | | | Theme | char(16) | NO | | NULL | | | IconSet | char(16) | NO | | NULL | | | Menu | tinyint(4) | NO | | 0 | | | SideCols | tinyint(4) | NO | | NULL | | +----------------+------------+------+-----+---------+-------+ -8 rows in set (0.01 sec) +9 rows in set (0,00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS IP_prefs (" "IP CHAR(15) NOT NULL," // Cns_MAX_BYTES_IP "UsrCod INT NOT NULL DEFAULT -1," "LastChange DATETIME NOT NULL," "FirstDayOfWeek TINYINT NOT NULL DEFAULT 0," + "DateFormat TINYINT NOT NULL DEFAULT 0," "Theme CHAR(16) NOT NULL," // The_MAX_BYTES_THEME_ID "IconSet CHAR(16) NOT NULL," // Ico_MAX_BYTES_ICON_SET_ID "Menu TINYINT NOT NULL DEFAULT 0," @@ -2532,6 +2534,7 @@ mysql> DESCRIBE usr_data; | IconSet | char(16) | NO | MUL | | | | Language | char(2) | NO | MUL | | | | FirstDayOfWeek | tinyint(4) | NO | MUL | 0 | | +| DateFormat | tinyint(4) | NO | MUL | 0 | | | Photo | char(43) | NO | | | | | PhotoVisibility | enum('unknown','user','course','system','world') | NO | MUL | unknown | | | ProfileVisibility | enum('unknown','user','course','system','world') | NO | MUL | unknown | | @@ -2554,7 +2557,7 @@ mysql> DESCRIBE usr_data; | NotifNtfEvents | int(11) | NO | | 0 | | | EmailNtfEvents | int(11) | NO | | 0 | | +-------------------+--------------------------------------------------+------+-----+---------+----------------+ -32 rows in set (0,00 sec) +33 rows in set (0,00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS usr_data (" "UsrCod INT NOT NULL AUTO_INCREMENT," @@ -2568,6 +2571,7 @@ mysql> DESCRIBE usr_data; "IconSet CHAR(16) NOT NULL DEFAULT ''," "Language CHAR(2) NOT NULL DEFAULT ''," "FirstDayOfWeek TINYINT NOT NULL DEFAULT 0," + "DateFormat TINYINT NOT NULL DEFAULT 0," "Photo CHAR(43) NOT NULL DEFAULT ''," // Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 "PhotoVisibility ENUM('unknown','user','course','system','world') NOT NULL DEFAULT 'unknown'," "ProfileVisibility ENUM('unknown','user','course','system','world') NOT NULL DEFAULT 'unknown'," @@ -2595,6 +2599,7 @@ mysql> DESCRIBE usr_data; "INDEX(IconSet)," "INDEX(Language)," "INDEX(FirstDayOfWeek)," + "INDEX(DateFormat)," "INDEX(PhotoVisibility)," "INDEX(ProfileVisibility)," "INDEX(CtyCod)," diff --git a/swad_date.c b/swad_date.c index c09a9315..0004148f 100644 --- a/swad_date.c +++ b/swad_date.c @@ -42,6 +42,18 @@ extern struct Globals Gbl; +/*****************************************************************************/ +/***************************** Public constants ******************************/ +/*****************************************************************************/ + +/***** Date format *****/ +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 + }; + /*****************************************************************************/ /**************************** Private constants ******************************/ /*****************************************************************************/ @@ -76,14 +88,6 @@ 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 *******************************/ /*****************************************************************************/ @@ -121,10 +125,10 @@ void Dat_PutIconsToSelectDateFormat (void) fprintf (Gbl.F.Out,"
  • " "