Version 16.155

This commit is contained in:
Antonio Cañas Vargas 2017-03-09 11:16:17 +01:00
parent 1dce7654a1
commit b787992053
14 changed files with 221 additions and 100 deletions

View File

@ -138,8 +138,8 @@ CREATE TABLE IF NOT EXISTS att_usr (
CREATE TABLE IF NOT EXISTS banners (
BanCod INT NOT NULL AUTO_INCREMENT,
Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',
ShortName VARCHAR(32) NOT NULL,
FullName VARCHAR(127) NOT NULL,
ShortName VARCHAR(511) NOT NULL,
FullName VARCHAR(2047) NOT NULL,
Img VARCHAR(255) NOT NULL,
WWW VARCHAR(255) NOT NULL,
UNIQUE INDEX(BanCod),

View File

@ -64,8 +64,11 @@ static void Ban_GetListBanners (const char *Query);
static void Ban_ListBannersForEdition (void);
static void Ban_PutParamBanCod (long BanCod);
static void Ban_ShowOrHideBanner (bool Hide);
static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName);
static bool Ban_CheckIfBannerNameExists (const char *FieldName,const char *Name,long BanCod);
static void Ban_UpdateBanNameDB (long BanCod,const char *FieldName,const char *NewBanName);
static void Ban_PutFormToCreateBanner (void);
static void Ban_PutHeadBanners (void);
static void Ban_CreateBanner (struct Banner *Ban);
@ -544,7 +547,6 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName)
extern const char *Txt_The_banner_X_already_exists;
extern const char *Txt_The_banner_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_banner_X_has_not_changed;
char Query[512];
struct Banner *Ban;
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
@ -602,11 +604,9 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName)
else
{
/* Update the table changing old name by new name */
sprintf (Query,"UPDATE banners SET %s='%s' WHERE BanCod='%ld'",
FieldName,NewBanName,Ban->BanCod);
DB_QueryUPDATE (Query,"can not update the name of a banner");
Ban_UpdateBanNameDB (Ban->BanCod,FieldName,NewBanName);
/***** Write message to show the change made *****/
/* Write message to show the change made */
sprintf (Gbl.Message,Txt_The_banner_X_has_been_renamed_as_Y,
CurrentBanName,NewBanName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
@ -633,7 +633,7 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName)
static bool Ban_CheckIfBannerNameExists (const char *FieldName,const char *Name,long BanCod)
{
char Query[512];
char Query[128 + Ban_MAX_BYTES_FULL_NAME];
/***** Get number of banners with a name from database *****/
sprintf (Query,"SELECT COUNT(*) FROM banners WHERE %s='%s' AND BanCod<>'%ld'",
@ -641,6 +641,20 @@ static bool Ban_CheckIfBannerNameExists (const char *FieldName,const char *Name,
return (DB_QueryCOUNT (Query,"can not check if the name of a banner already existed") != 0);
}
/*****************************************************************************/
/***************** Update banner name in table of banners ********************/
/*****************************************************************************/
static void Ban_UpdateBanNameDB (long BanCod,const char *FieldName,const char *NewBanName)
{
char Query[128 + Ban_MAX_BYTES_FULL_NAME];
/***** Update banner changing old name by new name *****/
sprintf (Query,"UPDATE banners SET %s='%s' WHERE BanCod='%ld'",
FieldName,NewBanName,BanCod);
DB_QueryUPDATE (Query,"can not update the name of a banner");
}
/*****************************************************************************/
/*********************** Change the image of a banner ************************/
/*****************************************************************************/

View File

@ -39,8 +39,8 @@
#define Ban_MAX_CHARS_FULL_NAME (128 - 1) // 127
#define Ban_MAX_BYTES_FULL_NAME ((Ban_MAX_CHARS_FULL_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
#define Ban_MAX_CHARS_IMAGE NAME_MAX
#define Ban_MAX_BYTES_IMAGE Ban_MAX_CHARS_IMAGE
#define Ban_MAX_CHARS_IMAGE NAME_MAX // 255
#define Ban_MAX_BYTES_IMAGE Ban_MAX_CHARS_IMAGE // 255
struct Banner
{

View File

@ -96,8 +96,11 @@ static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt);
static void Ctr_PutParamOtherCtrCod (long CtrCod);
static void Ctr_UpdateCtrInsDB (long CtrCod,long InsCod);
static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFullName);
static bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,long CtrCod,long InsCod);
static void Ctr_UpdateInsNameDB (long CtrCod,const char *FieldName,const char *NewCtrName);
static void Ctr_UpdateCtrWWWDB (long CtrCod,
const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
static void Ctr_PutButtonToGoToCtr (struct Centre *Ctr);
@ -1884,10 +1887,9 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull
extern const char *Txt_The_centre_X_already_exists;
extern const char *Txt_The_centre_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_centre_X_has_not_changed;
char Query[128 + Hie_MAX_BYTES_FULL_NAME];
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
unsigned NaxBytes = 0; // Initialized to avoid warning
unsigned MaxBytes = 0; // Initialized to avoid warning
char *CurrentCtrName = NULL; // Initialized to avoid warning
char NewCtrName[Hie_MAX_BYTES_FULL_NAME + 1];
@ -1896,20 +1898,20 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull
case Cns_SHRT_NAME:
ParamName = "ShortName";
FieldName = "ShortName";
NaxBytes = Hie_MAX_BYTES_SHRT_NAME;
MaxBytes = Hie_MAX_BYTES_SHRT_NAME;
CurrentCtrName = Ctr->ShrtName;
break;
case Cns_FULL_NAME:
ParamName = "FullName";
FieldName = "FullName";
NaxBytes = Hie_MAX_BYTES_FULL_NAME;
MaxBytes = Hie_MAX_BYTES_FULL_NAME;
CurrentCtrName = Ctr->FullName;
break;
}
/***** Get parameters from form *****/
/* Get the new name for the centre */
Par_GetParToText (ParamName,NewCtrName,NaxBytes);
Par_GetParToText (ParamName,NewCtrName,MaxBytes);
/***** Get from the database the old names of the centre *****/
Ctr_GetDataOfCentreByCod (Ctr);
@ -1936,9 +1938,7 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull
else
{
/* Update the table changing old name by new name */
sprintf (Query,"UPDATE centres SET %s='%s' WHERE CtrCod='%ld'",
FieldName,NewCtrName,Ctr->CtrCod);
DB_QueryUPDATE (Query,"can not update the name of a centre");
Ctr_UpdateInsNameDB (Ctr->CtrCod,FieldName,NewCtrName);
/* Write message to show the change made */
sprintf (Gbl.Message,Txt_The_centre_X_has_been_renamed_as_Y,
@ -1946,7 +1946,7 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull
/* Change current centre name in order to display it properly */
Str_Copy (CurrentCtrName,NewCtrName,
NaxBytes);
MaxBytes);
}
}
else // The same name
@ -1970,6 +1970,20 @@ static bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Nam
return (DB_QueryCOUNT (Query,"can not check if the name of a centre already existed") != 0);
}
/*****************************************************************************/
/****************** Update centre name in table of centres *******************/
/*****************************************************************************/
static void Ctr_UpdateInsNameDB (long CtrCod,const char *FieldName,const char *NewCtrName)
{
char Query[128 + Hie_MAX_BYTES_FULL_NAME];
/***** Update centre changing old name by new name */
sprintf (Query,"UPDATE centres SET %s='%s' WHERE CtrCod='%ld'",
FieldName,NewCtrName,CtrCod);
DB_QueryUPDATE (Query,"can not update the name of a centre");
}
/*****************************************************************************/
/************************* Change the URL of a centre ************************/
/*****************************************************************************/

View File

@ -204,13 +204,19 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.154.4 (2017-03-09)"
#define Log_PLATFORM_VERSION "SWAD 16.155 (2017-03-09)"
#define CSS_FILE "swad16.147.css"
#define JS_FILE "swad16.144.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.155: Mar 09, 2017 Adjusting size of database fields.
Code refactoring related with renaming some fields. (216583 lines)
2 changes necessary in database:
ALTER TABLE banners CHANGE COLUMN ShortName ShortName VARCHAR(511) NOT NULL;
ALTER TABLE banners CHANGE COLUMN FullName FullName VARCHAR(2047) NOT NULL;
Version 16.154.4: Mar 09, 2017 Adjusting size of database fields.
Bug fixing related to agendas, assignments and attendance events. (216504 lines)
1 change necessary in database:

View File

@ -33,8 +33,8 @@
/***************************** Public constants ******************************/
/*****************************************************************************/
#define Cns_MAX_CHARS_WWW (256 - 1) // Max. number of chars of a URL
#define Cns_MAX_BYTES_WWW Cns_MAX_CHARS_WWW
#define Cns_MAX_CHARS_WWW (256 - 1) // 255: max. number of chars of a URL
#define Cns_MAX_BYTES_WWW Cns_MAX_CHARS_WWW // 255
#define Cns_MAX_CHARS_IP (3 + 1 + 3 + 1 + 3 + 1 + 3) // 15: max. number of chars of an IP address
// Example: 255.255.255.255

View File

@ -94,8 +94,7 @@ static void Crs_PutHeadCoursesForSeeing (void);
static void Crs_PutHeadCoursesForEdition (void);
static void Crs_RecFormRequestOrCreateCrs (unsigned Status);
static void Crs_GetParamsNewCourse (struct Course *Crs);
static bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod,
long DegCod,unsigned Year);
static void Crs_CreateCourse (struct Course *Crs,unsigned Status);
static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row);
@ -110,6 +109,10 @@ static void Crs_GetShortNamesByCod (long CrsCod,
static void Crs_EmptyCourseCompletely (long CrsCod);
static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName);
static bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod,
long DegCod,unsigned Year);
static void Crs_UpdateCrsNameDB (long CrsCod,const char *FieldName,const char *NewCrsName);
static void Crs_PutButtonToGoToCrs (struct Course *Crs);
static void Crs_PutButtonToRegisterInCrs (struct Course *Crs);
@ -1927,23 +1930,6 @@ static void Crs_GetParamsNewCourse (struct Course *Crs)
Par_GetParToText ("FullName",Crs->FullName,Hie_MAX_BYTES_FULL_NAME);
}
/*****************************************************************************/
/********** Check if the name of course exists in existing courses ***********/
/*****************************************************************************/
static bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod,
long DegCod,unsigned Year)
{
char Query[512];
/***** Get number of courses in a year of a degree and with a name from database *****/
sprintf (Query,"SELECT COUNT(*) FROM courses"
" WHERE DegCod='%ld' AND Year='%u'"
" AND %s='%s' AND CrsCod<>'%ld'",
DegCod,Year,FieldName,Name,CrsCod);
return (DB_QueryCOUNT (Query,"can not check if the name of a course already existed") != 0);
}
/*****************************************************************************/
/************* Add a new requested course to pending requests ****************/
/*****************************************************************************/
@ -2642,7 +2628,6 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull
extern const char *Txt_The_name_of_the_course_X_has_changed_to_Y;
extern const char *Txt_The_name_of_the_course_X_has_not_changed;
extern const char *Txt_You_dont_have_permission_to_edit_this_course;
char Query[128 + Hie_MAX_BYTES_FULL_NAME];
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
unsigned MaxBytes = 0; // Initialized to avoid warning
@ -2697,9 +2682,7 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull
else
{
/* Update the table changing old name by new name */
sprintf (Query,"UPDATE courses SET %s='%s' WHERE CrsCod='%ld'",
FieldName,NewCrsName,Crs->CrsCod);
DB_QueryUPDATE (Query,"can not update the name of a course");
Crs_UpdateCrsNameDB (Crs->CrsCod,FieldName,NewCrsName);
/* Create message to show the change made */
sprintf (Gbl.Message,Txt_The_name_of_the_course_X_has_changed_to_Y,
@ -2722,6 +2705,37 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull
}
}
/*****************************************************************************/
/********** Check if the name of course exists in existing courses ***********/
/*****************************************************************************/
static bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod,
long DegCod,unsigned Year)
{
char Query[256 + Hie_MAX_BYTES_FULL_NAME];
/***** Get number of courses in a year of a degree and with a name from database *****/
sprintf (Query,"SELECT COUNT(*) FROM courses"
" WHERE DegCod='%ld' AND Year='%u'"
" AND %s='%s' AND CrsCod<>'%ld'",
DegCod,Year,FieldName,Name,CrsCod);
return (DB_QueryCOUNT (Query,"can not check if the name of a course already existed") != 0);
}
/*****************************************************************************/
/***************** Update course name in table of courses ********************/
/*****************************************************************************/
static void Crs_UpdateCrsNameDB (long CrsCod,const char *FieldName,const char *NewCrsName)
{
char Query[128 + Hie_MAX_BYTES_FULL_NAME];
/***** Update course changing old name by new name *****/
sprintf (Query,"UPDATE courses SET %s='%s' WHERE CrsCod='%ld'",
FieldName,NewCrsName,CrsCod);
DB_QueryUPDATE (Query,"can not update the name of a course");
}
/*****************************************************************************/
/*********************** Change the status of a course ***********************/
/*****************************************************************************/

View File

@ -322,8 +322,8 @@ mysql> DESCRIBE att_events;
"CommentTchVisible ENUM('N','Y') NOT NULL DEFAULT 'N',"
"Title VARCHAR(2047) NOT NULL," // Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE
"Txt TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"UNIQUE INDEX(AttCod),"
"INDEX(CrsCod,Hidden))");
"UNIQUE INDEX(AttCod),"
"INDEX(CrsCod,Hidden))");
/***** Table att_grp *****/
/*
@ -337,9 +337,9 @@ mysql> DESCRIBE att_grp;
2 rows in set (0.00 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS att_grp ("
"AttCod INT NOT NULL,"
"GrpCod INT NOT NULL,"
"UNIQUE INDEX(AttCod,GrpCod))");
"AttCod INT NOT NULL,"
"GrpCod INT NOT NULL,"
"UNIQUE INDEX(AttCod,GrpCod))");
/***** Table att_usr *****/
/*
@ -356,13 +356,13 @@ mysql> DESCRIBE att_usr;
5 rows in set (0.00 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS att_usr ("
"AttCod INT NOT NULL,"
"UsrCod INT NOT NULL,"
"Present ENUM('N','Y') NOT NULL DEFAULT 'Y',"
"CommentStd TEXT NOT NULL,"
"CommentTch TEXT NOT NULL,"
"UNIQUE INDEX(AttCod,UsrCod),"
"INDEX(UsrCod))");
"AttCod INT NOT NULL,"
"UsrCod INT NOT NULL,"
"Present ENUM('N','Y') NOT NULL DEFAULT 'Y',"
"CommentStd TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"CommentTch TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"UNIQUE INDEX(AttCod,UsrCod),"
"INDEX(UsrCod))");
/***** Table banners *****/
/*
@ -372,22 +372,22 @@ mysql> DESCRIBE banners;
+-----------+---------------+------+-----+---------+----------------+
| BanCod | int(11) | NO | PRI | NULL | auto_increment |
| Hidden | enum('N','Y') | NO | MUL | N | |
| ShortName | varchar(32) | NO | | NULL | |
| FullName | varchar(127) | NO | | NULL | |
| ShortName | varchar(511) | NO | | NULL | |
| FullName | varchar(2047) | NO | | NULL | |
| Img | varchar(255) | NO | | NULL | |
| WWW | varchar(255) | NO | | NULL | |
+-----------+---------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
6 rows in set (0,00 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS banners ("
"BanCod INT NOT NULL AUTO_INCREMENT,"
"Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',"
"ShortName VARCHAR(32) NOT NULL,"
"FullName VARCHAR(127) NOT NULL,"
"Img VARCHAR(255) NOT NULL,"
"WWW VARCHAR(255) NOT NULL,"
"UNIQUE INDEX(BanCod),"
"INDEX(Hidden))");
"BanCod INT NOT NULL AUTO_INCREMENT,"
"Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',"
"ShortName VARCHAR(511) NOT NULL," // Ban_MAX_BYTES_SHRT_NAME
"FullName VARCHAR(2047) NOT NULL," // Ban_MAX_BYTES_FULL_NAME
"Img VARCHAR(255) NOT NULL," // Ban_MAX_BYTES_IMAGE
"WWW VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW
"UNIQUE INDEX(BanCod),"
"INDEX(Hidden))");
/***** Table birthdays_today *****/
// Stores birthdays already congratulated today

View File

@ -104,8 +104,11 @@ static void Deg_RecFormRequestOrCreateDeg (unsigned Status);
static void Deg_PutParamOtherDegCod (long DegCod);
static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row);
static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullName);
static bool Deg_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,long DegCod,long CtrCod);
static void Deg_UpdateDegNameDB (long DegCod,const char *FieldName,const char *NewDegName);
static void Deg_UpdateDegCtrDB (long DegCod,long CtrCod);
static void Deg_UpdateDegWWWDB (long DegCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
@ -1939,7 +1942,6 @@ static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFull
extern const char *Txt_The_degree_X_already_exists;
extern const char *Txt_The_name_of_the_degree_X_has_changed_to_Y;
extern const char *Txt_The_name_of_the_degree_X_has_not_changed;
char Query[512 + Hie_MAX_BYTES_FULL_NAME];
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
unsigned MaxBytes = 0; // Initialized to avoid warning
@ -1991,9 +1993,7 @@ static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFull
else
{
/* Update the table changing old name by new name */
sprintf (Query,"UPDATE degrees SET %s='%s' WHERE DegCod='%ld'",
FieldName,NewDegName,Deg->DegCod);
DB_QueryUPDATE (Query,"can not update the name of a degree");
Deg_UpdateDegNameDB (Deg->DegCod,FieldName,NewDegName);
/* Write message to show the change made */
sprintf (Gbl.Message,Txt_The_name_of_the_degree_X_has_changed_to_Y,
@ -2016,7 +2016,7 @@ static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFull
static bool Deg_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,long DegCod,long CtrCod)
{
char Query[512];
char Query[256 + Hie_MAX_BYTES_FULL_NAME];
/***** Get number of degrees with a type and a name from database *****/
sprintf (Query,"SELECT COUNT(*) FROM degrees"
@ -2025,6 +2025,20 @@ static bool Deg_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Nam
return (DB_QueryCOUNT (Query,"can not check if the name of a degree already existed") != 0);
}
/*****************************************************************************/
/***************** Update degree name in table of degrees ********************/
/*****************************************************************************/
static void Deg_UpdateDegNameDB (long DegCod,const char *FieldName,const char *NewDegName)
{
char Query[128 + Hie_MAX_BYTES_FULL_NAME];
/***** Update degree changing old name by new name *****/
sprintf (Query,"UPDATE degrees SET %s='%s' WHERE DegCod='%ld'",
FieldName,NewDegName,DegCod);
DB_QueryUPDATE (Query,"can not update the name of a degree");
}
/*****************************************************************************/
/************************ Change the centre of a degree **********************/
/*****************************************************************************/

View File

@ -65,8 +65,11 @@ static void Dpt_GetParamDptOrder (void);
static void Dpt_PutIconToEditDpts (void);
static void Dpt_ListDepartmentsForEdition (void);
static void Dpt_PutParamDptCod (long DptCod);
static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName);
static bool Dpt_CheckIfDepartmentNameExists (const char *FieldName,const char *Name,long DptCod);
static void Dpt_UpdateDegNameDB (long DptCod,const char *FieldName,const char *NewDptName);
static void Dpt_PutFormToCreateDepartment (void);
static void Dpt_PutHeadDepartments (void);
static void Dpt_CreateDepartment (struct Department *Dpt);
@ -714,7 +717,6 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
extern const char *Txt_The_department_X_already_exists;
extern const char *Txt_The_department_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_department_X_has_not_changed;
char Query[512];
struct Department *Dpt;
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
@ -772,11 +774,9 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
else
{
/* Update the table changing old name by new name */
sprintf (Query,"UPDATE departments SET %s='%s' WHERE DptCod='%ld'",
FieldName,NewDptName,Dpt->DptCod);
DB_QueryUPDATE (Query,"can not update the name of a department");
Dpt_UpdateDegNameDB (Dpt->DptCod,FieldName,NewDptName);
/***** Write message to show the change made *****/
/* Write message to show the change made */
sprintf (Gbl.Message,Txt_The_department_X_has_been_renamed_as_Y,
CurrentDptName,NewDptName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
@ -802,7 +802,7 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
static bool Dpt_CheckIfDepartmentNameExists (const char *FieldName,const char *Name,long DptCod)
{
char Query[512];
char Query[256 + Hie_MAX_BYTES_FULL_NAME];
/***** Get number of departments with a name from database *****/
sprintf (Query,"SELECT COUNT(*) FROM departments"
@ -811,6 +811,20 @@ static bool Dpt_CheckIfDepartmentNameExists (const char *FieldName,const char *N
return (DB_QueryCOUNT (Query,"can not check if the name of a department already existed") != 0);
}
/*****************************************************************************/
/************* Update department name in table of departments ****************/
/*****************************************************************************/
static void Dpt_UpdateDegNameDB (long DptCod,const char *FieldName,const char *NewDptName)
{
char Query[128 + Hie_MAX_BYTES_FULL_NAME];
/***** Update department changing old name by new name *****/
sprintf (Query,"UPDATE departments SET %s='%s' WHERE DptCod='%ld'",
FieldName,NewDptName,DptCod);
DB_QueryUPDATE (Query,"can not update the name of a department");
}
/******************************************************************************/
/*********************** Change the URL of a department *********************/
/*****************************************************************************/

View File

@ -89,6 +89,7 @@ static long Ins_GetParamOtherInsCod (void);
static void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFullName);
static bool Ins_CheckIfInsNameExistsInCty (const char *FieldName,const char *Name,long InsCod,long CtyCod);
static void Ins_UpdateInsNameDB (long InsCod,const char *FieldName,const char *NewInsName);
static void Ins_UpdateInsCtyDB (long InsCod,long CtyCod);
static void Ins_UpdateInsWWWDB (long InsCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
static void Ins_PutButtonToGoToIns (struct Instit *Ins);
@ -1815,12 +1816,13 @@ static void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtO
/* Update the table changing old name by new name */
Ins_UpdateInsNameDB (Ins->InsCod,FieldName,NewInsName);
/* Write message to show the change made */
/* Create message to show the change made */
sprintf (Gbl.Message,Txt_The_institution_X_has_been_renamed_as_Y,
CurrentInsName,NewInsName);
/* Change current institution name in order to display it properly */
Str_Copy (CurrentInsName,NewInsName,MaxBytes);
Str_Copy (CurrentInsName,NewInsName,
MaxBytes);
}
}
else // The same name

View File

@ -63,8 +63,11 @@ static void Lnk_WriteListOfLinks (void);
static void Lnk_ListLinksForEdition (void);
static void Lnk_PutParamLnkCod (long LnkCod);
static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName);
static bool Lnk_CheckIfLinkNameExists (const char *FieldName,const char *Name,long LnkCod);
static void Lnk_UpdateLnkNameDB (long LnkCod,const char *FieldName,const char *NewLnkName);
static void Lnk_PutFormToCreateLink (void);
static void Lnk_PutHeadLinks (void);
static void Lnk_CreateLink (struct Link *Lnk);
@ -471,7 +474,6 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName)
extern const char *Txt_The_link_X_already_exists;
extern const char *Txt_The_link_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_link_X_has_not_changed;
char Query[512];
struct Link *Lnk;
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
@ -529,11 +531,9 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName)
else
{
/* Update the table changing old name by new name */
sprintf (Query,"UPDATE links SET %s='%s' WHERE LnkCod='%ld'",
FieldName,NewLnkName,Lnk->LnkCod);
DB_QueryUPDATE (Query,"can not update the name of an institutional link");
Lnk_UpdateLnkNameDB (Lnk->LnkCod,FieldName,NewLnkName);
/***** Write message to show the change made *****/
/* Write message to show the change made */
sprintf (Gbl.Message,Txt_The_link_X_has_been_renamed_as_Y,
CurrentLnkName,NewLnkName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
@ -559,7 +559,7 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName)
static bool Lnk_CheckIfLinkNameExists (const char *FieldName,const char *Name,long LnkCod)
{
char Query[512];
char Query[256 + Lnk_MAX_BYTES_LINK_FULL_NAME];
/***** Get number of links with a name from database *****/
sprintf (Query,"SELECT COUNT(*) FROM links WHERE %s='%s' AND LnkCod<>'%ld'",
@ -567,6 +567,20 @@ static bool Lnk_CheckIfLinkNameExists (const char *FieldName,const char *Name,lo
return (DB_QueryCOUNT (Query,"can not check if the name of an institutional link already existed") != 0);
}
/*****************************************************************************/
/************ Update link name in table of institutional links ***************/
/*****************************************************************************/
static void Lnk_UpdateLnkNameDB (long LnkCod,const char *FieldName,const char *NewLnkName)
{
char Query[128 + Lnk_MAX_BYTES_LINK_FULL_NAME];
/***** Update institutional link changing old name by new name */
sprintf (Query,"UPDATE links SET %s='%s' WHERE LnkCod='%ld'",
FieldName,NewLnkName,LnkCod);
DB_QueryUPDATE (Query,"can not update the name of an institutional link");
}
/*****************************************************************************/
/**************** Change the WWW of an institutional link ********************/
/*****************************************************************************/

View File

@ -72,8 +72,11 @@ static bool Mai_CheckIfMailDomainIsAllowedForNotif (const char MailDomain[Mai_MA
static void Mai_ListMailDomainsForEdition (void);
static void Mai_PutParamMaiCod (long MaiCod);
static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName);
static bool Mai_CheckIfMailDomainNameExists (const char *FieldName,const char *Name,long MaiCod);
static void Mai_UpdateMailDomainNameDB (long MaiCod,const char *FieldName,const char *NewMaiName);
static void Mai_PutFormToCreateMailDomain (void);
static void Mai_PutHeadMailDomains (void);
static void Mai_CreateMailDomain (struct Mail *Mai);
@ -592,7 +595,6 @@ static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName)
extern const char *Txt_The_email_domain_X_already_exists;
extern const char *Txt_The_email_domain_X_has_been_renamed_as_Y;
extern const char *Txt_The_email_domain_X_has_not_changed;
char Query[512];
struct Mail *Mai;
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
@ -650,11 +652,9 @@ static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName)
else
{
/* Update the table changing old name by new name */
sprintf (Query,"UPDATE mail_domains SET %s='%s' WHERE MaiCod='%ld'",
FieldName,NewMaiName,Mai->MaiCod);
DB_QueryUPDATE (Query,"can not update the name of a mail domain");
Mai_UpdateMailDomainNameDB (Mai->MaiCod,FieldName,NewMaiName);
/***** Write message to show the change made *****/
/* Write message to show the change made */
sprintf (Gbl.Message,Txt_The_email_domain_X_has_been_renamed_as_Y,
CurrentMaiName,NewMaiName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
@ -680,14 +680,29 @@ static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName)
static bool Mai_CheckIfMailDomainNameExists (const char *FieldName,const char *Name,long MaiCod)
{
char Query[512];
char Query[256 + Mai_MAX_BYTES_MAIL_INFO];
/***** Get number of mail_domains with a name from database *****/
sprintf (Query,"SELECT COUNT(*) FROM mail_domains WHERE %s='%s' AND MaiCod<>'%ld'",
sprintf (Query,"SELECT COUNT(*) FROM mail_domains"
" WHERE %s='%s' AND MaiCod<>'%ld'",
FieldName,Name,MaiCod);
return (DB_QueryCOUNT (Query,"can not check if the name of a mail domain already existed") != 0);
}
/*****************************************************************************/
/****************** Update name in table of mail domains *********************/
/*****************************************************************************/
static void Mai_UpdateMailDomainNameDB (long MaiCod,const char *FieldName,const char *NewMaiName)
{
char Query[128 + Mai_MAX_BYTES_MAIL_INFO];
/***** Update mail domain changing old name by new name */
sprintf (Query,"UPDATE mail_domains SET %s='%s' WHERE MaiCod='%ld'",
FieldName,NewMaiName,MaiCod);
DB_QueryUPDATE (Query,"can not update the name of a mail domain");
}
/*****************************************************************************/
/*********************** Put a form to create a new mail *********************/
/*****************************************************************************/

View File

@ -62,8 +62,11 @@ static void Plc_GetParamPlcOrder (void);
static void Plc_PutIconToEditPlaces (void);
static void Plc_ListPlacesForEdition (void);
static void Plc_PutParamPlcCod (long PlcCod);
static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName);
static bool Plc_CheckIfPlaceNameExists (const char *FieldName,const char *Name,long PlcCod);
static void Plc_UpdatePlcNameDB (long PlcCod,const char *FieldName,const char *NewPlcName);
static void Plc_PutFormToCreatePlace (void);
static void Plc_PutHeadPlaces (void);
static void Plc_CreatePlace (struct Place *Plc);
@ -591,7 +594,6 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName)
extern const char *Txt_The_place_X_already_exists;
extern const char *Txt_The_place_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_place_X_has_not_changed;
char Query[512];
struct Place *Plc;
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
@ -649,11 +651,9 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName)
else
{
/* Update the table changing old name by new name */
sprintf (Query,"UPDATE places SET %s='%s' WHERE PlcCod='%ld'",
FieldName,NewPlcName,Plc->PlcCod);
DB_QueryUPDATE (Query,"can not update the name of a place");
Plc_UpdatePlcNameDB (Plc->PlcCod,FieldName,NewPlcName);
/***** Write message to show the change made *****/
/* Write message to show the change made */
sprintf (Gbl.Message,Txt_The_place_X_has_been_renamed_as_Y,
CurrentPlcName,NewPlcName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
@ -679,7 +679,7 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName)
static bool Plc_CheckIfPlaceNameExists (const char *FieldName,const char *Name,long PlcCod)
{
char Query[512];
char Query[256 + Plc_MAX_BYTES_PLACE_FULL_NAME];
/***** Get number of places with a name from database *****/
sprintf (Query,"SELECT COUNT(*) FROM places"
@ -688,6 +688,20 @@ static bool Plc_CheckIfPlaceNameExists (const char *FieldName,const char *Name,l
return (DB_QueryCOUNT (Query,"can not check if the name of a place already existed") != 0);
}
/*****************************************************************************/
/****************** Update place name in table of places *********************/
/*****************************************************************************/
static void Plc_UpdatePlcNameDB (long PlcCod,const char *FieldName,const char *NewPlcName)
{
char Query[128 + Plc_MAX_BYTES_PLACE_FULL_NAME];
/***** Update place changing old name by new name */
sprintf (Query,"UPDATE places SET %s='%s' WHERE PlcCod='%ld'",
FieldName,NewPlcName,PlcCod);
DB_QueryUPDATE (Query,"can not update the name of a place");
}
/*****************************************************************************/
/********************* Put a form to create a new place **********************/
/*****************************************************************************/