Version 15.206

This commit is contained in:
Antonio Cañas Vargas 2016-04-30 17:16:41 +02:00
parent 2a35f40e9e
commit b126068f00
6 changed files with 80 additions and 64 deletions

View File

@ -190,7 +190,7 @@ CREATE TABLE IF NOT EXISTS connected (
UsrCod INT NOT NULL, UsrCod INT NOT NULL,
RoleInLastCrs TINYINT NOT NULL DEFAULT 0, RoleInLastCrs TINYINT NOT NULL DEFAULT 0,
LastCrsCod INT NOT NULL DEFAULT -1, LastCrsCod INT NOT NULL DEFAULT -1,
LastTime DATETIME, LastTime DATETIME NOT NULL,
UNIQUE INDEX(UsrCod), UNIQUE INDEX(UsrCod),
INDEX(LastCrsCod)); INDEX(LastCrsCod));
-- --
@ -266,7 +266,7 @@ CREATE TABLE IF NOT EXISTS crs_grp_types (
Mandatory ENUM('N','Y') NOT NULL, Mandatory ENUM('N','Y') NOT NULL,
Multiple ENUM('N','Y') NOT NULL, Multiple ENUM('N','Y') NOT NULL,
MustBeOpened ENUM('N','Y') NOT NULL DEFAULT 'N', MustBeOpened ENUM('N','Y') NOT NULL DEFAULT 'N',
OpenTime DATETIME NOT NULL DEFAULT 0, OpenTime DATETIME NOT NULL,
UNIQUE INDEX(GrpTypCod), UNIQUE INDEX(GrpTypCod),
INDEX(CrsCod)); INDEX(CrsCod));
-- --
@ -309,7 +309,7 @@ CREATE TABLE IF NOT EXISTS crs_info_txt (
-- --
CREATE TABLE IF NOT EXISTS crs_last ( CREATE TABLE IF NOT EXISTS crs_last (
CrsCod INT NOT NULL, CrsCod INT NOT NULL,
LastTime DATETIME NOT NULL DEFAULT 0, LastTime DATETIME NOT NULL,
UNIQUE INDEX(CrsCod), UNIQUE INDEX(CrsCod),
INDEX(LastTime)); INDEX(LastTime));
-- --
@ -908,8 +908,8 @@ CREATE TABLE IF NOT EXISTS sessions (
CtrCod INT NOT NULL DEFAULT -1, CtrCod INT NOT NULL DEFAULT -1,
DegCod INT NOT NULL DEFAULT -1, DegCod INT NOT NULL DEFAULT -1,
CrsCod INT NOT NULL DEFAULT -1, CrsCod INT NOT NULL DEFAULT -1,
LastTime DATETIME, LastTime DATETIME NOT NULL,
LastRefresh DATETIME, LastRefresh DATETIME NOT NULL,
FirstPubCod BIGINT NOT NULL DEFAULT 0, FirstPubCod BIGINT NOT NULL DEFAULT 0,
LastPubCod BIGINT NOT NULL DEFAULT 0, LastPubCod BIGINT NOT NULL DEFAULT 0,
LastPageMsgRcv INT NOT NULL DEFAULT 1, LastPageMsgRcv INT NOT NULL DEFAULT 1,
@ -1299,8 +1299,8 @@ CREATE TABLE IF NOT EXISTS usr_last (
WhatToSearch TINYINT NOT NULL DEFAULT 0, WhatToSearch TINYINT NOT NULL DEFAULT 0,
LastCrs INT NOT NULL DEFAULT -1, LastCrs INT NOT NULL DEFAULT -1,
LastTab TINYINT NOT NULL, LastTab TINYINT NOT NULL,
LastTime DATETIME NOT NULL DEFAULT 0, LastTime DATETIME NOT NULL,
LastAccNotif DATETIME NOT NULL DEFAULT 0, LastAccNotif DATETIME NOT NULL,
UNIQUE INDEX(UsrCod), UNIQUE INDEX(UsrCod),
INDEX(LastTime)); INDEX(LastTime));
-- --

View File

@ -135,13 +135,23 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.205 (2016-04-30)" #define Log_PLATFORM_VERSION "SWAD 15.206 (2016-04-30)"
#define CSS_FILE "swad15.204.1.css" #define CSS_FILE "swad15.204.1.css"
#define JS_FILE "swad15.197.js" #define JS_FILE "swad15.197.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // 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 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/* /*
Version 15.206: Apr 30, 2016 Remove default DATETIME fields to avoid errors if 0 is not allowed in date in database. (201424 lines)
6 changes necessary in database:
ALTER TABLE connected CHANGE COLUMN LastTime LastTime DATETIME NOT NULL;
ALTER TABLE crs_grp_types CHANGE COLUMN OpenTime OpenTime DATETIME NOT NULL;
ALTER TABLE crs_last CHANGE COLUMN LastTime LastTime DATETIME NOT NULL;
ALTER TABLE sessions CHANGE COLUMN LastTime LastTime DATETIME NOT NULL;
ALTER TABLE sessions CHANGE COLUMN LastRefresh LastRefresh DATETIME NOT NULL;
ALTER TABLE usr_last CHANGE COLUMN LastTime LastTime DATETIME NOT NULL;
ALTER TABLE usr_last CHANGE COLUMN LastAccNotif LastAccNotif DATETIME NOT NULL;
Version 15.205: Apr 30, 2016 New demo server added to swad_config.h: swadberry.ugr.es. (201409 lines) Version 15.205: Apr 30, 2016 New demo server added to swad_config.h: swadberry.ugr.es. (201409 lines)
Version 15.204.1: Apr 25, 2016 Fixed bug in changes in database necessary in version 15.201. (201366 lines) Version 15.204.1: Apr 25, 2016 Fixed bug in changes in database necessary in version 15.201. (201366 lines)
6 changes necessary in database: 6 changes necessary in database:

View File

@ -478,15 +478,15 @@ mysql> DESCRIBE connected;
| UsrCod | int(11) | NO | PRI | NULL | | | UsrCod | int(11) | NO | PRI | NULL | |
| RoleInLastCrs | tinyint(4) | NO | | 0 | | | RoleInLastCrs | tinyint(4) | NO | | 0 | |
| LastCrsCod | int(11) | NO | MUL | -1 | | | LastCrsCod | int(11) | NO | MUL | -1 | |
| LastTime | datetime | YES | | NULL | | | LastTime | datetime | NO | | NULL | |
+---------------+------------+------+-----+---------+-------+ +---------------+------------+------+-----+---------+-------+
4 rows in set (0.00 sec) 4 rows in set (0.01 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS connected (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS connected ("
"UsrCod INT NOT NULL," "UsrCod INT NOT NULL,"
"RoleInLastCrs TINYINT NOT NULL DEFAULT 0," "RoleInLastCrs TINYINT NOT NULL DEFAULT 0,"
"LastCrsCod INT NOT NULL DEFAULT -1," "LastCrsCod INT NOT NULL DEFAULT -1,"
"LastTime DATETIME," "LastTime DATETIME NOT NULL,"
"UNIQUE INDEX(UsrCod)," "UNIQUE INDEX(UsrCod),"
"INDEX(LastCrsCod))"); "INDEX(LastCrsCod))");
@ -611,17 +611,17 @@ mysql> DESCRIBE crs_grp;
/***** Table crs_grp_types *****/ /***** Table crs_grp_types *****/
/* /*
mysql> DESCRIBE crs_grp_types; mysql> DESCRIBE crs_grp_types;
+--------------+---------------+------+-----+---------------------+----------------+ +--------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+--------------+---------------+------+-----+---------------------+----------------+ +--------------+---------------+------+-----+---------+----------------+
| GrpTypCod | int(11) | NO | PRI | NULL | auto_increment | | GrpTypCod | int(11) | NO | PRI | NULL | auto_increment |
| CrsCod | int(11) | NO | MUL | -1 | | | CrsCod | int(11) | NO | MUL | -1 | |
| GrpTypName | varchar(255) | NO | | NULL | | | GrpTypName | varchar(255) | NO | | NULL | |
| Mandatory | enum('N','Y') | NO | | NULL | | | Mandatory | enum('N','Y') | NO | | NULL | |
| Multiple | enum('N','Y') | NO | | NULL | | | Multiple | enum('N','Y') | NO | | NULL | |
| MustBeOpened | enum('N','Y') | NO | | N | | | MustBeOpened | enum('N','Y') | NO | | N | |
| OpenTime | datetime | NO | | 0000-00-00 00:00:00 | | | OpenTime | datetime | NO | | NULL | |
+--------------+---------------+------+-----+---------------------+----------------+ +--------------+---------------+------+-----+---------+----------------+
7 rows in set (0.01 sec) 7 rows in set (0.01 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS crs_grp_types (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS crs_grp_types ("
@ -631,7 +631,7 @@ mysql> DESCRIBE crs_grp_types;
"Mandatory ENUM('N','Y') NOT NULL," "Mandatory ENUM('N','Y') NOT NULL,"
"Multiple ENUM('N','Y') NOT NULL," "Multiple ENUM('N','Y') NOT NULL,"
"MustBeOpened ENUM('N','Y') NOT NULL DEFAULT 'N'," "MustBeOpened ENUM('N','Y') NOT NULL DEFAULT 'N',"
"OpenTime DATETIME NOT NULL DEFAULT 0," "OpenTime DATETIME NOT NULL,"
"UNIQUE INDEX(GrpTypCod)," "UNIQUE INDEX(GrpTypCod),"
"INDEX(CrsCod))"); "INDEX(CrsCod))");
@ -714,17 +714,17 @@ mysql> DESCRIBE crs_info_txt;
/***** Table crs_last *****/ /***** Table crs_last *****/
/* /*
mysql> DESCRIBE crs_last; mysql> DESCRIBE crs_last;
+----------+----------+------+-----+---------------------+-------+ +----------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+----------+----------+------+-----+---------------------+-------+ +----------+----------+------+-----+---------+-------+
| CrsCod | int(11) | NO | PRI | NULL | | | CrsCod | int(11) | NO | PRI | NULL | |
| LastTime | datetime | NO | MUL | 0000-00-00 00:00:00 | | | LastTime | datetime | NO | MUL | NULL | |
+----------+----------+------+-----+---------------------+-------+ +----------+----------+------+-----+---------+-------+
2 rows in set (0.00 sec) 2 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS crs_last (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS crs_last ("
"CrsCod INT NOT NULL," "CrsCod INT NOT NULL,"
"LastTime DATETIME NOT NULL DEFAULT 0," "LastTime DATETIME NOT NULL,"
"UNIQUE INDEX(CrsCod)," "UNIQUE INDEX(CrsCod),"
"INDEX(LastTime))"); "INDEX(LastTime))");
@ -1916,8 +1916,8 @@ mysql> DESCRIBE sessions;
| CtrCod | int(11) | NO | | -1 | | | CtrCod | int(11) | NO | | -1 | |
| DegCod | int(11) | NO | | -1 | | | DegCod | int(11) | NO | | -1 | |
| CrsCod | int(11) | NO | | -1 | | | CrsCod | int(11) | NO | | -1 | |
| LastTime | datetime | YES | | NULL | | | LastTime | datetime | NO | | NULL | |
| LastRefresh | datetime | YES | | NULL | | | LastRefresh | datetime | NO | | NULL | |
| FirstPubCod | bigint(20) | NO | | 0 | | | FirstPubCod | bigint(20) | NO | | 0 | |
| LastPubCod | bigint(20) | NO | | 0 | | | LastPubCod | bigint(20) | NO | | 0 | |
| LastPageMsgRcv | int(11) | NO | | 1 | | | LastPageMsgRcv | int(11) | NO | | 1 | |
@ -1926,7 +1926,7 @@ mysql> DESCRIBE sessions;
| SearchString | varchar(255) | NO | | NULL | | | SearchString | varchar(255) | NO | | NULL | |
| SideCols | tinyint(4) | NO | | 3 | | | SideCols | tinyint(4) | NO | | 3 | |
+----------------+--------------+------+-----+---------+-------+ +----------------+--------------+------+-----+---------+-------+
18 rows in set (0.00 sec) 18 rows in set (0.01 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS sessions (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS sessions ("
"SessionId CHAR(43) NOT NULL," "SessionId CHAR(43) NOT NULL,"
@ -1938,8 +1938,8 @@ mysql> DESCRIBE sessions;
"CtrCod INT NOT NULL DEFAULT -1," "CtrCod INT NOT NULL DEFAULT -1,"
"DegCod INT NOT NULL DEFAULT -1," "DegCod INT NOT NULL DEFAULT -1,"
"CrsCod INT NOT NULL DEFAULT -1," "CrsCod INT NOT NULL DEFAULT -1,"
"LastTime DATETIME," "LastTime DATETIME NOT NULL,"
"LastRefresh DATETIME," "LastRefresh DATETIME NOT NULL,"
"FirstPubCod BIGINT NOT NULL DEFAULT 0," "FirstPubCod BIGINT NOT NULL DEFAULT 0,"
"LastPubCod BIGINT NOT NULL DEFAULT 0," "LastPubCod BIGINT NOT NULL DEFAULT 0,"
"LastPageMsgRcv INT NOT NULL DEFAULT 1," "LastPageMsgRcv INT NOT NULL DEFAULT 1,"
@ -2722,16 +2722,16 @@ mysql> DESCRIBE usr_IDs;
/***** Table usr_last *****/ /***** Table usr_last *****/
/* /*
mysql> DESCRIBE usr_last; mysql> DESCRIBE usr_last;
+--------------+------------+------+-----+---------------------+-------+ +--------------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+--------------+------------+------+-----+---------------------+-------+ +--------------+------------+------+-----+---------+-------+
| UsrCod | int(11) | NO | PRI | NULL | | | UsrCod | int(11) | NO | PRI | NULL | |
| WhatToSearch | tinyint(4) | NO | | 0 | | | WhatToSearch | tinyint(4) | NO | | 0 | |
| LastCrs | int(11) | NO | | -1 | | | LastCrs | int(11) | NO | | -1 | |
| LastTab | tinyint(4) | NO | | NULL | | | LastTab | tinyint(4) | NO | | NULL | |
| LastTime | datetime | NO | MUL | 0000-00-00 00:00:00 | | | LastTime | datetime | NO | MUL | NULL | |
| LastAccNotif | datetime | NO | | 0000-00-00 00:00:00 | | | LastAccNotif | datetime | NO | | NULL | |
+--------------+------------+------+-----+---------------------+-------+ +--------------+------------+------+-----+---------+-------+
6 rows in set (0.00 sec) 6 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS usr_last (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS usr_last ("
@ -2739,8 +2739,8 @@ mysql> DESCRIBE usr_last;
"WhatToSearch TINYINT NOT NULL DEFAULT 0," "WhatToSearch TINYINT NOT NULL DEFAULT 0,"
"LastCrs INT NOT NULL DEFAULT -1," "LastCrs INT NOT NULL DEFAULT -1,"
"LastTab TINYINT NOT NULL," "LastTab TINYINT NOT NULL,"
"LastTime DATETIME NOT NULL DEFAULT 0," "LastTime DATETIME NOT NULL,"
"LastAccNotif DATETIME NOT NULL DEFAULT 0," "LastAccNotif DATETIME NOT NULL,"
"UNIQUE INDEX(UsrCod)," "UNIQUE INDEX(UsrCod),"
"INDEX(LastTime))"); "INDEX(LastTime))");

View File

@ -108,15 +108,12 @@ void Dat_GetAndConvertCurrentDateTime (void)
time_t Dat_GetUNIXTimeFromStr (const char *Str) time_t Dat_GetUNIXTimeFromStr (const char *Str)
{ {
time_t Time; time_t Time = (time_t) 0;
if (Str[0]) if (Str)
{ if (Str[0])
if (sscanf (Str,"%ld",&Time) != 1) if (sscanf (Str,"%ld",&Time) != 1)
Time = (time_t) 0; Time = (time_t) 0;
}
else
Time = (time_t) 0;
return Time; return Time;
} }

View File

@ -3201,7 +3201,8 @@ static void Grp_CreateGroupType (void)
char Query[1024]; char Query[1024];
/***** Create a new group type *****/ /***** Create a new group type *****/
sprintf (Query,"INSERT INTO crs_grp_types (CrsCod,GrpTypName,Mandatory,Multiple,MustBeOpened,OpenTime)" sprintf (Query,"INSERT INTO crs_grp_types"
" (CrsCod,GrpTypName,Mandatory,Multiple,MustBeOpened,OpenTime)"
" VALUES ('%ld','%s','%c','%c','%c',FROM_UNIXTIME('%ld'))", " VALUES ('%ld','%s','%c','%c','%c',FROM_UNIXTIME('%ld'))",
Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName, Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,
Gbl.CurrentCrs.Grps.GrpTyp.MandatoryEnrollment ? 'Y' : Gbl.CurrentCrs.Grps.GrpTyp.MandatoryEnrollment ? 'Y' :
@ -3789,8 +3790,10 @@ void Grp_ChangeOpenTimeGrpTyp (void)
Gbl.CurrentCrs.Grps.GrpTyp.OpenTimeUTC = Dat_GetTimeUTCFromForm ("OpenTimeUTC"); Gbl.CurrentCrs.Grps.GrpTyp.OpenTimeUTC = Dat_GetTimeUTCFromForm ("OpenTimeUTC");
Gbl.CurrentCrs.Grps.GrpTyp.MustBeOpened = Grp_CheckIfOpenTimeInTheFuture (Gbl.CurrentCrs.Grps.GrpTyp.OpenTimeUTC); Gbl.CurrentCrs.Grps.GrpTyp.MustBeOpened = Grp_CheckIfOpenTimeInTheFuture (Gbl.CurrentCrs.Grps.GrpTyp.OpenTimeUTC);
/***** Update of the table of types of group changing the old open time of enrollment by the new *****/ /***** Update the table of types of group
sprintf (Query,"UPDATE crs_grp_types SET MustBeOpened='%c',OpenTime=FROM_UNIXTIME('%ld')" changing the old open time of enrollment by the new *****/
sprintf (Query,"UPDATE crs_grp_types"
" SET MustBeOpened='%c',OpenTime=FROM_UNIXTIME('%ld')"
" WHERE GrpTypCod='%ld'", " WHERE GrpTypCod='%ld'",
Gbl.CurrentCrs.Grps.GrpTyp.MustBeOpened ? 'Y' : Gbl.CurrentCrs.Grps.GrpTyp.MustBeOpened ? 'Y' :
'N', 'N',
@ -3934,8 +3937,11 @@ void Grp_RenameGroupType (void)
else else
{ {
/* Update the table changing old name by new name */ /* Update the table changing old name by new name */
sprintf (Query,"UPDATE crs_grp_types SET GrpTypName='%s' WHERE GrpTypCod='%ld'", sprintf (Query,"UPDATE crs_grp_types"
NewNameGrpTyp,Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod); " SET GrpTypName='%s'"
" WHERE GrpTypCod='%ld'",
NewNameGrpTyp,
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod);
DB_QueryUPDATE (Query,"can not update the type of a group"); DB_QueryUPDATE (Query,"can not update the type of a group");
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/

View File

@ -2675,12 +2675,15 @@ static void Usr_InsertMyLastData (void)
char Query[256]; char Query[256];
/***** Insert my last accessed course, tab and time of click in database *****/ /***** Insert my last accessed course, tab and time of click in database *****/
// WhatToSearch, LastAccNotif are set to default (0) sprintf (Query,"INSERT INTO usr_last"
sprintf (Query,"INSERT INTO usr_last (UsrCod,LastCrs,LastTab,LastTime)" " (UsrCod,WhatToSearch,LastCrs,LastTab,LastTime,LastAccessNotif)"
" VALUES ('%ld','%ld','%u',NOW())", " VALUES"
" ('%ld','%u','%ld','%u',NOW(),FROM_UNIXTIME('%ld'))",
Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Sch_SEARCH_ALL,
Gbl.CurrentCrs.Crs.CrsCod, Gbl.CurrentCrs.Crs.CrsCod,
(unsigned) Gbl.Action.Tab); (unsigned) Gbl.Action.Tab,
(long) (time_t) 0); // The user never accessed to notifications
DB_QueryINSERT (Query,"can not insert last user's data"); DB_QueryINSERT (Query,"can not insert last user's data");
} }
/*****************************************************************************/ /*****************************************************************************/