Version 16.155.13

This commit is contained in:
Antonio Cañas Vargas 2017-03-12 16:39:16 +01:00
parent 9de3b7d774
commit 6b643a722b
5 changed files with 55 additions and 39 deletions

View File

@ -584,7 +584,7 @@ CREATE TABLE IF NOT EXISTS holidays (
HldTyp TINYINT NOT NULL, HldTyp TINYINT NOT NULL,
StartDate DATE NOT NULL, StartDate DATE NOT NULL,
EndDate DATE NOT NULL, EndDate DATE NOT NULL,
Name VARCHAR(127) NOT NULL, Name VARCHAR(2047) NOT NULL,
UNIQUE INDEX(HldCod), UNIQUE INDEX(HldCod),
INDEX(InsCod), INDEX(InsCod),
INDEX(PlcCod)); INDEX(PlcCod));

View File

@ -207,13 +207,17 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.155.12 (2017-03-12)" #define Log_PLATFORM_VERSION "SWAD 16.155.13 (2017-03-12)"
#define CSS_FILE "swad16.147.css" #define CSS_FILE "swad16.147.css"
#define JS_FILE "swad16.144.js" #define JS_FILE "swad16.144.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 16.155.13:Mar 11, 2017 Adjusting size of database fields. (216734 lines)
1 change necessary in database:
ALTER TABLE holidays CHANGE COLUMN Name Name VARCHAR(2047) NOT NULL;
Version 16.155.12:Mar 12, 2017 Fixed bug while sending a message to several users, reported by Javier Fernández Baldomero. (216721 lines) Version 16.155.12:Mar 12, 2017 Fixed bug while sending a message to several users, reported by Javier Fernández Baldomero. (216721 lines)
Version 16.155.11:Mar 11, 2017 Adjusting size of database fields. (216711 lines) Version 16.155.11:Mar 11, 2017 Adjusting size of database fields. (216711 lines)
1 change necessary in database: 1 change necessary in database:

View File

@ -1246,39 +1246,39 @@ mysql> DESCRIBE hidden_params;
4 rows in set (0.00 sec) 4 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS hidden_params (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS hidden_params ("
"SessionId CHAR(43) NOT NULL," "SessionId CHAR(43) NOT NULL,"
"Action INT NOT NULL," "Action INT NOT NULL,"
"ParamName VARCHAR(255) NOT NULL," "ParamName VARCHAR(255) NOT NULL,"
"ParamValue TEXT NOT NULL," "ParamValue TEXT NOT NULL,"
"INDEX(SessionId,Action))"); "INDEX(SessionId,Action))");
/***** Table holidays *****/ /***** Table holidays *****/
/* /*
mysql> DESCRIBE holidays; mysql> DESCRIBE holidays;
+-----------+--------------+------+-----+---------+----------------+ +-----------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+----------------+ +-----------+---------------+------+-----+---------+----------------+
| HldCod | int(11) | NO | PRI | NULL | auto_increment | | HldCod | int(11) | NO | PRI | NULL | auto_increment |
| InsCod | int(11) | NO | MUL | NULL | | | InsCod | int(11) | NO | MUL | NULL | |
| PlcCod | int(11) | NO | MUL | -1 | | | PlcCod | int(11) | NO | MUL | -1 | |
| HldTyp | tinyint(4) | NO | | NULL | | | HldTyp | tinyint(4) | NO | | NULL | |
| StartDate | date | NO | | NULL | | | StartDate | date | NO | | NULL | |
| EndDate | date | NO | | NULL | | | EndDate | date | NO | | NULL | |
| Name | varchar(127) | NO | | NULL | | | Name | varchar(2047) | NO | | NULL | |
+-----------+--------------+------+-----+---------+----------------+ +-----------+---------------+------+-----+---------+----------------+
7 rows in set (0.00 sec) 7 rows in set (0,00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS holidays (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS holidays ("
"HldCod INT NOT NULL AUTO_INCREMENT," "HldCod INT NOT NULL AUTO_INCREMENT,"
"InsCod INT NOT NULL," "InsCod INT NOT NULL,"
"PlcCod INT NOT NULL DEFAULT -1," "PlcCod INT NOT NULL DEFAULT -1,"
"HldTyp TINYINT NOT NULL," "HldTyp TINYINT NOT NULL,"
"StartDate DATE NOT NULL," "StartDate DATE NOT NULL,"
"EndDate DATE NOT NULL," "EndDate DATE NOT NULL,"
"Name VARCHAR(127) NOT NULL," "Name VARCHAR(2047) NOT NULL," // Hld_MAX_BYTES_HOLIDAY_NAME
"UNIQUE INDEX (HldCod)," "UNIQUE INDEX (HldCod),"
"INDEX(InsCod)," "INDEX(InsCod),"
"INDEX(PlcCod))"); "INDEX(PlcCod))");
/***** Table institutions *****/ /***** Table institutions *****/
/* /*

View File

@ -241,7 +241,7 @@ void Hld_EditHolidays (void)
void Hld_GetListHolidays (void) void Hld_GetListHolidays (void)
{ {
char OrderBySubQuery[256]; char OrderBySubQuery[256];
char Query[1024]; char Query[2048];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumHld; unsigned NumHld;
@ -352,7 +352,7 @@ void Hld_GetListHolidays (void)
static void Hld_GetDataOfHolidayByCod (struct Holiday *Hld) static void Hld_GetDataOfHolidayByCod (struct Holiday *Hld)
{ {
char Query[1024]; char Query[2048];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
@ -642,7 +642,8 @@ void Hld_RemoveHoliday (void)
Hld_GetDataOfHolidayByCod (&Hld); Hld_GetDataOfHolidayByCod (&Hld);
/***** Remove holiday *****/ /***** Remove holiday *****/
sprintf (Query,"DELETE FROM holidays WHERE HldCod='%ld'",Hld.HldCod); sprintf (Query,"DELETE FROM holidays WHERE HldCod='%ld'",
Hld.HldCod);
DB_QueryDELETE (Query,"can not remove a holiday"); DB_QueryDELETE (Query,"can not remove a holiday");
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
@ -661,7 +662,7 @@ void Hld_RemoveHoliday (void)
void Hld_ChangeHolidayPlace (void) void Hld_ChangeHolidayPlace (void)
{ {
extern const char *Txt_The_place_of_the_holiday_X_has_changed_to_Y; extern const char *Txt_The_place_of_the_holiday_X_has_changed_to_Y;
char Query[512]; char Query[128];
struct Holiday *Hld; struct Holiday *Hld;
struct Place NewPlace; struct Place NewPlace;
@ -761,7 +762,7 @@ void Hld_ChangeEndDate (void)
static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate) static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate)
{ {
extern const char *Txt_The_date_of_the_holiday_X_has_changed_to_Y; extern const char *Txt_The_date_of_the_holiday_X_has_changed_to_Y;
char Query[512]; char Query[128];
struct Holiday *Hld; struct Holiday *Hld;
struct Date NewDate; struct Date NewDate;
struct Date *PtrDate = NULL; // Initialized to avoid warning struct Date *PtrDate = NULL; // Initialized to avoid warning
@ -840,7 +841,7 @@ void Hld_RenameHoliday (void)
extern const char *Txt_You_can_not_leave_the_name_of_the_holiday_X_empty; extern const char *Txt_You_can_not_leave_the_name_of_the_holiday_X_empty;
extern const char *Txt_The_name_of_the_holiday_X_has_changed_to_Y; extern const char *Txt_The_name_of_the_holiday_X_has_changed_to_Y;
extern const char *Txt_The_name_of_the_holiday_X_has_not_changed; extern const char *Txt_The_name_of_the_holiday_X_has_not_changed;
char Query[512]; char Query[128 + Hld_MAX_BYTES_HOLIDAY_NAME];
struct Holiday *Hld; struct Holiday *Hld;
char NewHldName[Hld_MAX_BYTES_HOLIDAY_NAME + 1]; char NewHldName[Hld_MAX_BYTES_HOLIDAY_NAME + 1];
@ -1121,10 +1122,11 @@ void Hld_RecFormNewHoliday (void)
static void Hld_CreateHoliday (struct Holiday *Hld) static void Hld_CreateHoliday (struct Holiday *Hld)
{ {
extern const char *Txt_Created_new_holiday_X; extern const char *Txt_Created_new_holiday_X;
char Query[1024]; char Query[256 + Hld_MAX_BYTES_HOLIDAY_NAME];
/***** Create a new holiday or no school period *****/ /***** Create a new holiday or no school period *****/
sprintf (Query,"INSERT INTO holidays (InsCod,PlcCod,HldTyp,StartDate,EndDate,Name)" sprintf (Query,"INSERT INTO holidays"
" (InsCod,PlcCod,HldTyp,StartDate,EndDate,Name)"
" VALUES ('%ld','%ld','%u','%04u%02u%02u','%04u%02u%02u','%s')", " VALUES ('%ld','%ld','%u','%04u%02u%02u','%04u%02u%02u','%s')",
Gbl.CurrentIns.Ins.InsCod,Hld->PlcCod,(unsigned) Hld->HldTyp, Gbl.CurrentIns.Ins.InsCod,Hld->PlcCod,(unsigned) Hld->HldTyp,
Hld->StartDate.Year, Hld->StartDate.Year,

View File

@ -340,7 +340,8 @@ bool Ses_GetSessionData (void)
void Ses_InsertHiddenParInDB (Act_Action_t Action,const char *ParamName,const char *ParamValue) void Ses_InsertHiddenParInDB (Act_Action_t Action,const char *ParamName,const char *ParamValue)
{ {
char Query[512 + Cns_MAX_BYTES_TEXT]; char *Query;
size_t MaxLength;
/***** Before of inserting the first hidden parameter passed to the next action, /***** Before of inserting the first hidden parameter passed to the next action,
delete all the parameters coming from the previous action *****/ delete all the parameters coming from the previous action *****/
@ -349,12 +350,21 @@ void Ses_InsertHiddenParInDB (Act_Action_t Action,const char *ParamName,const ch
/***** For a unique session-action-parameter, don't insert a parameter more than one time *****/ /***** For a unique session-action-parameter, don't insert a parameter more than one time *****/
if (!Ses_CheckIfHiddenParIsAlreadyInDB (Action,ParamName)) if (!Ses_CheckIfHiddenParIsAlreadyInDB (Action,ParamName))
{ {
/***** Allocate space for query *****/
MaxLength = 256 + Ses_LENGTH_SESSION_ID + strlen (ParamName) + strlen (ParamValue);
if ((Query = (char *) malloc (MaxLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory for query.");
/***** Insert parameter in the database *****/ /***** Insert parameter in the database *****/
sprintf (Query,"INSERT INTO hidden_params (SessionId,Action,ParamName,ParamValue)" sprintf (Query,"INSERT INTO hidden_params"
" (SessionId,Action,ParamName,ParamValue)"
" VALUES ('%s','%d','%s','%s')", " VALUES ('%s','%d','%s','%s')",
Gbl.Session.Id,(int) Action,ParamName,ParamValue); Gbl.Session.Id,(int) Action,ParamName,ParamValue);
DB_QueryINSERT (Query,"can not create hidden parameter"); DB_QueryINSERT (Query,"can not create hidden parameter");
Gbl.HiddenParamsInsertedIntoDB = true; Gbl.HiddenParamsInsertedIntoDB = true;
/***** Free query *****/
free ((void *) Query);
} }
} }