Version 22.78.11: Mar 23, 2023 Code refactoring in places.

This commit is contained in:
acanas 2023-03-23 18:28:56 +01:00
parent be35a9d058
commit 390c5dcb49
7 changed files with 52 additions and 50 deletions

View File

@ -629,10 +629,11 @@ TODO: Emilce Barrera Mesa: Podr
TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen.
*/
#define Log_PLATFORM_VERSION "SWAD 22.78.10 (2023-03-23)"
#define Log_PLATFORM_VERSION "SWAD 22.78.11 (2023-03-23)"
#define CSS_FILE "swad22.57.1.css"
#define JS_FILE "swad22.49.js"
/*
Version 22.78.11: Mar 23, 2023 Code refactoring in places. (337652 lines)
Version 22.78.10: Mar 23, 2023 Code refactoring in notices. (337650 lines)
Version 22.78.9: Mar 23, 2023 Code refactoring in mail domains. (337657 lines)
Version 22.78.8: Mar 23, 2023 Code refactoring in holidays. (337648 lines)

View File

@ -2374,6 +2374,8 @@ mysql> DESCRIBE not_notices;
"CrsCod INT NOT NULL DEFAULT -1,"
"UsrCod INT NOT NULL,"
"CreatTime DATETIME NOT NULL,"
// TODO: "Subject TEXT NOT NULL," // Cns_MAX_BYTES_SUBJECT
// TODO: "Content TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"Content TEXT NOT NULL,"
"Status TINYINT NOT NULL DEFAULT 0,"
"NumNotif INT NOT NULL DEFAULT 0,"

View File

@ -283,7 +283,7 @@ unsigned For_DB_GetPstSubjectAndContent (MYSQL_RES **mysql_res,long PstCod)
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get subject and content",
"SELECT Subject," // row[0]
"Content" // row[1]
"Content" // row[1]
" FROM for_posts"
" WHERE PstCod=%ld",
PstCod);

View File

@ -53,6 +53,7 @@ struct Not_Notice
long UsrCod;
time_t CreatTime;
Not_Status_t Status;
// TODO: char Subject[Cns_MAX_BYTES_SUBJECT + 1];
char Content[Cns_MAX_BYTES_TEXT + 1];
};

View File

@ -1318,14 +1318,15 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (const struct Usr_Data *ToUsrDat
{
/* Get next event */
row = mysql_fetch_row (mysql_res);
/* row[0]: NotifyEvent
row[1]: FromUsrCod
row[2]: InsCod
row[3]: CtrCod
row[4]: DegCod
row[5]: CrsCod
row[6]: Cod */
/*
row[0]: NotifyEvent
row[1]: FromUsrCod
row[2]: InsCod
row[3]: CtrCod
row[4]: DegCod
row[5]: CrsCod
row[6]: Cod
*/
/* Get event type (row[0]) */
NotifyEvent = Ntf_GetNotifyEventFromStr (row[0]);

View File

@ -68,6 +68,8 @@ static void Plc_PutIconToEditPlaces (void);
static void Plc_EditPlacesInternal (void);
static void Plc_PutIconsEditingPlaces (__attribute__((unused)) void *Args);
static void Plc_GetPlaceDataFromRow (MYSQL_RES *mysql_res,struct Plc_Place *Plc);
static void Plc_ListPlacesForEdition (const struct Plc_Places *Places);
static void Plc_PutParPlcCod (void *PlcCod);
@ -351,9 +353,7 @@ void Plc_PutIconToViewPlaces (void)
void Plc_GetListPlaces (struct Plc_Places *Places)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumPlc;
struct Plc_Place *Plc;
/***** Get places from database *****/
if ((Places->Num = Plc_DB_GetListPlaces (&mysql_res,Places->SelectedOrder))) // Places found...
@ -367,24 +367,7 @@ void Plc_GetListPlaces (struct Plc_Places *Places)
for (NumPlc = 0;
NumPlc < Places->Num;
NumPlc++)
{
Plc = &(Places->Lst[NumPlc]);
/* Get next place */
row = mysql_fetch_row (mysql_res);
/* Get place code (row[0]) */
if ((Plc->PlcCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongPlaceExit ();
/* Get the short (row[1]) and full (row[2]) names of the place */
Str_Copy (Plc->ShrtName,row[1],sizeof (Plc->ShrtName) - 1);
Str_Copy (Plc->FullName,row[2],sizeof (Plc->FullName) - 1);
/* Get number of centers in this place (row[3]) */
if (sscanf (row[3],"%u",&Plc->NumCtrs) != 1)
Plc->NumCtrs = 0;
}
Plc_GetPlaceDataFromRow (mysql_res,&(Places->Lst[NumPlc]));
}
/***** Free structure that stores the query result *****/
@ -392,7 +375,7 @@ void Plc_GetListPlaces (struct Plc_Places *Places)
}
/*****************************************************************************/
/**************************** Get place full name ****************************/
/************************ Get place data using its code **********************/
/*****************************************************************************/
void Plc_GetPlaceDataByCod (struct Plc_Place *Plc)
@ -400,7 +383,6 @@ void Plc_GetPlaceDataByCod (struct Plc_Place *Plc)
extern const char *Txt_Place_unspecified;
extern const char *Txt_Another_place;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
/***** Clear data *****/
Plc->ShrtName[0] = '\0';
@ -422,24 +404,37 @@ void Plc_GetPlaceDataByCod (struct Plc_Place *Plc)
{
/***** Get data of a place from database *****/
if (Plc_DB_GetPlaceDataByCod (&mysql_res,Plc->PlcCod)) // Place found...
{
/* Get row */
row = mysql_fetch_row (mysql_res);
/* Get the short (row[0]) and full (row[1]) names of the place */
Str_Copy (Plc->ShrtName,row[0],sizeof (Plc->ShrtName) - 1);
Str_Copy (Plc->FullName,row[1],sizeof (Plc->FullName) - 1);
/* Get number of centers in this place (row[2]) */
if (sscanf (row[2],"%u",&Plc->NumCtrs) != 1)
Plc->NumCtrs = 0;
}
Plc_GetPlaceDataFromRow (mysql_res,Plc);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
}
/*****************************************************************************/
/********************** Get place data from database row *********************/
/*****************************************************************************/
static void Plc_GetPlaceDataFromRow (MYSQL_RES *mysql_res,struct Plc_Place *Plc)
{
MYSQL_ROW row;
/***** Get row *****/
row = mysql_fetch_row (mysql_res);
/***** Get place code (row[0]) *****/
if ((Plc->PlcCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongPlaceExit ();
/***** Get the short (row[1]) and full (row[2]) names of the place *****/
Str_Copy (Plc->ShrtName,row[1],sizeof (Plc->ShrtName) - 1);
Str_Copy (Plc->FullName,row[2],sizeof (Plc->FullName) - 1);
/***** Get number of centers in this place (row[3]) *****/
if (sscanf (row[3],"%u",&Plc->NumCtrs) != 1)
Plc->NumCtrs = 0;
}
/*****************************************************************************/
/**************************** Free list of places ****************************/
/*****************************************************************************/

View File

@ -119,9 +119,10 @@ unsigned Plc_DB_GetPlaceDataByCod (MYSQL_RES **mysql_res,long PlcCod)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get data of a place",
"(SELECT plc_places.ShortName," // row[0]
"plc_places.FullName," // row[1]
"COUNT(*)" // row[2]
"(SELECT plc_places.PlcCod," // row[0]
"plc_places.ShortName," // row[1]
"plc_places.FullName," // row[2]
"COUNT(*)" // row[3]
" FROM plc_places,"
"ctr_centers"
" WHERE plc_places.PlcCod=%ld"
@ -129,9 +130,10 @@ unsigned Plc_DB_GetPlaceDataByCod (MYSQL_RES **mysql_res,long PlcCod)
" AND ctr_centers.PlcCod=%ld"
" GROUP BY plc_places.PlcCod)"
" UNION "
"(SELECT ShortName," // row[0]
"FullName," // row[1]
"0" // row[2]
"(SELECT PlcCod," // row[0]
"ShortName," // row[1]
"FullName," // row[2]
"0" // row[3]
" FROM plc_places"
" WHERE PlcCod=%ld"
" AND PlcCod NOT IN"