mirror of
https://github.com/acanas/swad-core.git
synced 2024-09-20 00:02:42 +02:00
Version 20.31: Feb 15, 2021 Code refactoring in copy, concat and sprintf.
This commit is contained in:
parent
87083fe7d8
commit
8ce0f8c6b5
343
swad_API.c
343
swad_API.c
|
@ -225,8 +225,8 @@ static int API_RemoveOldWSKeys (struct soap *soap);
|
||||||
static int API_GetCurrentDegCodFromCurrentCrsCod (void);
|
static int API_GetCurrentDegCodFromCurrentCrsCod (void);
|
||||||
static bool API_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod);
|
static bool API_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod);
|
||||||
|
|
||||||
static int API_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
|
static int API_CheckParamsNewAccount (char *NewNickWithArroba, // Input
|
||||||
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1], // Output
|
char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1], // Output
|
||||||
char *NewEmail, // Input-output
|
char *NewEmail, // Input-output
|
||||||
char *NewPlainPassword, // Input
|
char *NewPlainPassword, // Input
|
||||||
char *NewEncryptedPassword); // Output
|
char *NewEncryptedPassword); // Output
|
||||||
|
@ -531,8 +531,7 @@ static int API_GenerateNewWSKey (struct soap *soap,
|
||||||
return ReturnCode;
|
return ReturnCode;
|
||||||
|
|
||||||
/***** Create a unique name for the key *****/
|
/***** Create a unique name for the key *****/
|
||||||
Str_Copy (WSKey,Gbl.UniqueNameEncrypted,
|
Str_Copy (WSKey,Gbl.UniqueNameEncrypted,API_BYTES_WS_KEY);
|
||||||
API_BYTES_WS_KEY);
|
|
||||||
|
|
||||||
/***** Check that key does not exist in database *****/
|
/***** Check that key does not exist in database *****/
|
||||||
if (DB_QueryCOUNT ("can not get existence of key",
|
if (DB_QueryCOUNT ("can not get existence of key",
|
||||||
|
@ -629,16 +628,12 @@ static bool API_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod)
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get user's name */
|
/* Get user's name */
|
||||||
Str_Copy (UsrDat->Surname1,row[0],
|
Str_Copy (UsrDat->Surname1,row[0],sizeof (UsrDat->Surname1) - 1);
|
||||||
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
Str_Copy (UsrDat->Surname2,row[1],sizeof (UsrDat->Surname2) - 1);
|
||||||
Str_Copy (UsrDat->Surname2,row[1],
|
Str_Copy (UsrDat->FrstName,row[2],sizeof (UsrDat->FrstName) - 1);
|
||||||
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
|
||||||
Str_Copy (UsrDat->FirstName,row[2],
|
|
||||||
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
|
||||||
|
|
||||||
/* Get user's photo */
|
/* Get user's photo */
|
||||||
Str_Copy (UsrDat->Photo,row[3],
|
Str_Copy (UsrDat->Photo ,row[3],sizeof (UsrDat->Photo ) - 1);
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
|
||||||
|
|
||||||
/* Get user's brithday */
|
/* Get user's brithday */
|
||||||
Dat_GetDateFromYYYYMMDD (&(UsrDat->Birthday),row[4]);
|
Dat_GetDateFromYYYYMMDD (&(UsrDat->Birthday),row[4]);
|
||||||
|
@ -739,7 +734,7 @@ int swad__createAccount (struct soap *soap,
|
||||||
char *userNickname,char *userEmail,char *userPassword,char *appKey, // input
|
char *userNickname,char *userEmail,char *userPassword,char *appKey, // input
|
||||||
struct swad__createAccountOutput *createAccountOut) // output
|
struct swad__createAccountOutput *createAccountOut) // output
|
||||||
{
|
{
|
||||||
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
||||||
char NewEncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1];
|
char NewEncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1];
|
||||||
int Result;
|
int Result;
|
||||||
int ReturnCode;
|
int ReturnCode;
|
||||||
|
@ -761,7 +756,7 @@ int swad__createAccount (struct soap *soap,
|
||||||
|
|
||||||
/***** Check parameters used to create the new account *****/
|
/***** Check parameters used to create the new account *****/
|
||||||
Result = API_CheckParamsNewAccount (userNickname, // Input
|
Result = API_CheckParamsNewAccount (userNickname, // Input
|
||||||
NewNicknameWithoutArroba,// Output
|
NewNickWithoutArroba,// Output
|
||||||
userEmail, // Input-output
|
userEmail, // Input-output
|
||||||
userPassword, // Input
|
userPassword, // Input
|
||||||
NewEncryptedPassword); // Output
|
NewEncryptedPassword); // Output
|
||||||
|
@ -777,23 +772,23 @@ int swad__createAccount (struct soap *soap,
|
||||||
|
|
||||||
/***** Set password to the password typed by the user *****/
|
/***** Set password to the password typed by the user *****/
|
||||||
Str_Copy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword,
|
Str_Copy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword,
|
||||||
Pwd_BYTES_ENCRYPTED_PASSWORD);
|
sizeof (Gbl.Usrs.Me.UsrDat.Password) - 1);
|
||||||
|
|
||||||
/***** User does not exist in the platform, so create him/her! *****/
|
/***** User does not exist in the platform, so create him/her! *****/
|
||||||
Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat,
|
Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat,
|
||||||
true); // I am creating my own account
|
true); // I am creating my own account
|
||||||
|
|
||||||
/***** Save nickname *****/
|
/***** Save nickname *****/
|
||||||
Nck_UpdateNickInDB (Gbl.Usrs.Me.UsrDat.UsrCod,NewNicknameWithoutArroba);
|
Nck_UpdateNickInDB (Gbl.Usrs.Me.UsrDat.UsrCod,NewNickWithoutArroba);
|
||||||
Str_Copy (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba,
|
Str_Copy (Gbl.Usrs.Me.UsrDat.Nickname,NewNickWithoutArroba,
|
||||||
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
|
sizeof (Gbl.Usrs.Me.UsrDat.Nickname) - 1);
|
||||||
|
|
||||||
/***** Save email *****/
|
/***** Save email *****/
|
||||||
if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,userEmail))
|
if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,userEmail))
|
||||||
{
|
{
|
||||||
/* Email updated sucessfully */
|
/* Email updated sucessfully */
|
||||||
Str_Copy (Gbl.Usrs.Me.UsrDat.Email,userEmail,
|
Str_Copy (Gbl.Usrs.Me.UsrDat.Email,userEmail,
|
||||||
Cns_MAX_BYTES_EMAIL_ADDRESS);
|
sizeof (Gbl.Usrs.Me.UsrDat.Email) - 1);
|
||||||
Gbl.Usrs.Me.UsrDat.EmailConfirmed = false;
|
Gbl.Usrs.Me.UsrDat.EmailConfirmed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,26 +806,26 @@ int swad__createAccount (struct soap *soap,
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Return false on error
|
// Return false on error
|
||||||
//char *userNickname,char *userEmail,char *userID,char *userPassword
|
//char *userNickname,char *userEmail,char *userID,char *userPassword
|
||||||
static int API_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
|
static int API_CheckParamsNewAccount (char *NewNickWithArroba, // Input
|
||||||
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1], // Output
|
char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1], // Output
|
||||||
char *NewEmail, // Input-output
|
char *NewEmail, // Input-output
|
||||||
char *NewPlainPassword, // Input
|
char *NewPlainPassword, // Input
|
||||||
char *NewEncryptedPassword) // Output
|
char *NewEncryptedPassword) // Output
|
||||||
{
|
{
|
||||||
/***** Step 1/3: Check new nickname *****/
|
/***** Step 1/3: Check new nickname *****/
|
||||||
/* Make a copy without possible starting arrobas */
|
/* Make a copy without possible starting arrobas */
|
||||||
Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
|
Str_Copy (NewNickWithoutArroba,NewNickWithArroba,
|
||||||
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
|
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
|
||||||
if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid
|
if (Nck_CheckIfNickWithArrobaIsValid (NewNickWithArroba)) // If new nickname is valid
|
||||||
{
|
{
|
||||||
/***** Remove arrobas at the beginning *****/
|
/***** Remove arrobas at the beginning *****/
|
||||||
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
|
Str_RemoveLeadingArrobas (NewNickWithoutArroba);
|
||||||
|
|
||||||
/***** Check if the new nickname matches any of the nicknames of other users *****/
|
/***** Check if the new nickname matches any of the nicknames of other users *****/
|
||||||
if (DB_QueryCOUNT ("can not check if nickname already existed",
|
if (DB_QueryCOUNT ("can not check if nickname already existed",
|
||||||
"SELECT COUNT(*) FROM usr_nicknames"
|
"SELECT COUNT(*) FROM usr_nicknames"
|
||||||
" WHERE Nickname='%s'",
|
" WHERE Nickname='%s'",
|
||||||
NewNicknameWithoutArroba)) // A nickname of another user is the same that this nickname
|
NewNickWithoutArroba)) // A nickname of another user is the same that this nickname
|
||||||
return API_CHECK_NEW_ACCOUNT_NICKNAME_REGISTERED_BY_ANOTHER_USER;
|
return API_CHECK_NEW_ACCOUNT_NICKNAME_REGISTERED_BY_ANOTHER_USER;
|
||||||
}
|
}
|
||||||
else // New nickname is not valid
|
else // New nickname is not valid
|
||||||
|
@ -905,8 +900,7 @@ int swad__loginByUserPasswordKey (struct soap *soap,
|
||||||
return ReturnCode;
|
return ReturnCode;
|
||||||
|
|
||||||
/***** Check if user's email, @nickname or ID are valid *****/
|
/***** Check if user's email, @nickname or ID are valid *****/
|
||||||
Str_Copy (UsrIDNickOrEmail,userID,
|
Str_Copy (UsrIDNickOrEmail,userID,sizeof (UsrIDNickOrEmail) - 1);
|
||||||
Cns_MAX_BYTES_EMAIL_ADDRESS);
|
|
||||||
if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname
|
if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname
|
||||||
{
|
{
|
||||||
Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
|
Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
|
||||||
|
@ -998,7 +992,7 @@ int swad__loginByUserPasswordKey (struct soap *soap,
|
||||||
Gbl.Usrs.Me.UsrDat.Surname2,
|
Gbl.Usrs.Me.UsrDat.Surname2,
|
||||||
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
||||||
Str_Copy (loginByUserPasswordKeyOut->userFirstname,
|
Str_Copy (loginByUserPasswordKeyOut->userFirstname,
|
||||||
Gbl.Usrs.Me.UsrDat.FirstName,
|
Gbl.Usrs.Me.UsrDat.FrstName,
|
||||||
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
||||||
|
|
||||||
Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL);
|
Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL);
|
||||||
|
@ -1155,12 +1149,11 @@ int swad__loginBySessionKey (struct soap *soap,
|
||||||
Gbl.Usrs.Me.UsrDat.Surname2,
|
Gbl.Usrs.Me.UsrDat.Surname2,
|
||||||
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
||||||
Str_Copy (loginBySessionKeyOut->userFirstname,
|
Str_Copy (loginBySessionKeyOut->userFirstname,
|
||||||
Gbl.Usrs.Me.UsrDat.FirstName,
|
Gbl.Usrs.Me.UsrDat.FrstName,
|
||||||
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
||||||
|
|
||||||
Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL);
|
Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL);
|
||||||
Str_Copy (loginBySessionKeyOut->userPhoto,PhotoURL,
|
Str_Copy (loginBySessionKeyOut->userPhoto,PhotoURL,Cns_MAX_BYTES_WWW);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
|
|
||||||
Str_Copy (loginBySessionKeyOut->userBirthday,
|
Str_Copy (loginBySessionKeyOut->userBirthday,
|
||||||
Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,
|
Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,
|
||||||
|
@ -1274,8 +1267,7 @@ int swad__getNewPassword (struct soap *soap,
|
||||||
return ReturnCode;
|
return ReturnCode;
|
||||||
|
|
||||||
/***** Check if user's email, @nickname or ID are valid *****/
|
/***** Check if user's email, @nickname or ID are valid *****/
|
||||||
Str_Copy (UsrIDNickOrEmail,userID,
|
Str_Copy (UsrIDNickOrEmail,userID,sizeof (UsrIDNickOrEmail) - 1);
|
||||||
Cns_MAX_BYTES_EMAIL_ADDRESS);
|
|
||||||
if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname
|
if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname
|
||||||
{
|
{
|
||||||
Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
|
Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
|
||||||
|
@ -1414,14 +1406,14 @@ int swad__getCourses (struct soap *soap,
|
||||||
/* Get course short name (row[1]) */
|
/* Get course short name (row[1]) */
|
||||||
getCoursesOut->coursesArray.__ptr[NumRow].courseShortName =
|
getCoursesOut->coursesArray.__ptr[NumRow].courseShortName =
|
||||||
(char *) soap_malloc (soap,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1);
|
(char *) soap_malloc (soap,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1);
|
||||||
Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseShortName,row[1],
|
Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseShortName,
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
row[1],Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
||||||
|
|
||||||
/* Get course full name (row[2]) */
|
/* Get course full name (row[2]) */
|
||||||
getCoursesOut->coursesArray.__ptr[NumRow].courseFullName =
|
getCoursesOut->coursesArray.__ptr[NumRow].courseFullName =
|
||||||
(char *) soap_malloc (soap,Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1);
|
(char *) soap_malloc (soap,Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1);
|
||||||
Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseFullName,row[2],
|
Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseFullName,
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
row[2],Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
||||||
|
|
||||||
/* Get role (row[3]) */
|
/* Get role (row[3]) */
|
||||||
if (sscanf (row[3],"%u",&Role) != 1) // Role in this course
|
if (sscanf (row[3],"%u",&Role) != 1) // Role in this course
|
||||||
|
@ -1531,8 +1523,7 @@ int swad__getCourseInfo (struct soap *soap,
|
||||||
&InfoSrc,&MustBeRead);
|
&InfoSrc,&MustBeRead);
|
||||||
Length = strlen (NamesInWSForInfoSrc[InfoSrc]);
|
Length = strlen (NamesInWSForInfoSrc[InfoSrc]);
|
||||||
getCourseInfo->infoSrc = (char *) soap_malloc (soap,Length + 1);
|
getCourseInfo->infoSrc = (char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getCourseInfo->infoSrc,NamesInWSForInfoSrc[InfoSrc],
|
Str_Copy (getCourseInfo->infoSrc,NamesInWSForInfoSrc[InfoSrc],Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
/***** Get info text *****/
|
/***** Get info text *****/
|
||||||
getCourseInfo->infoTxt = NULL;
|
getCourseInfo->infoTxt = NULL;
|
||||||
|
@ -1596,8 +1587,7 @@ static int API_WriteSyllabusIntoHTMLBuffer (struct soap *soap,
|
||||||
if (Syl_LstItemsSyllabus.NumItems)
|
if (Syl_LstItemsSyllabus.NumItems)
|
||||||
{
|
{
|
||||||
/***** Create a unique name for the file *****/
|
/***** Create a unique name for the file *****/
|
||||||
snprintf (FileNameHTMLTmp,sizeof (FileNameHTMLTmp),
|
snprintf (FileNameHTMLTmp,sizeof (FileNameHTMLTmp),"%s/%s_syllabus.html",
|
||||||
"%s/%s_syllabus.html",
|
|
||||||
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
||||||
|
|
||||||
/***** Create a new temporary file for writing and reading *****/
|
/***** Create a new temporary file for writing and reading *****/
|
||||||
|
@ -1617,7 +1607,7 @@ static int API_WriteSyllabusIntoHTMLBuffer (struct soap *soap,
|
||||||
Length = (size_t) ftell (FileHTMLTmp);
|
Length = (size_t) ftell (FileHTMLTmp);
|
||||||
|
|
||||||
/* Allocate memory for buffer */
|
/* Allocate memory for buffer */
|
||||||
if ((*HTMLBuffer = (char *) malloc (Length + 1)) == NULL)
|
if ((*HTMLBuffer = malloc (Length + 1)) == NULL)
|
||||||
{
|
{
|
||||||
fclose (FileHTMLTmp);
|
fclose (FileHTMLTmp);
|
||||||
unlink (FileNameHTMLTmp);
|
unlink (FileNameHTMLTmp);
|
||||||
|
@ -1674,8 +1664,7 @@ static int API_WritePlainTextIntoHTMLBuffer (struct soap *soap,
|
||||||
if (TxtHTML[0])
|
if (TxtHTML[0])
|
||||||
{
|
{
|
||||||
/***** Create a unique name for the file *****/
|
/***** Create a unique name for the file *****/
|
||||||
snprintf (FileNameHTMLTmp,sizeof (FileNameHTMLTmp),
|
snprintf (FileNameHTMLTmp,sizeof (FileNameHTMLTmp),"%s/%s_info.html",
|
||||||
"%s/%s_info.html",
|
|
||||||
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
||||||
|
|
||||||
/***** Create a new temporary file for writing and reading *****/
|
/***** Create a new temporary file for writing and reading *****/
|
||||||
|
@ -1707,7 +1696,7 @@ static int API_WritePlainTextIntoHTMLBuffer (struct soap *soap,
|
||||||
Length = (size_t) ftell (FileHTMLTmp);
|
Length = (size_t) ftell (FileHTMLTmp);
|
||||||
|
|
||||||
/***** Allocate memory for buffer *****/
|
/***** Allocate memory for buffer *****/
|
||||||
if ((*HTMLBuffer = (char *) malloc (Length + 1)) == NULL)
|
if ((*HTMLBuffer = malloc (Length + 1)) == NULL)
|
||||||
{
|
{
|
||||||
fclose (FileHTMLTmp);
|
fclose (FileHTMLTmp);
|
||||||
unlink (FileNameHTMLTmp);
|
unlink (FileNameHTMLTmp);
|
||||||
|
@ -1757,16 +1746,14 @@ static int API_WritePageIntoHTMLBuffer (struct soap *soap,
|
||||||
|
|
||||||
/***** Open file with web page *****/
|
/***** Open file with web page *****/
|
||||||
/* 1. Check if index.html exists */
|
/* 1. Check if index.html exists */
|
||||||
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
|
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.html",
|
||||||
"%s/index.html",
|
|
||||||
PathRelDirHTML);
|
PathRelDirHTML);
|
||||||
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
|
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
|
||||||
FileExists = true;
|
FileExists = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* 2. If index.html not exists, try index.htm */
|
/* 2. If index.html not exists, try index.htm */
|
||||||
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
|
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.htm",
|
||||||
"%s/index.htm",
|
|
||||||
PathRelDirHTML);
|
PathRelDirHTML);
|
||||||
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
|
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
|
||||||
FileExists = true;
|
FileExists = true;
|
||||||
|
@ -1785,7 +1772,7 @@ static int API_WritePageIntoHTMLBuffer (struct soap *soap,
|
||||||
fseek (FileHTML,0L,SEEK_SET);
|
fseek (FileHTML,0L,SEEK_SET);
|
||||||
|
|
||||||
/* Allocate memory for buffer */
|
/* Allocate memory for buffer */
|
||||||
if ((*HTMLBuffer = (char *) malloc (Length + 1)) == NULL)
|
if ((*HTMLBuffer = malloc (Length + 1)) == NULL)
|
||||||
{
|
{
|
||||||
fclose (FileHTML);
|
fclose (FileHTML);
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
@ -1957,8 +1944,7 @@ int swad__findUsers (struct soap *soap,
|
||||||
Role = API_SvcRole_to_RolRole[userRole];
|
Role = API_SvcRole_to_RolRole[userRole];
|
||||||
|
|
||||||
/***** Query users beloging to course or group from database *****/
|
/***** Query users beloging to course or group from database *****/
|
||||||
Str_Copy (Gbl.Search.Str,filter,
|
Str_Copy (Gbl.Search.Str,filter,sizeof (Gbl.Search.Str) - 1);
|
||||||
Sch_MAX_BYTES_STRING_TO_FIND);
|
|
||||||
|
|
||||||
if (Gbl.Search.Str[0]) // Search some users
|
if (Gbl.Search.Str[0]) // Search some users
|
||||||
{
|
{
|
||||||
|
@ -2149,8 +2135,8 @@ int swad__getGroupTypes (struct soap *soap,
|
||||||
/* Get group type name (row[1]) */
|
/* Get group type name (row[1]) */
|
||||||
getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName =
|
getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName =
|
||||||
(char *) soap_malloc (soap,Grp_MAX_BYTES_GROUP_TYPE_NAME + 1);
|
(char *) soap_malloc (soap,Grp_MAX_BYTES_GROUP_TYPE_NAME + 1);
|
||||||
Str_Copy (getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName,row[1],
|
Str_Copy (getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName,
|
||||||
Grp_MAX_BYTES_GROUP_TYPE_NAME);
|
row[1],Grp_MAX_BYTES_GROUP_TYPE_NAME);
|
||||||
|
|
||||||
/* Get whether enrolment is mandatory ('Y') or voluntary ('N') (row[2]) */
|
/* Get whether enrolment is mandatory ('Y') or voluntary ('N') (row[2]) */
|
||||||
getGroupTypesOut->groupTypesArray.__ptr[NumRow].mandatory = (row[2][0] == 'Y') ? 1 :
|
getGroupTypesOut->groupTypesArray.__ptr[NumRow].mandatory = (row[2][0] == 'Y') ? 1 :
|
||||||
|
@ -2384,7 +2370,8 @@ int swad__sendMyGroups (struct soap *soap,
|
||||||
if (LstGrpsIWant.NumGrps) // If I have selected groups...
|
if (LstGrpsIWant.NumGrps) // If I have selected groups...
|
||||||
{
|
{
|
||||||
/***** Create a list of groups selected from myGroups *****/
|
/***** Create a list of groups selected from myGroups *****/
|
||||||
if ((LstGrpsIWant.GrpCods = (long *) calloc (LstGrpsIWant.NumGrps,sizeof (long))) == NULL)
|
if ((LstGrpsIWant.GrpCods = calloc (LstGrpsIWant.NumGrps,
|
||||||
|
sizeof (*LstGrpsIWant.GrpCods))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
for (NumGrp = 0, Ptr = myGroups;
|
for (NumGrp = 0, Ptr = myGroups;
|
||||||
*Ptr;
|
*Ptr;
|
||||||
|
@ -2502,8 +2489,7 @@ static void API_CopyUsrData (struct soap *soap,
|
||||||
/* Copy user's nickname */
|
/* Copy user's nickname */
|
||||||
Length = strlen (UsrDat->Nickname);
|
Length = strlen (UsrDat->Nickname);
|
||||||
Usr->userNickname = (char *) soap_malloc (soap,Length + 1);
|
Usr->userNickname = (char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (Usr->userNickname,UsrDat->Nickname,
|
Str_Copy (Usr->userNickname,UsrDat->Nickname,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
/* Copy user's first ID */
|
/* Copy user's first ID */
|
||||||
if (UsrIDIsVisible && UsrDat->IDs.List)
|
if (UsrIDIsVisible && UsrDat->IDs.List)
|
||||||
|
@ -2512,33 +2498,28 @@ static void API_CopyUsrData (struct soap *soap,
|
||||||
FirstID = "********";
|
FirstID = "********";
|
||||||
Length = strlen (FirstID);
|
Length = strlen (FirstID);
|
||||||
Usr->userID = (char *) soap_malloc (soap,Length + 1);
|
Usr->userID = (char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (Usr->userID,FirstID,
|
Str_Copy (Usr->userID,FirstID,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
/* Copy user's surname1 */
|
/* Copy user's surname1 */
|
||||||
Length = strlen (UsrDat->Surname1);
|
Length = strlen (UsrDat->Surname1);
|
||||||
Usr->userSurname1 = (char *) soap_malloc (soap,Length + 1);
|
Usr->userSurname1 = (char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (Usr->userSurname1,UsrDat->Surname1,
|
Str_Copy (Usr->userSurname1,UsrDat->Surname1,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
/* Copy user's surname2 */
|
/* Copy user's surname2 */
|
||||||
Length = strlen (UsrDat->Surname2);
|
Length = strlen (UsrDat->Surname2);
|
||||||
Usr->userSurname2 = (char *) soap_malloc (soap,Length + 1);
|
Usr->userSurname2 = (char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (Usr->userSurname2,UsrDat->Surname2,
|
Str_Copy (Usr->userSurname2,UsrDat->Surname2,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
/* Copy user's first name */
|
/* Copy user's first name */
|
||||||
Length = strlen (UsrDat->FirstName);
|
Length = strlen (UsrDat->FrstName);
|
||||||
Usr->userFirstname = (char *) soap_malloc (soap,Length + 1);
|
Usr->userFirstname = (char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (Usr->userFirstname,UsrDat->FirstName,
|
Str_Copy (Usr->userFirstname,UsrDat->FrstName,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
/* User's photo URL */
|
/* User's photo URL */
|
||||||
Pho_BuildLinkToPhoto (UsrDat,PhotoURL);
|
Pho_BuildLinkToPhoto (UsrDat,PhotoURL);
|
||||||
Length = strlen (PhotoURL);
|
Length = strlen (PhotoURL);
|
||||||
Usr->userPhoto = (char *) soap_malloc (soap,Length + 1);
|
Usr->userPhoto = (char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (Usr->userPhoto,PhotoURL,
|
Str_Copy (Usr->userPhoto,PhotoURL,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2639,30 +2620,26 @@ int swad__getAttendanceEvents (struct soap *soap,
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname1 =
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname1 =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname1,
|
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname1,
|
||||||
Gbl.Usrs.Other.UsrDat.Surname1,
|
Gbl.Usrs.Other.UsrDat.Surname1,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
|
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname2 =
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname2 =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname2,
|
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname2,
|
||||||
Gbl.Usrs.Other.UsrDat.Surname2,
|
Gbl.Usrs.Other.UsrDat.Surname2,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
Length = strlen (Gbl.Usrs.Other.UsrDat.FirstName);
|
Length = strlen (Gbl.Usrs.Other.UsrDat.FrstName);
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userFirstname =
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userFirstname =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userFirstname,
|
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userFirstname,
|
||||||
Gbl.Usrs.Other.UsrDat.FirstName,
|
Gbl.Usrs.Other.UsrDat.FrstName,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
||||||
Length = strlen (PhotoURL);
|
Length = strlen (PhotoURL);
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto =
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto,
|
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto,
|
||||||
PhotoURL,
|
PhotoURL,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2692,15 +2669,15 @@ int swad__getAttendanceEvents (struct soap *soap,
|
||||||
Length = strlen (row[6]);
|
Length = strlen (row[6]);
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title =
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title,row[6],
|
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title,
|
||||||
Length);
|
row[6],Length);
|
||||||
|
|
||||||
/* Get Txt (row[7]) */
|
/* Get Txt (row[7]) */
|
||||||
Length = strlen (row[7]);
|
Length = strlen (row[7]);
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text =
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text,row[7],
|
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text,
|
||||||
Length);
|
row[7],Length);
|
||||||
|
|
||||||
/* Get list of groups for this attendance event */
|
/* Get list of groups for this attendance event */
|
||||||
API_GetListGrpsInAttendanceEventFromDB (soap,
|
API_GetListGrpsInAttendanceEventFromDB (soap,
|
||||||
|
@ -2753,12 +2730,10 @@ static void API_GetListGrpsInAttendanceEventFromDB (struct soap *soap,
|
||||||
|
|
||||||
/* Get group code (row[0]) */
|
/* Get group code (row[0]) */
|
||||||
GrpCod = Str_ConvertStrCodToLongCod (row[0]);
|
GrpCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
snprintf (GrpCodStr,sizeof (GrpCodStr),
|
snprintf (GrpCodStr,sizeof (GrpCodStr),NumGrp ? ",%ld" :
|
||||||
NumGrp ? ",%ld" :
|
"%ld",
|
||||||
"%ld",
|
|
||||||
GrpCod);
|
GrpCod);
|
||||||
Str_Concat (*ListGroups,GrpCodStr,
|
Str_Concat (*ListGroups,GrpCodStr,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2855,8 +2830,7 @@ int swad__sendAttendanceEvent (struct soap *soap,
|
||||||
return soap_receiver_fault (soap,
|
return soap_receiver_fault (soap,
|
||||||
"Request forbidden",
|
"Request forbidden",
|
||||||
"Title of attendance event is empty");
|
"Title of attendance event is empty");
|
||||||
Str_Copy (Event.Title,title,
|
Str_Copy (Event.Title,title,sizeof (Event.Title) - 1);
|
||||||
Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE);
|
|
||||||
|
|
||||||
/* Create a list of groups selected */
|
/* Create a list of groups selected */
|
||||||
API_GetLstGrpsSel (groups);
|
API_GetLstGrpsSel (groups);
|
||||||
|
@ -2965,7 +2939,8 @@ static void API_GetLstGrpsSel (const char *Groups)
|
||||||
// Here NestedCalls is always 0
|
// Here NestedCalls is always 0
|
||||||
Gbl.Crs.Grps.LstGrpsSel.NestedCalls++;
|
Gbl.Crs.Grps.LstGrpsSel.NestedCalls++;
|
||||||
// Here NestedCalls is always 1
|
// Here NestedCalls is always 1
|
||||||
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = (long *) calloc (Gbl.Crs.Grps.LstGrpsSel.NumGrps,sizeof (long))) == NULL)
|
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = calloc (Gbl.Crs.Grps.LstGrpsSel.NumGrps,
|
||||||
|
sizeof (*Gbl.Crs.Grps.LstGrpsSel.GrpCods))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
for (Ptr = Groups, NumGrp = 0;
|
for (Ptr = Groups, NumGrp = 0;
|
||||||
|
@ -3105,8 +3080,7 @@ int swad__getAttendanceUsers (struct soap *soap,
|
||||||
getAttendanceUsersOut->usersArray.__ptr[NumRow].userNickname =
|
getAttendanceUsersOut->usersArray.__ptr[NumRow].userNickname =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userNickname,
|
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userNickname,
|
||||||
Gbl.Usrs.Other.UsrDat.Nickname,
|
Gbl.Usrs.Other.UsrDat.Nickname,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
if (Gbl.Usrs.Other.UsrDat.IDs.Num)
|
if (Gbl.Usrs.Other.UsrDat.IDs.Num)
|
||||||
{
|
{
|
||||||
|
@ -3114,8 +3088,7 @@ int swad__getAttendanceUsers (struct soap *soap,
|
||||||
getAttendanceUsersOut->usersArray.__ptr[NumRow].userID =
|
getAttendanceUsersOut->usersArray.__ptr[NumRow].userID =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userID,
|
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userID,
|
||||||
Gbl.Usrs.Other.UsrDat.IDs.List[0].ID,
|
Gbl.Usrs.Other.UsrDat.IDs.List[0].ID,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3128,30 +3101,26 @@ int swad__getAttendanceUsers (struct soap *soap,
|
||||||
getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname1 =
|
getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname1 =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname1,
|
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname1,
|
||||||
Gbl.Usrs.Other.UsrDat.Surname1,
|
Gbl.Usrs.Other.UsrDat.Surname1,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
|
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
|
||||||
getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname2 =
|
getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname2 =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname2,
|
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname2,
|
||||||
Gbl.Usrs.Other.UsrDat.Surname2,
|
Gbl.Usrs.Other.UsrDat.Surname2,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
Length = strlen (Gbl.Usrs.Other.UsrDat.FirstName);
|
Length = strlen (Gbl.Usrs.Other.UsrDat.FrstName);
|
||||||
getAttendanceUsersOut->usersArray.__ptr[NumRow].userFirstname =
|
getAttendanceUsersOut->usersArray.__ptr[NumRow].userFirstname =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userFirstname,
|
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userFirstname,
|
||||||
Gbl.Usrs.Other.UsrDat.FirstName,
|
Gbl.Usrs.Other.UsrDat.FrstName,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
||||||
Length = strlen (PhotoURL);
|
Length = strlen (PhotoURL);
|
||||||
getAttendanceUsersOut->usersArray.__ptr[NumRow].userPhoto =
|
getAttendanceUsersOut->usersArray.__ptr[NumRow].userPhoto =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userPhoto,
|
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userPhoto,
|
||||||
PhotoURL,
|
PhotoURL,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3244,7 +3213,7 @@ int swad__sendAttendanceUsers (struct soap *soap,
|
||||||
|
|
||||||
/* Allocate subquery used to mark not present users as absent */
|
/* Allocate subquery used to mark not present users as absent */
|
||||||
Length = 256 + NumCodsInList * (1 + Cns_MAX_DECIMAL_DIGITS_LONG + 1) - 1;
|
Length = 256 + NumCodsInList * (1 + Cns_MAX_DECIMAL_DIGITS_LONG + 1) - 1;
|
||||||
if ((SubQueryAllUsrs = (char *) malloc (Length + 1)) == NULL)
|
if ((SubQueryAllUsrs = malloc (Length + 1)) == NULL)
|
||||||
return soap_receiver_fault (soap,
|
return soap_receiver_fault (soap,
|
||||||
"Not enough memory",
|
"Not enough memory",
|
||||||
"Not enough memory to store list of users");
|
"Not enough memory to store list of users");
|
||||||
|
@ -3271,14 +3240,12 @@ int swad__sendAttendanceUsers (struct soap *soap,
|
||||||
{
|
{
|
||||||
if (sendAttendanceUsersOut->numUsers)
|
if (sendAttendanceUsersOut->numUsers)
|
||||||
{
|
{
|
||||||
snprintf (SubQueryOneUsr,sizeof (SubQueryOneUsr),
|
snprintf (SubQueryOneUsr,sizeof (SubQueryOneUsr),",%ld",
|
||||||
",%ld",UsrDat.UsrCod);
|
UsrDat.UsrCod);
|
||||||
Str_Concat (SubQueryAllUsrs,SubQueryOneUsr,
|
Str_Concat (SubQueryAllUsrs,SubQueryOneUsr,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
snprintf (SubQueryAllUsrs,Length,
|
snprintf (SubQueryAllUsrs,Length," AND UsrCod NOT IN (%ld",
|
||||||
" AND UsrCod NOT IN (%ld",
|
|
||||||
UsrDat.UsrCod);
|
UsrDat.UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3290,8 +3257,7 @@ int swad__sendAttendanceUsers (struct soap *soap,
|
||||||
{
|
{
|
||||||
/* Mark not present users as absent in table of users */
|
/* Mark not present users as absent in table of users */
|
||||||
if (sendAttendanceUsersOut->numUsers)
|
if (sendAttendanceUsersOut->numUsers)
|
||||||
Str_Concat (SubQueryAllUsrs,")",
|
Str_Concat (SubQueryAllUsrs,")",Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
DB_QueryUPDATE ("can not set other users as absent",
|
DB_QueryUPDATE ("can not set other users as absent",
|
||||||
"UPDATE att_usr SET Present='N'"
|
"UPDATE att_usr SET Present='N'"
|
||||||
|
@ -3411,8 +3377,7 @@ int swad__getNotifications (struct soap *soap,
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType =
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType =
|
||||||
(char *) soap_malloc (soap,Ntf_MAX_BYTES_NOTIFY_EVENT + 1);
|
(char *) soap_malloc (soap,Ntf_MAX_BYTES_NOTIFY_EVENT + 1);
|
||||||
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType,
|
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType,
|
||||||
Ntf_WSNotifyEvents[NotifyEvent],
|
Ntf_WSNotifyEvents[NotifyEvent],Ntf_MAX_BYTES_NOTIFY_EVENT);
|
||||||
Ntf_MAX_BYTES_NOTIFY_EVENT);
|
|
||||||
|
|
||||||
/* Get time of the event (row[2]) */
|
/* Get time of the event (row[2]) */
|
||||||
EventTime = 0L;
|
EventTime = 0L;
|
||||||
|
@ -3450,15 +3415,14 @@ int swad__getNotifications (struct soap *soap,
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname =
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname =
|
||||||
(char *) soap_malloc (soap,Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1);
|
(char *) soap_malloc (soap,Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1);
|
||||||
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname,
|
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname,
|
||||||
Gbl.Usrs.Other.UsrDat.FirstName,
|
Gbl.Usrs.Other.UsrDat.FrstName,
|
||||||
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
||||||
|
|
||||||
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto =
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto =
|
||||||
(char *) soap_malloc (soap,Cns_MAX_BYTES_WWW + 1);
|
(char *) soap_malloc (soap,Cns_MAX_BYTES_WWW + 1);
|
||||||
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto,
|
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto,
|
||||||
PhotoURL,
|
PhotoURL,Cns_MAX_BYTES_WWW);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3529,8 +3493,7 @@ int swad__getNotifications (struct soap *soap,
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumNotif].summary =
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].summary =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].summary,
|
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].summary,
|
||||||
SummaryStr,
|
SummaryStr,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
if (ContentStr == NULL)
|
if (ContentStr == NULL)
|
||||||
{
|
{
|
||||||
|
@ -3544,8 +3507,7 @@ int swad__getNotifications (struct soap *soap,
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumNotif].content =
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].content =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].content,
|
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].content,
|
||||||
ContentStr,
|
ContentStr,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
/* Free memory used by content string */
|
/* Free memory used by content string */
|
||||||
free (ContentStr);
|
free (ContentStr);
|
||||||
|
@ -3773,15 +3735,13 @@ int swad__sendMessage (struct soap *soap,
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Allocate space for query *****/
|
/***** Allocate space for query *****/
|
||||||
if ((Query = (char *) malloc (API_MAX_BYTES_QUERY_RECIPIENTS + 1)) == NULL)
|
if ((Query = malloc (API_MAX_BYTES_QUERY_RECIPIENTS + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Build query for recipients from database *****/
|
/***** Build query for recipients from database *****/
|
||||||
if (ReplyUsrCod > 0)
|
if (ReplyUsrCod > 0)
|
||||||
snprintf (Query,API_MAX_BYTES_QUERY_RECIPIENTS + 1,
|
snprintf (Query,API_MAX_BYTES_QUERY_RECIPIENTS + 1,
|
||||||
"SELECT UsrCod FROM usr_data"
|
"SELECT UsrCod FROM usr_data WHERE UsrCod=%ld",ReplyUsrCod);
|
||||||
" WHERE UsrCod=%ld",
|
|
||||||
ReplyUsrCod);
|
|
||||||
else
|
else
|
||||||
Query[0] = '\0';
|
Query[0] = '\0';
|
||||||
|
|
||||||
|
@ -3808,8 +3768,7 @@ int swad__sendMessage (struct soap *soap,
|
||||||
if (FirstNickname)
|
if (FirstNickname)
|
||||||
{
|
{
|
||||||
if (ReplyUsrCod > 0)
|
if (ReplyUsrCod > 0)
|
||||||
Str_Concat (Query," UNION ",
|
Str_Concat (Query," UNION ",API_MAX_BYTES_QUERY_RECIPIENTS);
|
||||||
API_MAX_BYTES_QUERY_RECIPIENTS);
|
|
||||||
Str_Concat (Query,"SELECT UsrCod FROM usr_nicknames"
|
Str_Concat (Query,"SELECT UsrCod FROM usr_nicknames"
|
||||||
" WHERE Nickname IN ('",
|
" WHERE Nickname IN ('",
|
||||||
API_MAX_BYTES_QUERY_RECIPIENTS);
|
API_MAX_BYTES_QUERY_RECIPIENTS);
|
||||||
|
@ -3817,17 +3776,13 @@ int swad__sendMessage (struct soap *soap,
|
||||||
ThereAreNicknames = true;
|
ThereAreNicknames = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Str_Concat (Query,",'",
|
Str_Concat (Query,",'",API_MAX_BYTES_QUERY_RECIPIENTS);
|
||||||
API_MAX_BYTES_QUERY_RECIPIENTS);
|
Str_Concat (Query,Nickname,API_MAX_BYTES_QUERY_RECIPIENTS);
|
||||||
Str_Concat (Query,Nickname,
|
Str_Concat (Query,"'",API_MAX_BYTES_QUERY_RECIPIENTS);
|
||||||
API_MAX_BYTES_QUERY_RECIPIENTS);
|
|
||||||
Str_Concat (Query,"'",
|
|
||||||
API_MAX_BYTES_QUERY_RECIPIENTS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ThereAreNicknames)
|
if (ThereAreNicknames)
|
||||||
Str_Concat (Query,")",
|
Str_Concat (Query,")",API_MAX_BYTES_QUERY_RECIPIENTS);
|
||||||
API_MAX_BYTES_QUERY_RECIPIENTS);
|
|
||||||
|
|
||||||
/***** Initialize output structure *****/
|
/***** Initialize output structure *****/
|
||||||
sendMessageOut->numUsers = 0;
|
sendMessageOut->numUsers = 0;
|
||||||
|
@ -4108,24 +4063,19 @@ int swad__getTestConfig (struct soap *soap,
|
||||||
/* Convert from visibility to old feedback */
|
/* Convert from visibility to old feedback */
|
||||||
/* TODO: Remove these lines in 2021 */
|
/* TODO: Remove these lines in 2021 */
|
||||||
if (!TstVis_IsVisibleTotalScore (TstCfg_GetConfigVisibility ()))
|
if (!TstVis_IsVisibleTotalScore (TstCfg_GetConfigVisibility ()))
|
||||||
Str_Copy (getTestConfigOut->feedback,
|
Str_Copy (getTestConfigOut->feedback,"nothing",
|
||||||
"nothing",
|
|
||||||
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
|
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
|
||||||
else if (!TstVis_IsVisibleEachQstScore (TstCfg_GetConfigVisibility ()))
|
else if (!TstVis_IsVisibleEachQstScore (TstCfg_GetConfigVisibility ()))
|
||||||
Str_Copy (getTestConfigOut->feedback,
|
Str_Copy (getTestConfigOut->feedback,"totalResult",
|
||||||
"totalResult",
|
|
||||||
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
|
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
|
||||||
else if (!TstVis_IsVisibleCorrectAns (TstCfg_GetConfigVisibility ()))
|
else if (!TstVis_IsVisibleCorrectAns (TstCfg_GetConfigVisibility ()))
|
||||||
Str_Copy (getTestConfigOut->feedback,
|
Str_Copy (getTestConfigOut->feedback,"eachResult",
|
||||||
"eachResult",
|
|
||||||
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
|
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
|
||||||
else if (!TstVis_IsVisibleFeedbackTxt (TstCfg_GetConfigVisibility ()))
|
else if (!TstVis_IsVisibleFeedbackTxt (TstCfg_GetConfigVisibility ()))
|
||||||
Str_Copy (getTestConfigOut->feedback,
|
Str_Copy (getTestConfigOut->feedback,"eachGoodBad",
|
||||||
"eachGoodBad",
|
|
||||||
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
|
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
|
||||||
else
|
else
|
||||||
Str_Copy (getTestConfigOut->feedback,
|
Str_Copy (getTestConfigOut->feedback,"fullFeedback",
|
||||||
"fullFeedback",
|
|
||||||
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
|
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
|
||||||
|
|
||||||
/***** Get number of tests *****/
|
/***** Get number of tests *****/
|
||||||
|
@ -4510,14 +4460,14 @@ static int API_GetTstAnswers (struct soap *soap,
|
||||||
/* Get answer (row[3]) */
|
/* Get answer (row[3]) */
|
||||||
getTestsOut->answersArray.__ptr[NumRow].answerText =
|
getTestsOut->answersArray.__ptr[NumRow].answerText =
|
||||||
(char *) soap_malloc (soap,Cns_MAX_BYTES_TEXT + 1);
|
(char *) soap_malloc (soap,Cns_MAX_BYTES_TEXT + 1);
|
||||||
Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerText,row[3],
|
Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerText,
|
||||||
Cns_MAX_BYTES_TEXT);
|
row[3],Cns_MAX_BYTES_TEXT);
|
||||||
|
|
||||||
/* Get feedback (row[4]) */
|
/* Get feedback (row[4]) */
|
||||||
getTestsOut->answersArray.__ptr[NumRow].answerFeedback =
|
getTestsOut->answersArray.__ptr[NumRow].answerFeedback =
|
||||||
(char *) soap_malloc (soap,Cns_MAX_BYTES_TEXT + 1);
|
(char *) soap_malloc (soap,Cns_MAX_BYTES_TEXT + 1);
|
||||||
Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerFeedback,row[4],
|
Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerFeedback,
|
||||||
Cns_MAX_BYTES_TEXT);
|
row[4],Cns_MAX_BYTES_TEXT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4667,18 +4617,13 @@ int swad__getTrivialQuestion (struct soap *soap,
|
||||||
/* Add this degree to query */
|
/* Add this degree to query */
|
||||||
if (FirstDegree)
|
if (FirstDegree)
|
||||||
{
|
{
|
||||||
snprintf (DegreesStr,sizeof (DegreesStr),
|
snprintf (DegreesStr,sizeof (DegreesStr),"%ld",DegCod);
|
||||||
"%ld",
|
|
||||||
DegCod);
|
|
||||||
FirstDegree = false;
|
FirstDegree = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf (DegStr,sizeof (DegStr),
|
snprintf (DegStr,sizeof (DegStr),",%ld",DegCod);
|
||||||
",%ld",
|
Str_Concat (DegreesStr,DegStr,sizeof (DegreesStr) - 1);
|
||||||
DegCod);
|
|
||||||
Str_Concat (DegreesStr,DegStr,
|
|
||||||
API_MAX_BYTES_DEGREES_STR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4823,14 +4768,14 @@ int swad__getTrivialQuestion (struct soap *soap,
|
||||||
/* Get answer (row[3]) */
|
/* Get answer (row[3]) */
|
||||||
getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText =
|
getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText =
|
||||||
(char *) soap_malloc (soap,Cns_MAX_BYTES_TEXT + 1);
|
(char *) soap_malloc (soap,Cns_MAX_BYTES_TEXT + 1);
|
||||||
Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText,row[3],
|
Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText,
|
||||||
Cns_MAX_BYTES_TEXT);
|
row[3],Cns_MAX_BYTES_TEXT);
|
||||||
|
|
||||||
/* Get feedback (row[4]) */
|
/* Get feedback (row[4]) */
|
||||||
getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback =
|
getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback =
|
||||||
(char *) soap_malloc (soap,Cns_MAX_BYTES_TEXT + 1);
|
(char *) soap_malloc (soap,Cns_MAX_BYTES_TEXT + 1);
|
||||||
Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback,row[4],
|
Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback,
|
||||||
Cns_MAX_BYTES_TEXT);
|
row[4],Cns_MAX_BYTES_TEXT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4943,30 +4888,26 @@ int swad__getGames (struct soap *soap,
|
||||||
getGamesOut->gamesArray.__ptr[NumGame].userSurname1 =
|
getGamesOut->gamesArray.__ptr[NumGame].userSurname1 =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].userSurname1,
|
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].userSurname1,
|
||||||
Gbl.Usrs.Other.UsrDat.Surname1,
|
Gbl.Usrs.Other.UsrDat.Surname1,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
|
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
|
||||||
getGamesOut->gamesArray.__ptr[NumGame].userSurname2 =
|
getGamesOut->gamesArray.__ptr[NumGame].userSurname2 =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].userSurname2,
|
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].userSurname2,
|
||||||
Gbl.Usrs.Other.UsrDat.Surname2,
|
Gbl.Usrs.Other.UsrDat.Surname2,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
Length = strlen (Gbl.Usrs.Other.UsrDat.FirstName);
|
Length = strlen (Gbl.Usrs.Other.UsrDat.FrstName);
|
||||||
getGamesOut->gamesArray.__ptr[NumGame].userFirstname =
|
getGamesOut->gamesArray.__ptr[NumGame].userFirstname =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].userFirstname,
|
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].userFirstname,
|
||||||
Gbl.Usrs.Other.UsrDat.FirstName,
|
Gbl.Usrs.Other.UsrDat.FrstName,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
||||||
Length = strlen (PhotoURL);
|
Length = strlen (PhotoURL);
|
||||||
getGamesOut->gamesArray.__ptr[NumGame].userPhoto =
|
getGamesOut->gamesArray.__ptr[NumGame].userPhoto =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].userPhoto,
|
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].userPhoto,
|
||||||
PhotoURL,
|
PhotoURL,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5000,15 +4941,13 @@ int swad__getGames (struct soap *soap,
|
||||||
Length = strlen (row[6]);
|
Length = strlen (row[6]);
|
||||||
getGamesOut->gamesArray.__ptr[NumGame].title =
|
getGamesOut->gamesArray.__ptr[NumGame].title =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].title,row[6],
|
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].title,row[6],Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
/* Get Txt (row[7]) */
|
/* Get Txt (row[7]) */
|
||||||
Length = strlen (row[7]);
|
Length = strlen (row[7]);
|
||||||
getGamesOut->gamesArray.__ptr[NumGame].text =
|
getGamesOut->gamesArray.__ptr[NumGame].text =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].text,row[7],
|
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].text,row[7],Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5134,30 +5073,26 @@ int swad__getMatches (struct soap *soap,
|
||||||
getMatchesOut->matchesArray.__ptr[NumMatch].userSurname1 =
|
getMatchesOut->matchesArray.__ptr[NumMatch].userSurname1 =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getMatchesOut->matchesArray.__ptr[NumMatch].userSurname1,
|
Str_Copy (getMatchesOut->matchesArray.__ptr[NumMatch].userSurname1,
|
||||||
Gbl.Usrs.Other.UsrDat.Surname1,
|
Gbl.Usrs.Other.UsrDat.Surname1,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
|
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
|
||||||
getMatchesOut->matchesArray.__ptr[NumMatch].userSurname2 =
|
getMatchesOut->matchesArray.__ptr[NumMatch].userSurname2 =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getMatchesOut->matchesArray.__ptr[NumMatch].userSurname2,
|
Str_Copy (getMatchesOut->matchesArray.__ptr[NumMatch].userSurname2,
|
||||||
Gbl.Usrs.Other.UsrDat.Surname2,
|
Gbl.Usrs.Other.UsrDat.Surname2,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
Length = strlen (Gbl.Usrs.Other.UsrDat.FirstName);
|
Length = strlen (Gbl.Usrs.Other.UsrDat.FrstName);
|
||||||
getMatchesOut->matchesArray.__ptr[NumMatch].userFirstname =
|
getMatchesOut->matchesArray.__ptr[NumMatch].userFirstname =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getMatchesOut->matchesArray.__ptr[NumMatch].userFirstname,
|
Str_Copy (getMatchesOut->matchesArray.__ptr[NumMatch].userFirstname,
|
||||||
Gbl.Usrs.Other.UsrDat.FirstName,
|
Gbl.Usrs.Other.UsrDat.FrstName,Length);
|
||||||
Length);
|
|
||||||
|
|
||||||
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
||||||
Length = strlen (PhotoURL);
|
Length = strlen (PhotoURL);
|
||||||
getMatchesOut->matchesArray.__ptr[NumMatch].userPhoto =
|
getMatchesOut->matchesArray.__ptr[NumMatch].userPhoto =
|
||||||
(char *) soap_malloc (soap,Length + 1);
|
(char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getMatchesOut->matchesArray.__ptr[NumMatch].userPhoto,
|
Str_Copy (getMatchesOut->matchesArray.__ptr[NumMatch].userPhoto,
|
||||||
PhotoURL,
|
PhotoURL,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5450,12 +5385,10 @@ static void API_GetListGrpsInGameFromDB (struct soap *soap,
|
||||||
|
|
||||||
/* Get group code (row[0]) */
|
/* Get group code (row[0]) */
|
||||||
GrpCod = Str_ConvertStrCodToLongCod (row[0]);
|
GrpCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
snprintf (GrpCodStr,sizeof (GrpCodStr),
|
snprintf (GrpCodStr,sizeof (GrpCodStr),NumGrp ? ",%ld" :
|
||||||
NumGrp ? ",%ld" :
|
"%ld",
|
||||||
"%ld",
|
|
||||||
GrpCod);
|
GrpCod);
|
||||||
Str_Concat (*ListGroups,GrpCodStr,
|
Str_Concat (*ListGroups,GrpCodStr,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5571,22 +5504,20 @@ int swad__getDirectoryTree (struct soap *soap,
|
||||||
Gbl.Crs.Grps.GrpCod = (groupCode > 0) ? (long) groupCode :
|
Gbl.Crs.Grps.GrpCod = (groupCode > 0) ? (long) groupCode :
|
||||||
-1L;
|
-1L;
|
||||||
|
|
||||||
snprintf (Gbl.Crs.PathPriv,sizeof (Gbl.Crs.PathPriv),
|
snprintf (Gbl.Crs.PathPriv,sizeof (Gbl.Crs.PathPriv),"%s/%ld",
|
||||||
"%s/%ld",
|
|
||||||
Cfg_PATH_CRS_PRIVATE,Gbl.Hierarchy.Crs.CrsCod);
|
Cfg_PATH_CRS_PRIVATE,Gbl.Hierarchy.Crs.CrsCod);
|
||||||
Brw_InitializeFileBrowser ();
|
Brw_InitializeFileBrowser ();
|
||||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,Brw_RootFolderInternalNames[Gbl.FileBrowser.Type],
|
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,Brw_RootFolderInternalNames[Gbl.FileBrowser.Type],
|
||||||
PATH_MAX);
|
sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1);
|
||||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,".",
|
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,".",
|
||||||
NAME_MAX);
|
sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1);
|
||||||
Brw_SetFullPathInTree ();
|
Brw_SetFullPathInTree ();
|
||||||
|
|
||||||
/* Check if exists the directory for HTML output. If not exists, create it */
|
/* Check if exists the directory for HTML output. If not exists, create it */
|
||||||
Fil_CreateDirIfNotExists (Cfg_PATH_OUT_PRIVATE);
|
Fil_CreateDirIfNotExists (Cfg_PATH_OUT_PRIVATE);
|
||||||
|
|
||||||
/* Create a unique name for the file */
|
/* Create a unique name for the file */
|
||||||
snprintf (XMLFileName,sizeof (XMLFileName),
|
snprintf (XMLFileName,sizeof (XMLFileName),"%s/%s.xml",
|
||||||
"%s/%s.xml",
|
|
||||||
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
||||||
|
|
||||||
/* Open file for writing and reading */
|
/* Open file for writing and reading */
|
||||||
|
@ -5644,17 +5575,15 @@ static void API_ListDir (unsigned Level,const char *Path,const char *PathInTree)
|
||||||
if (strcmp (FileList[NumFile]->d_name,".") &&
|
if (strcmp (FileList[NumFile]->d_name,".") &&
|
||||||
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
||||||
{
|
{
|
||||||
snprintf (PathFileRel,sizeof (PathFileRel),
|
snprintf (PathFileRel,sizeof (PathFileRel),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
Path,FileList[NumFile]->d_name);
|
Path,FileList[NumFile]->d_name);
|
||||||
snprintf (PathFileInExplTree,sizeof (PathFileInExplTree),
|
snprintf (PathFileInExplTree,sizeof (PathFileInExplTree),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
PathInTree,FileList[NumFile]->d_name);
|
PathInTree,FileList[NumFile]->d_name);
|
||||||
|
|
||||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,PathInTree,
|
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,PathInTree,
|
||||||
PATH_MAX);
|
sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1);
|
||||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,FileList[NumFile]->d_name,
|
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,FileList[NumFile]->d_name,
|
||||||
NAME_MAX);
|
sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1);
|
||||||
|
|
||||||
if (!lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
|
if (!lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
|
||||||
{
|
{
|
||||||
|
@ -5884,9 +5813,9 @@ int swad__getFile (struct soap *soap,
|
||||||
/***** Set paths *****/
|
/***** Set paths *****/
|
||||||
Brw_InitializeFileBrowser ();
|
Brw_InitializeFileBrowser ();
|
||||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,FileMetadata.FilFolLnk.Path,
|
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,FileMetadata.FilFolLnk.Path,
|
||||||
PATH_MAX);
|
sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1);
|
||||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,FileMetadata.FilFolLnk.Name,
|
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,FileMetadata.FilFolLnk.Name,
|
||||||
NAME_MAX);
|
sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1);
|
||||||
Brw_SetFullPathInTree ();
|
Brw_SetFullPathInTree ();
|
||||||
|
|
||||||
/***** Get file size and date *****/
|
/***** Get file size and date *****/
|
||||||
|
@ -5901,11 +5830,9 @@ int swad__getFile (struct soap *soap,
|
||||||
URL);
|
URL);
|
||||||
|
|
||||||
/***** Copy data into output structure *****/
|
/***** Copy data into output structure *****/
|
||||||
Str_Copy (getFileOut->fileName,FileMetadata.FilFolLnk.Name,
|
Str_Copy (getFileOut->fileName,FileMetadata.FilFolLnk.Name,NAME_MAX);
|
||||||
NAME_MAX);
|
|
||||||
|
|
||||||
Str_Copy (getFileOut->URL,URL,
|
Str_Copy (getFileOut->URL,URL,Cns_MAX_BYTES_WWW);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
|
|
||||||
getFileOut->size = (int) FileMetadata.Size;
|
getFileOut->size = (int) FileMetadata.Size;
|
||||||
|
|
||||||
|
@ -5923,8 +5850,7 @@ int swad__getFile (struct soap *soap,
|
||||||
Usr_MAX_BYTES_FULL_NAME);
|
Usr_MAX_BYTES_FULL_NAME);
|
||||||
|
|
||||||
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
||||||
Str_Copy (getFileOut->publisherPhoto,PhotoURL,
|
Str_Copy (getFileOut->publisherPhoto,PhotoURL,Cns_MAX_BYTES_WWW);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return SOAP_OK;
|
return SOAP_OK;
|
||||||
|
@ -6015,8 +5941,7 @@ int swad__getMarks (struct soap *soap,
|
||||||
{
|
{
|
||||||
Length = strlen (ContentStr);
|
Length = strlen (ContentStr);
|
||||||
getMarksOut->content = (char *) soap_malloc (soap,Length + 1);
|
getMarksOut->content = (char *) soap_malloc (soap,Length + 1);
|
||||||
Str_Copy (getMarksOut->content,ContentStr,
|
Str_Copy (getMarksOut->content,ContentStr,Length);
|
||||||
Length);
|
|
||||||
free (ContentStr);
|
free (ContentStr);
|
||||||
ContentStr = NULL;
|
ContentStr = NULL;
|
||||||
}
|
}
|
||||||
|
|
28
swad_ID.c
28
swad_ID.c
|
@ -121,7 +121,7 @@ void ID_GetListIDsFromUsrCod (struct UsrData *UsrDat)
|
||||||
|
|
||||||
/* Get ID from row[0] */
|
/* Get ID from row[0] */
|
||||||
Str_Copy (UsrDat->IDs.List[NumID].ID,row[0],
|
Str_Copy (UsrDat->IDs.List[NumID].ID,row[0],
|
||||||
ID_MAX_BYTES_USR_ID);
|
sizeof (UsrDat->IDs.List[NumID].ID) - 1);
|
||||||
|
|
||||||
/* Get if ID is confirmed from row[1] */
|
/* Get if ID is confirmed from row[1] */
|
||||||
UsrDat->IDs.List[NumID].Confirmed = (row[1][0] == 'Y');
|
UsrDat->IDs.List[NumID].Confirmed = (row[1][0] == 'Y');
|
||||||
|
@ -146,7 +146,7 @@ void ID_ReallocateListIDs (struct UsrData *UsrDat,unsigned NumIDs)
|
||||||
UsrDat->IDs.Num = NumIDs;
|
UsrDat->IDs.Num = NumIDs;
|
||||||
|
|
||||||
/***** Allocate space for the list *****/
|
/***** Allocate space for the list *****/
|
||||||
if ((UsrDat->IDs.List = (struct ListIDs *) malloc (NumIDs * sizeof (struct ListIDs))) == NULL)
|
if ((UsrDat->IDs.List = malloc (NumIDs * sizeof (*UsrDat->IDs.List))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
|
||||||
|
|
||||||
/***** Allocate memory for subquery string *****/
|
/***** Allocate memory for subquery string *****/
|
||||||
MaxLength = 512 + UsrDat->IDs.Num * (1 + ID_MAX_BYTES_USR_ID + 1) - 1;
|
MaxLength = 512 + UsrDat->IDs.Num * (1 + ID_MAX_BYTES_USR_ID + 1) - 1;
|
||||||
if ((SubQueryAllUsrs = (char *) malloc (MaxLength + 1)) == NULL)
|
if ((SubQueryAllUsrs = malloc (MaxLength + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
SubQueryAllUsrs[0] = '\0';
|
SubQueryAllUsrs[0] = '\0';
|
||||||
|
|
||||||
|
@ -203,12 +203,10 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
|
||||||
NumID++)
|
NumID++)
|
||||||
{
|
{
|
||||||
if (NumID)
|
if (NumID)
|
||||||
Str_Concat (SubQueryAllUsrs,",",
|
Str_Concat (SubQueryAllUsrs,",",MaxLength);
|
||||||
MaxLength);
|
|
||||||
sprintf (SubQueryOneUsr,"'%s'",UsrDat->IDs.List[NumID].ID);
|
sprintf (SubQueryOneUsr,"'%s'",UsrDat->IDs.List[NumID].ID);
|
||||||
|
|
||||||
Str_Concat (SubQueryAllUsrs,SubQueryOneUsr,
|
Str_Concat (SubQueryAllUsrs,SubQueryOneUsr,MaxLength);
|
||||||
MaxLength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckPassword)
|
if (CheckPassword)
|
||||||
|
@ -435,7 +433,7 @@ bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat)
|
||||||
if (!UsrDat->Password[0] && // User has no password (never logged)
|
if (!UsrDat->Password[0] && // User has no password (never logged)
|
||||||
!UsrDat->Surname1[0] && // and who has no surname 1 (nobody filled user's surname 1)
|
!UsrDat->Surname1[0] && // and who has no surname 1 (nobody filled user's surname 1)
|
||||||
!UsrDat->Surname2[0] && // and who has no surname 2 (nobody filled user's surname 2)
|
!UsrDat->Surname2[0] && // and who has no surname 2 (nobody filled user's surname 2)
|
||||||
!UsrDat->FirstName[0] && // and who has no first name (nobody filled user's first name)
|
!UsrDat->FrstName[0] && // and who has no first name (nobody filled user's first name)
|
||||||
!UsrDat->Email[0]) // and who has no email (nobody filled user's email)
|
!UsrDat->Email[0]) // and who has no email (nobody filled user's email)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -491,7 +489,7 @@ static void ID_PutLinkToConfirmID (struct UsrData *UsrDat,unsigned NumID,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
Par_PutHiddenParamString (NULL,"UsrID",UsrDat->IDs.List[NumID].ID);
|
Par_PutHiddenParamString (NULL,"UsrID",UsrDat->IDs.List[NumID].ID);
|
||||||
|
|
||||||
/***** Put link *****/
|
/***** Put link *****/
|
||||||
|
@ -517,9 +515,7 @@ void ID_ShowFormChangeMyID (bool IShouldFillInID)
|
||||||
HTM_SECTION_Begin (ID_ID_SECTION_ID);
|
HTM_SECTION_Begin (ID_ID_SECTION_ID);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
|
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
|
||||||
"%upx",
|
|
||||||
Rec_RECORD_WIDTH);
|
|
||||||
Box_BoxBegin (StrRecordWidth,Txt_ID,
|
Box_BoxBegin (StrRecordWidth,Txt_ID,
|
||||||
Acc_PutLinkToRemoveMyAccount,NULL,
|
Acc_PutLinkToRemoveMyAccount,NULL,
|
||||||
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
|
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
|
||||||
|
@ -549,9 +545,7 @@ void ID_ShowFormChangeOtherUsrID (void)
|
||||||
HTM_SECTION_Begin (ID_ID_SECTION_ID);
|
HTM_SECTION_Begin (ID_ID_SECTION_ID);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
|
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
|
||||||
"%upx",
|
|
||||||
Rec_RECORD_WIDTH);
|
|
||||||
Box_BoxBegin (StrRecordWidth,Txt_ID,
|
Box_BoxBegin (StrRecordWidth,Txt_ID,
|
||||||
NULL,NULL,
|
NULL,NULL,
|
||||||
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
|
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
|
||||||
|
@ -704,7 +698,7 @@ static void ID_ShowFormChangeUsrID (bool ItsMe,bool IShouldFillInID)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Frm_StartFormAnchor (NextAction,ID_ID_SECTION_ID);
|
Frm_StartFormAnchor (NextAction,ID_ID_SECTION_ID);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
}
|
}
|
||||||
HTM_INPUT_TEXT ("NewID",ID_MAX_BYTES_USR_ID,
|
HTM_INPUT_TEXT ("NewID",ID_MAX_BYTES_USR_ID,
|
||||||
UsrDat->IDs.Num ? UsrDat->IDs.List[UsrDat->IDs.Num - 1].ID :
|
UsrDat->IDs.Num ? UsrDat->IDs.List[UsrDat->IDs.Num - 1].ID :
|
||||||
|
@ -733,7 +727,7 @@ static void ID_PutParamsRemoveOtherID (void *ID)
|
||||||
{
|
{
|
||||||
if (ID)
|
if (ID)
|
||||||
{
|
{
|
||||||
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
Par_PutHiddenParamString (NULL,"UsrID",(char *) ID);
|
Par_PutHiddenParamString (NULL,"UsrID",(char *) ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
21
swad_MFU.c
21
swad_MFU.c
|
@ -78,7 +78,8 @@ extern struct Globals Gbl;
|
||||||
|
|
||||||
void MFU_AllocateMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned MaxActionsShown)
|
void MFU_AllocateMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned MaxActionsShown)
|
||||||
{
|
{
|
||||||
if ((ListMFUActions->Actions = (Act_Action_t *) malloc (sizeof (Act_Action_t) * MaxActionsShown)) == NULL)
|
if ((ListMFUActions->Actions = malloc (MaxActionsShown *
|
||||||
|
sizeof (*ListMFUActions->Actions))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Can not allocate memory for list of most frequently used actions.");
|
Lay_ShowErrorAndExit ("Can not allocate memory for list of most frequently used actions.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,12 +237,9 @@ void MFU_WriteBigMFUActions (struct MFU_ListMFUActions *ListMFUActions)
|
||||||
{
|
{
|
||||||
/* Action string */
|
/* Action string */
|
||||||
Str_Copy (TabStr,Txt_TABS_TXT[Act_GetTab (Act_GetSuperAction (Action))],
|
Str_Copy (TabStr,Txt_TABS_TXT[Act_GetTab (Act_GetSuperAction (Action))],
|
||||||
MFU_MAX_BYTES_TAB);
|
sizeof (TabStr) - 1);
|
||||||
Str_Copy (MenuStr,Title,
|
Str_Copy (MenuStr,Title,sizeof (MenuStr) - 1);
|
||||||
MFU_MAX_BYTES_MENU);
|
snprintf (TabMenuStr,sizeof (TabMenuStr),"%s > %s",TabStr,MenuStr);
|
||||||
snprintf (TabMenuStr,sizeof (TabMenuStr),
|
|
||||||
"%s > %s",
|
|
||||||
TabStr,MenuStr);
|
|
||||||
|
|
||||||
/* Icon and text */
|
/* Icon and text */
|
||||||
HTM_LI_Begin ("class=\"ICO_HIGHLIGHT\"");
|
HTM_LI_Begin ("class=\"ICO_HIGHLIGHT\"");
|
||||||
|
@ -297,12 +295,9 @@ void MFU_WriteSmallMFUActions (struct MFU_ListMFUActions *ListMFUActions)
|
||||||
{
|
{
|
||||||
/* Action string */
|
/* Action string */
|
||||||
Str_Copy (TabStr,Txt_TABS_TXT[Act_GetTab (Act_GetSuperAction (Action))],
|
Str_Copy (TabStr,Txt_TABS_TXT[Act_GetTab (Act_GetSuperAction (Action))],
|
||||||
MFU_MAX_BYTES_TAB);
|
sizeof (TabStr) - 1);
|
||||||
Str_Copy (MenuStr,Title,
|
Str_Copy (MenuStr,Title,sizeof (MenuStr) - 1);
|
||||||
MFU_MAX_BYTES_MENU);
|
snprintf (TabMenuStr,sizeof (TabMenuStr),"%s > %s",TabStr,MenuStr);
|
||||||
snprintf (TabMenuStr,sizeof (TabMenuStr),
|
|
||||||
"%s > %s",
|
|
||||||
TabStr,MenuStr);
|
|
||||||
|
|
||||||
/* Icon and text */
|
/* Icon and text */
|
||||||
HTM_LI_Begin ("class=\"ICO_HIGHLIGHT\"");
|
HTM_LI_Begin ("class=\"ICO_HIGHLIGHT\"");
|
||||||
|
|
19
swad_RSS.c
19
swad_RSS.c
|
@ -66,14 +66,12 @@ void RSS_UpdateRSSFileForACrs (struct Crs_Course *Crs)
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
|
|
||||||
/***** Create RSS directory if not exists *****/
|
/***** Create RSS directory if not exists *****/
|
||||||
snprintf (PathRelPublRSSDir,sizeof (PathRelPublRSSDir),
|
snprintf (PathRelPublRSSDir,sizeof (PathRelPublRSSDir),"%s/%ld/%s",
|
||||||
"%s/%ld/%s",
|
|
||||||
Cfg_PATH_CRS_PUBLIC,Crs->CrsCod,Cfg_RSS_FOLDER);
|
Cfg_PATH_CRS_PUBLIC,Crs->CrsCod,Cfg_RSS_FOLDER);
|
||||||
Fil_CreateDirIfNotExists (PathRelPublRSSDir);
|
Fil_CreateDirIfNotExists (PathRelPublRSSDir);
|
||||||
|
|
||||||
/***** Create RSS file *****/
|
/***** Create RSS file *****/
|
||||||
snprintf (PathRelPublRSSFile,sizeof (PathRelPublRSSFile),
|
snprintf (PathRelPublRSSFile,sizeof (PathRelPublRSSFile),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
PathRelPublRSSDir,Cfg_RSS_FILE);
|
PathRelPublRSSDir,Cfg_RSS_FILE);
|
||||||
if ((FileRSS = fopen (PathRelPublRSSFile,"wb")) == NULL)
|
if ((FileRSS = fopen (PathRelPublRSSFile,"wb")) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Can not create RSS file.");
|
Lay_ShowErrorAndExit ("Can not create RSS file.");
|
||||||
|
@ -196,8 +194,7 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs)
|
||||||
fprintf (FileRSS,"<item>\n");
|
fprintf (FileRSS,"<item>\n");
|
||||||
|
|
||||||
/* Write title (first characters) of the notice */
|
/* Write title (first characters) of the notice */
|
||||||
Str_Copy (Content,row[3],
|
Str_Copy (Content,row[3],sizeof (Content) - 1);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
Str_LimitLengthHTMLStr (Content,40); // Remove when notice has a Subject
|
Str_LimitLengthHTMLStr (Content,40); // Remove when notice has a Subject
|
||||||
fprintf (FileRSS,"<title>%s: ",Txt_Notice);
|
fprintf (FileRSS,"<title>%s: ",Txt_Notice);
|
||||||
Str_FilePrintStrChangingBRToRetAndNBSPToSpace (FileRSS,Content);
|
Str_FilePrintStrChangingBRToRetAndNBSPToSpace (FileRSS,Content);
|
||||||
|
@ -208,16 +205,15 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs)
|
||||||
Cfg_URL_SWAD_CGI,Crs->CrsCod);
|
Cfg_URL_SWAD_CGI,Crs->CrsCod);
|
||||||
|
|
||||||
/* Write full content of the notice */
|
/* Write full content of the notice */
|
||||||
Str_Copy (Content,row[3],
|
Str_Copy (Content,row[3],sizeof (Content) - 1);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,40);
|
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,40);
|
||||||
fprintf (FileRSS,"<description><![CDATA[<p><em>%s %s %s:</em></p><p>%s</p>]]></description>\n",
|
fprintf (FileRSS,"<description><![CDATA[<p><em>%s %s %s:</em></p><p>%s</p>]]></description>\n",
|
||||||
UsrDat.FirstName,UsrDat.Surname1,UsrDat.Surname2,Content);
|
UsrDat.FrstName,UsrDat.Surname1,UsrDat.Surname2,Content);
|
||||||
|
|
||||||
/* Write author */
|
/* Write author */
|
||||||
if (UsrDat.Email[0])
|
if (UsrDat.Email[0])
|
||||||
fprintf (FileRSS,"<author>%s (%s %s %s)</author>\n",
|
fprintf (FileRSS,"<author>%s (%s %s %s)</author>\n",
|
||||||
UsrDat.Email,UsrDat.FirstName,UsrDat.Surname1,UsrDat.Surname2);
|
UsrDat.Email,UsrDat.FrstName,UsrDat.Surname1,UsrDat.Surname2);
|
||||||
|
|
||||||
/* Write unique string for this item */
|
/* Write unique string for this item */
|
||||||
fprintf (FileRSS,"<guid isPermaLink=\"false\">%s, course #%ld, notice #%ld</guid>\n",
|
fprintf (FileRSS,"<guid isPermaLink=\"false\">%s, course #%ld, notice #%ld</guid>\n",
|
||||||
|
@ -326,7 +322,6 @@ static void RSS_WriteExamAnnouncements (FILE *FileRSS,struct Crs_Course *Crs)
|
||||||
|
|
||||||
void RSS_BuildRSSLink (char RSSLink[Cns_MAX_BYTES_WWW + 1],long CrsCod)
|
void RSS_BuildRSSLink (char RSSLink[Cns_MAX_BYTES_WWW + 1],long CrsCod)
|
||||||
{
|
{
|
||||||
snprintf (RSSLink,Cns_MAX_BYTES_WWW + 1,
|
snprintf (RSSLink,Cns_MAX_BYTES_WWW + 1,"%s/%ld/%s/%s",
|
||||||
"%s/%ld/%s/%s",
|
|
||||||
Cfg_URL_CRS_PUBLIC,CrsCod,Cfg_RSS_FOLDER,Cfg_RSS_FILE);
|
Cfg_URL_CRS_PUBLIC,CrsCod,Cfg_RSS_FOLDER,Cfg_RSS_FILE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,9 +83,9 @@ extern struct Globals Gbl;
|
||||||
|
|
||||||
static void Acc_ShowFormCheckIfIHaveAccount (const char *Title);
|
static void Acc_ShowFormCheckIfIHaveAccount (const char *Title);
|
||||||
static void Acc_WriteRowEmptyAccount (unsigned NumUsr,const char *ID,struct UsrData *UsrDat);
|
static void Acc_WriteRowEmptyAccount (unsigned NumUsr,const char *ID,struct UsrData *UsrDat);
|
||||||
static void Acc_ShowFormRequestNewAccountWithParams (const char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
|
static void Acc_ShowFormRequestNewAccountWithParams (const char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
|
||||||
const char *NewEmail);
|
const char *NewEmail);
|
||||||
static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
|
static bool Acc_GetParamsNewAccount (char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
|
||||||
char *NewEmail,
|
char *NewEmail,
|
||||||
char *NewEncryptedPassword);
|
char *NewEncryptedPassword);
|
||||||
static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat);
|
static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat);
|
||||||
|
@ -313,7 +313,7 @@ static void Acc_WriteRowEmptyAccount (unsigned NumUsr,const char *ID,struct UsrD
|
||||||
/***** Button to login with this account *****/
|
/***** Button to login with this account *****/
|
||||||
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
|
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
|
||||||
Frm_StartForm (ActLogInNew);
|
Frm_StartForm (ActLogInNew);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
Btn_PutCreateButtonInline (Txt_Its_me);
|
Btn_PutCreateButtonInline (Txt_Its_me);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
@ -353,7 +353,7 @@ void Acc_ShowFormCreateMyAccount (void)
|
||||||
/************ Show form to create a new account using parameters *************/
|
/************ Show form to create a new account using parameters *************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Acc_ShowFormRequestNewAccountWithParams (const char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
|
static void Acc_ShowFormRequestNewAccountWithParams (const char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
|
||||||
const char *NewEmail)
|
const char *NewEmail)
|
||||||
{
|
{
|
||||||
extern const char *Hlp_PROFILE_SignUp;
|
extern const char *Hlp_PROFILE_SignUp;
|
||||||
|
@ -363,7 +363,7 @@ static void Acc_ShowFormRequestNewAccountWithParams (const char NewNicknameWitho
|
||||||
extern const char *Txt_HELP_nickname;
|
extern const char *Txt_HELP_nickname;
|
||||||
extern const char *Txt_HELP_email;
|
extern const char *Txt_HELP_email;
|
||||||
extern const char *Txt_Email;
|
extern const char *Txt_Email;
|
||||||
char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
char NewNickWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
||||||
|
|
||||||
/***** Begin form to enter some data of the new user *****/
|
/***** Begin form to enter some data of the new user *****/
|
||||||
Frm_StartForm (ActCreUsrAcc);
|
Frm_StartForm (ActCreUsrAcc);
|
||||||
|
@ -374,12 +374,11 @@ static void Acc_ShowFormRequestNewAccountWithParams (const char NewNicknameWitho
|
||||||
Hlp_PROFILE_SignUp,Box_NOT_CLOSABLE,2);
|
Hlp_PROFILE_SignUp,Box_NOT_CLOSABLE,2);
|
||||||
|
|
||||||
/***** Nickname *****/
|
/***** Nickname *****/
|
||||||
if (NewNicknameWithoutArroba[0])
|
if (NewNickWithoutArroba[0])
|
||||||
snprintf (NewNicknameWithArroba,sizeof (NewNicknameWithArroba),
|
snprintf (NewNickWithArroba,sizeof (NewNickWithArroba),"@%s",
|
||||||
"@%s",
|
NewNickWithoutArroba);
|
||||||
NewNicknameWithoutArroba);
|
|
||||||
else
|
else
|
||||||
NewNicknameWithArroba[0] = '\0';
|
NewNickWithArroba[0] = '\0';
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
|
||||||
/* Label */
|
/* Label */
|
||||||
|
@ -388,7 +387,7 @@ static void Acc_ShowFormRequestNewAccountWithParams (const char NewNicknameWitho
|
||||||
/* Data */
|
/* Data */
|
||||||
HTM_TD_Begin ("class=\"LT\"");
|
HTM_TD_Begin ("class=\"LT\"");
|
||||||
HTM_INPUT_TEXT ("NewNick",1 + Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA,
|
HTM_INPUT_TEXT ("NewNick",1 + Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA,
|
||||||
NewNicknameWithArroba,HTM_DONT_SUBMIT_ON_CHANGE,
|
NewNickWithArroba,HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"id=\"NewNick\" size=\"18\" placeholder=\"%s\" required=\"required\"",
|
"id=\"NewNick\" size=\"18\" placeholder=\"%s\" required=\"required\"",
|
||||||
Txt_HELP_nickname);
|
Txt_HELP_nickname);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
@ -563,7 +562,7 @@ void Acc_PutLinkToRemoveMyAccount (__attribute__((unused)) void *Args)
|
||||||
|
|
||||||
if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Me.UsrDat.UsrCod))
|
if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||||
Lay_PutContextualLinkOnlyIcon (ActReqRemMyAcc,NULL,
|
Lay_PutContextualLinkOnlyIcon (ActReqRemMyAcc,NULL,
|
||||||
Acc_PutParamsToRemoveMyAccount,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod,
|
Acc_PutParamsToRemoveMyAccount,Gbl.Usrs.Me.UsrDat.EnUsrCod,
|
||||||
"trash.svg",
|
"trash.svg",
|
||||||
Txt_Remove_account);
|
Txt_Remove_account);
|
||||||
}
|
}
|
||||||
|
@ -583,11 +582,11 @@ static void Acc_PutParamsToRemoveMyAccount (void *EncryptedUsrCod)
|
||||||
|
|
||||||
bool Acc_CreateMyNewAccountAndLogIn (void)
|
bool Acc_CreateMyNewAccountAndLogIn (void)
|
||||||
{
|
{
|
||||||
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
||||||
char NewEmail[Cns_MAX_BYTES_EMAIL_ADDRESS + 1];
|
char NewEmail[Cns_MAX_BYTES_EMAIL_ADDRESS + 1];
|
||||||
char NewEncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1];
|
char NewEncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1];
|
||||||
|
|
||||||
if (Acc_GetParamsNewAccount (NewNicknameWithoutArroba,NewEmail,NewEncryptedPassword))
|
if (Acc_GetParamsNewAccount (NewNickWithoutArroba,NewEmail,NewEncryptedPassword))
|
||||||
{
|
{
|
||||||
/***** User's has no ID *****/
|
/***** User's has no ID *****/
|
||||||
Gbl.Usrs.Me.UsrDat.IDs.Num = 0;
|
Gbl.Usrs.Me.UsrDat.IDs.Num = 0;
|
||||||
|
@ -595,23 +594,23 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
|
||||||
|
|
||||||
/***** Set password to the password typed by the user *****/
|
/***** Set password to the password typed by the user *****/
|
||||||
Str_Copy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword,
|
Str_Copy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword,
|
||||||
Pwd_BYTES_ENCRYPTED_PASSWORD);
|
sizeof (Gbl.Usrs.Me.UsrDat.Password) - 1);
|
||||||
|
|
||||||
/***** User does not exist in the platform, so create him/her! *****/
|
/***** User does not exist in the platform, so create him/her! *****/
|
||||||
Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat,
|
Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat,
|
||||||
true); // I am creating my own account
|
true); // I am creating my own account
|
||||||
|
|
||||||
/***** Save nickname *****/
|
/***** Save nickname *****/
|
||||||
Nck_UpdateNickInDB (Gbl.Usrs.Me.UsrDat.UsrCod,NewNicknameWithoutArroba);
|
Nck_UpdateNickInDB (Gbl.Usrs.Me.UsrDat.UsrCod,NewNickWithoutArroba);
|
||||||
Str_Copy (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba,
|
Str_Copy (Gbl.Usrs.Me.UsrDat.Nickname,NewNickWithoutArroba,
|
||||||
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
|
sizeof (Gbl.Usrs.Me.UsrDat.Nickname) - 1);
|
||||||
|
|
||||||
/***** Save email *****/
|
/***** Save email *****/
|
||||||
if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,NewEmail))
|
if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,NewEmail))
|
||||||
{
|
{
|
||||||
/* Email updated sucessfully */
|
/* Email updated sucessfully */
|
||||||
Str_Copy (Gbl.Usrs.Me.UsrDat.Email,NewEmail,
|
Str_Copy (Gbl.Usrs.Me.UsrDat.Email,NewEmail,
|
||||||
Cns_MAX_BYTES_EMAIL_ADDRESS);
|
sizeof (Gbl.Usrs.Me.UsrDat.Email) - 1);
|
||||||
|
|
||||||
Gbl.Usrs.Me.UsrDat.EmailConfirmed = false;
|
Gbl.Usrs.Me.UsrDat.EmailConfirmed = false;
|
||||||
}
|
}
|
||||||
|
@ -621,7 +620,7 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/***** Show form again ******/
|
/***** Show form again ******/
|
||||||
Acc_ShowFormRequestNewAccountWithParams (NewNicknameWithoutArroba,NewEmail);
|
Acc_ShowFormRequestNewAccountWithParams (NewNickWithoutArroba,NewEmail);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -631,7 +630,7 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Return false on error
|
// Return false on error
|
||||||
|
|
||||||
static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
|
static bool Acc_GetParamsNewAccount (char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
|
||||||
char *NewEmail,
|
char *NewEmail,
|
||||||
char *NewEncryptedPassword)
|
char *NewEncryptedPassword)
|
||||||
{
|
{
|
||||||
|
@ -639,44 +638,43 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES
|
||||||
extern const char *Txt_The_nickname_entered_X_is_not_valid_;
|
extern const char *Txt_The_nickname_entered_X_is_not_valid_;
|
||||||
extern const char *Txt_The_email_address_X_had_been_registered_by_another_user;
|
extern const char *Txt_The_email_address_X_had_been_registered_by_another_user;
|
||||||
extern const char *Txt_The_email_address_entered_X_is_not_valid;
|
extern const char *Txt_The_email_address_entered_X_is_not_valid;
|
||||||
char NewNicknameWithArroba[1 + Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
char NewNickWithArroba[1 + Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
||||||
char NewPlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1];
|
char NewPlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1];
|
||||||
bool Error = false;
|
bool Error = false;
|
||||||
|
|
||||||
/***** Step 1/3: Get new nickname from form *****/
|
/***** Step 1/3: Get new nickname from form *****/
|
||||||
Par_GetParToText ("NewNick",NewNicknameWithArroba,
|
Par_GetParToText ("NewNick",NewNickWithArroba,
|
||||||
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
|
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
|
||||||
|
|
||||||
/* Remove arrobas at the beginning */
|
/* Remove arrobas at the beginning */
|
||||||
Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
|
Str_Copy (NewNickWithoutArroba,NewNickWithArroba,
|
||||||
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
|
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
|
||||||
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
|
Str_RemoveLeadingArrobas (NewNickWithoutArroba);
|
||||||
|
|
||||||
/* Create a new version of the nickname with arroba */
|
/* Create a new version of the nickname with arroba */
|
||||||
snprintf (NewNicknameWithArroba,sizeof (NewNicknameWithArroba),
|
snprintf (NewNickWithArroba,sizeof (NewNickWithArroba),"@%s",
|
||||||
"@%s",
|
NewNickWithoutArroba);
|
||||||
NewNicknameWithoutArroba);
|
|
||||||
|
|
||||||
if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid
|
if (Nck_CheckIfNickWithArrobaIsValid (NewNickWithArroba)) // If new nickname is valid
|
||||||
{
|
{
|
||||||
/* Check if the new nickname
|
/* Check if the new nickname
|
||||||
matches any of the nicknames of other users */
|
matches any of the nicknames of other users */
|
||||||
if (DB_QueryCOUNT ("can not check if nickname already existed",
|
if (DB_QueryCOUNT ("can not check if nickname already existed",
|
||||||
"SELECT COUNT(*) FROM usr_nicknames"
|
"SELECT COUNT(*) FROM usr_nicknames"
|
||||||
" WHERE Nickname='%s' AND UsrCod<>%ld",
|
" WHERE Nickname='%s' AND UsrCod<>%ld",
|
||||||
NewNicknameWithoutArroba,
|
NewNickWithoutArroba,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // A nickname of another user is the same that this nickname
|
Gbl.Usrs.Me.UsrDat.UsrCod)) // A nickname of another user is the same that this nickname
|
||||||
{
|
{
|
||||||
Error = true;
|
Error = true;
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_The_nickname_X_had_been_registered_by_another_user,
|
Ale_ShowAlert (Ale_WARNING,Txt_The_nickname_X_had_been_registered_by_another_user,
|
||||||
NewNicknameWithoutArroba);
|
NewNickWithoutArroba);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // New nickname is not valid
|
else // New nickname is not valid
|
||||||
{
|
{
|
||||||
Error = true;
|
Error = true;
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_The_nickname_entered_X_is_not_valid_,
|
Ale_ShowAlert (Ale_WARNING,Txt_The_nickname_entered_X_is_not_valid_,
|
||||||
NewNicknameWithArroba,
|
NewNickWithArroba,
|
||||||
Nck_MIN_CHARS_NICKNAME_WITHOUT_ARROBA,
|
Nck_MIN_CHARS_NICKNAME_WITHOUT_ARROBA,
|
||||||
Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA);
|
Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA);
|
||||||
}
|
}
|
||||||
|
@ -773,9 +771,9 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
|
||||||
"'%s','%s',"
|
"'%s','%s',"
|
||||||
"%s,'%s',"
|
"%s,'%s',"
|
||||||
"%u,%u,-1,0)",
|
"%u,%u,-1,0)",
|
||||||
UsrDat->EncryptedUsrCod,
|
UsrDat->EnUsrCod,
|
||||||
UsrDat->Password,
|
UsrDat->Password,
|
||||||
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName,
|
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FrstName,
|
||||||
Usr_StringsSexDB[UsrDat->Sex],
|
Usr_StringsSexDB[UsrDat->Sex],
|
||||||
The_ThemeId[UsrDat->Prefs.Theme],
|
The_ThemeId[UsrDat->Prefs.Theme],
|
||||||
Ico_IconSetId[UsrDat->Prefs.IconSet],
|
Ico_IconSetId[UsrDat->Prefs.IconSet],
|
||||||
|
@ -836,8 +834,8 @@ static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat)
|
||||||
NumTry++)
|
NumTry++)
|
||||||
{
|
{
|
||||||
Str_CreateRandomAlphanumStr (RandomStr,LENGTH_RANDOM_STR);
|
Str_CreateRandomAlphanumStr (RandomStr,LENGTH_RANDOM_STR);
|
||||||
Cry_EncryptSHA256Base64 (RandomStr,UsrDat->EncryptedUsrCod);
|
Cry_EncryptSHA256Base64 (RandomStr,UsrDat->EnUsrCod);
|
||||||
if (!Usr_ChkIfEncryptedUsrCodExists (UsrDat->EncryptedUsrCod))
|
if (!Usr_ChkIfEncryptedUsrCodExists (UsrDat->EnUsrCod))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (NumTry == MAX_TRY)
|
if (NumTry == MAX_TRY)
|
||||||
|
@ -985,7 +983,7 @@ static void Acc_AskIfRemoveOtherUsrAccount (void)
|
||||||
|
|
||||||
/* Show form to request confirmation */
|
/* Show form to request confirmation */
|
||||||
Frm_StartForm (ActRemUsrGbl);
|
Frm_StartForm (ActRemUsrGbl);
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
Pwd_AskForConfirmationOnDangerousAction ();
|
Pwd_AskForConfirmationOnDangerousAction ();
|
||||||
Btn_PutRemoveButton (Txt_Eliminate_user_account);
|
Btn_PutRemoveButton (Txt_Eliminate_user_account);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
|
|
|
@ -3965,8 +3965,7 @@ static const char *Act_GetActionTextFromDB (long ActCod) // TODO: Remove when da
|
||||||
{
|
{
|
||||||
/***** Get text *****/
|
/***** Get text *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (ActTxt,row[0],
|
Str_Copy (ActTxt,row[0],sizeof (ActTxt) - 1);
|
||||||
Act_MAX_BYTES_ACTION_TXT);
|
|
||||||
}
|
}
|
||||||
else // ActCod-Language not found on database
|
else // ActCod-Language not found on database
|
||||||
ActTxt[0] = '\0';
|
ActTxt[0] = '\0';
|
||||||
|
@ -4084,7 +4083,7 @@ void Act_AdjustCurrentAction (void)
|
||||||
the only action possible
|
the only action possible
|
||||||
is to show a form to change my shared record card *****/
|
is to show a form to change my shared record card *****/
|
||||||
if ( Gbl.Usrs.Me.UsrDat.Sex == Usr_SEX_UNKNOWN ||
|
if ( Gbl.Usrs.Me.UsrDat.Sex == Usr_SEX_UNKNOWN ||
|
||||||
!Gbl.Usrs.Me.UsrDat.FirstName[0] ||
|
!Gbl.Usrs.Me.UsrDat.FrstName[0] ||
|
||||||
!Gbl.Usrs.Me.UsrDat.Surname1 [0] ||
|
!Gbl.Usrs.Me.UsrDat.Surname1 [0] ||
|
||||||
Gbl.Usrs.Me.UsrDat.CtyCod <= 0 ||
|
Gbl.Usrs.Me.UsrDat.CtyCod <= 0 ||
|
||||||
Gbl.Usrs.Me.UsrDat.InsCod < 0 ||
|
Gbl.Usrs.Me.UsrDat.InsCod < 0 ||
|
||||||
|
|
|
@ -170,9 +170,7 @@ void Agd_PutParamAgd (void)
|
||||||
{
|
{
|
||||||
char Nickname[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
char Nickname[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
||||||
|
|
||||||
snprintf (Nickname,sizeof (Nickname),
|
snprintf (Nickname,sizeof (Nickname),"@%s",Gbl.Usrs.Other.UsrDat.Nickname);
|
||||||
"@%s",
|
|
||||||
Gbl.Usrs.Other.UsrDat.Nickname);
|
|
||||||
Par_PutHiddenParamString (NULL,"agd",Nickname);
|
Par_PutHiddenParamString (NULL,"agd",Nickname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,12 +409,12 @@ void Agd_ShowUsrAgenda (void)
|
||||||
if (ItsMe)
|
if (ItsMe)
|
||||||
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
|
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
|
||||||
Gbl.Usrs.Me.UsrDat.FullName),
|
Gbl.Usrs.Me.UsrDat.FullName),
|
||||||
Agd_PutIconsMyPublicAgenda,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod,
|
Agd_PutIconsMyPublicAgenda,Gbl.Usrs.Me.UsrDat.EnUsrCod,
|
||||||
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
|
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
|
||||||
else
|
else
|
||||||
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
|
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
|
||||||
Gbl.Usrs.Other.UsrDat.FullName),
|
Gbl.Usrs.Other.UsrDat.FullName),
|
||||||
Agd_PutIconsOtherPublicAgenda,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
Agd_PutIconsOtherPublicAgenda,Gbl.Usrs.Other.UsrDat.EnUsrCod,
|
||||||
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
|
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
|
||||||
Str_FreeString ();
|
Str_FreeString ();
|
||||||
|
|
||||||
|
@ -463,12 +461,12 @@ void Agd_ShowOtherAgendaAfterLogIn (void)
|
||||||
if (ItsMe)
|
if (ItsMe)
|
||||||
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
|
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
|
||||||
Gbl.Usrs.Me.UsrDat.FullName),
|
Gbl.Usrs.Me.UsrDat.FullName),
|
||||||
Agd_PutIconToViewEditMyFullAgenda,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod,
|
Agd_PutIconToViewEditMyFullAgenda,Gbl.Usrs.Me.UsrDat.EnUsrCod,
|
||||||
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
|
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
|
||||||
else
|
else
|
||||||
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
|
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
|
||||||
Gbl.Usrs.Other.UsrDat.FullName),
|
Gbl.Usrs.Other.UsrDat.FullName),
|
||||||
Agd_PutIconsOtherPublicAgenda,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
Agd_PutIconsOtherPublicAgenda,Gbl.Usrs.Other.UsrDat.EnUsrCod,
|
||||||
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
|
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
|
||||||
Str_FreeString ();
|
Str_FreeString ();
|
||||||
|
|
||||||
|
@ -650,7 +648,7 @@ static void Agd_WriteHeaderListEvents (const struct Agd_Agenda *Agenda,
|
||||||
case Agd_ANOTHER_AGENDA_TODAY:
|
case Agd_ANOTHER_AGENDA_TODAY:
|
||||||
case Agd_ANOTHER_AGENDA:
|
case Agd_ANOTHER_AGENDA:
|
||||||
Frm_StartForm (ActSeeUsrAgd);
|
Frm_StartForm (ActSeeUsrAgd);
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
Pag_PutHiddenParamPagNum (Pag_ANOTHER_AGENDA,Agenda->CurrentPage);
|
Pag_PutHiddenParamPagNum (Pag_ANOTHER_AGENDA,Agenda->CurrentPage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -723,10 +721,8 @@ static void Agd_PutIconToShowQR (void)
|
||||||
char URL[Cns_MAX_BYTES_WWW + 1];
|
char URL[Cns_MAX_BYTES_WWW + 1];
|
||||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||||
|
|
||||||
snprintf (URL,sizeof (URL),
|
snprintf (URL,sizeof (URL),"%s/%s?agd=@%s",
|
||||||
"%s/%s?agd=@%s",
|
Cfg_URL_SWAD_CGI,Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
||||||
Cfg_URL_SWAD_CGI,
|
|
||||||
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
|
||||||
Gbl.Usrs.Me.UsrDat.Nickname);
|
Gbl.Usrs.Me.UsrDat.Nickname);
|
||||||
QR_PutLinkToPrintQRCode (ActPrnAgdQR,
|
QR_PutLinkToPrintQRCode (ActPrnAgdQR,
|
||||||
QR_PutParamQRString,URL);
|
QR_PutParamQRString,URL);
|
||||||
|
@ -1047,9 +1043,9 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
|
||||||
Agd_AgendaType_t AgendaType)
|
Agd_AgendaType_t AgendaType)
|
||||||
{
|
{
|
||||||
char *UsrSubQuery;
|
char *UsrSubQuery;
|
||||||
char Past__FutureEventsSubQuery[Agd_MAX_BYTES_SUBQUERY];
|
char Past__FutureEventsSubQuery[Agd_MAX_BYTES_SUBQUERY + 1];
|
||||||
char PrivatPublicEventsSubQuery[Agd_MAX_BYTES_SUBQUERY];
|
char PrivatPublicEventsSubQuery[Agd_MAX_BYTES_SUBQUERY + 1];
|
||||||
char HiddenVisiblEventsSubQuery[Agd_MAX_BYTES_SUBQUERY];
|
char HiddenVisiblEventsSubQuery[Agd_MAX_BYTES_SUBQUERY + 1];
|
||||||
static const char *OrderBySubQuery[Dat_NUM_START_END_TIME] =
|
static const char *OrderBySubQuery[Dat_NUM_START_END_TIME] =
|
||||||
{
|
{
|
||||||
[Dat_START_TIME] = "StartTime,EndTime,Event,Location",
|
[Dat_START_TIME] = "StartTime,EndTime,Event,Location",
|
||||||
|
@ -1083,19 +1079,19 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
|
||||||
Str_Copy (Past__FutureEventsSubQuery,
|
Str_Copy (Past__FutureEventsSubQuery,
|
||||||
" AND DATE(StartTime)<=CURDATE()"
|
" AND DATE(StartTime)<=CURDATE()"
|
||||||
" AND DATE(EndTime)>=CURDATE()",
|
" AND DATE(EndTime)>=CURDATE()",
|
||||||
Agd_MAX_BYTES_SUBQUERY); // Today events
|
sizeof (Past__FutureEventsSubQuery) - 1); // Today events
|
||||||
else
|
else
|
||||||
switch (Agenda->Past__FutureEvents)
|
switch (Agenda->Past__FutureEvents)
|
||||||
{
|
{
|
||||||
case (1 << Agd_PAST___EVENTS):
|
case (1 << Agd_PAST___EVENTS):
|
||||||
Str_Copy (Past__FutureEventsSubQuery,
|
Str_Copy (Past__FutureEventsSubQuery,
|
||||||
" AND DATE(StartTime)<=CURDATE()",
|
" AND DATE(StartTime)<=CURDATE()",
|
||||||
Agd_MAX_BYTES_SUBQUERY); // Past and today events
|
sizeof (Past__FutureEventsSubQuery) - 1); // Past and today events
|
||||||
break;
|
break;
|
||||||
case (1 << Agd_FUTURE_EVENTS):
|
case (1 << Agd_FUTURE_EVENTS):
|
||||||
Str_Copy (Past__FutureEventsSubQuery,
|
Str_Copy (Past__FutureEventsSubQuery,
|
||||||
" AND DATE(EndTime)>=CURDATE()",
|
" AND DATE(EndTime)>=CURDATE()",
|
||||||
Agd_MAX_BYTES_SUBQUERY); // Today and future events
|
sizeof (Past__FutureEventsSubQuery) - 1); // Today and future events
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Past__FutureEventsSubQuery[0] = '\0'; // All events
|
Past__FutureEventsSubQuery[0] = '\0'; // All events
|
||||||
|
@ -1105,11 +1101,11 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
|
||||||
{
|
{
|
||||||
case (1 << Agd_PRIVAT_EVENTS):
|
case (1 << Agd_PRIVAT_EVENTS):
|
||||||
Str_Copy (PrivatPublicEventsSubQuery," AND Public='N'",
|
Str_Copy (PrivatPublicEventsSubQuery," AND Public='N'",
|
||||||
Agd_MAX_BYTES_SUBQUERY); // Private events
|
sizeof (PrivatPublicEventsSubQuery) - 1); // Private events
|
||||||
break;
|
break;
|
||||||
case (1 << Agd_PUBLIC_EVENTS):
|
case (1 << Agd_PUBLIC_EVENTS):
|
||||||
Str_Copy (PrivatPublicEventsSubQuery," AND Public='Y'",
|
Str_Copy (PrivatPublicEventsSubQuery," AND Public='Y'",
|
||||||
Agd_MAX_BYTES_SUBQUERY); // Public events
|
sizeof (PrivatPublicEventsSubQuery) - 1); // Public events
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PrivatPublicEventsSubQuery[0] = '\0'; // All events
|
PrivatPublicEventsSubQuery[0] = '\0'; // All events
|
||||||
|
@ -1119,11 +1115,11 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
|
||||||
{
|
{
|
||||||
case (1 << Agd_HIDDEN_EVENTS):
|
case (1 << Agd_HIDDEN_EVENTS):
|
||||||
Str_Copy (HiddenVisiblEventsSubQuery," AND Hidden='Y'",
|
Str_Copy (HiddenVisiblEventsSubQuery," AND Hidden='Y'",
|
||||||
Agd_MAX_BYTES_SUBQUERY); // Hidden events
|
sizeof (HiddenVisiblEventsSubQuery) - 1); // Hidden events
|
||||||
break;
|
break;
|
||||||
case (1 << Agd_VISIBL_EVENTS):
|
case (1 << Agd_VISIBL_EVENTS):
|
||||||
Str_Copy (HiddenVisiblEventsSubQuery," AND Hidden='N'",
|
Str_Copy (HiddenVisiblEventsSubQuery," AND Hidden='N'",
|
||||||
Agd_MAX_BYTES_SUBQUERY); // Visible events
|
sizeof (HiddenVisiblEventsSubQuery) - 1); // Visible events
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
HiddenVisiblEventsSubQuery[0] = '\0'; // All events
|
HiddenVisiblEventsSubQuery[0] = '\0'; // All events
|
||||||
|
@ -1140,15 +1136,15 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
|
||||||
Str_Copy (Past__FutureEventsSubQuery,
|
Str_Copy (Past__FutureEventsSubQuery,
|
||||||
" AND DATE(StartTime)<=CURDATE()"
|
" AND DATE(StartTime)<=CURDATE()"
|
||||||
" AND DATE(EndTime)>=CURDATE()",
|
" AND DATE(EndTime)>=CURDATE()",
|
||||||
Agd_MAX_BYTES_SUBQUERY); // Today events
|
sizeof (Past__FutureEventsSubQuery) - 1); // Today events
|
||||||
else
|
else
|
||||||
Str_Copy (Past__FutureEventsSubQuery,
|
Str_Copy (Past__FutureEventsSubQuery,
|
||||||
" AND DATE(EndTime)>=CURDATE()",
|
" AND DATE(EndTime)>=CURDATE()",
|
||||||
Agd_MAX_BYTES_SUBQUERY); // Today and future events
|
sizeof (Past__FutureEventsSubQuery) - 1); // Today and future events
|
||||||
Str_Copy (PrivatPublicEventsSubQuery," AND Public='Y'",
|
Str_Copy (PrivatPublicEventsSubQuery," AND Public='Y'",
|
||||||
Agd_MAX_BYTES_SUBQUERY); // Public events
|
sizeof (PrivatPublicEventsSubQuery) - 1); // Public events
|
||||||
Str_Copy (HiddenVisiblEventsSubQuery," AND Hidden='N'",
|
Str_Copy (HiddenVisiblEventsSubQuery," AND Hidden='N'",
|
||||||
Agd_MAX_BYTES_SUBQUERY); // Visible events
|
sizeof (HiddenVisiblEventsSubQuery) - 1); // Visible events
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DoQuery)
|
if (DoQuery)
|
||||||
|
@ -1172,7 +1168,8 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
|
||||||
Agenda->Num = (unsigned) NumRows;
|
Agenda->Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list of events *****/
|
/***** Create list of events *****/
|
||||||
if ((Agenda->LstAgdCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
|
if ((Agenda->LstAgdCods = calloc (NumRows,
|
||||||
|
sizeof (*Agenda->LstAgdCods))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the events codes *****/
|
/***** Get the events codes *****/
|
||||||
|
@ -1251,12 +1248,10 @@ static void Agd_GetDataOfEventByCod (struct Agd_Event *AgdEvent)
|
||||||
Dat_PRESENT));
|
Dat_PRESENT));
|
||||||
|
|
||||||
/* Get the event (row[7]) */
|
/* Get the event (row[7]) */
|
||||||
Str_Copy (AgdEvent->Event,row[7],
|
Str_Copy (AgdEvent->Event ,row[7],sizeof (AgdEvent->Event ) - 1);
|
||||||
Agd_MAX_BYTES_EVENT);
|
|
||||||
|
|
||||||
/* Get the event (row[8]) */
|
/* Get the event (row[8]) */
|
||||||
Str_Copy (AgdEvent->Location,row[8],
|
Str_Copy (AgdEvent->Location,row[8],sizeof (AgdEvent->Location) - 1);
|
||||||
Agd_MAX_BYTES_LOCATION);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1313,8 +1308,7 @@ static void Agd_GetEventTxtFromDB (struct Agd_Event *AgdEvent,
|
||||||
{
|
{
|
||||||
/* Get info text */
|
/* Get info text */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Txt,row[0],
|
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Txt[0] = '\0';
|
Txt[0] = '\0';
|
||||||
|
|
|
@ -156,12 +156,10 @@ void Ann_ShowAllAnnouncements (void)
|
||||||
Lay_ShowErrorAndExit ("Error when reading roles of announcement.");
|
Lay_ShowErrorAndExit ("Error when reading roles of announcement.");
|
||||||
|
|
||||||
/* Get the content (row[3]) */
|
/* Get the content (row[3]) */
|
||||||
Str_Copy (Subject,row[3],
|
Str_Copy (Subject,row[3],sizeof (Subject) - 1);
|
||||||
Cns_MAX_BYTES_SUBJECT);
|
|
||||||
|
|
||||||
/* Get the content (row[4]) and insert links */
|
/* Get the content (row[4]) and insert links */
|
||||||
Str_Copy (Content,row[4],
|
Str_Copy (Content,row[4],sizeof (Content) - 1);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50);
|
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50);
|
||||||
|
|
||||||
/* Show the announcement */
|
/* Show the announcement */
|
||||||
|
@ -248,12 +246,10 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of announcement.");
|
Lay_ShowErrorAndExit ("Wrong code of announcement.");
|
||||||
|
|
||||||
/* Get the content (row[1]) */
|
/* Get the content (row[1]) */
|
||||||
Str_Copy (Subject,row[1],
|
Str_Copy (Subject,row[1],sizeof (Subject) - 1);
|
||||||
Cns_MAX_BYTES_SUBJECT);
|
|
||||||
|
|
||||||
/* Get the content (row[2]) and insert links */
|
/* Get the content (row[2]) and insert links */
|
||||||
Str_Copy (Content,row[2],
|
Str_Copy (Content,row[2],sizeof (Content) - 1);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50);
|
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50);
|
||||||
|
|
||||||
/* Show the announcement */
|
/* Show the announcement */
|
||||||
|
|
|
@ -543,8 +543,9 @@ static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,bool PrintView
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
Gbl.FileBrowser.Type = Brw_ADMI_ASG_CRS; // Course assignments
|
Gbl.FileBrowser.Type = Brw_ADMI_ASG_CRS; // Course assignments
|
||||||
Str_Copy (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod,
|
Str_Copy (Gbl.Usrs.Other.UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Gbl.Usrs.Me.UsrDat.EnUsrCod,
|
||||||
|
sizeof (Gbl.Usrs.Other.UsrDat.EnUsrCod) - 1);
|
||||||
Usr_CreateListSelectedUsrsCodsAndFillWithOtherUsr (&Gbl.Usrs.Selected);
|
Usr_CreateListSelectedUsrsCodsAndFillWithOtherUsr (&Gbl.Usrs.Selected);
|
||||||
Frm_StartForm (ActFrmCreAsgCrs);
|
Frm_StartForm (ActFrmCreAsgCrs);
|
||||||
break;
|
break;
|
||||||
|
@ -552,10 +553,11 @@ static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,bool PrintView
|
||||||
Rol_WrongRoleExit ();
|
Rol_WrongRoleExit ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,Brw_INTERNAL_NAME_ROOT_FOLDER_ASSIGNMENTS,
|
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,
|
||||||
PATH_MAX);
|
Brw_INTERNAL_NAME_ROOT_FOLDER_ASSIGNMENTS,
|
||||||
|
sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1);
|
||||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,Asg->Folder,
|
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,Asg->Folder,
|
||||||
NAME_MAX);
|
sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1);
|
||||||
Gbl.FileBrowser.FilFolLnk.Type = Brw_IS_FOLDER;
|
Gbl.FileBrowser.FilFolLnk.Type = Brw_IS_FOLDER;
|
||||||
Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk);
|
Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk);
|
||||||
Ico_PutIconLink ("folder-open-yellow-plus.png",
|
Ico_PutIconLink ("folder-open-yellow-plus.png",
|
||||||
|
@ -720,7 +722,8 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
|
||||||
Assignments->Num = (unsigned) NumRows;
|
Assignments->Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list of assignments *****/
|
/***** Create list of assignments *****/
|
||||||
if ((Assignments->LstAsgCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
|
if ((Assignments->LstAsgCods = calloc (NumRows,
|
||||||
|
sizeof (*Assignments->LstAsgCods))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the assignments codes *****/
|
/***** Get the assignments codes *****/
|
||||||
|
@ -863,12 +866,10 @@ static void Asg_GetDataOfAssignment (struct Asg_Assignment *Asg,
|
||||||
Asg->Open = (row[5][0] == '1');
|
Asg->Open = (row[5][0] == '1');
|
||||||
|
|
||||||
/* Get the title of the assignment (row[6]) */
|
/* Get the title of the assignment (row[6]) */
|
||||||
Str_Copy (Asg->Title,row[6],
|
Str_Copy (Asg->Title ,row[6],sizeof (Asg->Title ) - 1);
|
||||||
Asg_MAX_BYTES_ASSIGNMENT_TITLE);
|
|
||||||
|
|
||||||
/* Get the folder for the assignment files (row[7]) */
|
/* Get the folder for the assignment files (row[7]) */
|
||||||
Str_Copy (Asg->Folder,row[7],
|
Str_Copy (Asg->Folder,row[7],sizeof (Asg->Folder) - 1);
|
||||||
Brw_MAX_BYTES_FOLDER);
|
|
||||||
Asg->SendWork = (Asg->Folder[0] != '\0');
|
Asg->SendWork = (Asg->Folder[0] != '\0');
|
||||||
|
|
||||||
/* Can I do this assignment? */
|
/* Can I do this assignment? */
|
||||||
|
@ -937,8 +938,7 @@ static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT
|
||||||
{
|
{
|
||||||
/* Get info text */
|
/* Get info text */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Txt,row[0],
|
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Txt[0] = '\0';
|
Txt[0] = '\0';
|
||||||
|
@ -979,17 +979,15 @@ void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/***** Get summary *****/
|
/***** Get summary *****/
|
||||||
Str_Copy (SummaryStr,row[0],
|
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
|
||||||
Ntf_MAX_BYTES_SUMMARY);
|
|
||||||
|
|
||||||
/***** Get content *****/
|
/***** Get content *****/
|
||||||
if (GetContent)
|
if (GetContent)
|
||||||
{
|
{
|
||||||
Length = strlen (row[1]);
|
Length = strlen (row[1]);
|
||||||
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
|
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (*ContentStr,row[1],
|
Str_Copy (*ContentStr,row[1],Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -371,7 +371,7 @@ static void Att_PutIconsInListOfAttEvents (void *Events)
|
||||||
|
|
||||||
/***** Put icon to print my QR code *****/
|
/***** Put icon to print my QR code *****/
|
||||||
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
|
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
|
||||||
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
|
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,7 +705,7 @@ static void Att_GetListAttEvents (struct Att_Events *Events,
|
||||||
Events->Num = (unsigned) NumRows;
|
Events->Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list of attendance events *****/
|
/***** Create list of attendance events *****/
|
||||||
if ((Events->Lst = (struct Att_Event *) calloc (NumRows,sizeof (struct Att_Event))) == NULL)
|
if ((Events->Lst = calloc (NumRows,sizeof (*Events->Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the attendance events codes *****/
|
/***** Get the attendance events codes *****/
|
||||||
|
@ -804,8 +804,7 @@ bool Att_GetDataOfAttEventByCod (struct Att_Event *Event)
|
||||||
Event->CommentTchVisible = (row[7][0] == 'Y');
|
Event->CommentTchVisible = (row[7][0] == 'Y');
|
||||||
|
|
||||||
/* Get the title of the attendance event (row[8]) */
|
/* Get the title of the attendance event (row[8]) */
|
||||||
Str_Copy (Event->Title,row[8],
|
Str_Copy (Event->Title,row[8],sizeof (Event->Title) - 1);
|
||||||
Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -877,8 +876,7 @@ static void Att_GetAttEventDescriptionFromDB (long AttCod,char Description[Cns_M
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get info text */
|
/* Get info text */
|
||||||
Str_Copy (Description,row[0],
|
Str_Copy (Description,row[0],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Description[0] = '\0';
|
Description[0] = '\0';
|
||||||
|
@ -2128,7 +2126,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
||||||
HTM_TD_Begin ("class=\"CT COLOR%u\"",Gbl.RowEvenOdd);
|
HTM_TD_Begin ("class=\"CT COLOR%u\"",Gbl.RowEvenOdd);
|
||||||
HTM_INPUT_CHECKBOX ("UsrCodStd",HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_INPUT_CHECKBOX ("UsrCodStd",HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"id=\"Std%u\" value=\"%s\"%s%s",
|
"id=\"Std%u\" value=\"%s\"%s%s",
|
||||||
NumUsr,UsrDat->EncryptedUsrCod,
|
NumUsr,UsrDat->EnUsrCod,
|
||||||
Present ? " checked=\"checked\"" : "",
|
Present ? " checked=\"checked\"" : "",
|
||||||
ICanChangeStdAttendance ? "" : " disabled=\"disabled\"");
|
ICanChangeStdAttendance ? "" : " disabled=\"disabled\"");
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
@ -2168,7 +2166,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
||||||
HTM_Txt (UsrDat->Surname1);
|
HTM_Txt (UsrDat->Surname1);
|
||||||
if (UsrDat->Surname2[0])
|
if (UsrDat->Surname2[0])
|
||||||
HTM_TxtF (" %s",UsrDat->Surname2);
|
HTM_TxtF (" %s",UsrDat->Surname2);
|
||||||
HTM_TxtF (", %s",UsrDat->FirstName);
|
HTM_TxtF (", %s",UsrDat->FrstName);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Student's comment: write form or text */
|
/***** Student's comment: write form or text */
|
||||||
|
@ -2176,7 +2174,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
||||||
if (ICanEditStdComment) // Show with form
|
if (ICanEditStdComment) // Show with form
|
||||||
{
|
{
|
||||||
HTM_TEXTAREA_Begin ("name=\"CommentStd%s\" cols=\"40\" rows=\"3\"",
|
HTM_TEXTAREA_Begin ("name=\"CommentStd%s\" cols=\"40\" rows=\"3\"",
|
||||||
UsrDat->EncryptedUsrCod);
|
UsrDat->EnUsrCod);
|
||||||
HTM_Txt (CommentStd);
|
HTM_Txt (CommentStd);
|
||||||
HTM_TEXTAREA_End ();
|
HTM_TEXTAREA_End ();
|
||||||
}
|
}
|
||||||
|
@ -2193,7 +2191,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
||||||
if (ICanEditTchComment) // Show with form
|
if (ICanEditTchComment) // Show with form
|
||||||
{
|
{
|
||||||
HTM_TEXTAREA_Begin ("name=\"CommentTch%s\" cols=\"40\" rows=\"3\"",
|
HTM_TEXTAREA_Begin ("name=\"CommentTch%s\" cols=\"40\" rows=\"3\"",
|
||||||
UsrDat->EncryptedUsrCod);
|
UsrDat->EnUsrCod);
|
||||||
HTM_Txt (CommentTch);
|
HTM_Txt (CommentTch);
|
||||||
HTM_TEXTAREA_End ();
|
HTM_TEXTAREA_End ();
|
||||||
}
|
}
|
||||||
|
@ -2253,7 +2251,7 @@ static void Att_PutParamsCodGrps (long AttCod)
|
||||||
if (NumGrps) // Groups found...
|
if (NumGrps) // Groups found...
|
||||||
{
|
{
|
||||||
MaxLengthGrpCods = NumGrps * (1 + 20) - 1;
|
MaxLengthGrpCods = NumGrps * (1 + 20) - 1;
|
||||||
if ((GrpCods = (char *) malloc (MaxLengthGrpCods + 1)) == NULL)
|
if ((GrpCods = malloc (MaxLengthGrpCods + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
GrpCods[0] = '\0';
|
GrpCods[0] = '\0';
|
||||||
|
|
||||||
|
@ -2310,7 +2308,7 @@ void Att_RegisterMeAsStdInAttEvent (void)
|
||||||
Present = Att_CheckIfUsrIsPresentInAttEventAndGetComments (Event.AttCod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
Present = Att_CheckIfUsrIsPresentInAttEventAndGetComments (Event.AttCod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
CommentStd,CommentTch);
|
CommentStd,CommentTch);
|
||||||
Par_GetParToHTML (Str_BuildStringStr ("CommentStd%s",
|
Par_GetParToHTML (Str_BuildStringStr ("CommentStd%s",
|
||||||
Gbl.Usrs.Me.UsrDat.EncryptedUsrCod),
|
Gbl.Usrs.Me.UsrDat.EnUsrCod),
|
||||||
CommentStd,Cns_MAX_BYTES_TEXT);
|
CommentStd,Cns_MAX_BYTES_TEXT);
|
||||||
Str_FreeString ();
|
Str_FreeString ();
|
||||||
|
|
||||||
|
@ -2396,7 +2394,7 @@ void Att_RegisterStudentsInAttEvent (void)
|
||||||
Ptr = Gbl.Usrs.Selected.List[Rol_STD];
|
Ptr = Gbl.Usrs.Selected.List[Rol_STD];
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrData.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrData.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&UsrData);
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrData);
|
||||||
if (UsrData.UsrCod > 0) // Student exists in database
|
if (UsrData.UsrCod > 0) // Student exists in database
|
||||||
|
@ -2427,7 +2425,7 @@ void Att_RegisterStudentsInAttEvent (void)
|
||||||
/***** Get comments for this student *****/
|
/***** Get comments for this student *****/
|
||||||
Att_CheckIfUsrIsPresentInAttEventAndGetComments (Event.AttCod,Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].UsrCod,CommentStd,CommentTch);
|
Att_CheckIfUsrIsPresentInAttEventAndGetComments (Event.AttCod,Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].UsrCod,CommentStd,CommentTch);
|
||||||
Par_GetParToHTML (Str_BuildStringStr ("CommentTch%s",
|
Par_GetParToHTML (Str_BuildStringStr ("CommentTch%s",
|
||||||
Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].EncryptedUsrCod),
|
Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].EnUsrCod),
|
||||||
CommentTch,Cns_MAX_BYTES_TEXT);
|
CommentTch,Cns_MAX_BYTES_TEXT);
|
||||||
Str_FreeString ();
|
Str_FreeString ();
|
||||||
|
|
||||||
|
@ -2603,12 +2601,10 @@ static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long Us
|
||||||
Present = (row[0][0] == 'Y');
|
Present = (row[0][0] == 'Y');
|
||||||
|
|
||||||
/* Get student's comment (row[1]) */
|
/* Get student's comment (row[1]) */
|
||||||
Str_Copy (CommentStd,row[1],
|
Str_Copy (CommentStd,row[1],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
|
|
||||||
/* Get teacher's comment (row[2]) */
|
/* Get teacher's comment (row[2]) */
|
||||||
Str_Copy (CommentTch,row[2],
|
Str_Copy (CommentTch,row[2],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
}
|
}
|
||||||
else // User is not present
|
else // User is not present
|
||||||
{
|
{
|
||||||
|
@ -2977,7 +2973,7 @@ static void Att_GetListSelectedAttCods (struct Att_Events *Events)
|
||||||
|
|
||||||
/***** Allocate memory for list of attendance events selected *****/
|
/***** Allocate memory for list of attendance events selected *****/
|
||||||
MaxSizeListAttCodsSelected = (size_t) Events->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
MaxSizeListAttCodsSelected = (size_t) Events->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
||||||
if ((Events->StrAttCodsSelected = (char *) malloc (MaxSizeListAttCodsSelected + 1)) == NULL)
|
if ((Events->StrAttCodsSelected = malloc (MaxSizeListAttCodsSelected + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get parameter multiple with list of attendance events selected *****/
|
/***** Get parameter multiple with list of attendance events selected *****/
|
||||||
|
@ -3083,7 +3079,7 @@ static void Att_PutIconsMyAttList (void *Events)
|
||||||
|
|
||||||
/***** Put icon to print my QR code *****/
|
/***** Put icon to print my QR code *****/
|
||||||
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
|
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
|
||||||
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
|
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3113,7 +3109,7 @@ static void Att_PutIconsStdsAttList (void *Events)
|
||||||
|
|
||||||
/***** Put icon to print my QR code *****/
|
/***** Put icon to print my QR code *****/
|
||||||
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
|
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
|
||||||
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
|
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3422,9 +3418,7 @@ static void Att_WriteTableHeadSeveralAttEvents (const struct Att_Events *Events)
|
||||||
|
|
||||||
/***** Put link to this attendance event *****/
|
/***** Put link to this attendance event *****/
|
||||||
HTM_TH_Begin (1,1,"CM");
|
HTM_TH_Begin (1,1,"CM");
|
||||||
snprintf (StrNumAttEvent,sizeof (StrNumAttEvent),
|
snprintf (StrNumAttEvent,sizeof (StrNumAttEvent),"%u",NumAttEvent + 1);
|
||||||
"%u",
|
|
||||||
NumAttEvent + 1);
|
|
||||||
Att_PutLinkAttEvent (&Events->Lst[NumAttEvent],
|
Att_PutLinkAttEvent (&Events->Lst[NumAttEvent],
|
||||||
Events->Lst[NumAttEvent].Title,
|
Events->Lst[NumAttEvent].Title,
|
||||||
StrNumAttEvent,
|
StrNumAttEvent,
|
||||||
|
@ -3487,7 +3481,7 @@ static void Att_WriteRowUsrSeveralAttEvents (const struct Att_Events *Events,
|
||||||
HTM_Txt (UsrDat->Surname1);
|
HTM_Txt (UsrDat->Surname1);
|
||||||
if (UsrDat->Surname2[0])
|
if (UsrDat->Surname2[0])
|
||||||
HTM_TxtF (" %s",UsrDat->Surname2);
|
HTM_TxtF (" %s",UsrDat->Surname2);
|
||||||
HTM_TxtF (", %s",UsrDat->FirstName);
|
HTM_TxtF (", %s",UsrDat->FrstName);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Check/cross to show if the user is present/absent *****/
|
/***** Check/cross to show if the user is present/absent *****/
|
||||||
|
@ -3646,7 +3640,7 @@ static void Att_ListAttEventsForAStd (const struct Att_Events *Events,
|
||||||
HTM_Txt (UsrDat->Surname1);
|
HTM_Txt (UsrDat->Surname1);
|
||||||
if (UsrDat->Surname2[0])
|
if (UsrDat->Surname2[0])
|
||||||
HTM_TxtF (" %s",UsrDat->Surname2);
|
HTM_TxtF (" %s",UsrDat->Surname2);
|
||||||
HTM_TxtF (", %s",UsrDat->FirstName);
|
HTM_TxtF (", %s",UsrDat->FrstName);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TR_End ();
|
HTM_TR_End ();
|
||||||
|
|
|
@ -297,8 +297,7 @@ static void Ban_GetListBanners (struct Ban_Banners *Banners,
|
||||||
Banners->Num = (unsigned) NumRows;
|
Banners->Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with banners *****/
|
/***** Create list with banners *****/
|
||||||
if ((Banners->Lst = (struct Ban_Banner *)
|
if ((Banners->Lst = calloc (NumRows,sizeof (*Banners->Lst))) == NULL)
|
||||||
calloc (NumRows,sizeof (struct Ban_Banner))) == NULL)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the banners *****/
|
/***** Get the banners *****/
|
||||||
|
@ -319,20 +318,16 @@ static void Ban_GetListBanners (struct Ban_Banners *Banners,
|
||||||
Ban->Hidden = (row[1][0] == 'Y');
|
Ban->Hidden = (row[1][0] == 'Y');
|
||||||
|
|
||||||
/* Get the short name of the banner (row[2]) */
|
/* Get the short name of the banner (row[2]) */
|
||||||
Str_Copy (Ban->ShrtName,row[2],
|
Str_Copy (Ban->ShrtName,row[2],sizeof (Ban->ShrtName) - 1);
|
||||||
Ban_MAX_BYTES_SHRT_NAME);
|
|
||||||
|
|
||||||
/* Get the full name of the banner (row[3]) */
|
/* Get the full name of the banner (row[3]) */
|
||||||
Str_Copy (Ban->FullName,row[3],
|
Str_Copy (Ban->FullName,row[3],sizeof (Ban->FullName) - 1);
|
||||||
Ban_MAX_BYTES_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get the image of the banner (row[4]) */
|
/* Get the image of the banner (row[4]) */
|
||||||
Str_Copy (Ban->Img,row[4],
|
Str_Copy (Ban->Img ,row[4],sizeof (Ban->Img ) - 1);
|
||||||
Ban_MAX_BYTES_IMAGE);
|
|
||||||
|
|
||||||
/* Get the URL of the banner (row[5]) */
|
/* Get the URL of the banner (row[5]) */
|
||||||
Str_Copy (Ban->WWW,row[5],
|
Str_Copy (Ban->WWW ,row[5],sizeof (Ban->WWW ) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -373,20 +368,16 @@ void Ban_GetDataOfBannerByCod (struct Ban_Banner *Ban)
|
||||||
Ban->Hidden = (row[0][0] == 'Y');
|
Ban->Hidden = (row[0][0] == 'Y');
|
||||||
|
|
||||||
/* Get the short name of the banner (row[1]) */
|
/* Get the short name of the banner (row[1]) */
|
||||||
Str_Copy (Ban->ShrtName,row[1],
|
Str_Copy (Ban->ShrtName,row[1],sizeof (Ban->ShrtName) - 1);
|
||||||
Ban_MAX_BYTES_SHRT_NAME);
|
|
||||||
|
|
||||||
/* Get the full name of the banner (row[2]) */
|
/* Get the full name of the banner (row[2]) */
|
||||||
Str_Copy (Ban->FullName,row[2],
|
Str_Copy (Ban->FullName,row[2],sizeof (Ban->FullName) - 1);
|
||||||
Ban_MAX_BYTES_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get the image of the banner (row[3]) */
|
/* Get the image of the banner (row[3]) */
|
||||||
Str_Copy (Ban->Img,row[3],
|
Str_Copy (Ban->Img ,row[3],sizeof (Ban->Img ) - 1);
|
||||||
Ban_MAX_BYTES_IMAGE);
|
|
||||||
|
|
||||||
/* Get the URL of the banner (row[4]) */
|
/* Get the URL of the banner (row[4]) */
|
||||||
Str_Copy (Ban->WWW,row[4],
|
Str_Copy (Ban->WWW ,row[4],sizeof (Ban->WWW ) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -767,8 +758,7 @@ static void Ban_RenameBanner (struct Ban_Banner *Ban,
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Update name *****/
|
/***** Update name *****/
|
||||||
Str_Copy (CurrentBanName,NewBanName,
|
Str_Copy (CurrentBanName,NewBanName,MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -841,8 +831,7 @@ void Ban_ChangeBannerImg (void)
|
||||||
Txt_You_can_not_leave_the_image_empty);
|
Txt_You_can_not_leave_the_image_empty);
|
||||||
|
|
||||||
/***** Update image *****/
|
/***** Update image *****/
|
||||||
Str_Copy (Ban.Img,NewImg,
|
Str_Copy (Ban.Img,NewImg,sizeof (Ban.Img) - 1);
|
||||||
Ban_MAX_BYTES_IMAGE);
|
|
||||||
|
|
||||||
/***** Set editing banner to use ot in a posterior function *****/
|
/***** Set editing banner to use ot in a posterior function *****/
|
||||||
Ban_SetEditingBanner (&Ban);
|
Ban_SetEditingBanner (&Ban);
|
||||||
|
@ -889,8 +878,7 @@ void Ban_ChangeBannerWWW (void)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update web *****/
|
/***** Update web *****/
|
||||||
Str_Copy (Ban.WWW,NewWWW,
|
Str_Copy (Ban.WWW,NewWWW,sizeof (Ban.WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
|
|
||||||
/***** Set editing banner to use ot in a posterior function *****/
|
/***** Set editing banner to use ot in a posterior function *****/
|
||||||
Ban_SetEditingBanner (&Ban);
|
Ban_SetEditingBanner (&Ban);
|
||||||
|
|
|
@ -132,8 +132,8 @@ static void Box_BoxInternalBegin (const char *Width,const char *Title,
|
||||||
/***** Create unique identifier for this box *****/
|
/***** Create unique identifier for this box *****/
|
||||||
if (Closable == Box_CLOSABLE)
|
if (Closable == Box_CLOSABLE)
|
||||||
{
|
{
|
||||||
if ((Gbl.Box.Ids[Gbl.Box.Nested] = (char *) malloc (Frm_MAX_BYTES_ID + 1)) == NULL)
|
if ((Gbl.Box.Ids[Gbl.Box.Nested] = malloc (Frm_MAX_BYTES_ID + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for box id.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Gbl.Box.Ids[Gbl.Box.Nested] = NULL;
|
Gbl.Box.Ids[Gbl.Box.Nested] = NULL;
|
||||||
|
|
|
@ -355,9 +355,7 @@ void Bld_GetListBuildings (struct Bld_Buildings *Buildings,
|
||||||
Buildings->Num = (unsigned) NumRows;
|
Buildings->Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with courses in centre *****/
|
/***** Create list with courses in centre *****/
|
||||||
if ((Buildings->Lst = (struct Bld_Building *)
|
if ((Buildings->Lst = calloc (NumRows,sizeof (*Buildings->Lst))) == NULL)
|
||||||
calloc (NumRows,
|
|
||||||
sizeof (struct Bld_Building))) == NULL)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the buildings *****/
|
/***** Get the buildings *****/
|
||||||
|
@ -375,18 +373,17 @@ void Bld_GetListBuildings (struct Bld_Buildings *Buildings,
|
||||||
Lay_ShowErrorAndExit ("Wrong code of building.");
|
Lay_ShowErrorAndExit ("Wrong code of building.");
|
||||||
|
|
||||||
/* Get the short name of the building (row[1]) */
|
/* Get the short name of the building (row[1]) */
|
||||||
Str_Copy (Building->ShrtName,row[1],
|
Str_Copy (Building->ShrtName,row[1],sizeof (Building->ShrtName) - 1);
|
||||||
Bld_MAX_BYTES_SHRT_NAME);
|
|
||||||
|
|
||||||
if (WhichData == Bld_ALL_DATA)
|
if (WhichData == Bld_ALL_DATA)
|
||||||
{
|
{
|
||||||
/* Get the full name of the building (row[2]) */
|
/* Get the full name of the building (row[2]) */
|
||||||
Str_Copy (Building->FullName,row[2],
|
Str_Copy (Building->FullName,row[2],
|
||||||
Bld_MAX_BYTES_FULL_NAME);
|
sizeof (Building->FullName) - 1);
|
||||||
|
|
||||||
/* Get the full name of the building (row[3]) */
|
/* Get the full name of the building (row[3]) */
|
||||||
Str_Copy (Building->Location,row[3],
|
Str_Copy (Building->Location,row[3],
|
||||||
Bld_MAX_BYTES_LOCATION);
|
sizeof (Building->Location) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,16 +428,13 @@ void Bld_GetDataOfBuildingByCod (struct Bld_Building *Building)
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get the short name of the building (row[0]) */
|
/* Get the short name of the building (row[0]) */
|
||||||
Str_Copy (Building->ShrtName,row[0],
|
Str_Copy (Building->ShrtName,row[0],sizeof (Building->ShrtName) - 1);
|
||||||
Bld_MAX_BYTES_SHRT_NAME);
|
|
||||||
|
|
||||||
/* Get the full name of the building (row[1]) */
|
/* Get the full name of the building (row[1]) */
|
||||||
Str_Copy (Building->FullName,row[1],
|
Str_Copy (Building->FullName,row[1],sizeof (Building->FullName) - 1);
|
||||||
Bld_MAX_BYTES_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get the location of the building (row[2]) */
|
/* Get the location of the building (row[2]) */
|
||||||
Str_Copy (Building->Location,row[2],
|
Str_Copy (Building->Location,row[2],sizeof (Building->Location) - 1);
|
||||||
Bld_MAX_BYTES_LOCATION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -709,8 +703,7 @@ static void Bld_RenameBuilding (Cns_ShrtOrFullName_t ShrtOrFullName)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update building name *****/
|
/***** Update building name *****/
|
||||||
Str_Copy (CurrentClaName,NewClaName,
|
Str_Copy (CurrentClaName,NewClaName,MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -772,7 +765,7 @@ void Bld_ChangeBuildingLocation (void)
|
||||||
/* Update the table changing old name by new name */
|
/* Update the table changing old name by new name */
|
||||||
Bld_UpdateBuildingNameDB (Bld_EditingBuilding->BldCod,"Location",NewLocation);
|
Bld_UpdateBuildingNameDB (Bld_EditingBuilding->BldCod,"Location",NewLocation);
|
||||||
Str_Copy (Bld_EditingBuilding->Location,NewLocation,
|
Str_Copy (Bld_EditingBuilding->Location,NewLocation,
|
||||||
Bld_MAX_BYTES_LOCATION);
|
sizeof (Bld_EditingBuilding->Location) - 1);
|
||||||
|
|
||||||
/* Write message to show the change made */
|
/* Write message to show the change made */
|
||||||
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
||||||
|
@ -958,8 +951,8 @@ static void Bld_EditingBuildingConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing building.");
|
Lay_ShowErrorAndExit ("Error initializing building.");
|
||||||
|
|
||||||
/***** Allocate memory for building *****/
|
/***** Allocate memory for building *****/
|
||||||
if ((Bld_EditingBuilding = (struct Bld_Building *) malloc (sizeof (struct Bld_Building))) == NULL)
|
if ((Bld_EditingBuilding = malloc (sizeof (*Bld_EditingBuilding))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for building.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset building *****/
|
/***** Reset building *****/
|
||||||
Bld_EditingBuilding->BldCod = -1L;
|
Bld_EditingBuilding->BldCod = -1L;
|
||||||
|
|
|
@ -128,9 +128,7 @@ void Cal_ShowFormToSelFirstDayOfWeek (Act_Action_t Action,
|
||||||
Par_PutHiddenParamUnsigned (NULL,"FirstDayOfWeek",FirstDayOfWeek);
|
Par_PutHiddenParamUnsigned (NULL,"FirstDayOfWeek",FirstDayOfWeek);
|
||||||
if (FuncParams) // Extra parameters depending on the action
|
if (FuncParams) // Extra parameters depending on the action
|
||||||
FuncParams (Args);
|
FuncParams (Args);
|
||||||
snprintf (Icon,sizeof (Icon),
|
snprintf (Icon,sizeof (Icon),"first-day-of-week-%u.png",FirstDayOfWeek);
|
||||||
"first-day-of-week-%u.png",
|
|
||||||
FirstDayOfWeek);
|
|
||||||
Ico_PutSettingIconLink (Icon,
|
Ico_PutSettingIconLink (Icon,
|
||||||
Str_BuildStringStr (Txt_First_day_of_the_week_X,
|
Str_BuildStringStr (Txt_First_day_of_the_week_X,
|
||||||
Txt_DAYS_SMALL[FirstDayOfWeek]));
|
Txt_DAYS_SMALL[FirstDayOfWeek]));
|
||||||
|
|
|
@ -571,8 +571,8 @@ void Ctr_GetBasicListOfCentres (long InsCod)
|
||||||
Gbl.Hierarchy.Ctrs.Num = (unsigned) NumRows;
|
Gbl.Hierarchy.Ctrs.Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with courses in degree *****/
|
/***** Create list with courses in degree *****/
|
||||||
if ((Gbl.Hierarchy.Ctrs.Lst = (struct Ctr_Centre *) calloc (NumRows,
|
if ((Gbl.Hierarchy.Ctrs.Lst = calloc (NumRows,
|
||||||
sizeof (struct Ctr_Centre))) == NULL)
|
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the centres *****/
|
/***** Get the centres *****/
|
||||||
|
@ -660,8 +660,8 @@ void Ctr_GetFullListOfCentres (long InsCod)
|
||||||
Gbl.Hierarchy.Ctrs.Num = (unsigned) NumRows;
|
Gbl.Hierarchy.Ctrs.Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with courses in degree *****/
|
/***** Create list with courses in degree *****/
|
||||||
if ((Gbl.Hierarchy.Ctrs.Lst = (struct Ctr_Centre *) calloc (NumRows,
|
if ((Gbl.Hierarchy.Ctrs.Lst = calloc (NumRows,
|
||||||
sizeof (struct Ctr_Centre))) == NULL)
|
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the centres *****/
|
/***** Get the centres *****/
|
||||||
|
@ -778,16 +778,13 @@ static void Ctr_GetDataOfCentreFromRow (struct Ctr_Centre *Ctr,MYSQL_ROW row)
|
||||||
Ctr->Coord.Altitude = Map_GetAltitudeFromStr (row[7]);
|
Ctr->Coord.Altitude = Map_GetAltitudeFromStr (row[7]);
|
||||||
|
|
||||||
/***** Get the short name of the centre (row[8]) *****/
|
/***** Get the short name of the centre (row[8]) *****/
|
||||||
Str_Copy (Ctr->ShrtName,row[8],
|
Str_Copy (Ctr->ShrtName,row[8],sizeof (Ctr->ShrtName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
|
||||||
|
|
||||||
/***** Get the full name of the centre (row[9]) *****/
|
/***** Get the full name of the centre (row[9]) *****/
|
||||||
Str_Copy (Ctr->FullName,row[9],
|
Str_Copy (Ctr->FullName,row[9],sizeof (Ctr->FullName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
|
||||||
|
|
||||||
/***** Get the URL of the centre (row[10]) *****/
|
/***** Get the URL of the centre (row[10]) *****/
|
||||||
Str_Copy (Ctr->WWW,row[10],
|
Str_Copy (Ctr->WWW,row[10],sizeof (Ctr->WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -840,8 +837,7 @@ void Ctr_GetShortNameOfCentreByCod (struct Ctr_Centre *Ctr)
|
||||||
/***** Get the short name of this centre *****/
|
/***** Get the short name of this centre *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
Str_Copy (Ctr->ShrtName,row[0],
|
Str_Copy (Ctr->ShrtName,row[0],sizeof (Ctr->ShrtName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -1064,8 +1060,7 @@ static void Ctr_ListCentresForEdition (const struct Plc_Places *Places)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Str_Copy (WWW,Ctr->WWW,
|
Str_Copy (WWW,Ctr->WWW,sizeof (WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\"");
|
HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\"");
|
||||||
HTM_A_Begin ("href=\"%s\" target=\"_blank\""
|
HTM_A_Begin ("href=\"%s\" target=\"_blank\""
|
||||||
" class=\"DAT\" title=\"%s\"",Ctr->WWW,Ctr->WWW);
|
" class=\"DAT\" title=\"%s\"",Ctr->WWW,Ctr->WWW);
|
||||||
|
@ -1266,11 +1261,10 @@ void Ctr_RemoveCentre (void)
|
||||||
Roo_RemoveAllRoomsInCtr (Ctr_EditingCtr->CtrCod);
|
Roo_RemoveAllRoomsInCtr (Ctr_EditingCtr->CtrCod);
|
||||||
|
|
||||||
/***** Remove directories of the centre *****/
|
/***** Remove directories of the centre *****/
|
||||||
snprintf (PathCtr,sizeof (PathCtr),
|
snprintf (PathCtr,sizeof (PathCtr),"%s/%02u/%u",
|
||||||
"%s/%02u/%u",
|
|
||||||
Cfg_PATH_CTR_PUBLIC,
|
Cfg_PATH_CTR_PUBLIC,
|
||||||
(unsigned) (Ctr_EditingCtr->CtrCod % 100),
|
(unsigned) (Ctr_EditingCtr->CtrCod % 100),
|
||||||
(unsigned) Ctr_EditingCtr->CtrCod);
|
(unsigned) Ctr_EditingCtr->CtrCod);
|
||||||
Fil_RemoveTree (PathCtr);
|
Fil_RemoveTree (PathCtr);
|
||||||
|
|
||||||
/***** Remove centre *****/
|
/***** Remove centre *****/
|
||||||
|
@ -1421,8 +1415,7 @@ void Ctr_RenameCentre (struct Ctr_Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFullNam
|
||||||
CurrentCtrName,NewCtrName);
|
CurrentCtrName,NewCtrName);
|
||||||
|
|
||||||
/* Change current centre name in order to display it properly */
|
/* Change current centre name in order to display it properly */
|
||||||
Str_Copy (CurrentCtrName,NewCtrName,
|
Str_Copy (CurrentCtrName,NewCtrName,MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // The same name
|
else // The same name
|
||||||
|
@ -1485,8 +1478,7 @@ void Ctr_ChangeCtrWWW (void)
|
||||||
{
|
{
|
||||||
/***** Update database changing old WWW by new WWW *****/
|
/***** Update database changing old WWW by new WWW *****/
|
||||||
Ctr_UpdateCtrWWWDB (Ctr_EditingCtr->CtrCod,NewWWW);
|
Ctr_UpdateCtrWWWDB (Ctr_EditingCtr->CtrCod,NewWWW);
|
||||||
Str_Copy (Ctr_EditingCtr->WWW,NewWWW,
|
Str_Copy (Ctr_EditingCtr->WWW,NewWWW,sizeof (Ctr_EditingCtr->WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
|
|
||||||
/***** Write message to show the change made
|
/***** Write message to show the change made
|
||||||
and put button to go to centre changed *****/
|
and put button to go to centre changed *****/
|
||||||
|
@ -2279,8 +2271,8 @@ static void Ctr_EditingCentreConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing centre.");
|
Lay_ShowErrorAndExit ("Error initializing centre.");
|
||||||
|
|
||||||
/***** Allocate memory for centre *****/
|
/***** Allocate memory for centre *****/
|
||||||
if ((Ctr_EditingCtr = (struct Ctr_Centre *) malloc (sizeof (struct Ctr_Centre))) == NULL)
|
if ((Ctr_EditingCtr = malloc (sizeof (*Ctr_EditingCtr))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for centre.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset centre *****/
|
/***** Reset centre *****/
|
||||||
Ctr_EditingCtr->CtrCod = -1L;
|
Ctr_EditingCtr->CtrCod = -1L;
|
||||||
|
|
|
@ -228,12 +228,11 @@ static void CtrCfg_Configuration (bool PrintView)
|
||||||
MapIsAvailable = Ctr_GetIfMapIsAvailable (&Gbl.Hierarchy.Ctr);
|
MapIsAvailable = Ctr_GetIfMapIsAvailable (&Gbl.Hierarchy.Ctr);
|
||||||
|
|
||||||
/***** Check photo *****/
|
/***** Check photo *****/
|
||||||
snprintf (PathPhoto,sizeof (PathPhoto),
|
snprintf (PathPhoto,sizeof (PathPhoto),"%s/%02u/%u/%u.jpg",
|
||||||
"%s/%02u/%u/%u.jpg",
|
|
||||||
Cfg_PATH_CTR_PUBLIC,
|
Cfg_PATH_CTR_PUBLIC,
|
||||||
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
|
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
|
||||||
(unsigned) Gbl.Hierarchy.Ctr.CtrCod,
|
(unsigned) Gbl.Hierarchy.Ctr.CtrCod,
|
||||||
(unsigned) Gbl.Hierarchy.Ctr.CtrCod);
|
(unsigned) Gbl.Hierarchy.Ctr.CtrCod);
|
||||||
PhotoExists = Fil_CheckIfPathExists (PathPhoto);
|
PhotoExists = Fil_CheckIfPathExists (PathPhoto);
|
||||||
|
|
||||||
if (MapIsAvailable || PhotoExists)
|
if (MapIsAvailable || PhotoExists)
|
||||||
|
@ -292,8 +291,7 @@ static void CtrCfg_PutIconToChangePhoto (void)
|
||||||
bool PhotoExists;
|
bool PhotoExists;
|
||||||
|
|
||||||
/***** Link to upload photo of centre *****/
|
/***** Link to upload photo of centre *****/
|
||||||
snprintf (PathPhoto,sizeof (PathPhoto),
|
snprintf (PathPhoto,sizeof (PathPhoto),"%s/%02u/%u/%u.jpg",
|
||||||
"%s/%02u/%u/%u.jpg",
|
|
||||||
Cfg_PATH_CTR_PUBLIC,
|
Cfg_PATH_CTR_PUBLIC,
|
||||||
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
|
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
|
||||||
(unsigned) Gbl.Hierarchy.Ctr.CtrCod,
|
(unsigned) Gbl.Hierarchy.Ctr.CtrCod,
|
||||||
|
@ -531,10 +529,9 @@ static void CtrCfg_GetPhotoAttr (long CtrCod,char **PhotoAttribution)
|
||||||
if (row[0][0])
|
if (row[0][0])
|
||||||
{
|
{
|
||||||
Length = strlen (row[0]);
|
Length = strlen (row[0]);
|
||||||
if (((*PhotoAttribution) = (char *) malloc (Length + 1)) == NULL)
|
if (((*PhotoAttribution) = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for photo attribution.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (*PhotoAttribution,row[0],
|
Str_Copy (*PhotoAttribution,row[0],Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -936,8 +933,7 @@ void CtrCfg_ReceivePhoto (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End the reception of image in a temporary file */
|
/* End the reception of image in a temporary file */
|
||||||
snprintf (PathFileImgTmp,sizeof (PathFileImgTmp),
|
snprintf (PathFileImgTmp,sizeof (PathFileImgTmp),"%s/%s.%s",
|
||||||
"%s/%s.%s",
|
|
||||||
Cfg_PATH_MEDIA_TMP_PRIVATE,Gbl.UniqueNameEncrypted,PtrExtension);
|
Cfg_PATH_MEDIA_TMP_PRIVATE,Gbl.UniqueNameEncrypted,PtrExtension);
|
||||||
if (!Fil_EndReceptionOfFile (PathFileImgTmp,Param))
|
if (!Fil_EndReceptionOfFile (PathFileImgTmp,Param))
|
||||||
{
|
{
|
||||||
|
@ -947,29 +943,25 @@ void CtrCfg_ReceivePhoto (void)
|
||||||
|
|
||||||
/***** Creates public directories if not exist *****/
|
/***** Creates public directories if not exist *****/
|
||||||
Fil_CreateDirIfNotExists (Cfg_PATH_CTR_PUBLIC);
|
Fil_CreateDirIfNotExists (Cfg_PATH_CTR_PUBLIC);
|
||||||
snprintf (Path,sizeof (Path),
|
snprintf (Path,sizeof (Path),"%s/%02u",
|
||||||
"%s/%02u",
|
Cfg_PATH_CTR_PUBLIC,(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100));
|
||||||
Cfg_PATH_CTR_PUBLIC,
|
|
||||||
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100));
|
|
||||||
Fil_CreateDirIfNotExists (Path);
|
Fil_CreateDirIfNotExists (Path);
|
||||||
snprintf (Path,sizeof (Path),
|
snprintf (Path,sizeof (Path),"%s/%02u/%u",
|
||||||
"%s/%02u/%u",
|
|
||||||
Cfg_PATH_CTR_PUBLIC,
|
Cfg_PATH_CTR_PUBLIC,
|
||||||
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
|
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
|
||||||
(unsigned) Gbl.Hierarchy.Ctr.CtrCod);
|
(unsigned) Gbl.Hierarchy.Ctr.CtrCod);
|
||||||
Fil_CreateDirIfNotExists (Path);
|
Fil_CreateDirIfNotExists (Path);
|
||||||
|
|
||||||
/***** Convert temporary file to public JPEG file *****/
|
/***** Convert temporary file to public JPEG file *****/
|
||||||
snprintf (PathFileImg,sizeof (PathFileImg),
|
snprintf (PathFileImg,sizeof (PathFileImg),"%s/%02u/%u/%u.jpg",
|
||||||
"%s/%02u/%u/%u.jpg",
|
|
||||||
Cfg_PATH_CTR_PUBLIC,
|
Cfg_PATH_CTR_PUBLIC,
|
||||||
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
|
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
|
||||||
(unsigned) Gbl.Hierarchy.Ctr.CtrCod,
|
(unsigned) Gbl.Hierarchy.Ctr.CtrCod,
|
||||||
(unsigned) Gbl.Hierarchy.Ctr.CtrCod);
|
(unsigned) Gbl.Hierarchy.Ctr.CtrCod);
|
||||||
|
|
||||||
/* Call to program that makes the conversion */
|
/* Call to program that makes the conversion */
|
||||||
snprintf (Command,sizeof (Command),
|
snprintf (Command,sizeof (Command),
|
||||||
"convert %s -resize '%ux%u>' -quality %u %s",
|
"convert %s -resize '%ux%u>' -quality %u %s",
|
||||||
PathFileImgTmp,
|
PathFileImgTmp,
|
||||||
Ctr_PHOTO_SAVED_MAX_WIDTH,
|
Ctr_PHOTO_SAVED_MAX_WIDTH,
|
||||||
Ctr_PHOTO_SAVED_MAX_HEIGHT,
|
Ctr_PHOTO_SAVED_MAX_HEIGHT,
|
||||||
|
@ -1220,7 +1212,7 @@ void CtrCfg_ChangeCtrWWW (void)
|
||||||
/***** Update database changing old WWW by new WWW *****/
|
/***** Update database changing old WWW by new WWW *****/
|
||||||
Ctr_UpdateCtrWWWDB (Gbl.Hierarchy.Ctr.CtrCod,NewWWW);
|
Ctr_UpdateCtrWWWDB (Gbl.Hierarchy.Ctr.CtrCod,NewWWW);
|
||||||
Str_Copy (Gbl.Hierarchy.Ctr.WWW,NewWWW,
|
Str_Copy (Gbl.Hierarchy.Ctr.WWW,NewWWW,
|
||||||
Cns_MAX_BYTES_WWW);
|
sizeof (Gbl.Hierarchy.Ctr.WWW) - 1);
|
||||||
|
|
||||||
/***** Write message to show the change made *****/
|
/***** Write message to show the change made *****/
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X,
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X,
|
||||||
|
|
|
@ -553,7 +553,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
||||||
En OpenSWAD:
|
En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 20.30.1 (2021-02-14)"
|
#define Log_PLATFORM_VERSION "SWAD 20.31 (2021-02-15)"
|
||||||
#define CSS_FILE "swad20.8.css"
|
#define CSS_FILE "swad20.8.css"
|
||||||
#define JS_FILE "swad20.6.2.js"
|
#define JS_FILE "swad20.6.2.js"
|
||||||
/*
|
/*
|
||||||
|
@ -601,6 +601,7 @@ TODO: DNI de un estudiante sale err
|
||||||
TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede.
|
TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede.
|
||||||
TODO: Salvador Romero Cortés: @acanas opción para editar posts
|
TODO: Salvador Romero Cortés: @acanas opción para editar posts
|
||||||
|
|
||||||
|
Version 20.31: Feb 15, 2021 Code refactoring in copy, concat and sprintf. (304811 lines)
|
||||||
Version 20.30.1: Feb 14, 2021 Code refactoring in timeline related to temporary tables. (305883 lines)
|
Version 20.30.1: Feb 14, 2021 Code refactoring in timeline related to temporary tables. (305883 lines)
|
||||||
Version 20.30: Feb 11, 2021 Code refactoring in hierarchy. (305853 lines)
|
Version 20.30: Feb 11, 2021 Code refactoring in hierarchy. (305853 lines)
|
||||||
Version 20.29.3: Feb 11, 2021 Code refactoring in timeline. (305826 lines)
|
Version 20.29.3: Feb 11, 2021 Code refactoring in timeline. (305826 lines)
|
||||||
|
|
155
swad_chat.c
155
swad_chat.c
|
@ -138,8 +138,7 @@ void Cht_ShowListOfAvailableChatRooms (void)
|
||||||
/***** Link to chat available for all the users *****/
|
/***** Link to chat available for all the users *****/
|
||||||
IsLastItemInLevel[1] = (!Gbl.Usrs.Me.IBelongToCurrentCrs &&
|
IsLastItemInLevel[1] = (!Gbl.Usrs.Me.IBelongToCurrentCrs &&
|
||||||
!Gbl.Usrs.Me.MyDegs.Num);
|
!Gbl.Usrs.Me.MyDegs.Num);
|
||||||
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s (%s)",
|
||||||
"%s (%s)",
|
|
||||||
Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]);
|
Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]);
|
||||||
Cht_WriteLinkToChat1 ("GBL_USR",Txt_SEX_PLURAL_Abc[Usr_SEX_ALL],ThisRoomFullName,1,IsLastItemInLevel);
|
Cht_WriteLinkToChat1 ("GBL_USR",Txt_SEX_PLURAL_Abc[Usr_SEX_ALL],ThisRoomFullName,1,IsLastItemInLevel);
|
||||||
Ico_PutIcon ("comments.svg",ThisRoomFullName,"ICO16x16");
|
Ico_PutIcon ("comments.svg",ThisRoomFullName,"ICO16x16");
|
||||||
|
@ -149,19 +148,19 @@ void Cht_ShowListOfAvailableChatRooms (void)
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s (%s)",
|
||||||
"%s (%s)",
|
|
||||||
Txt_General,Txt_ROLES_PLURAL_abc[Rol_STD][Usr_SEX_ALL]);
|
Txt_General,Txt_ROLES_PLURAL_abc[Rol_STD][Usr_SEX_ALL]);
|
||||||
Cht_WriteLinkToChat1 ("GBL_STD",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD],ThisRoomFullName,1,IsLastItemInLevel);
|
Cht_WriteLinkToChat1 ("GBL_STD",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD],
|
||||||
|
ThisRoomFullName,1,IsLastItemInLevel);
|
||||||
Ico_PutIcon ("comments.svg",ThisRoomFullName,"ICO16x16");
|
Ico_PutIcon ("comments.svg",ThisRoomFullName,"ICO16x16");
|
||||||
Cht_WriteLinkToChat2 ("GBL_STD",ThisRoomFullName);
|
Cht_WriteLinkToChat2 ("GBL_STD",ThisRoomFullName);
|
||||||
break;
|
break;
|
||||||
case Rol_NET:
|
case Rol_NET:
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s (%s)",
|
||||||
"%s (%s)",
|
|
||||||
Txt_General,Txt_ROLES_PLURAL_abc[Rol_TCH][Usr_SEX_ALL]);
|
Txt_General,Txt_ROLES_PLURAL_abc[Rol_TCH][Usr_SEX_ALL]);
|
||||||
Cht_WriteLinkToChat1 ("GBL_TCH",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH],ThisRoomFullName,1,IsLastItemInLevel);
|
Cht_WriteLinkToChat1 ("GBL_TCH",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH],
|
||||||
|
ThisRoomFullName,1,IsLastItemInLevel);
|
||||||
Ico_PutIcon ("comments.svg",ThisRoomFullName,"ICO16x16");
|
Ico_PutIcon ("comments.svg",ThisRoomFullName,"ICO16x16");
|
||||||
Cht_WriteLinkToChat2 ("GBL_TCH",ThisRoomFullName);
|
Cht_WriteLinkToChat2 ("GBL_TCH",ThisRoomFullName);
|
||||||
break;
|
break;
|
||||||
|
@ -181,14 +180,10 @@ void Cht_ShowListOfAvailableChatRooms (void)
|
||||||
|
|
||||||
/* Link to the room of this degree */
|
/* Link to the room of this degree */
|
||||||
IsLastItemInLevel[1] = (NumMyDeg == Gbl.Usrs.Me.MyDegs.Num - 1);
|
IsLastItemInLevel[1] = (NumMyDeg == Gbl.Usrs.Me.MyDegs.Num - 1);
|
||||||
snprintf (ThisRoomCode,sizeof (ThisRoomCode),
|
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"DEG_%ld",Deg.DegCod);
|
||||||
"DEG_%ld",
|
snprintf (ThisRoomShrtName,sizeof (ThisRoomShrtName),"%s",
|
||||||
Deg.DegCod);
|
|
||||||
snprintf (ThisRoomShrtName,sizeof (ThisRoomShrtName),
|
|
||||||
"%s",
|
|
||||||
Deg.ShrtName);
|
Deg.ShrtName);
|
||||||
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
|
||||||
"%s %s",
|
|
||||||
Txt_Degree,Deg.ShrtName);
|
Txt_Degree,Deg.ShrtName);
|
||||||
Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShrtName,ThisRoomFullName,1,IsLastItemInLevel);
|
Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShrtName,ThisRoomFullName,1,IsLastItemInLevel);
|
||||||
Lgo_DrawLogo (Hie_Lvl_DEG,Deg.DegCod,Deg.ShrtName,16,NULL,true);
|
Lgo_DrawLogo (Hie_Lvl_DEG,Deg.DegCod,Deg.ShrtName,16,NULL,true);
|
||||||
|
@ -211,14 +206,11 @@ void Cht_ShowListOfAvailableChatRooms (void)
|
||||||
|
|
||||||
/* Link to the room of this course */
|
/* Link to the room of this course */
|
||||||
IsLastItemInLevel[2] = (NumRow == NumRows - 1);
|
IsLastItemInLevel[2] = (NumRow == NumRows - 1);
|
||||||
snprintf (ThisRoomCode,sizeof (ThisRoomCode),
|
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"CRS_%ld",
|
||||||
"CRS_%ld",
|
|
||||||
Crs.CrsCod);
|
Crs.CrsCod);
|
||||||
snprintf (ThisRoomShrtName,sizeof (ThisRoomShrtName),
|
snprintf (ThisRoomShrtName,sizeof (ThisRoomShrtName),"%s",
|
||||||
"%s",
|
|
||||||
Crs.ShrtName);
|
Crs.ShrtName);
|
||||||
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
|
||||||
"%s %s",
|
|
||||||
Txt_Course,Crs.ShrtName);
|
Txt_Course,Crs.ShrtName);
|
||||||
Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShrtName,ThisRoomFullName,2,IsLastItemInLevel);
|
Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShrtName,ThisRoomFullName,2,IsLastItemInLevel);
|
||||||
Ico_PutIcon ("chalkboard-teacher.svg",ThisRoomFullName,"ICO16x16");
|
Ico_PutIcon ("chalkboard-teacher.svg",ThisRoomFullName,"ICO16x16");
|
||||||
|
@ -427,119 +419,86 @@ void Cht_OpenChatWindow (void)
|
||||||
Usr_GetMyCourses ();
|
Usr_GetMyCourses ();
|
||||||
|
|
||||||
/***** Build my user's name *****/
|
/***** Build my user's name *****/
|
||||||
Str_Copy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1,
|
Str_Copy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1,sizeof (UsrName) - 1);
|
||||||
Usr_MAX_BYTES_FULL_NAME);
|
|
||||||
if (Gbl.Usrs.Me.UsrDat.Surname2[0])
|
if (Gbl.Usrs.Me.UsrDat.Surname2[0])
|
||||||
{
|
{
|
||||||
Str_Concat (UsrName," ",
|
Str_Concat (UsrName," ",sizeof (UsrName) - 1);
|
||||||
Usr_MAX_BYTES_FULL_NAME);
|
Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.Surname2,sizeof (UsrName) - 1);
|
||||||
Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.Surname2,
|
|
||||||
Usr_MAX_BYTES_FULL_NAME);
|
|
||||||
}
|
}
|
||||||
Str_Concat (UsrName,", ",
|
Str_Concat (UsrName,", ",sizeof (UsrName) - 1);
|
||||||
Usr_MAX_BYTES_FULL_NAME);
|
Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.FrstName,sizeof (UsrName) - 1);
|
||||||
Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.FirstName,
|
|
||||||
Usr_MAX_BYTES_FULL_NAME);
|
|
||||||
|
|
||||||
/***** Build the lists of available rooms *****/
|
/***** Build the lists of available rooms *****/
|
||||||
snprintf (ListRoomCodes,sizeof (ListRoomCodes),
|
snprintf (ListRoomCodes,sizeof (ListRoomCodes),"#%s",RoomCode);
|
||||||
"#%s",
|
Str_Copy (ListRoomShrtNames,RoomShrtName,sizeof (ListRoomShrtNames) - 1);
|
||||||
RoomCode);
|
Str_Copy (ListRoomFullNames,RoomFullName,sizeof (ListRoomFullNames) - 1);
|
||||||
Str_Copy (ListRoomShrtNames,RoomShrtName,
|
|
||||||
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
|
|
||||||
Str_Copy (ListRoomFullNames ,RoomFullName,
|
|
||||||
Cht_MAX_BYTES_ROOM_FULL_NAMES);
|
|
||||||
|
|
||||||
if (strcmp (RoomCode,"GBL_USR"))
|
if (strcmp (RoomCode,"GBL_USR"))
|
||||||
{
|
{
|
||||||
Str_Concat (ListRoomCodes,"|#GBL_USR",
|
Str_Concat (ListRoomCodes,"|#GBL_USR",sizeof (ListRoomCodes) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_CODES);
|
|
||||||
|
|
||||||
snprintf (RoomShrtName,sizeof (RoomShrtName),
|
snprintf (RoomShrtName,sizeof (RoomShrtName),"|%s",
|
||||||
"|%s",
|
|
||||||
Txt_SEX_PLURAL_Abc[Usr_SEX_ALL]);
|
Txt_SEX_PLURAL_Abc[Usr_SEX_ALL]);
|
||||||
Str_Concat (ListRoomShrtNames,RoomShrtName,
|
Str_Concat (ListRoomShrtNames,RoomShrtName,sizeof (ListRoomShrtNames) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
|
|
||||||
|
|
||||||
snprintf (RoomFullName,sizeof (RoomFullName),
|
snprintf (RoomFullName,sizeof (RoomFullName),"|%s (%s)",
|
||||||
"|%s (%s)",
|
|
||||||
Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]);
|
Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]);
|
||||||
Str_Concat (ListRoomFullNames,RoomFullName,
|
Str_Concat (ListRoomFullNames,RoomFullName,sizeof (ListRoomFullNames) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_FULL_NAMES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Gbl.Usrs.Me.Role.Logged == Rol_STD)
|
if (Gbl.Usrs.Me.Role.Logged == Rol_STD)
|
||||||
if (strcmp (RoomCode,"GBL_STD"))
|
if (strcmp (RoomCode,"GBL_STD"))
|
||||||
{
|
{
|
||||||
Str_Concat (ListRoomCodes,"|#GBL_STD",
|
Str_Concat (ListRoomCodes,"|#GBL_STD",sizeof (ListRoomCodes) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_CODES);
|
|
||||||
|
|
||||||
snprintf (RoomShrtName,sizeof (RoomShrtName),
|
snprintf (RoomShrtName,sizeof (RoomShrtName),"|%s",
|
||||||
"|%s",
|
|
||||||
Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]);
|
Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]);
|
||||||
Str_Concat (ListRoomShrtNames,RoomShrtName,
|
Str_Concat (ListRoomShrtNames,RoomShrtName,sizeof (ListRoomShrtNames) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
|
|
||||||
|
|
||||||
snprintf (RoomFullName,sizeof (RoomFullName),
|
snprintf (RoomFullName,sizeof (RoomFullName),"|%s (%s)",
|
||||||
"|%s (%s)",
|
|
||||||
Txt_General,Txt_ROLES_PLURAL_abc[Rol_STD][Usr_SEX_ALL]);
|
Txt_General,Txt_ROLES_PLURAL_abc[Rol_STD][Usr_SEX_ALL]);
|
||||||
Str_Concat (ListRoomFullNames,RoomFullName,
|
Str_Concat (ListRoomFullNames,RoomFullName,sizeof (ListRoomFullNames) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_FULL_NAMES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
if (Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_TCH)
|
Gbl.Usrs.Me.Role.Logged == Rol_TCH)
|
||||||
if (strcmp (RoomCode,"GBL_TCH"))
|
if (strcmp (RoomCode,"GBL_TCH"))
|
||||||
{
|
{
|
||||||
Str_Concat (ListRoomCodes,"|#GBL_TCH",
|
Str_Concat (ListRoomCodes,"|#GBL_TCH",sizeof (ListRoomCodes) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_CODES);
|
|
||||||
|
|
||||||
snprintf (RoomShrtName,sizeof (RoomShrtName),
|
snprintf (RoomShrtName,sizeof (RoomShrtName),"|%s",
|
||||||
"|%s",
|
|
||||||
Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH]);
|
Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH]);
|
||||||
Str_Concat (ListRoomShrtNames,RoomShrtName,
|
Str_Concat (ListRoomShrtNames,RoomShrtName,sizeof (ListRoomShrtNames) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
|
|
||||||
|
|
||||||
snprintf (RoomFullName,sizeof (RoomFullName),
|
snprintf (RoomFullName,sizeof (RoomFullName),"|%s (%s)",
|
||||||
"|%s (%s)",
|
|
||||||
Txt_General,Txt_ROLES_PLURAL_abc[Rol_TCH][Usr_SEX_ALL]);
|
Txt_General,Txt_ROLES_PLURAL_abc[Rol_TCH][Usr_SEX_ALL]);
|
||||||
Str_Concat (ListRoomFullNames,RoomFullName,
|
Str_Concat (ListRoomFullNames,RoomFullName,sizeof (ListRoomFullNames) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_FULL_NAMES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (NumMyDeg = 0;
|
for (NumMyDeg = 0;
|
||||||
NumMyDeg < Gbl.Usrs.Me.MyDegs.Num;
|
NumMyDeg < Gbl.Usrs.Me.MyDegs.Num;
|
||||||
NumMyDeg++)
|
NumMyDeg++)
|
||||||
{
|
{
|
||||||
snprintf (ThisRoomCode,sizeof (ThisRoomCode),
|
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"DEG_%ld",
|
||||||
"DEG_%ld",
|
|
||||||
Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod);
|
Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod);
|
||||||
if (strcmp (RoomCode,ThisRoomCode))
|
if (strcmp (RoomCode,ThisRoomCode))
|
||||||
{
|
{
|
||||||
Str_Concat (ListRoomCodes,"|#",
|
Str_Concat (ListRoomCodes,"|#",sizeof (ListRoomCodes) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_CODES);
|
Str_Concat (ListRoomCodes,ThisRoomCode,sizeof (ListRoomCodes) - 1);
|
||||||
Str_Concat (ListRoomCodes,ThisRoomCode,
|
|
||||||
Cht_MAX_BYTES_ROOM_CODES);
|
|
||||||
|
|
||||||
/* Get data of this degree */
|
/* Get data of this degree */
|
||||||
Deg.DegCod = Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod;
|
Deg.DegCod = Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod;
|
||||||
Deg_GetDataOfDegreeByCod (&Deg);
|
Deg_GetDataOfDegreeByCod (&Deg);
|
||||||
|
|
||||||
snprintf (ThisRoomShortName,sizeof (ThisRoomShortName),
|
snprintf (ThisRoomShortName,sizeof (ThisRoomShortName),"%s",
|
||||||
"%s",
|
|
||||||
Deg.ShrtName);
|
Deg.ShrtName);
|
||||||
Str_Concat (ListRoomShrtNames,"|",
|
Str_Concat (ListRoomShrtNames,"|",sizeof (ListRoomShrtNames) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
|
Str_Concat (ListRoomShrtNames,ThisRoomShortName,sizeof (ListRoomShrtNames) - 1);
|
||||||
Str_Concat (ListRoomShrtNames,ThisRoomShortName,
|
|
||||||
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
|
|
||||||
|
|
||||||
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
|
||||||
"%s %s",
|
|
||||||
Txt_Degree,Deg.ShrtName);
|
Txt_Degree,Deg.ShrtName);
|
||||||
Str_Concat (ListRoomFullNames,"|",
|
Str_Concat (ListRoomFullNames,"|",sizeof (ListRoomFullNames) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_FULL_NAMES);
|
Str_Concat (ListRoomFullNames,ThisRoomFullName,sizeof (ListRoomFullNames) - 1);
|
||||||
Str_Concat (ListRoomFullNames,ThisRoomFullName,
|
|
||||||
Cht_MAX_BYTES_ROOM_FULL_NAMES);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,15 +506,12 @@ void Cht_OpenChatWindow (void)
|
||||||
NumMyCrs < Gbl.Usrs.Me.MyCrss.Num;
|
NumMyCrs < Gbl.Usrs.Me.MyCrss.Num;
|
||||||
NumMyCrs++)
|
NumMyCrs++)
|
||||||
{
|
{
|
||||||
snprintf (ThisRoomCode,sizeof (ThisRoomCode),
|
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"CRS_%ld",
|
||||||
"CRS_%ld",
|
|
||||||
Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod);
|
Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod);
|
||||||
if (strcmp (RoomCode,ThisRoomCode))
|
if (strcmp (RoomCode,ThisRoomCode))
|
||||||
{
|
{
|
||||||
Str_Concat (ListRoomCodes,"|#",
|
Str_Concat (ListRoomCodes,"|#",sizeof (ListRoomCodes) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_CODES);
|
Str_Concat (ListRoomCodes,ThisRoomCode,sizeof (ListRoomCodes) - 1);
|
||||||
Str_Concat (ListRoomCodes,ThisRoomCode,
|
|
||||||
Cht_MAX_BYTES_ROOM_CODES);
|
|
||||||
|
|
||||||
/* Get data of this course */
|
/* Get data of this course */
|
||||||
Crs.CrsCod = Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod;
|
Crs.CrsCod = Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod;
|
||||||
|
@ -564,18 +520,13 @@ void Cht_OpenChatWindow (void)
|
||||||
snprintf (ThisRoomShortName,sizeof (ThisRoomShortName),
|
snprintf (ThisRoomShortName,sizeof (ThisRoomShortName),
|
||||||
"%s",
|
"%s",
|
||||||
Crs.ShrtName);
|
Crs.ShrtName);
|
||||||
Str_Concat (ListRoomShrtNames,"|",
|
Str_Concat (ListRoomShrtNames,"|",sizeof (ListRoomShrtNames) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
|
Str_Concat (ListRoomShrtNames,ThisRoomShortName,sizeof (ListRoomShrtNames) - 1);
|
||||||
Str_Concat (ListRoomShrtNames,ThisRoomShortName,
|
|
||||||
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
|
|
||||||
|
|
||||||
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
|
||||||
"%s %s",
|
|
||||||
Txt_Course,Crs.ShrtName);
|
Txt_Course,Crs.ShrtName);
|
||||||
Str_Concat (ListRoomFullNames,"|",
|
Str_Concat (ListRoomFullNames,"|",sizeof (ListRoomFullNames) - 1);
|
||||||
Cht_MAX_BYTES_ROOM_FULL_NAMES);
|
Str_Concat (ListRoomFullNames,ThisRoomFullName,sizeof (ListRoomFullNames) - 1);
|
||||||
Str_Concat (ListRoomFullNames,ThisRoomFullName,
|
|
||||||
Cht_MAX_BYTES_ROOM_FULL_NAMES);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ void Cfg_GetConfigFromFile (void)
|
||||||
fseek (FileCfg,0L,SEEK_SET);
|
fseek (FileCfg,0L,SEEK_SET);
|
||||||
|
|
||||||
/* Allocate memory for buffer */
|
/* Allocate memory for buffer */
|
||||||
if ((Config = (char *) malloc (Length + 1)) == NULL)
|
if ((Config = malloc (Length + 1)) == NULL)
|
||||||
{
|
{
|
||||||
fclose (FileCfg);
|
fclose (FileCfg);
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
|
@ -321,8 +321,7 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void)
|
||||||
// the list of connected users
|
// the list of connected users
|
||||||
// is dynamically updated via AJAX
|
// is dynamically updated via AJAX
|
||||||
HTM_BUTTON_SUBMIT_Begin (Txt_Connected_users,"BT_LINK CONNECTED_TXT",NULL);
|
HTM_BUTTON_SUBMIT_Begin (Txt_Connected_users,"BT_LINK CONNECTED_TXT",NULL);
|
||||||
Str_Copy (CourseName,Gbl.Hierarchy.Crs.ShrtName,
|
Str_Copy (CourseName,Gbl.Hierarchy.Crs.ShrtName,sizeof (CourseName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
|
||||||
Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_UNK,&Usrs);
|
Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_UNK,&Usrs);
|
||||||
HTM_TxtF ("%u %s %s",Usrs.NumUsrs,Txt_from,CourseName);
|
HTM_TxtF ("%u %s %s",Usrs.NumUsrs,Txt_from,CourseName);
|
||||||
HTM_BUTTON_End ();
|
HTM_BUTTON_End ();
|
||||||
|
@ -851,7 +850,7 @@ static void Con_WriteRowConnectedUsrOnRightColumn (Rol_Role_t Role)
|
||||||
Rol_WrongRoleExit ();
|
Rol_WrongRoleExit ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
|
|
||||||
HTM_DIV_Begin ("class=\"CON_NAME_NARROW\""); // Limited width
|
HTM_DIV_Begin ("class=\"CON_NAME_NARROW\""); // Limited width
|
||||||
HTM_BUTTON_SUBMIT_Begin (Txt_View_record_for_this_course,ClassLink,NULL);
|
HTM_BUTTON_SUBMIT_Begin (Txt_View_record_for_this_course,ClassLink,NULL);
|
||||||
|
@ -1075,7 +1074,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R
|
||||||
default:
|
default:
|
||||||
Rol_WrongRoleExit ();
|
Rol_WrongRoleExit ();
|
||||||
}
|
}
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat.EnUsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
HTM_DIV_Begin ("class=\"CON_NAME_WIDE\""); // Limited width
|
HTM_DIV_Begin ("class=\"CON_NAME_WIDE\""); // Limited width
|
||||||
|
|
133
swad_country.c
133
swad_country.c
|
@ -533,7 +533,7 @@ void Cty_DrawCountryMapAndNameWithLink (struct Cty_Countr *Cty,Act_Action_t Acti
|
||||||
|
|
||||||
/***** Write country name *****/
|
/***** Write country name *****/
|
||||||
Str_Copy (CountryName,Cty->Name[Gbl.Prefs.Language],
|
Str_Copy (CountryName,Cty->Name[Gbl.Prefs.Language],
|
||||||
Cty_MAX_BYTES_NAME);
|
sizeof (CountryName) - 1);
|
||||||
HTM_TxtF (" %s ",CountryName);
|
HTM_TxtF (" %s ",CountryName);
|
||||||
HTM_TxtF ("(%s)",Cty->Alpha2);
|
HTM_TxtF ("(%s)",Cty->Alpha2);
|
||||||
|
|
||||||
|
@ -581,8 +581,7 @@ bool Cty_CheckIfCountryPhotoExists (struct Cty_Countr *Cty)
|
||||||
{
|
{
|
||||||
char PathMap[PATH_MAX + 1];
|
char PathMap[PATH_MAX + 1];
|
||||||
|
|
||||||
snprintf (PathMap,sizeof (PathMap),
|
snprintf (PathMap,sizeof (PathMap),"%s/%s/%s.png",
|
||||||
"%s/%s/%s.png",
|
|
||||||
Cfg_PATH_ICON_COUNTRIES_PUBLIC,
|
Cfg_PATH_ICON_COUNTRIES_PUBLIC,
|
||||||
Cty->Alpha2,
|
Cty->Alpha2,
|
||||||
Cty->Alpha2);
|
Cty->Alpha2);
|
||||||
|
@ -768,8 +767,8 @@ void Cty_GetBasicListOfCountries (void)
|
||||||
Gbl.Hierarchy.Ctys.Num = (unsigned) NumRows;
|
Gbl.Hierarchy.Ctys.Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with countries *****/
|
/***** Create list with countries *****/
|
||||||
if ((Gbl.Hierarchy.Ctys.Lst = (struct Cty_Countr *)
|
if ((Gbl.Hierarchy.Ctys.Lst = calloc (NumRows,
|
||||||
calloc (NumRows,sizeof (struct Cty_Countr))) == NULL)
|
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the countries *****/
|
/***** Get the countries *****/
|
||||||
|
@ -787,8 +786,7 @@ void Cty_GetBasicListOfCountries (void)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of country.");
|
Lay_ShowErrorAndExit ("Wrong code of country.");
|
||||||
|
|
||||||
/* Get Alpha-2 country code (row[1]) */
|
/* Get Alpha-2 country code (row[1]) */
|
||||||
Str_Copy (Cty->Alpha2,row[1],
|
Str_Copy (Cty->Alpha2,row[1],sizeof (Cty->Alpha2) - 1);
|
||||||
2);
|
|
||||||
|
|
||||||
for (Lan = (Lan_Language_t) 1;
|
for (Lan = (Lan_Language_t) 1;
|
||||||
Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES;
|
Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES;
|
||||||
|
@ -800,7 +798,7 @@ void Cty_GetBasicListOfCountries (void)
|
||||||
|
|
||||||
/* Get the name of the country in current language */
|
/* Get the name of the country in current language */
|
||||||
Str_Copy (Cty->Name[Gbl.Prefs.Language],row[2],
|
Str_Copy (Cty->Name[Gbl.Prefs.Language],row[2],
|
||||||
Cty_MAX_BYTES_NAME);
|
sizeof (Cty->Name[Gbl.Prefs.Language]) - 1);
|
||||||
|
|
||||||
/* Reset number of users who claim to belong to country */
|
/* Reset number of users who claim to belong to country */
|
||||||
Cty->NumUsrsWhoClaimToBelongToCty.Valid = false;
|
Cty->NumUsrsWhoClaimToBelongToCty.Valid = false;
|
||||||
|
@ -850,27 +848,15 @@ void Cty_GetFullListOfCountries (void)
|
||||||
Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES;
|
Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES;
|
||||||
Lan++)
|
Lan++)
|
||||||
{
|
{
|
||||||
snprintf (StrField,sizeof (StrField),
|
snprintf (StrField,sizeof (StrField),"countries.Name_%s,",Lan_STR_LANG_ID[Lan]);
|
||||||
"countries.Name_%s,",
|
Str_Concat (SubQueryNam1,StrField,sizeof (SubQueryNam1) - 1);
|
||||||
Lan_STR_LANG_ID[Lan]);
|
snprintf (StrField,sizeof (StrField),"Name_%s,",Lan_STR_LANG_ID[Lan]);
|
||||||
Str_Concat (SubQueryNam1,StrField,
|
Str_Concat (SubQueryNam2,StrField,sizeof (SubQueryNam2) - 1);
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
|
||||||
snprintf (StrField,sizeof (StrField),
|
|
||||||
"Name_%s,",
|
|
||||||
Lan_STR_LANG_ID[Lan]);
|
|
||||||
Str_Concat (SubQueryNam2,StrField,
|
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
|
||||||
|
|
||||||
snprintf (StrField,sizeof (StrField),
|
snprintf (StrField,sizeof (StrField),"countries.WWW_%s,",Lan_STR_LANG_ID[Lan]);
|
||||||
"countries.WWW_%s,",
|
Str_Concat (SubQueryWWW1,StrField,sizeof (SubQueryWWW1) - 1);
|
||||||
Lan_STR_LANG_ID[Lan]);
|
snprintf (StrField,sizeof (StrField),"WWW_%s,",Lan_STR_LANG_ID[Lan]);
|
||||||
Str_Concat (SubQueryWWW1,StrField,
|
Str_Concat (SubQueryWWW2,StrField,sizeof (SubQueryWWW2) - 1);
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
|
||||||
snprintf (StrField,sizeof (StrField),
|
|
||||||
"WWW_%s,",
|
|
||||||
Lan_STR_LANG_ID[Lan]);
|
|
||||||
Str_Concat (SubQueryWWW2,StrField,
|
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build order subquery */
|
/* Build order subquery */
|
||||||
|
@ -902,8 +888,8 @@ void Cty_GetFullListOfCountries (void)
|
||||||
Gbl.Hierarchy.Ctys.Num = (unsigned) NumRows;
|
Gbl.Hierarchy.Ctys.Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with countries *****/
|
/***** Create list with countries *****/
|
||||||
if ((Gbl.Hierarchy.Ctys.Lst = (struct Cty_Countr *)
|
if ((Gbl.Hierarchy.Ctys.Lst = calloc (NumRows,
|
||||||
calloc (NumRows,sizeof (struct Cty_Countr))) == NULL)
|
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the countries *****/
|
/***** Get the countries *****/
|
||||||
|
@ -921,8 +907,7 @@ void Cty_GetFullListOfCountries (void)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of country.");
|
Lay_ShowErrorAndExit ("Wrong code of country.");
|
||||||
|
|
||||||
/* Get Alpha-2 country code (row[1]) */
|
/* Get Alpha-2 country code (row[1]) */
|
||||||
Str_Copy (Cty->Alpha2,row[1],
|
Str_Copy (Cty->Alpha2,row[1],sizeof (Cty->Alpha2) - 1);
|
||||||
2);
|
|
||||||
|
|
||||||
/* Get the name of the country in several languages */
|
/* Get the name of the country in several languages */
|
||||||
for (Lan = (Lan_Language_t) 1;
|
for (Lan = (Lan_Language_t) 1;
|
||||||
|
@ -930,9 +915,9 @@ void Cty_GetFullListOfCountries (void)
|
||||||
Lan++)
|
Lan++)
|
||||||
{
|
{
|
||||||
Str_Copy (Cty->Name[Lan],row[1 + Lan],
|
Str_Copy (Cty->Name[Lan],row[1 + Lan],
|
||||||
Cty_MAX_BYTES_NAME);
|
sizeof (Cty->Name[Lan]) - 1);
|
||||||
Str_Copy (Cty->WWW[Lan],row[1 + Lan_NUM_LANGUAGES + Lan],
|
Str_Copy (Cty->WWW[Lan],row[1 + Lan_NUM_LANGUAGES + Lan],
|
||||||
Cns_MAX_BYTES_WWW);
|
sizeof (Cty->WWW[Lan]) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get number of users who claim to belong to this country */
|
/* Get number of users who claim to belong to this country */
|
||||||
|
@ -1069,7 +1054,7 @@ bool Cty_GetDataOfCountryByCod (struct Cty_Countr *Cty)
|
||||||
Lan++)
|
Lan++)
|
||||||
if (Lan == Gbl.Prefs.Language)
|
if (Lan == Gbl.Prefs.Language)
|
||||||
Str_Copy (Cty->Name[Lan],Txt_Another_country,
|
Str_Copy (Cty->Name[Lan],Txt_Another_country,
|
||||||
Cty_MAX_BYTES_NAME);
|
sizeof (Cty->Name[Lan]) - 1);
|
||||||
else
|
else
|
||||||
Cty->Name[Lan][0] = '\0';
|
Cty->Name[Lan][0] = '\0';
|
||||||
return false;
|
return false;
|
||||||
|
@ -1095,14 +1080,13 @@ bool Cty_GetDataOfCountryByCod (struct Cty_Countr *Cty)
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get Alpha-2 country code (row[0]) */
|
/* Get Alpha-2 country code (row[0]) */
|
||||||
Str_Copy (Cty->Alpha2,row[0],
|
Str_Copy (Cty->Alpha2,row[0],sizeof (Cty->Alpha2) - 1);
|
||||||
2);
|
|
||||||
|
|
||||||
/* Get name and WWW of the country in current language */
|
/* Get name and WWW of the country in current language */
|
||||||
Str_Copy (Cty->Name[Gbl.Prefs.Language],row[1],
|
Str_Copy (Cty->Name[Gbl.Prefs.Language],row[1],
|
||||||
Cty_MAX_BYTES_NAME);
|
sizeof (Cty->Name[Gbl.Prefs.Language]) - 1);
|
||||||
Str_Copy (Cty->WWW[Gbl.Prefs.Language],row[2],
|
Str_Copy (Cty->WWW[Gbl.Prefs.Language],row[2],
|
||||||
Cns_MAX_BYTES_WWW);
|
sizeof (Cty->WWW[Gbl.Prefs.Language]) - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CtyFound = false;
|
CtyFound = false;
|
||||||
|
@ -1142,8 +1126,7 @@ void Cty_GetCountryName (long CtyCod,Lan_Language_t Language,
|
||||||
if (CtyCod == Gbl.Cache.CountryName.CtyCod &&
|
if (CtyCod == Gbl.Cache.CountryName.CtyCod &&
|
||||||
Language == Gbl.Cache.CountryName.Language)
|
Language == Gbl.Cache.CountryName.Language)
|
||||||
{
|
{
|
||||||
Str_Copy (CtyName,Gbl.Cache.CountryName.CtyName,
|
Str_Copy (CtyName,Gbl.Cache.CountryName.CtyName,Cty_MAX_BYTES_NAME);
|
||||||
Cty_MAX_BYTES_NAME);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1160,7 +1143,7 @@ void Cty_GetCountryName (long CtyCod,Lan_Language_t Language,
|
||||||
|
|
||||||
/* Get the name of the country */
|
/* Get the name of the country */
|
||||||
Str_Copy (Gbl.Cache.CountryName.CtyName,row[0],
|
Str_Copy (Gbl.Cache.CountryName.CtyName,row[0],
|
||||||
Cty_MAX_BYTES_NAME);
|
sizeof (Gbl.Cache.CountryName.CtyName) - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Gbl.Cache.CountryName.CtyName[0] = '\0';
|
Gbl.Cache.CountryName.CtyName[0] = '\0';
|
||||||
|
@ -1168,8 +1151,7 @@ void Cty_GetCountryName (long CtyCod,Lan_Language_t Language,
|
||||||
/* Free structure that stores the query result */
|
/* Free structure that stores the query result */
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
Str_Copy (CtyName,Gbl.Cache.CountryName.CtyName,
|
Str_Copy (CtyName,Gbl.Cache.CountryName.CtyName,Cty_MAX_BYTES_NAME);
|
||||||
Cty_MAX_BYTES_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1441,8 +1423,7 @@ void Cty_RenameCountry (void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Update the table changing old name by new name */
|
/* Update the table changing old name by new name */
|
||||||
snprintf (FieldName,sizeof (FieldName),
|
snprintf (FieldName,sizeof (FieldName),"Name_%s",
|
||||||
"Name_%s",
|
|
||||||
Lan_STR_LANG_ID[Language]);
|
Lan_STR_LANG_ID[Language]);
|
||||||
Cty_UpdateCtyNameDB (Cty_EditingCty->CtyCod,FieldName,NewCtyName);
|
Cty_UpdateCtyNameDB (Cty_EditingCty->CtyCod,FieldName,NewCtyName);
|
||||||
|
|
||||||
|
@ -1453,7 +1434,7 @@ void Cty_RenameCountry (void)
|
||||||
|
|
||||||
/* Update country name */
|
/* Update country name */
|
||||||
Str_Copy (Cty_EditingCty->Name[Language],NewCtyName,
|
Str_Copy (Cty_EditingCty->Name[Language],NewCtyName,
|
||||||
Cty_MAX_BYTES_NAME);
|
sizeof (Cty_EditingCty->Name[Language]) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // The same name
|
else // The same name
|
||||||
|
@ -1556,7 +1537,7 @@ void Cty_ChangeCtyWWW (void)
|
||||||
" WHERE CtyCod='%03ld'",
|
" WHERE CtyCod='%03ld'",
|
||||||
Lan_STR_LANG_ID[Language],NewWWW,Cty_EditingCty->CtyCod);
|
Lan_STR_LANG_ID[Language],NewWWW,Cty_EditingCty->CtyCod);
|
||||||
Str_Copy (Cty_EditingCty->WWW[Language],NewWWW,
|
Str_Copy (Cty_EditingCty->WWW[Language],NewWWW,
|
||||||
Cns_MAX_BYTES_WWW);
|
sizeof (Cty_EditingCty->WWW[Language]) - 1);
|
||||||
|
|
||||||
/***** Write message to show the change made *****/
|
/***** Write message to show the change made *****/
|
||||||
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
||||||
|
@ -1644,9 +1625,7 @@ static void Cty_PutFormToCreateCountry (void)
|
||||||
/***** Numerical country code (ISO 3166-1) *****/
|
/***** Numerical country code (ISO 3166-1) *****/
|
||||||
HTM_TD_Begin ("rowspan=\"%u\" class=\"RT\"",1 + Lan_NUM_LANGUAGES);
|
HTM_TD_Begin ("rowspan=\"%u\" class=\"RT\"",1 + Lan_NUM_LANGUAGES);
|
||||||
if (Cty_EditingCty->CtyCod > 0)
|
if (Cty_EditingCty->CtyCod > 0)
|
||||||
snprintf (StrCtyCod,sizeof (StrCtyCod),
|
snprintf (StrCtyCod,sizeof (StrCtyCod),"%03ld",Cty_EditingCty->CtyCod);
|
||||||
"%03ld",
|
|
||||||
Cty_EditingCty->CtyCod);
|
|
||||||
else
|
else
|
||||||
StrCtyCod[0] = '\0';
|
StrCtyCod[0] = '\0';
|
||||||
HTM_INPUT_TEXT ("OthCtyCod",3,StrCtyCod,HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_INPUT_TEXT ("OthCtyCod",3,StrCtyCod,HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
|
@ -1687,9 +1666,7 @@ static void Cty_PutFormToCreateCountry (void)
|
||||||
|
|
||||||
/* Name */
|
/* Name */
|
||||||
HTM_TD_Begin ("class=\"LM\"");
|
HTM_TD_Begin ("class=\"LM\"");
|
||||||
snprintf (StrName,sizeof (StrName),
|
snprintf (StrName,sizeof (StrName),"Name_%s",Lan_STR_LANG_ID[Lan]);
|
||||||
"Name_%s",
|
|
||||||
Lan_STR_LANG_ID[Lan]);
|
|
||||||
HTM_INPUT_TEXT (StrName,Cty_MAX_CHARS_NAME,Cty_EditingCty->Name[Lan],
|
HTM_INPUT_TEXT (StrName,Cty_MAX_CHARS_NAME,Cty_EditingCty->Name[Lan],
|
||||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"size=\"15\" required=\"required\"");
|
"size=\"15\" required=\"required\"");
|
||||||
|
@ -1697,9 +1674,7 @@ static void Cty_PutFormToCreateCountry (void)
|
||||||
|
|
||||||
/* WWW */
|
/* WWW */
|
||||||
HTM_TD_Begin ("class=\"LM\"");
|
HTM_TD_Begin ("class=\"LM\"");
|
||||||
snprintf (StrName,sizeof (StrName),
|
snprintf (StrName,sizeof (StrName),"WWW_%s",Lan_STR_LANG_ID[Lan]);
|
||||||
"WWW_%s",
|
|
||||||
Lan_STR_LANG_ID[Lan]);
|
|
||||||
HTM_INPUT_URL (StrName,Cty_EditingCty->WWW[Lan],HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_INPUT_URL (StrName,Cty_EditingCty->WWW[Lan],HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"class=\"INPUT_WWW_NARROW\" required=\"required\"");
|
"class=\"INPUT_WWW_NARROW\" required=\"required\"");
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
@ -1810,9 +1785,7 @@ void Cty_ReceiveFormNewCountry (void)
|
||||||
Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES;
|
Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES;
|
||||||
Lan++)
|
Lan++)
|
||||||
{
|
{
|
||||||
snprintf (ParamName,sizeof (ParamName),
|
snprintf (ParamName,sizeof (ParamName),"Name_%s",Lan_STR_LANG_ID[Lan]);
|
||||||
"Name_%s",
|
|
||||||
Lan_STR_LANG_ID[Lan]);
|
|
||||||
Par_GetParToText (ParamName,Cty_EditingCty->Name[Lan],Cty_MAX_BYTES_NAME);
|
Par_GetParToText (ParamName,Cty_EditingCty->Name[Lan],Cty_MAX_BYTES_NAME);
|
||||||
|
|
||||||
if (Cty_EditingCty->Name[Lan][0]) // If there's a country name
|
if (Cty_EditingCty->Name[Lan][0]) // If there's a country name
|
||||||
|
@ -1835,9 +1808,7 @@ void Cty_ReceiveFormNewCountry (void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf (ParamName,sizeof (ParamName),
|
snprintf (ParamName,sizeof (ParamName),"WWW_%s",Lan_STR_LANG_ID[Lan]);
|
||||||
"WWW_%s",
|
|
||||||
Lan_STR_LANG_ID[Lan]);
|
|
||||||
Par_GetParToText (ParamName,Cty_EditingCty->WWW[Lan],Cns_MAX_BYTES_WWW);
|
Par_GetParToText (ParamName,Cty_EditingCty->WWW[Lan],Cns_MAX_BYTES_WWW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1878,31 +1849,19 @@ static void Cty_CreateCountry (void)
|
||||||
Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES;
|
Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES;
|
||||||
Lan++)
|
Lan++)
|
||||||
{
|
{
|
||||||
snprintf (StrField,sizeof (StrField),
|
snprintf (StrField,sizeof (StrField),",Name_%s",Lan_STR_LANG_ID[Lan]);
|
||||||
",Name_%s",
|
Str_Concat (SubQueryNam1,StrField,sizeof (SubQueryNam1) - 1);
|
||||||
Lan_STR_LANG_ID[Lan]);
|
|
||||||
Str_Concat (SubQueryNam1,StrField,
|
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
|
||||||
|
|
||||||
Str_Concat (SubQueryNam2,",'",
|
Str_Concat (SubQueryNam2,",'",sizeof (SubQueryNam2) - 1);
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS_NAME);
|
Str_Concat (SubQueryNam2,Cty_EditingCty->Name[Lan],sizeof (SubQueryNam2) - 1);
|
||||||
Str_Concat (SubQueryNam2,Cty_EditingCty->Name[Lan],
|
Str_Concat (SubQueryNam2,"'",sizeof (SubQueryNam2) - 1);
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS_NAME);
|
|
||||||
Str_Concat (SubQueryNam2,"'",
|
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS_NAME);
|
|
||||||
|
|
||||||
snprintf (StrField,sizeof (StrField),
|
snprintf (StrField,sizeof (StrField),",WWW_%s",Lan_STR_LANG_ID[Lan]);
|
||||||
",WWW_%s",
|
Str_Concat (SubQueryWWW1,StrField,sizeof (SubQueryWWW1) - 1);
|
||||||
Lan_STR_LANG_ID[Lan]);
|
|
||||||
Str_Concat (SubQueryWWW1,StrField,
|
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
|
||||||
|
|
||||||
Str_Concat (SubQueryWWW2,",'",
|
Str_Concat (SubQueryWWW2,",'",sizeof (SubQueryWWW2) - 1);
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
|
Str_Concat (SubQueryWWW2,Cty_EditingCty->WWW[Lan],sizeof (SubQueryWWW2) - 1);
|
||||||
Str_Concat (SubQueryWWW2,Cty_EditingCty->WWW[Lan],
|
Str_Concat (SubQueryWWW2,"'",sizeof (SubQueryWWW2) - 1);
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
|
|
||||||
Str_Concat (SubQueryWWW2,"'",
|
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
|
|
||||||
}
|
}
|
||||||
DB_QueryINSERT ("can not create country",
|
DB_QueryINSERT ("can not create country",
|
||||||
"INSERT INTO countries"
|
"INSERT INTO countries"
|
||||||
|
@ -2144,8 +2103,8 @@ static void Cty_EditingCountryConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing country.");
|
Lay_ShowErrorAndExit ("Error initializing country.");
|
||||||
|
|
||||||
/***** Allocate memory for country *****/
|
/***** Allocate memory for country *****/
|
||||||
if ((Cty_EditingCty = (struct Cty_Countr *) malloc (sizeof (struct Cty_Countr))) == NULL)
|
if ((Cty_EditingCty = malloc (sizeof (*Cty_EditingCty))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for country.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset country *****/
|
/***** Reset country *****/
|
||||||
Cty_EditingCty->CtyCod = -1L;
|
Cty_EditingCty->CtyCod = -1L;
|
||||||
|
|
|
@ -592,10 +592,9 @@ static void CtyCfg_GetMapAttr (long CtyCod,char **MapAttribution)
|
||||||
if (row[0][0])
|
if (row[0][0])
|
||||||
{
|
{
|
||||||
Length = strlen (row[0]);
|
Length = strlen (row[0]);
|
||||||
if ((*MapAttribution = (char *) malloc (Length + 1)) == NULL)
|
if ((*MapAttribution = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for map attribution.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (*MapAttribution,row[0],
|
Str_Copy (*MapAttribution,row[0],Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,8 +178,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
||||||
char ClassHighlight[64];
|
char ClassHighlight[64];
|
||||||
|
|
||||||
ClassNormal = The_ClassFormLinkInBox[Gbl.Prefs.Theme];
|
ClassNormal = The_ClassFormLinkInBox[Gbl.Prefs.Theme];
|
||||||
snprintf (ClassHighlight,sizeof (ClassHighlight),
|
snprintf (ClassHighlight,sizeof (ClassHighlight),"%s LIGHT_BLUE",
|
||||||
"%s LIGHT_BLUE",
|
|
||||||
The_ClassFormLinkInBoxBold[Gbl.Prefs.Theme]);
|
The_ClassFormLinkInBoxBold[Gbl.Prefs.Theme]);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
|
@ -775,8 +774,8 @@ static void Crs_GetListCrssInCurrentDeg (Crs_WhatCourses_t WhatCourses)
|
||||||
if (NumCrss) // Courses found...
|
if (NumCrss) // Courses found...
|
||||||
{
|
{
|
||||||
/***** Create list with courses in degree *****/
|
/***** Create list with courses in degree *****/
|
||||||
if ((Gbl.Hierarchy.Crss.Lst = (struct Crs_Course *) calloc ((size_t) NumCrss,
|
if ((Gbl.Hierarchy.Crss.Lst = calloc (NumCrss,
|
||||||
sizeof (struct Crs_Course))) == NULL)
|
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the courses in degree *****/
|
/***** Get the courses in degree *****/
|
||||||
|
@ -1804,7 +1803,7 @@ static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row)
|
||||||
|
|
||||||
/***** Get institutional course code (row[3]) *****/
|
/***** Get institutional course code (row[3]) *****/
|
||||||
Str_Copy (Crs->InstitutionalCrsCod,row[3],
|
Str_Copy (Crs->InstitutionalCrsCod,row[3],
|
||||||
Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD);
|
sizeof (Crs->InstitutionalCrsCod) - 1);
|
||||||
|
|
||||||
/***** Get course status (row[4]) *****/
|
/***** Get course status (row[4]) *****/
|
||||||
if (sscanf (row[4],"%u",&(Crs->Status)) != 1)
|
if (sscanf (row[4],"%u",&(Crs->Status)) != 1)
|
||||||
|
@ -1814,12 +1813,10 @@ static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row)
|
||||||
Crs->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[5]);
|
Crs->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||||
|
|
||||||
/***** Get the short name of the course (row[6]) *****/
|
/***** Get the short name of the course (row[6]) *****/
|
||||||
Str_Copy (Crs->ShrtName,row[6],
|
Str_Copy (Crs->ShrtName,row[6],sizeof (Crs->ShrtName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
|
||||||
|
|
||||||
/***** Get the full name of the course (row[7]) *****/
|
/***** Get the full name of the course (row[7]) *****/
|
||||||
Str_Copy (Crs->FullName,row[7],
|
Str_Copy (Crs->FullName,row[7],sizeof (Crs->FullName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1848,10 +1845,8 @@ static void Crs_GetShortNamesByCod (long CrsCod,
|
||||||
/***** Get the short name of this course *****/
|
/***** Get the short name of this course *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
Str_Copy (CrsShortName,row[0],
|
Str_Copy (CrsShortName,row[0],Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
Str_Copy (DegShortName,row[1],Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
||||||
Str_Copy (DegShortName,row[1],
|
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -2024,12 +2019,10 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
|
||||||
CrsCod);
|
CrsCod);
|
||||||
|
|
||||||
/***** Remove directories of the course *****/
|
/***** Remove directories of the course *****/
|
||||||
snprintf (PathRelCrs,sizeof (PathRelCrs),
|
snprintf (PathRelCrs,sizeof (PathRelCrs),"%s/%ld",
|
||||||
"%s/%ld",
|
|
||||||
Cfg_PATH_CRS_PRIVATE,CrsCod);
|
Cfg_PATH_CRS_PRIVATE,CrsCod);
|
||||||
Fil_RemoveTree (PathRelCrs);
|
Fil_RemoveTree (PathRelCrs);
|
||||||
snprintf (PathRelCrs,sizeof (PathRelCrs),
|
snprintf (PathRelCrs,sizeof (PathRelCrs),"%s/%ld",
|
||||||
"%s/%ld",
|
|
||||||
Cfg_PATH_CRS_PUBLIC,CrsCod);
|
Cfg_PATH_CRS_PUBLIC,CrsCod);
|
||||||
Fil_RemoveTree (PathRelCrs);
|
Fil_RemoveTree (PathRelCrs);
|
||||||
}
|
}
|
||||||
|
@ -2170,7 +2163,7 @@ void Crs_UpdateInstitutionalCrsCod (struct Crs_Course *Crs,const char *NewInstit
|
||||||
|
|
||||||
/***** Copy institutional course code *****/
|
/***** Copy institutional course code *****/
|
||||||
Str_Copy (Crs->InstitutionalCrsCod,NewInstitutionalCrsCod,
|
Str_Copy (Crs->InstitutionalCrsCod,NewInstitutionalCrsCod,
|
||||||
Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD);
|
sizeof (Crs->InstitutionalCrsCod) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2261,8 +2254,7 @@ void Crs_RenameCourse (struct Crs_Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullNam
|
||||||
CurrentCrsName,NewCrsName);
|
CurrentCrsName,NewCrsName);
|
||||||
|
|
||||||
/* Change current course name in order to display it properly */
|
/* Change current course name in order to display it properly */
|
||||||
Str_Copy (CurrentCrsName,NewCrsName,
|
Str_Copy (CurrentCrsName,NewCrsName,MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // The same name
|
else // The same name
|
||||||
|
@ -2987,8 +2979,8 @@ static void Crs_EditingCourseConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing course.");
|
Lay_ShowErrorAndExit ("Error initializing course.");
|
||||||
|
|
||||||
/***** Allocate memory for course *****/
|
/***** Allocate memory for course *****/
|
||||||
if ((Crs_EditingCrs = (struct Crs_Course *) malloc (sizeof (struct Crs_Course))) == NULL)
|
if ((Crs_EditingCrs = malloc (sizeof (*Crs_EditingCrs))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for course.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset course *****/
|
/***** Reset course *****/
|
||||||
Crs_EditingCrs->CrsCod = -1L;
|
Crs_EditingCrs->CrsCod = -1L;
|
||||||
|
|
|
@ -148,8 +148,7 @@ void Cry_CreateUniqueNameEncrypted (char UniqueNameEncrypted[Cry_BYTES_ENCRYPTED
|
||||||
char UniqueNamePlain[Cns_MAX_BYTES_IP + Cns_MAX_DECIMAL_DIGITS_LONG + Cns_MAX_DECIMAL_DIGITS_LONG + Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
char UniqueNamePlain[Cns_MAX_BYTES_IP + Cns_MAX_DECIMAL_DIGITS_LONG + Cns_MAX_DECIMAL_DIGITS_LONG + Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
||||||
|
|
||||||
NumCall++;
|
NumCall++;
|
||||||
snprintf (UniqueNamePlain,sizeof (UniqueNamePlain),
|
snprintf (UniqueNamePlain,sizeof (UniqueNamePlain),"%s-%lx-%x-%x",
|
||||||
"%s-%lx-%x-%x",
|
|
||||||
Gbl.IP,Gbl.StartExecutionTimeUTC,Gbl.PID,NumCall);
|
Gbl.IP,Gbl.StartExecutionTimeUTC,Gbl.PID,NumCall);
|
||||||
Cry_EncryptSHA256Base64 (UniqueNamePlain,UniqueNameEncrypted); // Make difficult to guess a unique name
|
Cry_EncryptSHA256Base64 (UniqueNamePlain,UniqueNameEncrypted); // Make difficult to guess a unique name
|
||||||
}
|
}
|
||||||
|
|
|
@ -4058,8 +4058,7 @@ void DB_ExitOnMySQLError (const char *Message)
|
||||||
{
|
{
|
||||||
char BigErrorMsg[64 * 1024];
|
char BigErrorMsg[64 * 1024];
|
||||||
|
|
||||||
snprintf (BigErrorMsg,sizeof (BigErrorMsg),
|
snprintf (BigErrorMsg,sizeof (BigErrorMsg),"Database error: %s (%s).",
|
||||||
"Database error: %s (%s).",
|
|
||||||
Message,mysql_error (&Gbl.mysql));
|
Message,mysql_error (&Gbl.mysql));
|
||||||
Lay_ShowErrorAndExit (BigErrorMsg);
|
Lay_ShowErrorAndExit (BigErrorMsg);
|
||||||
}
|
}
|
||||||
|
|
20
swad_date.c
20
swad_date.c
|
@ -309,8 +309,7 @@ bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDD)
|
||||||
if (YYYYMMDD[0])
|
if (YYYYMMDD[0])
|
||||||
if (sscanf (YYYYMMDD,"%04u%02u%02u",&(Date->Year),&(Date->Month),&(Date->Day)) == 3)
|
if (sscanf (YYYYMMDD,"%04u%02u%02u",&(Date->Year),&(Date->Month),&(Date->Day)) == 3)
|
||||||
{
|
{
|
||||||
Str_Copy (Date->YYYYMMDD,YYYYMMDD,
|
Str_Copy (Date->YYYYMMDD,YYYYMMDD,sizeof (Date->YYYYMMDD) - 1);
|
||||||
Dat_LENGTH_YYYYMMDD);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,22 +414,19 @@ void Dat_ConvDateToDateStr (const struct Date *Date,char StrDate[Cns_MAX_BYTES_D
|
||||||
switch (Gbl.Prefs.DateFormat)
|
switch (Gbl.Prefs.DateFormat)
|
||||||
{
|
{
|
||||||
case Dat_FORMAT_YYYY_MM_DD:
|
case Dat_FORMAT_YYYY_MM_DD:
|
||||||
snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,
|
snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,"%04u-%02u-%02u",
|
||||||
"%04u-%02u-%02u",
|
|
||||||
Date->Year,
|
Date->Year,
|
||||||
Date->Month,
|
Date->Month,
|
||||||
Date->Day);
|
Date->Day);
|
||||||
break;
|
break;
|
||||||
case Dat_FORMAT_DD_MONTH_YYYY:
|
case Dat_FORMAT_DD_MONTH_YYYY:
|
||||||
snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,
|
snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,"%u %s %04u",
|
||||||
"%u %s %04u",
|
|
||||||
Date->Day,
|
Date->Day,
|
||||||
Txt_MONTHS_SMALL_SHORT[Date->Month - 1],
|
Txt_MONTHS_SMALL_SHORT[Date->Month - 1],
|
||||||
Date->Year);
|
Date->Year);
|
||||||
break;
|
break;
|
||||||
case Dat_FORMAT_MONTH_DD_YYYY:
|
case Dat_FORMAT_MONTH_DD_YYYY:
|
||||||
snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,
|
snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,"%s %u, %04u",
|
||||||
"%s %u, %04u",
|
|
||||||
Txt_MONTHS_SMALL_SHORT[Date->Month - 1],
|
Txt_MONTHS_SMALL_SHORT[Date->Month - 1],
|
||||||
Date->Day,
|
Date->Day,
|
||||||
Date->Year);
|
Date->Year);
|
||||||
|
@ -831,13 +827,11 @@ void Dat_GetBrowserTimeZone (char BrowserTimeZone[Dat_MAX_BYTES_TIME_ZONE + 1])
|
||||||
/* Convert from minutes to +-hh:mm */
|
/* Convert from minutes to +-hh:mm */
|
||||||
// BrowserTimeZone must have space for strings in +hh:mm format (6 chars + \0)
|
// BrowserTimeZone must have space for strings in +hh:mm format (6 chars + \0)
|
||||||
if (ClientUTCMinusLocal > 0)
|
if (ClientUTCMinusLocal > 0)
|
||||||
snprintf (BrowserTimeZone,Dat_MAX_BYTES_TIME_ZONE + 1,
|
snprintf (BrowserTimeZone,Dat_MAX_BYTES_TIME_ZONE + 1,"-%02u:%02u",
|
||||||
"-%02u:%02u",
|
|
||||||
(unsigned) ClientUTCMinusLocal / 60,
|
(unsigned) ClientUTCMinusLocal / 60,
|
||||||
(unsigned) ClientUTCMinusLocal % 60);
|
(unsigned) ClientUTCMinusLocal % 60);
|
||||||
else // ClientUTCMinusLocal <= 0
|
else // ClientUTCMinusLocal <= 0
|
||||||
snprintf (BrowserTimeZone,Dat_MAX_BYTES_TIME_ZONE + 1,
|
snprintf (BrowserTimeZone,Dat_MAX_BYTES_TIME_ZONE + 1,"+%02u:%02u",
|
||||||
"+%02u:%02u",
|
|
||||||
(unsigned) (-ClientUTCMinusLocal) / 60,
|
(unsigned) (-ClientUTCMinusLocal) / 60,
|
||||||
(unsigned) (-ClientUTCMinusLocal) % 60);
|
(unsigned) (-ClientUTCMinusLocal) % 60);
|
||||||
}
|
}
|
||||||
|
@ -1577,7 +1571,7 @@ void Dat_AssignDate (struct Date *DateDst,struct Date *DateSrc)
|
||||||
DateDst->Day = DateSrc->Day;
|
DateDst->Day = DateSrc->Day;
|
||||||
DateDst->Week = DateSrc->Week;
|
DateDst->Week = DateSrc->Week;
|
||||||
Str_Copy (DateDst->YYYYMMDD,DateSrc->YYYYMMDD,
|
Str_Copy (DateDst->YYYYMMDD,DateSrc->YYYYMMDD,
|
||||||
Dat_LENGTH_YYYYMMDD);
|
sizeof (DateDst->YYYYMMDD) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -464,8 +464,7 @@ static void Deg_ListDegreesForEdition (void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Str_Copy (WWW,Deg->WWW,
|
Str_Copy (WWW,Deg->WWW,sizeof (WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\"");
|
HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\"");
|
||||||
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\"",
|
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\"",
|
||||||
Deg->WWW,Deg->WWW);
|
Deg->WWW,Deg->WWW);
|
||||||
|
@ -1081,7 +1080,7 @@ void Deg_GetListAllDegsWithStds (struct ListDegrees *Degs)
|
||||||
if (Degs->Num) // Degrees found...
|
if (Degs->Num) // Degrees found...
|
||||||
{
|
{
|
||||||
/***** Create list with degrees *****/
|
/***** Create list with degrees *****/
|
||||||
if ((Degs->Lst = (struct Deg_Degree *) calloc (Degs->Num,sizeof (struct Deg_Degree))) == NULL)
|
if ((Degs->Lst = calloc (Degs->Num,sizeof (*Degs->Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the degrees *****/
|
/***** Get the degrees *****/
|
||||||
|
@ -1126,8 +1125,8 @@ void Deg_GetListDegsInCurrentCtr (void)
|
||||||
Gbl.Hierarchy.Degs.Num = (unsigned) NumRows;
|
Gbl.Hierarchy.Degs.Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with degrees of this centre *****/
|
/***** Create list with degrees of this centre *****/
|
||||||
if ((Gbl.Hierarchy.Degs.Lst = (struct Deg_Degree *) calloc (Gbl.Hierarchy.Degs.Num,
|
if ((Gbl.Hierarchy.Degs.Lst = calloc (Gbl.Hierarchy.Degs.Num,
|
||||||
sizeof (struct Deg_Degree))) == NULL)
|
sizeof (*Gbl.Hierarchy.Degs.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the degrees of this centre *****/
|
/***** Get the degrees of this centre *****/
|
||||||
|
@ -1388,16 +1387,13 @@ static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row)
|
||||||
Deg->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]);
|
Deg->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]);
|
||||||
|
|
||||||
/***** Get degree short name (row[5]) *****/
|
/***** Get degree short name (row[5]) *****/
|
||||||
Str_Copy (Deg->ShrtName,row[5],
|
Str_Copy (Deg->ShrtName,row[5],sizeof (Deg->ShrtName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
|
||||||
|
|
||||||
/***** Get degree full name (row[6]) *****/
|
/***** Get degree full name (row[6]) *****/
|
||||||
Str_Copy (Deg->FullName,row[6],
|
Str_Copy (Deg->FullName,row[6],sizeof (Deg->FullName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
|
||||||
|
|
||||||
/***** Get WWW (row[7]) *****/
|
/***** Get WWW (row[7]) *****/
|
||||||
Str_Copy (Deg->WWW,row[7],
|
Str_Copy (Deg->WWW,row[7],sizeof (Deg->WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1420,8 +1416,7 @@ void Deg_GetShortNameOfDegreeByCod (struct Deg_Degree *Deg)
|
||||||
/***** Get the short name of this degree *****/
|
/***** Get the short name of this degree *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
Str_Copy (Deg->ShrtName,row[0],
|
Str_Copy (Deg->ShrtName,row[0],sizeof (Deg->ShrtName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -1537,11 +1532,10 @@ void Deg_RemoveDegreeCompletely (long DegCod)
|
||||||
Brw_RemoveDegFilesFromDB (DegCod);
|
Brw_RemoveDegFilesFromDB (DegCod);
|
||||||
|
|
||||||
/***** Remove directories of the degree *****/
|
/***** Remove directories of the degree *****/
|
||||||
snprintf (PathDeg,sizeof (PathDeg),
|
snprintf (PathDeg,sizeof (PathDeg),"%s/%02u/%u",
|
||||||
"%s/%02u/%u",
|
|
||||||
Cfg_PATH_DEG_PUBLIC,
|
Cfg_PATH_DEG_PUBLIC,
|
||||||
(unsigned) (DegCod % 100),
|
(unsigned) (DegCod % 100),
|
||||||
(unsigned) DegCod);
|
(unsigned) DegCod);
|
||||||
Fil_RemoveTree (PathDeg);
|
Fil_RemoveTree (PathDeg);
|
||||||
|
|
||||||
/***** Remove administrators of this degree *****/
|
/***** Remove administrators of this degree *****/
|
||||||
|
@ -1646,8 +1640,7 @@ void Deg_RenameDegree (struct Deg_Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullNam
|
||||||
CurrentDegName,NewDegName);
|
CurrentDegName,NewDegName);
|
||||||
|
|
||||||
/* Change current degree name in order to display it properly */
|
/* Change current degree name in order to display it properly */
|
||||||
Str_Copy (CurrentDegName,NewDegName,
|
Str_Copy (CurrentDegName,NewDegName,MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // The same name
|
else // The same name
|
||||||
|
@ -1748,8 +1741,7 @@ void Deg_ChangeDegWWW (void)
|
||||||
{
|
{
|
||||||
/***** Update the table changing old WWW by new WWW *****/
|
/***** Update the table changing old WWW by new WWW *****/
|
||||||
Deg_UpdateDegWWWDB (Deg_EditingDeg->DegCod,NewWWW);
|
Deg_UpdateDegWWWDB (Deg_EditingDeg->DegCod,NewWWW);
|
||||||
Str_Copy (Deg_EditingDeg->WWW,NewWWW,
|
Str_Copy (Deg_EditingDeg->WWW,NewWWW,sizeof (Deg_EditingDeg->WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
|
|
||||||
/***** Write alert to show the change made
|
/***** Write alert to show the change made
|
||||||
and put button to go to degree changed *****/
|
and put button to go to degree changed *****/
|
||||||
|
@ -2179,8 +2171,8 @@ static void Deg_EditingDegreeConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing degree.");
|
Lay_ShowErrorAndExit ("Error initializing degree.");
|
||||||
|
|
||||||
/***** Allocate memory for degree *****/
|
/***** Allocate memory for degree *****/
|
||||||
if ((Deg_EditingDeg = (struct Deg_Degree *) malloc (sizeof (struct Deg_Degree))) == NULL)
|
if ((Deg_EditingDeg = malloc (sizeof (*Deg_EditingDeg))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for degree.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset degree *****/
|
/***** Reset degree *****/
|
||||||
Deg_EditingDeg->DegCod = -1L;
|
Deg_EditingDeg->DegCod = -1L;
|
||||||
|
|
|
@ -441,7 +441,7 @@ void DegCfg_ChangeDegWWW (void)
|
||||||
/***** Update the table changing old WWW by new WWW *****/
|
/***** Update the table changing old WWW by new WWW *****/
|
||||||
Deg_UpdateDegWWWDB (Gbl.Hierarchy.Deg.DegCod,NewWWW);
|
Deg_UpdateDegWWWDB (Gbl.Hierarchy.Deg.DegCod,NewWWW);
|
||||||
Str_Copy (Gbl.Hierarchy.Deg.WWW,NewWWW,
|
Str_Copy (Gbl.Hierarchy.Deg.WWW,NewWWW,
|
||||||
Cns_MAX_BYTES_WWW);
|
sizeof (Gbl.Hierarchy.Deg.WWW) - 1);
|
||||||
|
|
||||||
/***** Write message to show the change made *****/
|
/***** Write message to show the change made *****/
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X,
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X,
|
||||||
|
|
|
@ -695,9 +695,8 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
|
||||||
if (Gbl.DegTypes.Num)
|
if (Gbl.DegTypes.Num)
|
||||||
{
|
{
|
||||||
/***** Create a list of degree types *****/
|
/***** Create a list of degree types *****/
|
||||||
if ((Gbl.DegTypes.Lst = (struct DegreeType *)
|
if ((Gbl.DegTypes.Lst = calloc (Gbl.DegTypes.Num,
|
||||||
calloc (Gbl.DegTypes.Num,
|
sizeof (*Gbl.DegTypes.Lst))) == NULL)
|
||||||
sizeof (struct DegreeType))) == NULL)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get degree types *****/
|
/***** Get degree types *****/
|
||||||
|
@ -714,7 +713,7 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
|
||||||
|
|
||||||
/* Get degree type name (row[1]) */
|
/* Get degree type name (row[1]) */
|
||||||
Str_Copy (Gbl.DegTypes.Lst[NumRow].DegTypName,row[1],
|
Str_Copy (Gbl.DegTypes.Lst[NumRow].DegTypName,row[1],
|
||||||
Deg_MAX_BYTES_DEGREE_TYPE_NAME);
|
sizeof (Gbl.DegTypes.Lst[NumRow].DegTypName) - 1);
|
||||||
|
|
||||||
/* Number of degrees of this type (row[2]) */
|
/* Number of degrees of this type (row[2]) */
|
||||||
if (sscanf (row[2],"%u",&Gbl.DegTypes.Lst[NumRow].NumDegs) != 1)
|
if (sscanf (row[2],"%u",&Gbl.DegTypes.Lst[NumRow].NumDegs) != 1)
|
||||||
|
@ -881,8 +880,7 @@ bool DT_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp)
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get the name of the degree type (row[0]) */
|
/* Get the name of the degree type (row[0]) */
|
||||||
Str_Copy (DegTyp->DegTypName,row[0],
|
Str_Copy (DegTyp->DegTypName,row[0],sizeof (DegTyp->DegTypName) - 1);
|
||||||
Deg_MAX_BYTES_DEGREE_TYPE_NAME);
|
|
||||||
|
|
||||||
/* Count number of degrees of this type */
|
/* Count number of degrees of this type */
|
||||||
DegTyp->NumDegs = DT_CountNumDegsOfType (DegTyp->DegTypCod);
|
DegTyp->NumDegs = DT_CountNumDegsOfType (DegTyp->DegTypCod);
|
||||||
|
@ -1011,7 +1009,7 @@ void DT_RenameDegreeType (void)
|
||||||
|
|
||||||
/***** Set degree type name *****/
|
/***** Set degree type name *****/
|
||||||
Str_Copy (DT_EditingDegTyp->DegTypName,NewNameDegTyp,
|
Str_Copy (DT_EditingDegTyp->DegTypName,NewNameDegTyp,
|
||||||
Deg_MAX_BYTES_DEGREE_TYPE_NAME);
|
sizeof (DT_EditingDegTyp->DegTypName) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1055,8 +1053,8 @@ static void DT_EditingDegreeTypeConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing degree type.");
|
Lay_ShowErrorAndExit ("Error initializing degree type.");
|
||||||
|
|
||||||
/***** Allocate memory for degree type *****/
|
/***** Allocate memory for degree type *****/
|
||||||
if ((DT_EditingDegTyp = (struct DegreeType *) malloc (sizeof (struct DegreeType))) == NULL)
|
if ((DT_EditingDegTyp = malloc (sizeof (*DT_EditingDegTyp))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for degree type.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset degree type *****/
|
/***** Reset degree type *****/
|
||||||
DT_EditingDegTyp->DegTypCod = -1L;
|
DT_EditingDegTyp->DegTypCod = -1L;
|
||||||
|
|
|
@ -372,9 +372,8 @@ static void Dpt_GetListDepartments (struct Dpt_Departments *Departments,long Ins
|
||||||
if (Departments->Num) // Departments found...
|
if (Departments->Num) // Departments found...
|
||||||
{
|
{
|
||||||
/***** Create list with courses in degree *****/
|
/***** Create list with courses in degree *****/
|
||||||
if ((Departments->Lst = (struct Dpt_Department *)
|
if ((Departments->Lst = calloc (Departments->Num,
|
||||||
calloc ((size_t) Departments->Num,
|
sizeof (*Departments->Lst))) == NULL)
|
||||||
sizeof (struct Dpt_Department))) == NULL)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the departments *****/
|
/***** Get the departments *****/
|
||||||
|
@ -396,16 +395,13 @@ static void Dpt_GetListDepartments (struct Dpt_Departments *Departments,long Ins
|
||||||
Lay_ShowErrorAndExit ("Wrong code of institution.");
|
Lay_ShowErrorAndExit ("Wrong code of institution.");
|
||||||
|
|
||||||
/* Get the short name of the department (row[2]) */
|
/* Get the short name of the department (row[2]) */
|
||||||
Str_Copy (Dpt->ShrtName,row[2],
|
Str_Copy (Dpt->ShrtName,row[2],sizeof (Dpt->ShrtName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
|
||||||
|
|
||||||
/* Get the full name of the department (row[3]) */
|
/* Get the full name of the department (row[3]) */
|
||||||
Str_Copy (Dpt->FullName,row[3],
|
Str_Copy (Dpt->FullName,row[3],sizeof (Dpt->FullName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get the URL of the department (row[4]) */
|
/* Get the URL of the department (row[4]) */
|
||||||
Str_Copy (Dpt->WWW,row[4],
|
Str_Copy (Dpt->WWW,row[4],sizeof (Dpt->WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
|
|
||||||
/* Get number of non-editing teachers and teachers in this department (row[5]) */
|
/* Get number of non-editing teachers and teachers in this department (row[5]) */
|
||||||
if (sscanf (row[5],"%u",&Dpt->NumTchs) != 1)
|
if (sscanf (row[5],"%u",&Dpt->NumTchs) != 1)
|
||||||
|
@ -437,10 +433,8 @@ void Dpt_GetDataOfDepartmentByCod (struct Dpt_Department *Dpt)
|
||||||
/***** Check if department code is correct *****/
|
/***** Check if department code is correct *****/
|
||||||
if (Dpt->DptCod == 0)
|
if (Dpt->DptCod == 0)
|
||||||
{
|
{
|
||||||
Str_Copy (Dpt->ShrtName,Txt_Another_department,
|
Str_Copy (Dpt->ShrtName,Txt_Another_department,sizeof (Dpt->ShrtName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
Str_Copy (Dpt->FullName,Txt_Another_department,sizeof (Dpt->FullName) - 1);
|
||||||
Str_Copy (Dpt->FullName,Txt_Another_department,
|
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
|
||||||
}
|
}
|
||||||
else if (Dpt->DptCod > 0)
|
else if (Dpt->DptCod > 0)
|
||||||
{
|
{
|
||||||
|
@ -471,16 +465,13 @@ void Dpt_GetDataOfDepartmentByCod (struct Dpt_Department *Dpt)
|
||||||
Dpt->InsCod = Str_ConvertStrCodToLongCod (row[0]);
|
Dpt->InsCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
|
||||||
/* Get the short name of the department (row[1]) */
|
/* Get the short name of the department (row[1]) */
|
||||||
Str_Copy (Dpt->ShrtName,row[1],
|
Str_Copy (Dpt->ShrtName,row[1],sizeof (Dpt->ShrtName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
|
||||||
|
|
||||||
/* Get the full name of the department (row[2]) */
|
/* Get the full name of the department (row[2]) */
|
||||||
Str_Copy (Dpt->FullName,row[2],
|
Str_Copy (Dpt->FullName,row[2],sizeof (Dpt->FullName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get the URL of the department (row[3]) */
|
/* Get the URL of the department (row[3]) */
|
||||||
Str_Copy (Dpt->WWW,row[3],
|
Str_Copy (Dpt->WWW,row[3],sizeof (Dpt->WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
|
|
||||||
/* Get number of teachers in this department (row[4]) */
|
/* Get number of teachers in this department (row[4]) */
|
||||||
if (sscanf (row[4],"%u",&Dpt->NumTchs) != 1)
|
if (sscanf (row[4],"%u",&Dpt->NumTchs) != 1)
|
||||||
|
@ -817,8 +808,7 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update name *****/
|
/***** Update name *****/
|
||||||
Str_Copy (CurrentDptName,NewDptName,
|
Str_Copy (CurrentDptName,NewDptName,MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -886,8 +876,7 @@ void Dpt_ChangeDptWWW (void)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update web *****/
|
/***** Update web *****/
|
||||||
Str_Copy (Dpt_EditingDpt->WWW,NewWWW,
|
Str_Copy (Dpt_EditingDpt->WWW,NewWWW,sizeof (Dpt_EditingDpt->WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1197,8 +1186,8 @@ static void Dpt_EditingDepartmentConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing department.");
|
Lay_ShowErrorAndExit ("Error initializing department.");
|
||||||
|
|
||||||
/***** Allocate memory for department *****/
|
/***** Allocate memory for department *****/
|
||||||
if ((Dpt_EditingDpt = (struct Dpt_Department *) malloc (sizeof (struct Dpt_Department))) == NULL)
|
if ((Dpt_EditingDpt = malloc (sizeof (*Dpt_EditingDpt))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for department.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset department *****/
|
/***** Reset department *****/
|
||||||
Dpt_EditingDpt->DptCod = -1L;
|
Dpt_EditingDpt->DptCod = -1L;
|
||||||
|
|
|
@ -271,7 +271,7 @@ static void Dup_ListSimilarUsrs (void)
|
||||||
|
|
||||||
/***** Make query *****/
|
/***** Make query *****/
|
||||||
if (Gbl.Usrs.Other.UsrDat.Surname1[0] &&
|
if (Gbl.Usrs.Other.UsrDat.Surname1[0] &&
|
||||||
Gbl.Usrs.Other.UsrDat.FirstName[0]) // Name and surname 1 not empty
|
Gbl.Usrs.Other.UsrDat.FrstName[0]) // Name and surname 1 not empty
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get similar users",
|
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get similar users",
|
||||||
"SELECT DISTINCT UsrCod FROM"
|
"SELECT DISTINCT UsrCod FROM"
|
||||||
"(SELECT DISTINCT UsrCod FROM usr_IDs"
|
"(SELECT DISTINCT UsrCod FROM usr_IDs"
|
||||||
|
@ -283,7 +283,7 @@ static void Dup_ListSimilarUsrs (void)
|
||||||
Gbl.Usrs.Other.UsrDat.UsrCod,
|
Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||||
Gbl.Usrs.Other.UsrDat.Surname1,
|
Gbl.Usrs.Other.UsrDat.Surname1,
|
||||||
Gbl.Usrs.Other.UsrDat.Surname2,
|
Gbl.Usrs.Other.UsrDat.Surname2,
|
||||||
Gbl.Usrs.Other.UsrDat.FirstName);
|
Gbl.Usrs.Other.UsrDat.FrstName);
|
||||||
else
|
else
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get similar users",
|
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get similar users",
|
||||||
"SELECT DISTINCT UsrCod FROM usr_IDs"
|
"SELECT DISTINCT UsrCod FROM usr_IDs"
|
||||||
|
@ -408,7 +408,7 @@ static void Dup_PutButtonToViewSimilarUsrs (const struct UsrData *UsrDat)
|
||||||
extern const char *Txt_Similar_users;
|
extern const char *Txt_Similar_users;
|
||||||
|
|
||||||
Frm_StartForm (ActLstSimUsr);
|
Frm_StartForm (ActLstSimUsr);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
Btn_PutConfirmButtonInline (Txt_Similar_users);
|
Btn_PutConfirmButtonInline (Txt_Similar_users);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@ static void Dup_PutButtonToEliminateUsrAccount (const struct UsrData *UsrDat)
|
||||||
extern const char *Txt_Eliminate_user_account;
|
extern const char *Txt_Eliminate_user_account;
|
||||||
|
|
||||||
Frm_StartForm (ActUpdOth);
|
Frm_StartForm (ActUpdOth);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
Par_PutHiddenParamUnsigned (NULL,"RegRemAction",(unsigned) Enr_ELIMINATE_ONE_USR_FROM_PLATFORM);
|
Par_PutHiddenParamUnsigned (NULL,"RegRemAction",(unsigned) Enr_ELIMINATE_ONE_USR_FROM_PLATFORM);
|
||||||
Btn_PutRemoveButtonInline (Txt_Eliminate_user_account);
|
Btn_PutRemoveButtonInline (Txt_Eliminate_user_account);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
|
@ -437,7 +437,7 @@ static void Dup_PutButtonToRemoveFromListOfDupUsrs (const struct UsrData *UsrDat
|
||||||
extern const char *Txt_Not_duplicated;
|
extern const char *Txt_Not_duplicated;
|
||||||
|
|
||||||
Frm_StartForm (ActRemDupUsr);
|
Frm_StartForm (ActRemDupUsr);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
Btn_PutConfirmButtonInline (Txt_Not_duplicated);
|
Btn_PutConfirmButtonInline (Txt_Not_duplicated);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -571,7 +571,7 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat)
|
||||||
"Comments='%s'"
|
"Comments='%s'"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
UsrDat->Password,
|
UsrDat->Password,
|
||||||
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName,
|
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FrstName,
|
||||||
Usr_StringsSexDB[UsrDat->Sex],
|
Usr_StringsSexDB[UsrDat->Sex],
|
||||||
UsrDat->CtyCod,
|
UsrDat->CtyCod,
|
||||||
UsrDat->Phone[0],
|
UsrDat->Phone[0],
|
||||||
|
@ -1183,7 +1183,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get list of users' IDs *****/
|
/***** Get list of users' IDs *****/
|
||||||
if ((ListUsrsIDs = (char *) malloc (ID_MAX_BYTES_LIST_USRS_IDS + 1)) == NULL)
|
if ((ListUsrsIDs = malloc (ID_MAX_BYTES_LIST_USRS_IDS + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
Par_GetParToText ("UsrsIDs",ListUsrsIDs,ID_MAX_BYTES_LIST_USRS_IDS);
|
Par_GetParToText ("UsrsIDs",ListUsrsIDs,ID_MAX_BYTES_LIST_USRS_IDS);
|
||||||
|
|
||||||
|
@ -1248,7 +1248,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
|
||||||
/***** Find users for this user's ID *****/
|
/***** Find users for this user's ID *****/
|
||||||
ID_ReallocateListIDs (&UsrDat,1); // Only one user's ID
|
ID_ReallocateListIDs (&UsrDat,1); // Only one user's ID
|
||||||
Str_Copy (UsrDat.IDs.List[0].ID,UsrDat.UsrIDNickOrEmail,
|
Str_Copy (UsrDat.IDs.List[0].ID,UsrDat.UsrIDNickOrEmail,
|
||||||
ID_MAX_BYTES_USR_ID);
|
sizeof (UsrDat.IDs.List[0].ID) - 1);
|
||||||
Str_ConvertToUpperText (UsrDat.IDs.List[0].ID);
|
Str_ConvertToUpperText (UsrDat.IDs.List[0].ID);
|
||||||
ID_GetListUsrCodsFromUsrID (&UsrDat,NULL,&ListUsrCods,false);
|
ID_GetListUsrCodsFromUsrID (&UsrDat,NULL,&ListUsrCods,false);
|
||||||
}
|
}
|
||||||
|
@ -1375,7 +1375,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
|
||||||
/* Find users for this user's ID */
|
/* Find users for this user's ID */
|
||||||
ID_ReallocateListIDs (&UsrDat,1); // Only one user's ID
|
ID_ReallocateListIDs (&UsrDat,1); // Only one user's ID
|
||||||
Str_Copy (UsrDat.IDs.List[0].ID,UsrDat.UsrIDNickOrEmail,
|
Str_Copy (UsrDat.IDs.List[0].ID,UsrDat.UsrIDNickOrEmail,
|
||||||
ID_MAX_BYTES_USR_ID);
|
sizeof (UsrDat.IDs.List[0].ID) - 1);
|
||||||
Str_ConvertToUpperText (UsrDat.IDs.List[0].ID);
|
Str_ConvertToUpperText (UsrDat.IDs.List[0].ID);
|
||||||
ID_GetListUsrCodsFromUsrID (&UsrDat,NULL,&ListUsrCods,false);
|
ID_GetListUsrCodsFromUsrID (&UsrDat,NULL,&ListUsrCods,false);
|
||||||
}
|
}
|
||||||
|
@ -2144,7 +2144,7 @@ void Enr_AskIfRejectSignUp (void)
|
||||||
|
|
||||||
/* End alert */
|
/* End alert */
|
||||||
Ale_ShowAlertAndButton2 (ActRejSignUp,NULL,NULL,
|
Ale_ShowAlertAndButton2 (ActRejSignUp,NULL,NULL,
|
||||||
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EnUsrCod,
|
||||||
Btn_REMOVE_BUTTON,Txt_Reject);
|
Btn_REMOVE_BUTTON,Txt_Reject);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2919,7 +2919,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
}
|
}
|
||||||
Frm_StartForm (NextAction);
|
Frm_StartForm (NextAction);
|
||||||
Crs_PutParamCrsCod (Crs.CrsCod);
|
Crs_PutParamCrsCod (Crs.CrsCod);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat.EnUsrCod);
|
||||||
Btn_PutCreateButtonInline (Txt_Register);
|
Btn_PutCreateButtonInline (Txt_Register);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
@ -2928,7 +2928,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
HTM_TD_Begin ("class=\"DAT LT\"");
|
HTM_TD_Begin ("class=\"DAT LT\"");
|
||||||
Frm_StartForm (ActReqRejSignUp);
|
Frm_StartForm (ActReqRejSignUp);
|
||||||
Crs_PutParamCrsCod (Crs.CrsCod);
|
Crs_PutParamCrsCod (Crs.CrsCod);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat.EnUsrCod);
|
||||||
Btn_PutRemoveButtonInline (Txt_Reject);
|
Btn_PutRemoveButtonInline (Txt_Reject);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
@ -3657,7 +3657,7 @@ static void Enr_ReqAddAdm (Hie_Lvl_Level_t Scope,long Cod,const char *InsCtrDegN
|
||||||
|
|
||||||
/* End alert */
|
/* End alert */
|
||||||
Ale_ShowAlertAndButton2 (Enr_ActNewAdm[Scope],NULL,NULL,
|
Ale_ShowAlertAndButton2 (Enr_ActNewAdm[Scope],NULL,NULL,
|
||||||
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EnUsrCod,
|
||||||
Btn_CREATE_BUTTON,Txt_Register_user_IN_A_COURSE_OR_DEGREE);
|
Btn_CREATE_BUTTON,Txt_Register_user_IN_A_COURSE_OR_DEGREE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4075,7 +4075,7 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Frm_StartForm (NextAction);
|
Frm_StartForm (NextAction);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
Pwd_AskForConfirmationOnDangerousAction ();
|
Pwd_AskForConfirmationOnDangerousAction ();
|
||||||
Btn_PutRemoveButton (ItsMe ? Txt_Remove_me_from_this_course :
|
Btn_PutRemoveButton (ItsMe ? Txt_Remove_me_from_this_course :
|
||||||
Txt_Remove_user_from_this_course);
|
Txt_Remove_user_from_this_course);
|
||||||
|
@ -4227,7 +4227,7 @@ static void Enr_AskIfRemAdm (bool ItsMe,Hie_Lvl_Level_t Scope,
|
||||||
|
|
||||||
/* End alert */
|
/* End alert */
|
||||||
Ale_ShowAlertAndButton2 (Enr_ActRemAdm[Scope],NULL,NULL,
|
Ale_ShowAlertAndButton2 (Enr_ActRemAdm[Scope],NULL,NULL,
|
||||||
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EnUsrCod,
|
||||||
Btn_REMOVE_BUTTON,
|
Btn_REMOVE_BUTTON,
|
||||||
ItsMe ? Txt_Remove_me_as_an_administrator :
|
ItsMe ? Txt_Remove_me_as_an_administrator :
|
||||||
Txt_Remove_USER_as_an_administrator);
|
Txt_Remove_USER_as_an_administrator);
|
||||||
|
|
11
swad_exam.c
11
swad_exam.c
|
@ -31,7 +31,6 @@
|
||||||
#include <linux/limits.h> // For PATH_MAX
|
#include <linux/limits.h> // For PATH_MAX
|
||||||
#include <stddef.h> // For NULL
|
#include <stddef.h> // For NULL
|
||||||
#include <stdio.h> // For asprintf
|
#include <stdio.h> // For asprintf
|
||||||
#include <stdlib.h> // For calloc
|
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
|
@ -853,7 +852,7 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder)
|
||||||
Exams->Num = (unsigned) NumRows;
|
Exams->Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list of exams *****/
|
/***** Create list of exams *****/
|
||||||
if ((Exams->Lst = (struct Exa_ExamSelected *) malloc (NumRows * sizeof (struct Exa_ExamSelected))) == NULL)
|
if ((Exams->Lst = malloc (NumRows * sizeof (*Exams->Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the exams codes *****/
|
/***** Get the exams codes *****/
|
||||||
|
@ -890,7 +889,7 @@ void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams)
|
||||||
|
|
||||||
/***** Allocate memory for list of exams selected *****/
|
/***** Allocate memory for list of exams selected *****/
|
||||||
MaxSizeListExaCodsSelected = Exams->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
MaxSizeListExaCodsSelected = Exams->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
||||||
if ((Exams->ExaCodsSelected = (char *) malloc (MaxSizeListExaCodsSelected + 1)) == NULL)
|
if ((Exams->ExaCodsSelected = malloc (MaxSizeListExaCodsSelected + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get parameter multiple with list of exams selected *****/
|
/***** Get parameter multiple with list of exams selected *****/
|
||||||
|
@ -994,8 +993,7 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam)
|
||||||
Exam->Visibility = TstVis_GetVisibilityFromStr (row[5]);
|
Exam->Visibility = TstVis_GetVisibilityFromStr (row[5]);
|
||||||
|
|
||||||
/* Get the title of the exam (row[6]) */
|
/* Get the title of the exam (row[6]) */
|
||||||
Str_Copy (Exam->Title,row[6],
|
Str_Copy (Exam->Title,row[6],sizeof (Exam->Title) - 1);
|
||||||
Exa_MAX_BYTES_TITLE);
|
|
||||||
|
|
||||||
/* Get number of sets */
|
/* Get number of sets */
|
||||||
Exam->NumSets = ExaSet_GetNumSetsExam (Exam->ExaCod);
|
Exam->NumSets = ExaSet_GetNumSetsExam (Exam->ExaCod);
|
||||||
|
@ -1083,8 +1081,7 @@ void Exa_GetExamTxtFromDB (long ExaCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
|
||||||
{
|
{
|
||||||
/* Get info text */
|
/* Get info text */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Txt,row[0],
|
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Txt[0] = '\0';
|
Txt[0] = '\0';
|
||||||
|
|
|
@ -192,7 +192,7 @@ static long ExaAnn_GetParamsExamAnn (struct ExaAnn_ExamAnnouncements *ExamAnns)
|
||||||
// If the parameter is not present or is empty, initialize the string to the full name of the current course
|
// If the parameter is not present or is empty, initialize the string to the full name of the current course
|
||||||
if (!ExamAnns->ExamAnn.CrsFullName[0])
|
if (!ExamAnns->ExamAnn.CrsFullName[0])
|
||||||
Str_Copy (ExamAnns->ExamAnn.CrsFullName,Gbl.Hierarchy.Crs.FullName,
|
Str_Copy (ExamAnns->ExamAnn.CrsFullName,Gbl.Hierarchy.Crs.FullName,
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
sizeof (ExamAnns->ExamAnn.CrsFullName) - 1);
|
||||||
|
|
||||||
/***** Get the year *****/
|
/***** Get the year *****/
|
||||||
ExamAnns->ExamAnn.Year = (unsigned)
|
ExamAnns->ExamAnn.Year = (unsigned)
|
||||||
|
@ -260,25 +260,25 @@ static long ExaAnn_GetParamsExamAnn (struct ExaAnn_ExamAnnouncements *ExamAnns)
|
||||||
|
|
||||||
static void ExaAnn_AllocMemExamAnn (struct ExaAnn_ExamAnnouncements *ExamAnns)
|
static void ExaAnn_AllocMemExamAnn (struct ExaAnn_ExamAnnouncements *ExamAnns)
|
||||||
{
|
{
|
||||||
if ((ExamAnns->ExamAnn.Place = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((ExamAnns->ExamAnn.Place = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
if ((ExamAnns->ExamAnn.Mode = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((ExamAnns->ExamAnn.Mode = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
if ((ExamAnns->ExamAnn.Structure = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((ExamAnns->ExamAnn.Structure = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
if ((ExamAnns->ExamAnn.DocRequired = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((ExamAnns->ExamAnn.DocRequired = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
if ((ExamAnns->ExamAnn.MatRequired = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((ExamAnns->ExamAnn.MatRequired = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
if ((ExamAnns->ExamAnn.MatAllowed = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((ExamAnns->ExamAnn.MatAllowed = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
if ((ExamAnns->ExamAnn.OtherInfo = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((ExamAnns->ExamAnn.OtherInfo = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -896,7 +896,7 @@ void ExaAnn_CreateListExamAnns (struct ExaAnn_ExamAnnouncements *ExamAnns)
|
||||||
if (NumExaAnns)
|
if (NumExaAnns)
|
||||||
{
|
{
|
||||||
/***** Allocate memory for the list *****/
|
/***** Allocate memory for the list *****/
|
||||||
if ((ExamAnns->Lst = (struct ExaAnn_ExamCodeAndDate *) calloc (NumExaAnns,sizeof (struct ExaAnn_ExamCodeAndDate))) == NULL)
|
if ((ExamAnns->Lst = calloc (NumExaAnns,sizeof (*ExamAnns->Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the dates of the existing exam announcements *****/
|
/***** Get the dates of the existing exam announcements *****/
|
||||||
|
@ -984,7 +984,7 @@ static void ExaAnn_GetDataExamAnnFromDB (struct ExaAnn_ExamAnnouncements *ExamAn
|
||||||
|
|
||||||
/* Name of the course (row[2]) */
|
/* Name of the course (row[2]) */
|
||||||
Str_Copy (ExamAnns->ExamAnn.CrsFullName,row[2],
|
Str_Copy (ExamAnns->ExamAnn.CrsFullName,row[2],
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
sizeof (ExamAnns->ExamAnn.CrsFullName) - 1);
|
||||||
|
|
||||||
/* Year (row[3]) */
|
/* Year (row[3]) */
|
||||||
if (sscanf (row[3],"%u",&ExamAnns->ExamAnn.Year) != 1)
|
if (sscanf (row[3],"%u",&ExamAnns->ExamAnn.Year) != 1)
|
||||||
|
@ -992,7 +992,7 @@ static void ExaAnn_GetDataExamAnnFromDB (struct ExaAnn_ExamAnnouncements *ExamAn
|
||||||
|
|
||||||
/* Exam session (row[4]) */
|
/* Exam session (row[4]) */
|
||||||
Str_Copy (ExamAnns->ExamAnn.Session,row[4],
|
Str_Copy (ExamAnns->ExamAnn.Session,row[4],
|
||||||
ExaAnn_MAX_BYTES_SESSION);
|
sizeof (ExamAnns->ExamAnn.Session) - 1);
|
||||||
|
|
||||||
/* Date of exam announcement (row[5]) */
|
/* Date of exam announcement (row[5]) */
|
||||||
if (sscanf (row[5],"%04u-%02u-%02u %02u:%02u:%02u",
|
if (sscanf (row[5],"%04u-%02u-%02u %02u:%02u:%02u",
|
||||||
|
@ -1013,8 +1013,8 @@ static void ExaAnn_GetDataExamAnnFromDB (struct ExaAnn_ExamAnnouncements *ExamAn
|
||||||
&ExamAnns->ExamAnn.StartTime.Minute,
|
&ExamAnns->ExamAnn.StartTime.Minute,
|
||||||
&Second) != 6)
|
&Second) != 6)
|
||||||
Lay_ShowErrorAndExit ("Wrong date of exam.");
|
Lay_ShowErrorAndExit ("Wrong date of exam.");
|
||||||
snprintf (ExamAnns->ExamAnn.ExamDate.YYYYMMDD,sizeof (ExamAnns->ExamAnn.ExamDate.YYYYMMDD),
|
snprintf (ExamAnns->ExamAnn.ExamDate.YYYYMMDD,
|
||||||
"%04u%02u%02u",
|
sizeof (ExamAnns->ExamAnn.ExamDate.YYYYMMDD),"%04u%02u%02u",
|
||||||
ExamAnns->ExamAnn.ExamDate.Year,
|
ExamAnns->ExamAnn.ExamDate.Year,
|
||||||
ExamAnns->ExamAnn.ExamDate.Month,
|
ExamAnns->ExamAnn.ExamDate.Month,
|
||||||
ExamAnns->ExamAnn.ExamDate.Day);
|
ExamAnns->ExamAnn.ExamDate.Day);
|
||||||
|
@ -1025,31 +1025,31 @@ static void ExaAnn_GetDataExamAnnFromDB (struct ExaAnn_ExamAnnouncements *ExamAn
|
||||||
|
|
||||||
/* Place (row[8]) */
|
/* Place (row[8]) */
|
||||||
Str_Copy (ExamAnns->ExamAnn.Place,row[8],
|
Str_Copy (ExamAnns->ExamAnn.Place,row[8],
|
||||||
Cns_MAX_BYTES_TEXT);
|
sizeof (ExamAnns->ExamAnn.Place) - 1);
|
||||||
|
|
||||||
/* Exam mode (row[9]) */
|
/* Exam mode (row[9]) */
|
||||||
Str_Copy (ExamAnns->ExamAnn.Mode,row[9],
|
Str_Copy (ExamAnns->ExamAnn.Mode,row[9],
|
||||||
Cns_MAX_BYTES_TEXT);
|
sizeof (ExamAnns->ExamAnn.Mode) - 1);
|
||||||
|
|
||||||
/* Structure (row[10]) */
|
/* Structure (row[10]) */
|
||||||
Str_Copy (ExamAnns->ExamAnn.Structure,row[10],
|
Str_Copy (ExamAnns->ExamAnn.Structure,row[10],
|
||||||
Cns_MAX_BYTES_TEXT);
|
sizeof (ExamAnns->ExamAnn.Structure) - 1);
|
||||||
|
|
||||||
/* Documentation required (row[11]) */
|
/* Documentation required (row[11]) */
|
||||||
Str_Copy (ExamAnns->ExamAnn.DocRequired,row[11],
|
Str_Copy (ExamAnns->ExamAnn.DocRequired,row[11],
|
||||||
Cns_MAX_BYTES_TEXT);
|
sizeof (ExamAnns->ExamAnn.DocRequired) - 1);
|
||||||
|
|
||||||
/* Material required (row[12]) */
|
/* Material required (row[12]) */
|
||||||
Str_Copy (ExamAnns->ExamAnn.MatRequired,row[12],
|
Str_Copy (ExamAnns->ExamAnn.MatRequired,row[12],
|
||||||
Cns_MAX_BYTES_TEXT);
|
sizeof (ExamAnns->ExamAnn.MatRequired) - 1);
|
||||||
|
|
||||||
/* Material allowed (row[13]) */
|
/* Material allowed (row[13]) */
|
||||||
Str_Copy (ExamAnns->ExamAnn.MatAllowed,row[13],
|
Str_Copy (ExamAnns->ExamAnn.MatAllowed,row[13],
|
||||||
Cns_MAX_BYTES_TEXT);
|
sizeof (ExamAnns->ExamAnn.MatAllowed) - 1);
|
||||||
|
|
||||||
/* Other information for students (row[14]) */
|
/* Other information for students (row[14]) */
|
||||||
Str_Copy (ExamAnns->ExamAnn.OtherInfo,row[14],
|
Str_Copy (ExamAnns->ExamAnn.OtherInfo,row[14],
|
||||||
Cns_MAX_BYTES_TEXT);
|
sizeof (ExamAnns->ExamAnn.OtherInfo) - 1);
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -1726,14 +1726,12 @@ void ExaAnn_GetSummaryAndContentExamAnn (char SummaryStr[Ntf_MAX_BYTES_SUMMARY +
|
||||||
/***** Summary *****/
|
/***** Summary *****/
|
||||||
/* Name of the course and date of exam */
|
/* Name of the course and date of exam */
|
||||||
Dat_ConvDateToDateStr (&ExamAnns.ExamAnn.ExamDate,StrExamDate);
|
Dat_ConvDateToDateStr (&ExamAnns.ExamAnn.ExamDate,StrExamDate);
|
||||||
snprintf (CrsNameAndDate,sizeof (CrsNameAndDate),
|
snprintf (CrsNameAndDate,sizeof (CrsNameAndDate),"%s, %s, %2u:%02u",
|
||||||
"%s, %s, %2u:%02u",
|
|
||||||
ExamAnns.ExamAnn.CrsFullName,
|
ExamAnns.ExamAnn.CrsFullName,
|
||||||
StrExamDate,
|
StrExamDate,
|
||||||
ExamAnns.ExamAnn.StartTime.Hour,
|
ExamAnns.ExamAnn.StartTime.Hour,
|
||||||
ExamAnns.ExamAnn.StartTime.Minute);
|
ExamAnns.ExamAnn.StartTime.Minute);
|
||||||
Str_Copy (SummaryStr,CrsNameAndDate,
|
Str_Copy (SummaryStr,CrsNameAndDate,Ntf_MAX_BYTES_SUMMARY);
|
||||||
Ntf_MAX_BYTES_SUMMARY);
|
|
||||||
|
|
||||||
/***** Free memory of the exam announcement *****/
|
/***** Free memory of the exam announcement *****/
|
||||||
ExaAnn_FreeMemExamAnn (&ExamAnns);
|
ExaAnn_FreeMemExamAnn (&ExamAnns);
|
||||||
|
|
|
@ -230,12 +230,11 @@ static void ExaLog_LogUsrAgent (long LogCod,long PrnCod)
|
||||||
MaxBytes = strlen (UserAgent) * Str_MAX_BYTES_PER_CHAR;
|
MaxBytes = strlen (UserAgent) * Str_MAX_BYTES_PER_CHAR;
|
||||||
else
|
else
|
||||||
MaxBytes = 0;
|
MaxBytes = 0;
|
||||||
if ((UserAgentDB = (char *) malloc (MaxBytes + 1)) == NULL)
|
if ((UserAgentDB = malloc (MaxBytes + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
if (UserAgent)
|
if (UserAgent)
|
||||||
{
|
{
|
||||||
Str_Copy (UserAgentDB,UserAgent,
|
Str_Copy (UserAgentDB,UserAgent,MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_TEXT,
|
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_TEXT,
|
||||||
UserAgentDB,MaxBytes,true);
|
UserAgentDB,MaxBytes,true);
|
||||||
}
|
}
|
||||||
|
@ -379,16 +378,12 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
|
||||||
ClickTimeUTC = Dat_GetUNIXTimeFromStr (row[3]);
|
ClickTimeUTC = Dat_GetUNIXTimeFromStr (row[3]);
|
||||||
|
|
||||||
/* Get IP (row[4]) */
|
/* Get IP (row[4]) */
|
||||||
Str_Copy (IP,row[4],
|
Str_Copy (IP,row[4],sizeof (IP) - 1);
|
||||||
Cns_MAX_BYTES_IP);
|
|
||||||
|
|
||||||
/* Get session id (row[5]) */
|
/* Get session id (row[5]) */
|
||||||
if (row[5]) // This row has a user agent stored in database
|
Str_Copy (SessionId,row[5] ? row[5] : // This row has a user agent stored in database
|
||||||
Str_Copy (SessionId,row[5],
|
"=",
|
||||||
Cns_BYTES_SESSION_ID);
|
sizeof (SessionId) - 1);
|
||||||
else
|
|
||||||
Str_Copy (SessionId,"=",
|
|
||||||
Cns_BYTES_SESSION_ID);
|
|
||||||
|
|
||||||
/* Get session id (row[6]) */
|
/* Get session id (row[6]) */
|
||||||
if (asprintf (&UserAgent,"%s",row[6] ? row[6] :
|
if (asprintf (&UserAgent,"%s",row[6] ? row[6] :
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <linux/limits.h> // For PATH_MAX
|
#include <linux/limits.h> // For PATH_MAX
|
||||||
#include <stddef.h> // For NULL
|
#include <stddef.h> // For NULL
|
||||||
#include <stdio.h> // For asprintf
|
#include <stdio.h> // For asprintf
|
||||||
#include <stdlib.h> // For calloc
|
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_box.h"
|
#include "swad_box.h"
|
||||||
|
@ -405,8 +404,7 @@ static void ExaPrn_GetQuestionsForNewPrintFromDB (struct ExaPrn_Print *Print,lon
|
||||||
Set.NumQstsToPrint = Str_ConvertStrToUnsigned (row[1]);
|
Set.NumQstsToPrint = Str_ConvertStrToUnsigned (row[1]);
|
||||||
|
|
||||||
/* Get the title of the set (row[2]) */
|
/* Get the title of the set (row[2]) */
|
||||||
Str_Copy (Set.Title,row[2],
|
Str_Copy (Set.Title,row[2],sizeof (Set.Title) - 1);
|
||||||
ExaSet_MAX_BYTES_TITLE);
|
|
||||||
|
|
||||||
/***** Questions in this set *****/
|
/***** Questions in this set *****/
|
||||||
NumQstsFromSet = ExaPrn_GetSomeQstsFromSetToPrint (Print,&Set,&NumQstInPrint);
|
NumQstsFromSet = ExaPrn_GetSomeQstsFromSetToPrint (Print,&Set,&NumQstInPrint);
|
||||||
|
@ -563,7 +561,7 @@ static void ExaPrn_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *Printed
|
||||||
else
|
else
|
||||||
snprintf (StrInd,sizeof (StrInd),",%u",Index);
|
snprintf (StrInd,sizeof (StrInd),",%u",Index);
|
||||||
Str_Concat (PrintedQuestion->StrIndexes,StrInd,
|
Str_Concat (PrintedQuestion->StrIndexes,StrInd,
|
||||||
Tst_MAX_BYTES_INDEXES_ONE_QST);
|
sizeof (PrintedQuestion->StrIndexes) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -648,11 +646,11 @@ void ExaPrn_GetPrintQuestionsFromDB (struct ExaPrn_Print *Print)
|
||||||
|
|
||||||
/* Get indexes for this question (row[3]) */
|
/* Get indexes for this question (row[3]) */
|
||||||
Str_Copy (Print->PrintedQuestions[NumQst].StrIndexes,row[3],
|
Str_Copy (Print->PrintedQuestions[NumQst].StrIndexes,row[3],
|
||||||
Tst_MAX_BYTES_INDEXES_ONE_QST);
|
strlen (Print->PrintedQuestions[NumQst].StrIndexes) - 1);
|
||||||
|
|
||||||
/* Get answers selected by user for this question (row[4]) */
|
/* Get answers selected by user for this question (row[4]) */
|
||||||
Str_Copy (Print->PrintedQuestions[NumQst].StrAnswers,row[4],
|
Str_Copy (Print->PrintedQuestions[NumQst].StrAnswers,row[4],
|
||||||
Tst_MAX_BYTES_ANSWERS_ONE_QST);
|
strlen (Print->PrintedQuestions[NumQst].StrAnswers) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -870,13 +868,10 @@ static void ExaPrn_WriteIntAnsToFill (const struct ExaPrn_Print *Print,
|
||||||
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||||
|
|
||||||
/***** Write input field for the answer *****/
|
/***** Write input field for the answer *****/
|
||||||
snprintf (Id,sizeof (Id),
|
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
|
||||||
"Ans%010u",
|
|
||||||
NumQst);
|
|
||||||
HTM_TxtF ("<input type=\"text\" id=\"%s\" name=\"Ans\""
|
HTM_TxtF ("<input type=\"text\" id=\"%s\" name=\"Ans\""
|
||||||
" size=\"11\" maxlength=\"11\" value=\"%s\"",
|
" size=\"11\" maxlength=\"11\" value=\"%s\"",
|
||||||
Id,
|
Id,Print->PrintedQuestions[NumQst].StrAnswers);
|
||||||
Print->PrintedQuestions[NumQst].StrAnswers);
|
|
||||||
ExaPrn_WriteJSToUpdateExamPrint (Print,NumQst,Id,-1);
|
ExaPrn_WriteJSToUpdateExamPrint (Print,NumQst,Id,-1);
|
||||||
HTM_Txt (" />");
|
HTM_Txt (" />");
|
||||||
}
|
}
|
||||||
|
@ -892,9 +887,7 @@ static void ExaPrn_WriteFltAnsToFill (const struct ExaPrn_Print *Print,
|
||||||
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||||
|
|
||||||
/***** Write input field for the answer *****/
|
/***** Write input field for the answer *****/
|
||||||
snprintf (Id,sizeof (Id),
|
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
|
||||||
"Ans%010u",
|
|
||||||
NumQst);
|
|
||||||
HTM_TxtF ("<input type=\"text\" id=\"%s\" name=\"Ans\""
|
HTM_TxtF ("<input type=\"text\" id=\"%s\" name=\"Ans\""
|
||||||
" size=\"11\" maxlength=\"%u\" value=\"%s\"",
|
" size=\"11\" maxlength=\"%u\" value=\"%s\"",
|
||||||
Id,Tst_MAX_BYTES_FLOAT_ANSWER,
|
Id,Tst_MAX_BYTES_FLOAT_ANSWER,
|
||||||
|
@ -918,9 +911,7 @@ static void ExaPrn_WriteTF_AnsToFill (const struct ExaPrn_Print *Print,
|
||||||
/* Initially user has not answered the question ==> initially all the answers will be blank.
|
/* Initially user has not answered the question ==> initially all the answers will be blank.
|
||||||
If the user does not confirm the submission of their exam ==>
|
If the user does not confirm the submission of their exam ==>
|
||||||
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
|
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
|
||||||
snprintf (Id,sizeof (Id),
|
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
|
||||||
"Ans%010u",
|
|
||||||
NumQst);
|
|
||||||
HTM_TxtF ("<select id=\"%s\" name=\"Ans\"",Id);
|
HTM_TxtF ("<select id=\"%s\" name=\"Ans\"",Id);
|
||||||
ExaPrn_WriteJSToUpdateExamPrint (Print,NumQst,Id,-1);
|
ExaPrn_WriteJSToUpdateExamPrint (Print,NumQst,Id,-1);
|
||||||
HTM_Txt (" />");
|
HTM_Txt (" />");
|
||||||
|
@ -968,9 +959,7 @@ static void ExaPrn_WriteChoAnsToFill (const struct ExaPrn_Print *Print,
|
||||||
If the user does not confirm the submission of their exam ==>
|
If the user does not confirm the submission of their exam ==>
|
||||||
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
|
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
|
||||||
HTM_TD_Begin ("class=\"LT\"");
|
HTM_TD_Begin ("class=\"LT\"");
|
||||||
snprintf (Id,sizeof (Id),
|
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
|
||||||
"Ans%010u",
|
|
||||||
NumQst);
|
|
||||||
HTM_TxtF ("<input type=\"%s\" id=\"%s_%u\" name=\"Ans\" value=\"%u\"%s",
|
HTM_TxtF ("<input type=\"%s\" id=\"%s_%u\" name=\"Ans\" value=\"%u\"%s",
|
||||||
Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE ? "radio" :
|
Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE ? "radio" :
|
||||||
"checkbox",
|
"checkbox",
|
||||||
|
@ -1015,9 +1004,7 @@ static void ExaPrn_WriteTxtAnsToFill (const struct ExaPrn_Print *Print,
|
||||||
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||||
|
|
||||||
/***** Write input field for the answer *****/
|
/***** Write input field for the answer *****/
|
||||||
snprintf (Id,sizeof (Id),
|
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
|
||||||
"Ans%010u",
|
|
||||||
NumQst);
|
|
||||||
HTM_TxtF ("<input type=\"text\" id=\"%s\" name=\"Ans\""
|
HTM_TxtF ("<input type=\"text\" id=\"%s\" name=\"Ans\""
|
||||||
" size=\"40\" maxlength=\"%u\" value=\"%s\"",
|
" size=\"40\" maxlength=\"%u\" value=\"%s\"",
|
||||||
Id,Tst_MAX_CHARS_ANSWERS_ONE_QST,
|
Id,Tst_MAX_CHARS_ANSWERS_ONE_QST,
|
||||||
|
@ -1427,7 +1414,7 @@ static void ExaPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question)
|
||||||
|
|
||||||
/***** Copy answer text (row[0]) ******/
|
/***** Copy answer text (row[0]) ******/
|
||||||
Str_Copy (Question->Answer.Options[NumOpt].Text,row[0],
|
Str_Copy (Question->Answer.Options[NumOpt].Text,row[0],
|
||||||
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
|
strlen (Question->Answer.Options[NumOpt].Text) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Change format of answers text *****/
|
/***** Change format of answers text *****/
|
||||||
|
@ -1457,8 +1444,7 @@ static void ExaPrn_GetAnswerFromDB (struct ExaPrn_Print *Print,long QstCod,
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get answers selected by user for this question (row[0]) */
|
/* Get answers selected by user for this question (row[0]) */
|
||||||
Str_Copy (StrAnswers,row[0],
|
Str_Copy (StrAnswers,row[0],strlen (StrAnswers) - 1);
|
||||||
Tst_MAX_BYTES_ANSWERS_ONE_QST);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
StrAnswers[0] = '\0';
|
StrAnswers[0] = '\0';
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <linux/limits.h> // For PATH_MAX
|
#include <linux/limits.h> // For PATH_MAX
|
||||||
#include <stddef.h> // For NULL
|
#include <stddef.h> // For NULL
|
||||||
#include <stdio.h> // For asprintf
|
#include <stdio.h> // For asprintf
|
||||||
#include <stdlib.h> // For calloc
|
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_action.h"
|
#include "swad_action.h"
|
||||||
|
@ -371,7 +370,7 @@ static void ExaRes_ListAllResultsInSelectedExams (struct Exa_Exams *Exams)
|
||||||
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
||||||
|
@ -782,7 +781,7 @@ static void ExaRes_BuildExamsSelectedCommas (struct Exa_Exams *Exams,
|
||||||
|
|
||||||
/***** Allocate memory for subquery of exams selected *****/
|
/***** Allocate memory for subquery of exams selected *****/
|
||||||
MaxLength = (size_t) Exams->NumSelected * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
MaxLength = (size_t) Exams->NumSelected * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
||||||
if ((*ExamsSelectedCommas = (char *) malloc (MaxLength + 1)) == NULL)
|
if ((*ExamsSelectedCommas = malloc (MaxLength + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Build subquery with list of selected exams *****/
|
/***** Build subquery with list of selected exams *****/
|
||||||
|
@ -1164,7 +1163,7 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
|
||||||
case Usr_OTHER:
|
case Usr_OTHER:
|
||||||
Frm_StartForm (ActSeeOneExaResOth);
|
Frm_StartForm (ActSeeOneExaResOth);
|
||||||
ExaSes_PutParamsEdit (Exams);
|
ExaSes_PutParamsEdit (Exams);
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Ico_PutIconLink ("tasks.svg",Txt_Result);
|
Ico_PutIconLink ("tasks.svg",Txt_Result);
|
||||||
|
@ -1650,8 +1649,8 @@ void ExaRes_ShowExamResultUser (struct UsrData *UsrDat)
|
||||||
HTM_TxtF (" %s",UsrDat->Surname1);
|
HTM_TxtF (" %s",UsrDat->Surname1);
|
||||||
if (UsrDat->Surname2[0])
|
if (UsrDat->Surname2[0])
|
||||||
HTM_TxtF (" %s",UsrDat->Surname2);
|
HTM_TxtF (" %s",UsrDat->Surname2);
|
||||||
if (UsrDat->FirstName[0])
|
if (UsrDat->FrstName[0])
|
||||||
HTM_TxtF (", %s",UsrDat->FirstName);
|
HTM_TxtF (", %s",UsrDat->FrstName);
|
||||||
HTM_BR ();
|
HTM_BR ();
|
||||||
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
|
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
|
||||||
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
|
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <linux/limits.h> // For PATH_MAX
|
#include <linux/limits.h> // For PATH_MAX
|
||||||
#include <stddef.h> // For NULL
|
#include <stddef.h> // For NULL
|
||||||
#include <stdio.h> // For asprintf
|
#include <stdio.h> // For asprintf
|
||||||
#include <stdlib.h> // For calloc
|
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
|
@ -268,8 +267,7 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams,
|
||||||
Session->ExaCod = Exam->ExaCod;
|
Session->ExaCod = Exam->ExaCod;
|
||||||
Session->TimeUTC[Dat_START_TIME] = Gbl.StartExecutionTimeUTC; // Now
|
Session->TimeUTC[Dat_START_TIME] = Gbl.StartExecutionTimeUTC; // Now
|
||||||
Session->TimeUTC[Dat_END_TIME ] = Gbl.StartExecutionTimeUTC + (1 * 60 * 60); // Now + 1 hour
|
Session->TimeUTC[Dat_END_TIME ] = Gbl.StartExecutionTimeUTC + (1 * 60 * 60); // Now + 1 hour
|
||||||
Str_Copy (Session->Title,Exam->Title,
|
Str_Copy (Session->Title,Exam->Title,sizeof (Session->Title) - 1);
|
||||||
ExaSes_MAX_BYTES_TITLE);
|
|
||||||
|
|
||||||
/* Put form to create new session */
|
/* Put form to create new session */
|
||||||
ExaSes_PutFormSession (Session); // Form to create session
|
ExaSes_PutFormSession (Session); // Form to create session
|
||||||
|
@ -890,8 +888,7 @@ static void ExaSes_GetSessionDataFromRow (MYSQL_RES *mysql_res,
|
||||||
|
|
||||||
/* Get the title of the session (row[7]) */
|
/* Get the title of the session (row[7]) */
|
||||||
if (row[7])
|
if (row[7])
|
||||||
Str_Copy (Session->Title,row[7],
|
Str_Copy (Session->Title,row[7],sizeof (Session->Title) - 1);
|
||||||
ExaSes_MAX_BYTES_TITLE);
|
|
||||||
else
|
else
|
||||||
Session->Title[0] = '\0';
|
Session->Title[0] = '\0';
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include <linux/limits.h> // For PATH_MAX
|
#include <linux/limits.h> // For PATH_MAX
|
||||||
#include <stddef.h> // For NULL
|
#include <stddef.h> // For NULL
|
||||||
#include <stdio.h> // For asprintf
|
#include <stdio.h> // For asprintf
|
||||||
#include <stdlib.h> // For calloc
|
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
|
@ -242,16 +241,13 @@ void ExaSet_GetDataOfSetByCod (struct ExaSet_Set *Set)
|
||||||
|
|
||||||
/* Get set index (row[2]) */
|
/* Get set index (row[2]) */
|
||||||
Set->SetInd = Str_ConvertStrToUnsigned (row[2]);
|
Set->SetInd = Str_ConvertStrToUnsigned (row[2]);
|
||||||
snprintf (StrSetInd,sizeof (Set->SetInd),
|
snprintf (StrSetInd,sizeof (Set->SetInd),"%u",Set->SetInd);
|
||||||
"%u",
|
|
||||||
Set->SetInd);
|
|
||||||
|
|
||||||
/* Get set index (row[3]) */
|
/* Get set index (row[3]) */
|
||||||
Set->NumQstsToPrint = Str_ConvertStrToUnsigned (row[3]);
|
Set->NumQstsToPrint = Str_ConvertStrToUnsigned (row[3]);
|
||||||
|
|
||||||
/* Get the title of the set (row[4]) */
|
/* Get the title of the set (row[4]) */
|
||||||
Str_Copy (Set->Title,row[4],
|
Str_Copy (Set->Title,row[4],sizeof (Set->Title) - 1);
|
||||||
ExaSet_MAX_BYTES_TITLE);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* Initialize to empty set */
|
/* Initialize to empty set */
|
||||||
|
@ -477,8 +473,7 @@ void ExaSet_ChangeSetTitle (void)
|
||||||
ExaSet_UpdateSetTitleDB (&Set,NewTitle);
|
ExaSet_UpdateSetTitleDB (&Set,NewTitle);
|
||||||
|
|
||||||
/* Update title */
|
/* Update title */
|
||||||
Str_Copy (Set.Title,NewTitle,
|
Str_Copy (Set.Title,NewTitle,sizeof (Set.Title) - 1);
|
||||||
ExaSet_MAX_BYTES_TITLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Show current exam and its sets *****/
|
/***** Show current exam and its sets *****/
|
||||||
|
@ -1085,16 +1080,13 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
|
||||||
|
|
||||||
/* Get set index (row[1]) */
|
/* Get set index (row[1]) */
|
||||||
Set.SetInd = Str_ConvertStrToUnsigned (row[1]);
|
Set.SetInd = Str_ConvertStrToUnsigned (row[1]);
|
||||||
snprintf (StrSetInd,sizeof (Set.SetInd),
|
snprintf (StrSetInd,sizeof (Set.SetInd),"%u",Set.SetInd);
|
||||||
"%u",
|
|
||||||
Set.SetInd);
|
|
||||||
|
|
||||||
/* Get number of questions to exam (row[2]) */
|
/* Get number of questions to exam (row[2]) */
|
||||||
Set.NumQstsToPrint = Str_ConvertStrToUnsigned (row[2]);
|
Set.NumQstsToPrint = Str_ConvertStrToUnsigned (row[2]);
|
||||||
|
|
||||||
/* Get the title of the set (row[3]) */
|
/* Get the title of the set (row[3]) */
|
||||||
Str_Copy (Set.Title,row[3],
|
Str_Copy (Set.Title,row[3],sizeof (Set.Title) - 1);
|
||||||
ExaSet_MAX_BYTES_TITLE);
|
|
||||||
|
|
||||||
/* Initialize context */
|
/* Initialize context */
|
||||||
Exams->SetCod = Set.SetCod;
|
Exams->SetCod = Set.SetCod;
|
||||||
|
@ -1433,15 +1425,13 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question)
|
||||||
Question->Stem[0] = '\0';
|
Question->Stem[0] = '\0';
|
||||||
if (row[3])
|
if (row[3])
|
||||||
if (row[3][0])
|
if (row[3][0])
|
||||||
Str_Copy (Question->Stem,row[3],
|
Str_Copy (Question->Stem,row[3],sizeof (Question->Stem) - 1);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
|
|
||||||
/* Get the feedback (row[4]) */
|
/* Get the feedback (row[4]) */
|
||||||
Question->Feedback[0] = '\0';
|
Question->Feedback[0] = '\0';
|
||||||
if (row[4])
|
if (row[4])
|
||||||
if (row[4][0])
|
if (row[4][0])
|
||||||
Str_Copy (Question->Feedback,row[4],
|
Str_Copy (Question->Feedback,row[4],sizeof (Question->Feedback) - 1);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
|
|
||||||
/* Get media (row[5]) */
|
/* Get media (row[5]) */
|
||||||
Question->Media.MedCod = Str_ConvertStrCodToLongCod (row[5]);
|
Question->Media.MedCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||||
|
@ -1497,14 +1487,14 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question)
|
||||||
if (row[1])
|
if (row[1])
|
||||||
if (row[1][0])
|
if (row[1][0])
|
||||||
Str_Copy (Question->Answer.Options[NumOpt].Text,row[1],
|
Str_Copy (Question->Answer.Options[NumOpt].Text,row[1],
|
||||||
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
|
sizeof (Question->Answer.Options[NumOpt].Text) - 1);
|
||||||
|
|
||||||
/* Get feedback (row[2]) */
|
/* Get feedback (row[2]) */
|
||||||
Question->Answer.Options[NumOpt].Feedback[0] = '\0';
|
Question->Answer.Options[NumOpt].Feedback[0] = '\0';
|
||||||
if (row[2])
|
if (row[2])
|
||||||
if (row[2][0])
|
if (row[2][0])
|
||||||
Str_Copy (Question->Answer.Options[NumOpt].Feedback,row[2],
|
Str_Copy (Question->Answer.Options[NumOpt].Feedback,row[2],
|
||||||
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
|
sizeof (Question->Answer.Options[NumOpt].Feedback) - 1);
|
||||||
|
|
||||||
/* Get media (row[3]) */
|
/* Get media (row[3]) */
|
||||||
Question->Answer.Options[NumOpt].Media.MedCod = Str_ConvertStrCodToLongCod (row[3]);
|
Question->Answer.Options[NumOpt].Media.MedCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||||
|
@ -1679,7 +1669,7 @@ static void ExaSet_AllocateListSelectedQuestions (struct Exa_Exams *Exams)
|
||||||
{
|
{
|
||||||
if (!Exams->ListQuestions)
|
if (!Exams->ListQuestions)
|
||||||
{
|
{
|
||||||
if ((Exams->ListQuestions = (char *) malloc (ExaSet_MAX_BYTES_LIST_SELECTED_QUESTIONS + 1)) == NULL)
|
if ((Exams->ListQuestions = malloc (ExaSet_MAX_BYTES_LIST_SELECTED_QUESTIONS + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
Exams->ListQuestions[0] = '\0';
|
Exams->ListQuestions[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
|
@ -2584,27 +2584,21 @@ static void Fig_WriteRowStatsFileBrowsers1 (const char *NameOfFileZones,
|
||||||
Fil_WriteFileSizeFull ((double) SizeOfFileZones->Size,FileSizeStr);
|
Fil_WriteFileSizeFull ((double) SizeOfFileZones->Size,FileSizeStr);
|
||||||
|
|
||||||
if (SizeOfFileZones->NumCrss == -1) // Not applicable
|
if (SizeOfFileZones->NumCrss == -1) // Not applicable
|
||||||
Str_Copy (StrNumCrss,"-",
|
Str_Copy (StrNumCrss,"-",sizeof (StrNumCrss) - 1);
|
||||||
Cns_MAX_DECIMAL_DIGITS_UINT);
|
|
||||||
else
|
else
|
||||||
snprintf (StrNumCrss,sizeof (StrNumCrss),
|
snprintf (StrNumCrss,sizeof (StrNumCrss),"%d",
|
||||||
"%d",
|
|
||||||
SizeOfFileZones->NumCrss);
|
SizeOfFileZones->NumCrss);
|
||||||
|
|
||||||
if (SizeOfFileZones->NumGrps == -1) // Not applicable
|
if (SizeOfFileZones->NumGrps == -1) // Not applicable
|
||||||
Str_Copy (StrNumGrps,"-",
|
Str_Copy (StrNumGrps,"-",sizeof (StrNumGrps) - 1);
|
||||||
Cns_MAX_DECIMAL_DIGITS_UINT);
|
|
||||||
else
|
else
|
||||||
snprintf (StrNumGrps,sizeof (StrNumGrps),
|
snprintf (StrNumGrps,sizeof (StrNumGrps),"%d",
|
||||||
"%d",
|
|
||||||
SizeOfFileZones->NumGrps);
|
SizeOfFileZones->NumGrps);
|
||||||
|
|
||||||
if (SizeOfFileZones->NumUsrs == -1) // Not applicable
|
if (SizeOfFileZones->NumUsrs == -1) // Not applicable
|
||||||
Str_Copy (StrNumUsrs,"-",
|
Str_Copy (StrNumUsrs,"-",sizeof (StrNumUsrs) - 1);
|
||||||
Cns_MAX_DECIMAL_DIGITS_UINT);
|
|
||||||
else
|
else
|
||||||
snprintf (StrNumUsrs,sizeof (StrNumUsrs),
|
snprintf (StrNumUsrs,sizeof (StrNumUsrs),"%d",
|
||||||
"%d",
|
|
||||||
SizeOfFileZones->NumUsrs);
|
SizeOfFileZones->NumUsrs);
|
||||||
|
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
@ -2656,22 +2650,17 @@ static void Fig_WriteRowStatsFileBrowsers2 (const char *NameOfFileZones,
|
||||||
|
|
||||||
if (SizeOfFileZones->NumCrss == -1) // Not applicable
|
if (SizeOfFileZones->NumCrss == -1) // Not applicable
|
||||||
{
|
{
|
||||||
Str_Copy (StrNumFoldersPerCrs,"-",
|
Str_Copy (StrNumFoldersPerCrs,"-",sizeof (StrNumFoldersPerCrs) - 1);
|
||||||
Cns_MAX_DECIMAL_DIGITS_UINT);
|
Str_Copy (StrNumFilesPerCrs ,"-",sizeof (StrNumFilesPerCrs ) - 1);
|
||||||
Str_Copy (StrNumFilesPerCrs,"-",
|
Str_Copy (FileSizePerCrsStr ,"-",sizeof (FileSizePerCrsStr ) - 1);
|
||||||
Cns_MAX_DECIMAL_DIGITS_UINT);
|
|
||||||
Str_Copy (FileSizePerCrsStr,"-",
|
|
||||||
Fil_MAX_BYTES_FILE_SIZE_STRING);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf (StrNumFoldersPerCrs,sizeof (StrNumFoldersPerCrs),
|
snprintf (StrNumFoldersPerCrs,sizeof (StrNumFoldersPerCrs),"%.1f",
|
||||||
"%.1f",
|
|
||||||
SizeOfFileZones->NumCrss ? (double) SizeOfFileZones->NumFolders /
|
SizeOfFileZones->NumCrss ? (double) SizeOfFileZones->NumFolders /
|
||||||
(double) SizeOfFileZones->NumCrss :
|
(double) SizeOfFileZones->NumCrss :
|
||||||
0.0);
|
0.0);
|
||||||
snprintf (StrNumFilesPerCrs,sizeof (StrNumFilesPerCrs),
|
snprintf (StrNumFilesPerCrs,sizeof (StrNumFilesPerCrs),"%.1f",
|
||||||
"%.1f",
|
|
||||||
SizeOfFileZones->NumCrss ? (double) SizeOfFileZones->NumFiles /
|
SizeOfFileZones->NumCrss ? (double) SizeOfFileZones->NumFiles /
|
||||||
(double) SizeOfFileZones->NumCrss :
|
(double) SizeOfFileZones->NumCrss :
|
||||||
0.0);
|
0.0);
|
||||||
|
@ -2714,22 +2703,17 @@ static void Fig_WriteRowStatsFileBrowsers3 (const char *NameOfFileZones,
|
||||||
|
|
||||||
if (SizeOfFileZones->NumUsrs == -1) // Not applicable
|
if (SizeOfFileZones->NumUsrs == -1) // Not applicable
|
||||||
{
|
{
|
||||||
Str_Copy (StrNumFoldersPerUsr,"-",
|
Str_Copy (StrNumFoldersPerUsr,"-",sizeof (StrNumFoldersPerUsr) - 1);
|
||||||
Cns_MAX_DECIMAL_DIGITS_UINT);
|
Str_Copy (StrNumFilesPerUsr ,"-",sizeof (StrNumFilesPerUsr ) - 1);
|
||||||
Str_Copy (StrNumFilesPerUsr,"-",
|
Str_Copy (FileSizePerUsrStr ,"-",sizeof (FileSizePerUsrStr ) - 1);
|
||||||
Cns_MAX_DECIMAL_DIGITS_UINT);
|
|
||||||
Str_Copy (FileSizePerUsrStr,"-",
|
|
||||||
Fil_MAX_BYTES_FILE_SIZE_STRING);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf (StrNumFoldersPerUsr,sizeof (StrNumFoldersPerUsr),
|
snprintf (StrNumFoldersPerUsr,sizeof (StrNumFoldersPerUsr),"%.1f",
|
||||||
"%.1f",
|
|
||||||
SizeOfFileZones->NumUsrs ? (double) SizeOfFileZones->NumFolders /
|
SizeOfFileZones->NumUsrs ? (double) SizeOfFileZones->NumFolders /
|
||||||
(double) SizeOfFileZones->NumUsrs :
|
(double) SizeOfFileZones->NumUsrs :
|
||||||
0.0);
|
0.0);
|
||||||
snprintf (StrNumFilesPerUsr,sizeof (StrNumFilesPerUsr),
|
snprintf (StrNumFilesPerUsr,sizeof (StrNumFilesPerUsr),"%.1f",
|
||||||
"%.1f",
|
|
||||||
SizeOfFileZones->NumUsrs ? (double) SizeOfFileZones->NumFiles /
|
SizeOfFileZones->NumUsrs ? (double) SizeOfFileZones->NumFiles /
|
||||||
(double) SizeOfFileZones->NumUsrs :
|
(double) SizeOfFileZones->NumUsrs :
|
||||||
0.0);
|
0.0);
|
||||||
|
|
58
swad_file.c
58
swad_file.c
|
@ -78,8 +78,7 @@ void Fil_CreateFileForHTMLOutput (void)
|
||||||
|
|
||||||
/***** Create a unique name for the file *****/
|
/***** Create a unique name for the file *****/
|
||||||
snprintf (Gbl.HTMLOutput.FileName,sizeof (Gbl.HTMLOutput.FileName),
|
snprintf (Gbl.HTMLOutput.FileName,sizeof (Gbl.HTMLOutput.FileName),
|
||||||
"%s/%s.html",
|
"%s/%s.html",Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
||||||
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
|
||||||
|
|
||||||
/***** Open file for writing and reading *****/
|
/***** Open file for writing and reading *****/
|
||||||
if ((Gbl.F.Out = fopen (Gbl.HTMLOutput.FileName,"w+t")) == NULL)
|
if ((Gbl.F.Out = fopen (Gbl.HTMLOutput.FileName,"w+t")) == NULL)
|
||||||
|
@ -322,14 +321,10 @@ void Fil_CreateUpdateFile (const char CurrentName[PATH_MAX + 1],
|
||||||
size_t LengthFileRoot = Str_GetLengthRootFileName (CurrentName);
|
size_t LengthFileRoot = Str_GetLengthRootFileName (CurrentName);
|
||||||
char ErrorMsg[128 + PATH_MAX];
|
char ErrorMsg[128 + PATH_MAX];
|
||||||
|
|
||||||
Str_Copy (NewName,CurrentName,
|
Str_Copy (NewName,CurrentName,PATH_MAX);
|
||||||
PATH_MAX);
|
|
||||||
NewName[LengthFileRoot] = '\0';
|
NewName[LengthFileRoot] = '\0';
|
||||||
snprintf (OldName,PATH_MAX + 1,
|
snprintf (OldName,PATH_MAX + 1,"%s%s",NewName,ExtensionOldName);
|
||||||
"%s%s",
|
Str_Concat (NewName,".new",PATH_MAX);
|
||||||
NewName,ExtensionOldName);
|
|
||||||
Str_Concat (NewName,".new",
|
|
||||||
PATH_MAX);
|
|
||||||
|
|
||||||
/* The new file shouldn't exist. If it exists is due to any error when running this CGI formerly
|
/* The new file shouldn't exist. If it exists is due to any error when running this CGI formerly
|
||||||
and the file was not renamed successfully. In this case, remove it! */
|
and the file was not renamed successfully. In this case, remove it! */
|
||||||
|
@ -340,8 +335,7 @@ void Fil_CreateUpdateFile (const char CurrentName[PATH_MAX + 1],
|
||||||
if ((*NewFile = fopen (NewName,"wb")) == NULL)
|
if ((*NewFile = fopen (NewName,"wb")) == NULL)
|
||||||
{
|
{
|
||||||
snprintf (ErrorMsg,sizeof (ErrorMsg),
|
snprintf (ErrorMsg,sizeof (ErrorMsg),
|
||||||
"Can not create file <strong>%s</strong>.",
|
"Can not create file <strong>%s</strong>.",NewName);
|
||||||
NewName);
|
|
||||||
Lay_ShowErrorAndExit (ErrorMsg);
|
Lay_ShowErrorAndExit (ErrorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,8 +396,7 @@ void Fil_CreateDirIfNotExists (const char Path[PATH_MAX + 1])
|
||||||
if (mkdir (Path,(mode_t) 0xFFF) != 0)
|
if (mkdir (Path,(mode_t) 0xFFF) != 0)
|
||||||
{
|
{
|
||||||
snprintf (ErrorMsg,sizeof (ErrorMsg),
|
snprintf (ErrorMsg,sizeof (ErrorMsg),
|
||||||
"Can not create folder <strong>%s</strong>.",
|
"Can not create folder <strong>%s</strong>.",Path);
|
||||||
Path);
|
|
||||||
Lay_ShowErrorAndExit (ErrorMsg);
|
Lay_ShowErrorAndExit (ErrorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -445,8 +438,7 @@ void Fil_RemoveTree (const char Path[PATH_MAX + 1])
|
||||||
if (strcmp (FileList[NumFile]->d_name,".") &&
|
if (strcmp (FileList[NumFile]->d_name,".") &&
|
||||||
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
||||||
{
|
{
|
||||||
snprintf (PathFileRel,sizeof (PathFileRel),
|
snprintf (PathFileRel,sizeof (PathFileRel),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
Path,FileList[NumFile]->d_name);
|
Path,FileList[NumFile]->d_name);
|
||||||
Fil_RemoveTree (PathFileRel);
|
Fil_RemoveTree (PathFileRel);
|
||||||
}
|
}
|
||||||
|
@ -466,8 +458,7 @@ void Fil_RemoveTree (const char Path[PATH_MAX + 1])
|
||||||
if (Error)
|
if (Error)
|
||||||
{
|
{
|
||||||
snprintf (ErrorMsg,sizeof (ErrorMsg),
|
snprintf (ErrorMsg,sizeof (ErrorMsg),
|
||||||
"Can not remove folder %s.",
|
"Can not remove folder %s.",Path);
|
||||||
Path);
|
|
||||||
Lay_ShowErrorAndExit (ErrorMsg);
|
Lay_ShowErrorAndExit (ErrorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -511,8 +502,7 @@ void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,
|
||||||
if (strcmp (FileList[NumFile]->d_name,".") &&
|
if (strcmp (FileList[NumFile]->d_name,".") &&
|
||||||
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
||||||
{
|
{
|
||||||
snprintf (Path2,sizeof (Path2),
|
snprintf (Path2,sizeof (Path2),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
Path,FileList[NumFile]->d_name);
|
Path,FileList[NumFile]->d_name);
|
||||||
Fil_RemoveOldTmpFiles (Path2,TimeToRemove,true); // Recursive call
|
Fil_RemoveOldTmpFiles (Path2,TimeToRemove,true); // Recursive call
|
||||||
}
|
}
|
||||||
|
@ -611,24 +601,19 @@ void Fil_WriteFileSizeBrief (double SizeInBytes,
|
||||||
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1])
|
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1])
|
||||||
{
|
{
|
||||||
if (SizeInBytes < Ki)
|
if (SizeInBytes < Ki)
|
||||||
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
|
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.0f B",
|
||||||
"%.0f B",
|
|
||||||
SizeInBytes);
|
SizeInBytes);
|
||||||
else if (SizeInBytes < Mi)
|
else if (SizeInBytes < Mi)
|
||||||
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
|
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.0f KiB",
|
||||||
"%.0f KiB",
|
|
||||||
SizeInBytes / Ki);
|
SizeInBytes / Ki);
|
||||||
else if (SizeInBytes < Gi)
|
else if (SizeInBytes < Gi)
|
||||||
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
|
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.0f MiB",
|
||||||
"%.0f MiB",
|
|
||||||
SizeInBytes / Mi);
|
SizeInBytes / Mi);
|
||||||
else if (SizeInBytes < Ti)
|
else if (SizeInBytes < Ti)
|
||||||
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
|
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.0f GiB",
|
||||||
"%.0f GiB",
|
|
||||||
SizeInBytes / Gi);
|
SizeInBytes / Gi);
|
||||||
else
|
else
|
||||||
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
|
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.0f TiB",
|
||||||
"%.0f TiB",
|
|
||||||
SizeInBytes / Ti);
|
SizeInBytes / Ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,23 +621,18 @@ void Fil_WriteFileSizeFull (double SizeInBytes,
|
||||||
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1])
|
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1])
|
||||||
{
|
{
|
||||||
if (SizeInBytes < Ki)
|
if (SizeInBytes < Ki)
|
||||||
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
|
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.0f B",
|
||||||
"%.0f B",
|
|
||||||
SizeInBytes);
|
SizeInBytes);
|
||||||
else if (SizeInBytes < Mi)
|
else if (SizeInBytes < Mi)
|
||||||
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
|
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.1f KiB",
|
||||||
"%.1f KiB",
|
|
||||||
SizeInBytes / Ki);
|
SizeInBytes / Ki);
|
||||||
else if (SizeInBytes < Gi)
|
else if (SizeInBytes < Gi)
|
||||||
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
|
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.1f MiB",
|
||||||
"%.1f MiB",
|
|
||||||
SizeInBytes / Mi);
|
SizeInBytes / Mi);
|
||||||
else if (SizeInBytes < Ti)
|
else if (SizeInBytes < Ti)
|
||||||
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
|
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.1f GiB",
|
||||||
"%.1f GiB",
|
|
||||||
SizeInBytes / Gi);
|
SizeInBytes / Gi);
|
||||||
else
|
else
|
||||||
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
|
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.1f TiB",
|
||||||
"%.1f TiB",
|
|
||||||
SizeInBytes / Ti);
|
SizeInBytes / Ti);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -557,7 +557,7 @@ void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat,
|
||||||
{
|
{
|
||||||
Frm_StartForm (IFollowUsr ? ActUnfUsr :
|
Frm_StartForm (IFollowUsr ? ActUnfUsr :
|
||||||
ActFolUsr);
|
ActFolUsr);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,
|
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,
|
||||||
IFollowUsr ? "user-check.svg" :
|
IFollowUsr ? "user-check.svg" :
|
||||||
"user-plus.svg",
|
"user-plus.svg",
|
||||||
|
@ -598,7 +598,7 @@ static void Fol_ShowNumberOfFollowingOrFollowers (const struct UsrData *UsrDat,
|
||||||
{
|
{
|
||||||
/* Form to list users */
|
/* Form to list users */
|
||||||
Frm_StartFormAnchor (Action,Fol_FOLLOW_SECTION_ID);
|
Frm_StartFormAnchor (Action,Fol_FOLLOW_SECTION_ID);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
HTM_BUTTON_SUBMIT_Begin (Title,
|
HTM_BUTTON_SUBMIT_Begin (Title,
|
||||||
(Gbl.Action.Act == Action) ? "BT_LINK FOLLOW_NUM_B" :
|
(Gbl.Action.Act == Action) ? "BT_LINK FOLLOW_NUM_B" :
|
||||||
"BT_LINK FOLLOW_NUM",
|
"BT_LINK FOLLOW_NUM",
|
||||||
|
@ -624,7 +624,7 @@ static void Fol_ShowNumberOfFollowingOrFollowers (const struct UsrData *UsrDat,
|
||||||
{
|
{
|
||||||
/* Form to list users */
|
/* Form to list users */
|
||||||
Frm_StartFormAnchor (Action,Fol_FOLLOW_SECTION_ID);
|
Frm_StartFormAnchor (Action,Fol_FOLLOW_SECTION_ID);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
HTM_BUTTON_SUBMIT_Begin (Title,
|
HTM_BUTTON_SUBMIT_Begin (Title,
|
||||||
(Gbl.Action.Act == Action) ? The_ClassFormLinkOutBoxBold[Gbl.Prefs.Theme] :
|
(Gbl.Action.Act == Action) ? The_ClassFormLinkOutBoxBold[Gbl.Prefs.Theme] :
|
||||||
The_ClassFormLinkOutBox [Gbl.Prefs.Theme],
|
The_ClassFormLinkOutBox [Gbl.Prefs.Theme],
|
||||||
|
@ -845,7 +845,7 @@ static void Fol_ShowFollowedOrFollower (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
/* Put form to go to public profile */
|
/* Put form to go to public profile */
|
||||||
Frm_StartForm (ActSeeOthPubPrf);
|
Frm_StartForm (ActSeeOthPubPrf);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
HTM_DIV_Begin ("class=\"FOLLOW_USR_NAME\""); // Limited width
|
HTM_DIV_Begin ("class=\"FOLLOW_USR_NAME\""); // Limited width
|
||||||
HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile,"BT_LINK LT DAT",NULL);
|
HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile,"BT_LINK LT DAT",NULL);
|
||||||
Usr_WriteFirstNameBRSurnames (UsrDat);
|
Usr_WriteFirstNameBRSurnames (UsrDat);
|
||||||
|
@ -902,7 +902,7 @@ static void Fol_WriteRowUsrToFollowOnRightColumn (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
/* Put form to go to public profile */
|
/* Put form to go to public profile */
|
||||||
Frm_StartForm (ActSeeOthPubPrf);
|
Frm_StartForm (ActSeeOthPubPrf);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
HTM_DIV_Begin ("class=\"CON_NAME_FOLLOW\""); // Limited width
|
HTM_DIV_Begin ("class=\"CON_NAME_FOLLOW\""); // Limited width
|
||||||
HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile,"BT_LINK CON_NAME_FOLLOW CON_CRS",NULL);
|
HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile,"BT_LINK CON_NAME_FOLLOW CON_CRS",NULL);
|
||||||
Usr_WriteFirstNameBRSurnames (UsrDat);
|
Usr_WriteFirstNameBRSurnames (UsrDat);
|
||||||
|
@ -956,7 +956,7 @@ static void Fol_PutIconToFollow (struct UsrData *UsrDat)
|
||||||
|
|
||||||
/***** Form to unfollow *****/
|
/***** Form to unfollow *****/
|
||||||
Frm_StartForm (ActFolUsr);
|
Frm_StartForm (ActFolUsr);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-plus.svg",
|
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-plus.svg",
|
||||||
Txt_Follow,"FOLLOW_USR_ICO ICO_HIGHLIGHT ICO16x16");
|
Txt_Follow,"FOLLOW_USR_ICO ICO_HIGHLIGHT ICO16x16");
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
|
@ -972,7 +972,7 @@ static void Fol_PutIconToUnfollow (struct UsrData *UsrDat)
|
||||||
|
|
||||||
/* Form to follow */
|
/* Form to follow */
|
||||||
Frm_StartForm (ActUnfUsr);
|
Frm_StartForm (ActUnfUsr);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-check.svg",
|
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-check.svg",
|
||||||
Txt_Unfollow,"FOLLOW_USR_ICO ICO_HIGHLIGHT ICO16x16");
|
Txt_Unfollow,"FOLLOW_USR_ICO ICO_HIGHLIGHT ICO16x16");
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
|
@ -1168,7 +1168,7 @@ static void Fol_GetFollowedFromSelectedUsrs (unsigned *NumFollowed,
|
||||||
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
||||||
if (Gbl.Usrs.Me.UsrDat.UsrCod != UsrDat.UsrCod) // Skip me
|
if (Gbl.Usrs.Me.UsrDat.UsrCod != UsrDat.UsrCod) // Skip me
|
||||||
|
@ -1217,7 +1217,7 @@ void Fol_FollowUsrs ()
|
||||||
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
||||||
if (Gbl.Usrs.Me.UsrDat.UsrCod != UsrDat.UsrCod) // Skip me
|
if (Gbl.Usrs.Me.UsrDat.UsrCod != UsrDat.UsrCod) // Skip me
|
||||||
|
@ -1264,7 +1264,7 @@ void Fol_UnfollowUsrs (void)
|
||||||
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
||||||
if (Gbl.Usrs.Me.UsrDat.UsrCod != UsrDat.UsrCod) // Skip me
|
if (Gbl.Usrs.Me.UsrDat.UsrCod != UsrDat.UsrCod) // Skip me
|
||||||
|
@ -1463,7 +1463,7 @@ void Fol_GetNotifFollower (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
{
|
{
|
||||||
SummaryStr[0] = '\0'; // Return nothing on error
|
SummaryStr[0] = '\0'; // Return nothing on error
|
||||||
|
|
||||||
if ((*ContentStr = (char *) malloc (1)))
|
if ((*ContentStr = malloc (1)))
|
||||||
*ContentStr[0] = '\0';
|
*ContentStr[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
20
swad_form.c
20
swad_form.c
|
@ -57,9 +57,7 @@ static void Frm_StartFormInternal (Act_Action_t NextAction,bool PutParameterLoca
|
||||||
void Frm_StartFormGoTo (Act_Action_t NextAction)
|
void Frm_StartFormGoTo (Act_Action_t NextAction)
|
||||||
{
|
{
|
||||||
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
|
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
|
||||||
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),
|
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),"form_%d",Gbl.Form.Num);
|
||||||
"form_%d",
|
|
||||||
Gbl.Form.Num);
|
|
||||||
Frm_StartFormInternal (NextAction,false,Gbl.Form.Id,NULL,NULL); // Do not put now parameter location
|
Frm_StartFormInternal (NextAction,false,Gbl.Form.Id,NULL,NULL); // Do not put now parameter location
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,9 +79,7 @@ void Frm_StartFormOnSubmit (Act_Action_t NextAction,const char *OnSubmit)
|
||||||
void Frm_StartFormAnchorOnSubmit (Act_Action_t NextAction,const char *Anchor,const char *OnSubmit)
|
void Frm_StartFormAnchorOnSubmit (Act_Action_t NextAction,const char *Anchor,const char *OnSubmit)
|
||||||
{
|
{
|
||||||
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
|
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
|
||||||
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),
|
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),"form_%d",Gbl.Form.Num);
|
||||||
"form_%d",
|
|
||||||
Gbl.Form.Num);
|
|
||||||
Frm_StartFormInternal (NextAction,true,Gbl.Form.Id,Anchor,OnSubmit); // Do put now parameter location (if no open session)
|
Frm_StartFormInternal (NextAction,true,Gbl.Form.Id,Anchor,OnSubmit); // Do put now parameter location (if no open session)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +91,7 @@ void Frm_StartFormUnique (Act_Action_t NextAction)
|
||||||
void Frm_StartFormUniqueAnchor (Act_Action_t NextAction,const char *Anchor)
|
void Frm_StartFormUniqueAnchor (Act_Action_t NextAction,const char *Anchor)
|
||||||
{
|
{
|
||||||
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
|
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
|
||||||
snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),
|
snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),"form_%s_%d",
|
||||||
"form_%s_%d",
|
|
||||||
Gbl.UniqueNameEncrypted,Gbl.Form.Num);
|
Gbl.UniqueNameEncrypted,Gbl.Form.Num);
|
||||||
Frm_StartFormInternal (NextAction,true,Gbl.Form.UniqueId,Anchor,NULL); // Do put now parameter location (if no open session)
|
Frm_StartFormInternal (NextAction,true,Gbl.Form.UniqueId,Anchor,NULL); // Do put now parameter location (if no open session)
|
||||||
}
|
}
|
||||||
|
@ -104,8 +99,7 @@ void Frm_StartFormUniqueAnchor (Act_Action_t NextAction,const char *Anchor)
|
||||||
void Frm_StartFormUniqueAnchorOnSubmit (Act_Action_t NextAction,const char *Anchor,const char *OnSubmit)
|
void Frm_StartFormUniqueAnchorOnSubmit (Act_Action_t NextAction,const char *Anchor,const char *OnSubmit)
|
||||||
{
|
{
|
||||||
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
|
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
|
||||||
snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),
|
snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),"form_%s_%d",
|
||||||
"form_%s_%d",
|
|
||||||
Gbl.UniqueNameEncrypted,Gbl.Form.Num);
|
Gbl.UniqueNameEncrypted,Gbl.Form.Num);
|
||||||
Frm_StartFormInternal (NextAction,true,Gbl.Form.UniqueId,Anchor,OnSubmit); // Do put now parameter location (if no open session)
|
Frm_StartFormInternal (NextAction,true,Gbl.Form.UniqueId,Anchor,OnSubmit); // Do put now parameter location (if no open session)
|
||||||
}
|
}
|
||||||
|
@ -236,8 +230,7 @@ void Frm_SetParamsForm (char ParamsStr[Frm_MAX_BYTES_PARAMS_STR + 1],Act_Action_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf (ParamsStr,Frm_MAX_BYTES_PARAMS_STR + 1,
|
snprintf (ParamsStr,Frm_MAX_BYTES_PARAMS_STR + 1,"%s%s%s",
|
||||||
"%s%s%s",
|
|
||||||
ParamAction,ParamSession,ParamLocation);
|
ParamAction,ParamSession,ParamLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,8 +256,7 @@ void Frm_SetUniqueId (char UniqueId[Frm_MAX_BYTES_ID + 1])
|
||||||
So, Id uses:
|
So, Id uses:
|
||||||
- a name for this execution (Gbl.UniqueNameEncrypted)
|
- a name for this execution (Gbl.UniqueNameEncrypted)
|
||||||
- a number for each element in this execution (CountForThisExecution) *****/
|
- a number for each element in this execution (CountForThisExecution) *****/
|
||||||
snprintf (UniqueId,Frm_MAX_BYTES_ID + 1,
|
snprintf (UniqueId,Frm_MAX_BYTES_ID + 1,"id_%s_%u",
|
||||||
"id_%s_%u",
|
|
||||||
Gbl.UniqueNameEncrypted,
|
Gbl.UniqueNameEncrypted,
|
||||||
++CountForThisExecution);
|
++CountForThisExecution);
|
||||||
}
|
}
|
||||||
|
|
88
swad_forum.c
88
swad_forum.c
|
@ -720,8 +720,7 @@ static void For_GetThrSubject (long ThrCod,char Subject[Cns_MAX_BYTES_SUBJECT +
|
||||||
|
|
||||||
/***** Write the subject of the thread *****/
|
/***** Write the subject of the thread *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Subject,row[0],
|
Str_Copy (Subject,row[0],Cns_MAX_BYTES_SUBJECT);
|
||||||
Cns_MAX_BYTES_SUBJECT);
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -1031,8 +1030,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
|
||||||
Ale_ShowAlert (AlertType,Message);
|
Ale_ShowAlert (AlertType,Message);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
snprintf (FrameTitle,sizeof (FrameTitle),
|
snprintf (FrameTitle,sizeof (FrameTitle),"%s: %s",
|
||||||
"%s: %s",
|
|
||||||
Txt_Thread,Thread.Subject);
|
Txt_Thread,Thread.Subject);
|
||||||
Box_BoxBegin (NULL,FrameTitle,
|
Box_BoxBegin (NULL,FrameTitle,
|
||||||
For_PutIconNewPost,Forums,
|
For_PutIconNewPost,Forums,
|
||||||
|
@ -1231,8 +1229,7 @@ static void For_ShowAForumPost (struct For_Forums *Forums,
|
||||||
|
|
||||||
if (Enabled)
|
if (Enabled)
|
||||||
/* Return this subject as last subject */
|
/* Return this subject as last subject */
|
||||||
Str_Copy (LastSubject,Subject,
|
Str_Copy (LastSubject,Subject,Cns_MAX_BYTES_SUBJECT);
|
||||||
Cns_MAX_BYTES_SUBJECT);
|
|
||||||
|
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
|
||||||
|
@ -1320,8 +1317,7 @@ static void For_ShowAForumPost (struct For_Forums *Forums,
|
||||||
HTM_TD_Begin ("class=\"MSG_TXT LT\"");
|
HTM_TD_Begin ("class=\"MSG_TXT LT\"");
|
||||||
if (Enabled)
|
if (Enabled)
|
||||||
{
|
{
|
||||||
Str_Copy (Content,OriginalContent,
|
Str_Copy (Content,OriginalContent,sizeof (Content) - 1);
|
||||||
Cns_MAX_BYTES_LONG_TEXT);
|
|
||||||
Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,true,false);
|
Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,true,false);
|
||||||
|
|
||||||
/***** Show image *****/
|
/***** Show image *****/
|
||||||
|
@ -1376,12 +1372,10 @@ static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
|
||||||
*CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]);
|
*CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]);
|
||||||
|
|
||||||
/***** Get subject (row[2]) *****/
|
/***** Get subject (row[2]) *****/
|
||||||
Str_Copy (Subject,row[2],
|
Str_Copy (Subject,row[2],Cns_MAX_BYTES_SUBJECT);
|
||||||
Cns_MAX_BYTES_SUBJECT);
|
|
||||||
|
|
||||||
/***** Get location (row[3]) *****/
|
/***** Get location (row[3]) *****/
|
||||||
Str_Copy (Content,row[3],
|
Str_Copy (Content,row[3],Cns_MAX_BYTES_LONG_TEXT);
|
||||||
Cns_MAX_BYTES_LONG_TEXT);
|
|
||||||
|
|
||||||
/***** Get media (row[4]) *****/
|
/***** Get media (row[4]) *****/
|
||||||
Media->MedCod = Str_ConvertStrCodToLongCod (row[4]);
|
Media->MedCod = Str_ConvertStrCodToLongCod (row[4]);
|
||||||
|
@ -1416,20 +1410,18 @@ void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/***** Copy subject *****/
|
/***** Copy subject *****/
|
||||||
Str_Copy (SummaryStr,row[0],
|
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
|
||||||
Ntf_MAX_BYTES_SUMMARY);
|
|
||||||
|
|
||||||
/***** Copy content *****/
|
/***** Copy content *****/
|
||||||
if (GetContent)
|
if (GetContent)
|
||||||
{
|
{
|
||||||
Length = strlen (row[1]);
|
Length = strlen (row[1]);
|
||||||
|
|
||||||
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
|
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
if (Length)
|
if (Length)
|
||||||
Str_Copy (*ContentStr,row[1],
|
Str_Copy (*ContentStr,row[1],Length);
|
||||||
Length);
|
|
||||||
else
|
else
|
||||||
**ContentStr = '\0';
|
**ContentStr = '\0';
|
||||||
}
|
}
|
||||||
|
@ -2179,20 +2171,18 @@ void For_SetForumName (const struct For_Forum *Forum,
|
||||||
For_MAX_BYTES_FORUM_NAME);
|
For_MAX_BYTES_FORUM_NAME);
|
||||||
break;
|
break;
|
||||||
case For_FORUM_GLOBAL_TCHS:
|
case For_FORUM_GLOBAL_TCHS:
|
||||||
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
|
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
||||||
"%s%s",
|
|
||||||
UseHTMLEntities ? Txt_General :
|
UseHTMLEntities ? Txt_General :
|
||||||
Txt_General_NO_HTML[Language],
|
Txt_General_NO_HTML[Language],
|
||||||
UseHTMLEntities ? Txt_only_teachers :
|
UseHTMLEntities ? Txt_only_teachers :
|
||||||
Txt_only_teachers_NO_HTML[Language]);
|
Txt_only_teachers_NO_HTML[Language]);
|
||||||
break;
|
break;
|
||||||
case For_FORUM__SWAD__USRS:
|
case For_FORUM__SWAD__USRS:
|
||||||
Str_Copy (ForumName,Cfg_PLATFORM_SHORT_NAME,
|
Str_Copy (ForumName,Cfg_PLATFORM_SHORT_NAME,For_MAX_BYTES_FORUM_NAME);
|
||||||
For_MAX_BYTES_FORUM_NAME);
|
|
||||||
break;
|
break;
|
||||||
case For_FORUM__SWAD__TCHS:
|
case For_FORUM__SWAD__TCHS:
|
||||||
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
|
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
||||||
"%s%s",Cfg_PLATFORM_SHORT_NAME,
|
Cfg_PLATFORM_SHORT_NAME,
|
||||||
UseHTMLEntities ? Txt_only_teachers :
|
UseHTMLEntities ? Txt_only_teachers :
|
||||||
Txt_only_teachers_NO_HTML[Language]);
|
Txt_only_teachers_NO_HTML[Language]);
|
||||||
break;
|
break;
|
||||||
|
@ -2200,15 +2190,14 @@ void For_SetForumName (const struct For_Forum *Forum,
|
||||||
Hie.Ins.InsCod = Forum->Location;
|
Hie.Ins.InsCod = Forum->Location;
|
||||||
if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins))
|
if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins))
|
||||||
Lay_ShowErrorAndExit ("Institution not found.");
|
Lay_ShowErrorAndExit ("Institution not found.");
|
||||||
Str_Copy (ForumName,Hie.Ins.ShrtName,
|
Str_Copy (ForumName,Hie.Ins.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
||||||
For_MAX_BYTES_FORUM_NAME);
|
|
||||||
break;
|
break;
|
||||||
case For_FORUM_INSTIT_TCHS:
|
case For_FORUM_INSTIT_TCHS:
|
||||||
Hie.Ins.InsCod = Forum->Location;
|
Hie.Ins.InsCod = Forum->Location;
|
||||||
if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins))
|
if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins))
|
||||||
Lay_ShowErrorAndExit ("Institution not found.");
|
Lay_ShowErrorAndExit ("Institution not found.");
|
||||||
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
|
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
||||||
"%s%s",Hie.Ins.ShrtName,
|
Hie.Ins.ShrtName,
|
||||||
UseHTMLEntities ? Txt_only_teachers :
|
UseHTMLEntities ? Txt_only_teachers :
|
||||||
Txt_only_teachers_NO_HTML[Language]);
|
Txt_only_teachers_NO_HTML[Language]);
|
||||||
break;
|
break;
|
||||||
|
@ -2216,15 +2205,14 @@ void For_SetForumName (const struct For_Forum *Forum,
|
||||||
Hie.Ctr.CtrCod = Forum->Location;
|
Hie.Ctr.CtrCod = Forum->Location;
|
||||||
if (!Ctr_GetDataOfCentreByCod (&Hie.Ctr))
|
if (!Ctr_GetDataOfCentreByCod (&Hie.Ctr))
|
||||||
Lay_ShowErrorAndExit ("Centre not found.");
|
Lay_ShowErrorAndExit ("Centre not found.");
|
||||||
Str_Copy (ForumName,Hie.Ctr.ShrtName,
|
Str_Copy (ForumName,Hie.Ctr.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
||||||
For_MAX_BYTES_FORUM_NAME);
|
|
||||||
break;
|
break;
|
||||||
case For_FORUM_CENTRE_TCHS:
|
case For_FORUM_CENTRE_TCHS:
|
||||||
Hie.Ctr.CtrCod = Forum->Location;
|
Hie.Ctr.CtrCod = Forum->Location;
|
||||||
if (!Ctr_GetDataOfCentreByCod (&Hie.Ctr))
|
if (!Ctr_GetDataOfCentreByCod (&Hie.Ctr))
|
||||||
Lay_ShowErrorAndExit ("Centre not found.");
|
Lay_ShowErrorAndExit ("Centre not found.");
|
||||||
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
|
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
||||||
"%s%s",Hie.Ctr.ShrtName,
|
Hie.Ctr.ShrtName,
|
||||||
UseHTMLEntities ? Txt_only_teachers :
|
UseHTMLEntities ? Txt_only_teachers :
|
||||||
Txt_only_teachers_NO_HTML[Language]);
|
Txt_only_teachers_NO_HTML[Language]);
|
||||||
break;
|
break;
|
||||||
|
@ -2232,15 +2220,14 @@ void For_SetForumName (const struct For_Forum *Forum,
|
||||||
Hie.Deg.DegCod = Forum->Location;
|
Hie.Deg.DegCod = Forum->Location;
|
||||||
if (!Deg_GetDataOfDegreeByCod (&Hie.Deg))
|
if (!Deg_GetDataOfDegreeByCod (&Hie.Deg))
|
||||||
Lay_ShowErrorAndExit ("Degree not found.");
|
Lay_ShowErrorAndExit ("Degree not found.");
|
||||||
Str_Copy (ForumName,Hie.Deg.ShrtName,
|
Str_Copy (ForumName,Hie.Deg.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
||||||
For_MAX_BYTES_FORUM_NAME);
|
|
||||||
break;
|
break;
|
||||||
case For_FORUM_DEGREE_TCHS:
|
case For_FORUM_DEGREE_TCHS:
|
||||||
Hie.Deg.DegCod = Forum->Location;
|
Hie.Deg.DegCod = Forum->Location;
|
||||||
if (!Deg_GetDataOfDegreeByCod (&Hie.Deg))
|
if (!Deg_GetDataOfDegreeByCod (&Hie.Deg))
|
||||||
Lay_ShowErrorAndExit ("Degree not found.");
|
Lay_ShowErrorAndExit ("Degree not found.");
|
||||||
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
|
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
||||||
"%s%s",Hie.Deg.ShrtName,
|
Hie.Deg.ShrtName,
|
||||||
UseHTMLEntities ? Txt_only_teachers :
|
UseHTMLEntities ? Txt_only_teachers :
|
||||||
Txt_only_teachers_NO_HTML[Language]);
|
Txt_only_teachers_NO_HTML[Language]);
|
||||||
break;
|
break;
|
||||||
|
@ -2248,21 +2235,19 @@ void For_SetForumName (const struct For_Forum *Forum,
|
||||||
Hie.Crs.CrsCod = Forum->Location;
|
Hie.Crs.CrsCod = Forum->Location;
|
||||||
if (!Crs_GetDataOfCourseByCod (&Hie.Crs))
|
if (!Crs_GetDataOfCourseByCod (&Hie.Crs))
|
||||||
Lay_ShowErrorAndExit ("Course not found.");
|
Lay_ShowErrorAndExit ("Course not found.");
|
||||||
Str_Copy (ForumName,Hie.Crs.ShrtName,
|
Str_Copy (ForumName,Hie.Crs.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
||||||
For_MAX_BYTES_FORUM_NAME);
|
|
||||||
break;
|
break;
|
||||||
case For_FORUM_COURSE_TCHS:
|
case For_FORUM_COURSE_TCHS:
|
||||||
Hie.Crs.CrsCod = Forum->Location;
|
Hie.Crs.CrsCod = Forum->Location;
|
||||||
if (!Crs_GetDataOfCourseByCod (&Hie.Crs))
|
if (!Crs_GetDataOfCourseByCod (&Hie.Crs))
|
||||||
Lay_ShowErrorAndExit ("Course not found.");
|
Lay_ShowErrorAndExit ("Course not found.");
|
||||||
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
|
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
||||||
"%s%s",Hie.Crs.ShrtName,
|
Hie.Crs.ShrtName,
|
||||||
UseHTMLEntities ? Txt_only_teachers :
|
UseHTMLEntities ? Txt_only_teachers :
|
||||||
Txt_only_teachers_NO_HTML[Language]);
|
Txt_only_teachers_NO_HTML[Language]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Str_Copy (ForumName,Txt_Unknown_FORUM,
|
Str_Copy (ForumName,Txt_Unknown_FORUM,For_MAX_BYTES_FORUM_NAME);
|
||||||
For_MAX_BYTES_FORUM_NAME);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2504,9 +2489,7 @@ static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums
|
||||||
Ale_ShowAlert (AlertType,Message);
|
Ale_ShowAlert (AlertType,Message);
|
||||||
|
|
||||||
/***** Begin box for threads of this forum *****/
|
/***** Begin box for threads of this forum *****/
|
||||||
snprintf (FrameTitle,sizeof (FrameTitle),
|
snprintf (FrameTitle,sizeof (FrameTitle),"%s: %s",Txt_Forum,ForumName);
|
||||||
"%s: %s",
|
|
||||||
Txt_Forum,ForumName);
|
|
||||||
Box_BoxBegin (NULL,FrameTitle,
|
Box_BoxBegin (NULL,FrameTitle,
|
||||||
For_PutIconNewThread,Forums,
|
For_PutIconNewThread,Forums,
|
||||||
Hlp_COMMUNICATION_Forums_threads,Box_NOT_CLOSABLE);
|
Hlp_COMMUNICATION_Forums_threads,Box_NOT_CLOSABLE);
|
||||||
|
@ -3520,12 +3503,9 @@ static void For_GetThreadData (struct For_Thread *Thr)
|
||||||
Thr->WriteTime[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[5]);
|
Thr->WriteTime[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[5]);
|
||||||
|
|
||||||
/***** Get the subject of this thread (row[6]) *****/
|
/***** Get the subject of this thread (row[6]) *****/
|
||||||
Str_Copy (Thr->Subject,row[6],
|
Str_Copy (Thr->Subject,row[6],sizeof (Thr->Subject) - 1);
|
||||||
Cns_MAX_BYTES_SUBJECT);
|
|
||||||
if (!Thr->Subject[0])
|
if (!Thr->Subject[0])
|
||||||
snprintf (Thr->Subject,sizeof (Thr->Subject),
|
snprintf (Thr->Subject,sizeof (Thr->Subject),"[%s]",Txt_no_subject);
|
||||||
"[%s]",
|
|
||||||
Txt_no_subject);
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -4260,7 +4240,7 @@ void For_CutThread (void)
|
||||||
if (Subject[0])
|
if (Subject[0])
|
||||||
{
|
{
|
||||||
snprintf (Message,sizeof (Message),
|
snprintf (Message,sizeof (Message),
|
||||||
Txt_Thread_X_marked_to_be_moved,Subject);
|
Txt_Thread_X_marked_to_be_moved,Subject);
|
||||||
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Message);
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -4301,8 +4281,7 @@ void For_PasteThread (void)
|
||||||
if (Subject[0])
|
if (Subject[0])
|
||||||
{
|
{
|
||||||
snprintf (Message,sizeof (Message),
|
snprintf (Message,sizeof (Message),
|
||||||
Txt_The_thread_X_is_already_in_this_forum,
|
Txt_The_thread_X_is_already_in_this_forum,Subject);
|
||||||
Subject);
|
|
||||||
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_WARNING,Message);
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_WARNING,Message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -4320,8 +4299,7 @@ void For_PasteThread (void)
|
||||||
if (Subject[0])
|
if (Subject[0])
|
||||||
{
|
{
|
||||||
snprintf (Message,sizeof (Message),
|
snprintf (Message,sizeof (Message),
|
||||||
Txt_Thread_X_moved_to_this_forum,
|
Txt_Thread_X_moved_to_this_forum,Subject);
|
||||||
Subject);
|
|
||||||
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Message);
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
17
swad_game.c
17
swad_game.c
|
@ -30,7 +30,6 @@
|
||||||
#include <linux/limits.h> // For PATH_MAX
|
#include <linux/limits.h> // For PATH_MAX
|
||||||
#include <stddef.h> // For NULL
|
#include <stddef.h> // For NULL
|
||||||
#include <stdio.h> // For asprintf
|
#include <stdio.h> // For asprintf
|
||||||
#include <stdlib.h> // For calloc
|
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
|
@ -919,7 +918,7 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder)
|
||||||
Games->Num = (unsigned) NumRows;
|
Games->Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list of games *****/
|
/***** Create list of games *****/
|
||||||
if ((Games->Lst = (struct Gam_GameSelected *) malloc (NumRows * sizeof (struct Gam_GameSelected))) == NULL)
|
if ((Games->Lst = malloc (NumRows * sizeof (*Games->Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the games codes *****/
|
/***** Get the games codes *****/
|
||||||
|
@ -963,7 +962,7 @@ void Gam_GetListSelectedGamCods (struct Gam_Games *Games)
|
||||||
|
|
||||||
/***** Allocate memory for list of games selected *****/
|
/***** Allocate memory for list of games selected *****/
|
||||||
MaxSizeListGamCodsSelected = Games->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
MaxSizeListGamCodsSelected = Games->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
||||||
if ((Games->GamCodsSelected = (char *) malloc (MaxSizeListGamCodsSelected + 1)) == NULL)
|
if ((Games->GamCodsSelected = malloc (MaxSizeListGamCodsSelected + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get parameter multiple with list of games selected *****/
|
/***** Get parameter multiple with list of games selected *****/
|
||||||
|
@ -1062,8 +1061,7 @@ void Gam_GetDataOfGameByCod (struct Gam_Game *Game)
|
||||||
Game->Visibility = TstVis_GetVisibilityFromStr (row[5]);
|
Game->Visibility = TstVis_GetVisibilityFromStr (row[5]);
|
||||||
|
|
||||||
/* Get the title of the game (row[6]) */
|
/* Get the title of the game (row[6]) */
|
||||||
Str_Copy (Game->Title,row[6],
|
Str_Copy (Game->Title,row[6],sizeof (Game->Title) - 1);
|
||||||
Gam_MAX_BYTES_TITLE);
|
|
||||||
|
|
||||||
/* Get number of questions */
|
/* Get number of questions */
|
||||||
Game->NumQsts = Gam_GetNumQstsGame (Game->GamCod);
|
Game->NumQsts = Gam_GetNumQstsGame (Game->GamCod);
|
||||||
|
@ -1148,8 +1146,7 @@ static void Gam_GetGameTxtFromDB (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
|
||||||
{
|
{
|
||||||
/* Get info text */
|
/* Get info text */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Txt,row[0],
|
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Txt[0] = '\0';
|
Txt[0] = '\0';
|
||||||
|
@ -2106,9 +2103,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
|
||||||
|
|
||||||
/* Get question index (row[0]) */
|
/* Get question index (row[0]) */
|
||||||
QstInd = Str_ConvertStrToUnsigned (row[0]);
|
QstInd = Str_ConvertStrToUnsigned (row[0]);
|
||||||
snprintf (StrQstInd,sizeof (StrQstInd),
|
snprintf (StrQstInd,sizeof (StrQstInd),"%u",QstInd);
|
||||||
"%u",
|
|
||||||
QstInd);
|
|
||||||
|
|
||||||
/* Get question code (row[1]) */
|
/* Get question code (row[1]) */
|
||||||
Question.QstCod = Str_ConvertStrCodToLongCod (row[1]);
|
Question.QstCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
|
@ -2309,7 +2304,7 @@ static void Gam_AllocateListSelectedQuestions (struct Gam_Games *Games)
|
||||||
{
|
{
|
||||||
if (!Games->ListQuestions)
|
if (!Games->ListQuestions)
|
||||||
{
|
{
|
||||||
if ((Games->ListQuestions = (char *) malloc (Gam_MAX_BYTES_LIST_SELECTED_QUESTIONS + 1)) == NULL)
|
if ((Games->ListQuestions = malloc (Gam_MAX_BYTES_LIST_SELECTED_QUESTIONS + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
Games->ListQuestions[0] = '\0';
|
Games->ListQuestions[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,14 +144,10 @@ void Gbl_InitializeGlobals (void)
|
||||||
Gbl.Prefs.Menu = Mnu_MENU_DEFAULT; // Default menu
|
Gbl.Prefs.Menu = Mnu_MENU_DEFAULT; // Default menu
|
||||||
Gbl.Prefs.Theme = The_THEME_DEFAULT; // Default theme
|
Gbl.Prefs.Theme = The_THEME_DEFAULT; // Default theme
|
||||||
Gbl.Prefs.IconSet = Ico_ICON_SET_DEFAULT; // Default icon set
|
Gbl.Prefs.IconSet = Ico_ICON_SET_DEFAULT; // Default icon set
|
||||||
snprintf (Gbl.Prefs.URLTheme,sizeof (Gbl.Prefs.URLTheme),
|
snprintf (Gbl.Prefs.URLTheme,sizeof (Gbl.Prefs.URLTheme),"%s/%s",
|
||||||
"%s/%s",
|
Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Gbl.Prefs.Theme]);
|
||||||
Cfg_URL_ICON_THEMES_PUBLIC,
|
snprintf (Gbl.Prefs.URLIconSet,sizeof (Gbl.Prefs.URLIconSet),"%s/%s",
|
||||||
The_ThemeId[Gbl.Prefs.Theme]);
|
Cfg_URL_ICON_SETS_PUBLIC,Ico_IconSetId[Gbl.Prefs.IconSet]);
|
||||||
snprintf (Gbl.Prefs.URLIconSet,sizeof (Gbl.Prefs.URLIconSet),
|
|
||||||
"%s/%s",
|
|
||||||
Cfg_URL_ICON_SETS_PUBLIC,
|
|
||||||
Ico_IconSetId[Gbl.Prefs.IconSet]);
|
|
||||||
|
|
||||||
Gbl.Session.NumSessions = 0;
|
Gbl.Session.NumSessions = 0;
|
||||||
Gbl.Session.IsOpen = false;
|
Gbl.Session.IsOpen = false;
|
||||||
|
|
116
swad_group.c
116
swad_group.c
|
@ -502,7 +502,7 @@ void Grp_PutParamsCodGrps (void)
|
||||||
Gbl.Crs.Grps.LstGrpsSel.NumGrps)
|
Gbl.Crs.Grps.LstGrpsSel.NumGrps)
|
||||||
{
|
{
|
||||||
MaxLengthGrpCods = Gbl.Crs.Grps.LstGrpsSel.NumGrps * (Cns_MAX_DECIMAL_DIGITS_LONG + 1) - 1;
|
MaxLengthGrpCods = Gbl.Crs.Grps.LstGrpsSel.NumGrps * (Cns_MAX_DECIMAL_DIGITS_LONG + 1) - 1;
|
||||||
if ((GrpCods = (char *) malloc (MaxLengthGrpCods + 1)) == NULL)
|
if ((GrpCods = malloc (MaxLengthGrpCods + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
GrpCods[0] = '\0';
|
GrpCods[0] = '\0';
|
||||||
|
|
||||||
|
@ -513,8 +513,7 @@ void Grp_PutParamsCodGrps (void)
|
||||||
/* Append group code to list */
|
/* Append group code to list */
|
||||||
if (NumGrpSel)
|
if (NumGrpSel)
|
||||||
Str_Concat (GrpCods,Par_SEPARATOR_PARAM_MULTIPLE,MaxLengthGrpCods);
|
Str_Concat (GrpCods,Par_SEPARATOR_PARAM_MULTIPLE,MaxLengthGrpCods);
|
||||||
snprintf (GrpCod,sizeof (GrpCod),
|
snprintf (GrpCod,sizeof (GrpCod),"%ld",
|
||||||
"%ld",
|
|
||||||
Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
|
Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
|
||||||
Str_Concat (GrpCods,GrpCod,MaxLengthGrpCods);
|
Str_Concat (GrpCods,GrpCod,MaxLengthGrpCods);
|
||||||
}
|
}
|
||||||
|
@ -553,7 +552,8 @@ void Grp_GetParCodsSeveralGrpsToShowUsrs (void)
|
||||||
if (LstGrpsIBelong.NumGrps)
|
if (LstGrpsIBelong.NumGrps)
|
||||||
{
|
{
|
||||||
/* Allocate space for list of selected groups */
|
/* Allocate space for list of selected groups */
|
||||||
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = (long *) calloc (LstGrpsIBelong.NumGrps,sizeof (long))) == NULL)
|
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = calloc (LstGrpsIBelong.NumGrps,
|
||||||
|
sizeof (*Gbl.Crs.Grps.LstGrpsSel.GrpCods))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/* Fill list of selected groups with list of groups I belong to */
|
/* Fill list of selected groups with list of groups I belong to */
|
||||||
|
@ -591,7 +591,7 @@ void Grp_GetParCodsSeveralGrps (void)
|
||||||
if (Gbl.Crs.Grps.NumGrps) // If course has groups
|
if (Gbl.Crs.Grps.NumGrps) // If course has groups
|
||||||
{
|
{
|
||||||
/***** Allocate memory for the list of group codes selected *****/
|
/***** Allocate memory for the list of group codes selected *****/
|
||||||
if ((ParamLstCodGrps = (char *) malloc (MaxSizeLstGrpCods + 1)) == NULL)
|
if ((ParamLstCodGrps = malloc (MaxSizeLstGrpCods + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get parameter with list of groups to list *****/
|
/***** Get parameter with list of groups to list *****/
|
||||||
|
@ -609,7 +609,8 @@ void Grp_GetParCodsSeveralGrps (void)
|
||||||
if (Gbl.Crs.Grps.LstGrpsSel.NumGrps) // If I have selected groups...
|
if (Gbl.Crs.Grps.LstGrpsSel.NumGrps) // If I have selected groups...
|
||||||
{
|
{
|
||||||
/***** Create a list of groups selected from LstCodGrps *****/
|
/***** Create a list of groups selected from LstCodGrps *****/
|
||||||
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = (long *) calloc (Gbl.Crs.Grps.LstGrpsSel.NumGrps,sizeof (long))) == NULL)
|
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = calloc (Gbl.Crs.Grps.LstGrpsSel.NumGrps,
|
||||||
|
sizeof (*Gbl.Crs.Grps.LstGrpsSel.GrpCods))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
for (Ptr = ParamLstCodGrps, NumGrp = 0;
|
for (Ptr = ParamLstCodGrps, NumGrp = 0;
|
||||||
*Ptr;
|
*Ptr;
|
||||||
|
@ -1064,7 +1065,8 @@ static void Grp_ConstructorListGrpAlreadySelec (struct ListGrpsAlreadySelec **Al
|
||||||
unsigned NumGrpTyp;
|
unsigned NumGrpTyp;
|
||||||
|
|
||||||
/***** Allocate memory to a list of booleanos that indica if already se ha selected a group of cada type *****/
|
/***** Allocate memory to a list of booleanos that indica if already se ha selected a group of cada type *****/
|
||||||
if ((*AlreadyExistsGroupOfType = (struct ListGrpsAlreadySelec *) calloc (Gbl.Crs.Grps.GrpTypes.Num,sizeof (struct ListGrpsAlreadySelec))) == NULL)
|
if ((*AlreadyExistsGroupOfType = calloc (Gbl.Crs.Grps.GrpTypes.Num,
|
||||||
|
sizeof (**AlreadyExistsGroupOfType))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Initialize the list *****/
|
/***** Initialize the list *****/
|
||||||
|
@ -1384,9 +1386,7 @@ static void Grp_ListGroupTypesForEdition (void)
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"LM\"");
|
HTM_TD_Begin ("class=\"LM\"");
|
||||||
snprintf (Id,sizeof (Id),
|
snprintf (Id,sizeof (Id),"open_time_%u",UniqueId);
|
||||||
"open_time_%u",
|
|
||||||
UniqueId);
|
|
||||||
Dat_WriteFormClientLocalDateTimeFromTimeUTC (Id,
|
Dat_WriteFormClientLocalDateTimeFromTimeUTC (Id,
|
||||||
"Open",
|
"Open",
|
||||||
Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].OpenTimeUTC,
|
Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].OpenTimeUTC,
|
||||||
|
@ -2064,9 +2064,7 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
||||||
else
|
else
|
||||||
HTM_TD_Begin ("class=\"LM\"");
|
HTM_TD_Begin ("class=\"LM\"");
|
||||||
|
|
||||||
snprintf (StrGrpCod,sizeof (StrGrpCod),
|
snprintf (StrGrpCod,sizeof (StrGrpCod),"GrpCod%ld",GrpTyp->GrpTypCod);
|
||||||
"GrpCod%ld",
|
|
||||||
GrpTyp->GrpTypCod);
|
|
||||||
if (Gbl.Usrs.Me.Role.Logged == Rol_STD && // If I am a student
|
if (Gbl.Usrs.Me.Role.Logged == Rol_STD && // If I am a student
|
||||||
!GrpTyp->MultipleEnrolment && // ...and the enrolment is single
|
!GrpTyp->MultipleEnrolment && // ...and the enrolment is single
|
||||||
GrpTyp->NumGrps > 1) // ...and there are more than one group
|
GrpTyp->NumGrps > 1) // ...and there are more than one group
|
||||||
|
@ -2191,9 +2189,7 @@ static void Grp_ListGrpsToAddOrRemUsrs (struct GroupType *GrpTyp,long UsrCod)
|
||||||
/* Put checkbox to select the group */
|
/* Put checkbox to select the group */
|
||||||
// Always checkbox, not radio, because the role in the form may be teacher,
|
// Always checkbox, not radio, because the role in the form may be teacher,
|
||||||
// so if he/she is registered as teacher, he/she can belong to several groups
|
// so if he/she is registered as teacher, he/she can belong to several groups
|
||||||
snprintf (StrGrpCod,sizeof (StrGrpCod),
|
snprintf (StrGrpCod,sizeof (StrGrpCod),"GrpCod%ld",GrpTyp->GrpTypCod);
|
||||||
"GrpCod%ld",
|
|
||||||
GrpTyp->GrpTypCod);
|
|
||||||
HTM_INPUT_CHECKBOX (StrGrpCod,HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_INPUT_CHECKBOX (StrGrpCod,HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"id=\"Grp%ld\" value=\"%ld\"%s",
|
"id=\"Grp%ld\" value=\"%ld\"%s",
|
||||||
Grp->GrpCod,Grp->GrpCod,
|
Grp->GrpCod,Grp->GrpCod,
|
||||||
|
@ -2808,7 +2804,8 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
||||||
if (Gbl.Crs.Grps.GrpTypes.Num)
|
if (Gbl.Crs.Grps.GrpTypes.Num)
|
||||||
{
|
{
|
||||||
/***** Create a list of group types *****/
|
/***** Create a list of group types *****/
|
||||||
if ((Gbl.Crs.Grps.GrpTypes.LstGrpTypes = (struct GroupType *) calloc (Gbl.Crs.Grps.GrpTypes.Num,sizeof (struct GroupType))) == NULL)
|
if ((Gbl.Crs.Grps.GrpTypes.LstGrpTypes = calloc (Gbl.Crs.Grps.GrpTypes.Num,
|
||||||
|
sizeof (*Gbl.Crs.Grps.GrpTypes.LstGrpTypes))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get group types *****/
|
/***** Get group types *****/
|
||||||
|
@ -2825,7 +2822,7 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
||||||
|
|
||||||
/* Get group type name (row[1]) */
|
/* Get group type name (row[1]) */
|
||||||
Str_Copy (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName,row[1],
|
Str_Copy (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName,row[1],
|
||||||
Grp_MAX_BYTES_GROUP_TYPE_NAME);
|
sizeof (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName) - 1);
|
||||||
|
|
||||||
/* Is it mandatory to register in any groups of this type? (row[2]) */
|
/* Is it mandatory to register in any groups of this type? (row[2]) */
|
||||||
Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MandatoryEnrolment = (row[2][0] == 'Y');
|
Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MandatoryEnrolment = (row[2][0] == 'Y');
|
||||||
|
@ -2939,7 +2936,8 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
||||||
GrpTyp->NumGrps = (unsigned) NumRows;
|
GrpTyp->NumGrps = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with groups of this type *****/
|
/***** Create list with groups of this type *****/
|
||||||
if ((GrpTyp->LstGrps = (struct Group *) calloc (GrpTyp->NumGrps,sizeof (struct Group))) == NULL)
|
if ((GrpTyp->LstGrps = calloc (GrpTyp->NumGrps,
|
||||||
|
sizeof (*GrpTyp->LstGrps))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the groups of this type *****/
|
/***** Get the groups of this type *****/
|
||||||
|
@ -2957,8 +2955,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of group.");
|
Lay_ShowErrorAndExit ("Wrong code of group.");
|
||||||
|
|
||||||
/* Get group name (row[1]) */
|
/* Get group name (row[1]) */
|
||||||
Str_Copy (Grp->GrpName,row[1],
|
Str_Copy (Grp->GrpName,row[1],sizeof (Grp->GrpName) - 1);
|
||||||
Grp_MAX_BYTES_GROUP_NAME);
|
|
||||||
|
|
||||||
/* Get room code (row[2]) */
|
/* Get room code (row[2]) */
|
||||||
Grp->Room.RooCod = Str_ConvertStrCodToLongCod (row[2]);
|
Grp->Room.RooCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||||
|
@ -2966,7 +2963,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
||||||
/* Get room short name (row[3]) */
|
/* Get room short name (row[3]) */
|
||||||
if (row[3]) // May be NULL because of LEFT JOIN
|
if (row[3]) // May be NULL because of LEFT JOIN
|
||||||
Str_Copy (Grp->Room.ShrtName,row[3],
|
Str_Copy (Grp->Room.ShrtName,row[3],
|
||||||
Roo_MAX_BYTES_SHRT_NAME);
|
sizeof (Grp->Room.ShrtName) - 1);
|
||||||
else // NULL
|
else // NULL
|
||||||
Grp->Room.ShrtName[0] = '\0';
|
Grp->Room.ShrtName[0] = '\0';
|
||||||
|
|
||||||
|
@ -3107,8 +3104,7 @@ static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp)
|
||||||
|
|
||||||
/***** Get some data of group type *****/
|
/***** Get some data of group type *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (GrpTyp->GrpTypName,row[0],
|
Str_Copy (GrpTyp->GrpTypName,row[0],sizeof (GrpTyp->GrpTypName) - 1);
|
||||||
Grp_MAX_BYTES_GROUP_TYPE_NAME);
|
|
||||||
GrpTyp->MandatoryEnrolment = (row[1][0] == 'Y');
|
GrpTyp->MandatoryEnrolment = (row[1][0] == 'Y');
|
||||||
GrpTyp->MultipleEnrolment = (row[2][0] == 'Y');
|
GrpTyp->MultipleEnrolment = (row[2][0] == 'Y');
|
||||||
GrpTyp->MustBeOpened = (row[3][0] == 'Y');
|
GrpTyp->MustBeOpened = (row[3][0] == 'Y');
|
||||||
|
@ -3204,15 +3200,13 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of course.");
|
Lay_ShowErrorAndExit ("Wrong code of course.");
|
||||||
|
|
||||||
/* Get the name of the group type (row[2]) */
|
/* Get the name of the group type (row[2]) */
|
||||||
Str_Copy (GrpDat->GrpTypName,row[2],
|
Str_Copy (GrpDat->GrpTypName,row[2],sizeof (GrpDat->GrpTypName) - 1);
|
||||||
Grp_MAX_BYTES_GROUP_TYPE_NAME);
|
|
||||||
|
|
||||||
/* Get whether a student may be in one or multiple groups (row[3]) */
|
/* Get whether a student may be in one or multiple groups (row[3]) */
|
||||||
GrpDat->MultipleEnrolment = (row[3][0] == 'Y');
|
GrpDat->MultipleEnrolment = (row[3][0] == 'Y');
|
||||||
|
|
||||||
/* Get the name of the group (row[4]) */
|
/* Get the name of the group (row[4]) */
|
||||||
Str_Copy (GrpDat->GrpName,row[4],
|
Str_Copy (GrpDat->GrpName,row[4],sizeof (GrpDat->GrpName) - 1);
|
||||||
Grp_MAX_BYTES_GROUP_NAME);
|
|
||||||
|
|
||||||
/* Get the code of the course (row[5]) */
|
/* Get the code of the course (row[5]) */
|
||||||
GrpDat->Room.RooCod = Str_ConvertStrCodToLongCod (row[5]);
|
GrpDat->Room.RooCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||||
|
@ -3220,7 +3214,7 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
|
||||||
/* Get the name of the room (row[6]) */
|
/* Get the name of the room (row[6]) */
|
||||||
if (row[6]) // May be NULL because of LEFT JOIN
|
if (row[6]) // May be NULL because of LEFT JOIN
|
||||||
Str_Copy (GrpDat->Room.ShrtName,row[6],
|
Str_Copy (GrpDat->Room.ShrtName,row[6],
|
||||||
Roo_MAX_BYTES_SHRT_NAME);
|
sizeof (GrpDat->Room.ShrtName) - 1);
|
||||||
else // NULL
|
else // NULL
|
||||||
GrpDat->Room.ShrtName[0] = '\0';
|
GrpDat->Room.ShrtName[0] = '\0';
|
||||||
|
|
||||||
|
@ -3611,7 +3605,8 @@ static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod,
|
||||||
if (LstGrps->NumGrps)
|
if (LstGrps->NumGrps)
|
||||||
{
|
{
|
||||||
/***** Create a list of groups the user belongs to *****/
|
/***** Create a list of groups the user belongs to *****/
|
||||||
if ((LstGrps->GrpCods = (long *) calloc (LstGrps->NumGrps,sizeof (long))) == NULL)
|
if ((LstGrps->GrpCods = calloc (LstGrps->NumGrps,
|
||||||
|
sizeof (*LstGrps->GrpCods))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
for (NumGrp = 0;
|
for (NumGrp = 0;
|
||||||
NumGrp < LstGrps->NumGrps;
|
NumGrp < LstGrps->NumGrps;
|
||||||
|
@ -3657,7 +3652,8 @@ void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps)
|
||||||
if (LstGrps->NumGrps)
|
if (LstGrps->NumGrps)
|
||||||
{
|
{
|
||||||
/***** Create a list of groups I belong to *****/
|
/***** Create a list of groups I belong to *****/
|
||||||
if ((LstGrps->GrpCods = (long *) calloc (LstGrps->NumGrps,sizeof (long))) == NULL)
|
if ((LstGrps->GrpCods = calloc (LstGrps->NumGrps,
|
||||||
|
sizeof (*LstGrps->GrpCods))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
for (NumGrp = 0;
|
for (NumGrp = 0;
|
||||||
NumGrp < LstGrps->NumGrps;
|
NumGrp < LstGrps->NumGrps;
|
||||||
|
@ -3726,10 +3722,8 @@ void Grp_GetNamesGrpsStdBelongsTo (long GrpTypCod,long UsrCod,char *GroupNames)
|
||||||
|
|
||||||
/* El group name in row[0] */
|
/* El group name in row[0] */
|
||||||
if (NumRow)
|
if (NumRow)
|
||||||
Str_Concat (GroupNames,", ",
|
Str_Concat (GroupNames,", ",MaxLength);
|
||||||
MaxLength);
|
Str_Concat (GroupNames,row[0],MaxLength);
|
||||||
Str_Concat (GroupNames,row[0],
|
|
||||||
MaxLength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -3770,7 +3764,7 @@ void Grp_ReceiveFormNewGrpTyp (void)
|
||||||
{
|
{
|
||||||
AlertType = Ale_WARNING;
|
AlertType = Ale_WARNING;
|
||||||
snprintf (AlertTxt,sizeof (AlertTxt),
|
snprintf (AlertTxt,sizeof (AlertTxt),
|
||||||
Txt_The_type_of_group_X_already_exists,
|
Txt_The_type_of_group_X_already_exists,
|
||||||
Gbl.Crs.Grps.GrpTyp.GrpTypName);
|
Gbl.Crs.Grps.GrpTyp.GrpTypName);
|
||||||
}
|
}
|
||||||
else // Add new group type to database
|
else // Add new group type to database
|
||||||
|
@ -4144,8 +4138,7 @@ static void Grp_RemoveGroupTypeCompletely (void)
|
||||||
Gbl.Crs.Grps.GrpTyp.GrpTypCod);
|
Gbl.Crs.Grps.GrpTyp.GrpTypCod);
|
||||||
|
|
||||||
/***** Create message to show the change made *****/
|
/***** Create message to show the change made *****/
|
||||||
snprintf (AlertTxt,sizeof (AlertTxt),
|
snprintf (AlertTxt,sizeof (AlertTxt),Txt_Type_of_group_X_removed,
|
||||||
Txt_Type_of_group_X_removed,
|
|
||||||
Gbl.Crs.Grps.GrpTyp.GrpTypName);
|
Gbl.Crs.Grps.GrpTyp.GrpTypName);
|
||||||
|
|
||||||
/***** Show the form again *****/
|
/***** Show the form again *****/
|
||||||
|
@ -4198,8 +4191,7 @@ static void Grp_RemoveGroupCompletely (void)
|
||||||
Gbl.Crs.Grps.GrpCod);
|
Gbl.Crs.Grps.GrpCod);
|
||||||
|
|
||||||
/***** Create message to show the change made *****/
|
/***** Create message to show the change made *****/
|
||||||
snprintf (AlertTxt,sizeof (AlertTxt),
|
snprintf (AlertTxt,sizeof (AlertTxt),Txt_Group_X_removed,
|
||||||
Txt_Group_X_removed,
|
|
||||||
GrpDat.GrpName);
|
GrpDat.GrpName);
|
||||||
|
|
||||||
/***** Show the form again *****/
|
/***** Show the form again *****/
|
||||||
|
@ -4231,8 +4223,7 @@ void Grp_OpenGroup (void)
|
||||||
Gbl.Crs.Grps.GrpCod);
|
Gbl.Crs.Grps.GrpCod);
|
||||||
|
|
||||||
/***** Create message to show the change made *****/
|
/***** Create message to show the change made *****/
|
||||||
snprintf (AlertTxt,sizeof (AlertTxt),
|
snprintf (AlertTxt,sizeof (AlertTxt),Txt_The_group_X_is_now_open,
|
||||||
Txt_The_group_X_is_now_open,
|
|
||||||
GrpDat.GrpName);
|
GrpDat.GrpName);
|
||||||
|
|
||||||
/***** Show the form again *****/
|
/***** Show the form again *****/
|
||||||
|
@ -4265,8 +4256,7 @@ void Grp_CloseGroup (void)
|
||||||
Gbl.Crs.Grps.GrpCod);
|
Gbl.Crs.Grps.GrpCod);
|
||||||
|
|
||||||
/***** Create message to show the change made *****/
|
/***** Create message to show the change made *****/
|
||||||
snprintf (AlertTxt,sizeof (AlertTxt),
|
snprintf (AlertTxt,sizeof (AlertTxt),Txt_The_group_X_is_now_closed,
|
||||||
Txt_The_group_X_is_now_closed,
|
|
||||||
GrpDat.GrpName);
|
GrpDat.GrpName);
|
||||||
|
|
||||||
/***** Show the form again *****/
|
/***** Show the form again *****/
|
||||||
|
@ -4300,7 +4290,7 @@ void Grp_EnableFileZonesGrp (void)
|
||||||
|
|
||||||
/***** Create message to show the change made *****/
|
/***** Create message to show the change made *****/
|
||||||
snprintf (AlertTxt,sizeof (AlertTxt),
|
snprintf (AlertTxt,sizeof (AlertTxt),
|
||||||
Txt_File_zones_of_the_group_X_are_now_enabled,
|
Txt_File_zones_of_the_group_X_are_now_enabled,
|
||||||
GrpDat.GrpName);
|
GrpDat.GrpName);
|
||||||
|
|
||||||
/***** Show the form again *****/
|
/***** Show the form again *****/
|
||||||
|
@ -4373,8 +4363,7 @@ void Grp_ChangeGroupType (void)
|
||||||
{
|
{
|
||||||
/* Create warning message */
|
/* Create warning message */
|
||||||
AlertType = Ale_WARNING;
|
AlertType = Ale_WARNING;
|
||||||
snprintf (AlertTxt,sizeof (AlertTxt),
|
snprintf (AlertTxt,sizeof (AlertTxt),Txt_The_group_X_already_exists,
|
||||||
Txt_The_group_X_already_exists,
|
|
||||||
GrpDat.GrpName);
|
GrpDat.GrpName);
|
||||||
}
|
}
|
||||||
else // Group is not in database
|
else // Group is not in database
|
||||||
|
@ -4662,9 +4651,7 @@ void Grp_ChangeMaxStdsGrp (void)
|
||||||
static void Grp_WriteMaxStds (char Str[Cns_MAX_DECIMAL_DIGITS_UINT + 1],unsigned MaxStudents)
|
static void Grp_WriteMaxStds (char Str[Cns_MAX_DECIMAL_DIGITS_UINT + 1],unsigned MaxStudents)
|
||||||
{
|
{
|
||||||
if (MaxStudents <= Grp_MAX_STUDENTS_IN_A_GROUP)
|
if (MaxStudents <= Grp_MAX_STUDENTS_IN_A_GROUP)
|
||||||
snprintf (Str,Cns_MAX_DECIMAL_DIGITS_UINT + 1,
|
snprintf (Str,Cns_MAX_DECIMAL_DIGITS_UINT + 1,"%u",MaxStudents);
|
||||||
"%u",
|
|
||||||
MaxStudents);
|
|
||||||
else
|
else
|
||||||
Str[0] = '\0';
|
Str[0] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -4721,8 +4708,7 @@ void Grp_RenameGroupType (void)
|
||||||
{
|
{
|
||||||
AlertType = Ale_WARNING;
|
AlertType = Ale_WARNING;
|
||||||
snprintf (AlertTxt,sizeof (AlertTxt),
|
snprintf (AlertTxt,sizeof (AlertTxt),
|
||||||
Txt_The_type_of_group_X_already_exists,
|
Txt_The_type_of_group_X_already_exists,NewNameGrpTyp);
|
||||||
NewNameGrpTyp);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4757,7 +4743,7 @@ void Grp_RenameGroupType (void)
|
||||||
|
|
||||||
/***** Show the form again *****/
|
/***** Show the form again *****/
|
||||||
Str_Copy (Gbl.Crs.Grps.GrpTyp.GrpTypName,NewNameGrpTyp,
|
Str_Copy (Gbl.Crs.Grps.GrpTyp.GrpTypName,NewNameGrpTyp,
|
||||||
Grp_MAX_BYTES_GROUP_TYPE_NAME);
|
sizeof (Gbl.Crs.Grps.GrpTyp.GrpTypName) - 1);
|
||||||
Grp_ReqEditGroupsInternal (AlertType,AlertTxt,
|
Grp_ReqEditGroupsInternal (AlertType,AlertTxt,
|
||||||
Ale_INFO,NULL);
|
Ale_INFO,NULL);
|
||||||
}
|
}
|
||||||
|
@ -4807,8 +4793,7 @@ void Grp_RenameGroup (void)
|
||||||
{
|
{
|
||||||
AlertType = Ale_WARNING;
|
AlertType = Ale_WARNING;
|
||||||
snprintf (AlertTxt,sizeof (AlertTxt),
|
snprintf (AlertTxt,sizeof (AlertTxt),
|
||||||
Txt_The_group_X_already_exists,
|
Txt_The_group_X_already_exists,NewNameGrp);
|
||||||
NewNameGrp);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4828,14 +4813,12 @@ void Grp_RenameGroup (void)
|
||||||
{
|
{
|
||||||
AlertType = Ale_INFO;
|
AlertType = Ale_INFO;
|
||||||
snprintf (AlertTxt,sizeof (AlertTxt),
|
snprintf (AlertTxt,sizeof (AlertTxt),
|
||||||
Txt_The_name_of_the_group_X_has_not_changed,
|
Txt_The_name_of_the_group_X_has_not_changed,NewNameGrp);
|
||||||
NewNameGrp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Show the form again *****/
|
/***** Show the form again *****/
|
||||||
Str_Copy (Gbl.Crs.Grps.GrpName,NewNameGrp,
|
Str_Copy (Gbl.Crs.Grps.GrpName,NewNameGrp,sizeof (Gbl.Crs.Grps.GrpName) - 1);
|
||||||
Grp_MAX_BYTES_GROUP_NAME);
|
|
||||||
Grp_ReqEditGroupsInternal (Ale_INFO,NULL,
|
Grp_ReqEditGroupsInternal (Ale_INFO,NULL,
|
||||||
AlertType,AlertTxt);
|
AlertType,AlertTxt);
|
||||||
}
|
}
|
||||||
|
@ -4894,7 +4877,8 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
|
||||||
unsigned NumGrpWanted;
|
unsigned NumGrpWanted;
|
||||||
|
|
||||||
/***** Allocate memory for the strings with group codes in each type *****/
|
/***** Allocate memory for the strings with group codes in each type *****/
|
||||||
if ((LstStrCodGrps = (char **) calloc (Gbl.Crs.Grps.GrpTypes.Num,sizeof (char *))) == NULL)
|
if ((LstStrCodGrps = calloc (Gbl.Crs.Grps.GrpTypes.Num,
|
||||||
|
sizeof (*LstStrCodGrps))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get lists with the groups that I want in each type
|
/***** Get lists with the groups that I want in each type
|
||||||
|
@ -4904,13 +4888,12 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
|
||||||
NumGrpTyp++)
|
NumGrpTyp++)
|
||||||
{
|
{
|
||||||
/***** Allocate memory for the list of group codes of this type *****/
|
/***** Allocate memory for the list of group codes of this type *****/
|
||||||
if ((LstStrCodGrps[NumGrpTyp] = (char *) malloc ((size_t) ((Cns_MAX_DECIMAL_DIGITS_LONG + 1) *
|
if ((LstStrCodGrps[NumGrpTyp] = malloc (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps *
|
||||||
Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps))) == NULL)
|
(Cns_MAX_DECIMAL_DIGITS_LONG + 1))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the multiple parameter code of group of this type *****/
|
/***** Get the multiple parameter code of group of this type *****/
|
||||||
snprintf (Param,sizeof (Param),
|
snprintf (Param,sizeof (Param),"GrpCod%ld",
|
||||||
"GrpCod%ld",
|
|
||||||
Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod);
|
Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod);
|
||||||
Par_GetParMultiToText (Param,LstStrCodGrps[NumGrpTyp],
|
Par_GetParMultiToText (Param,LstStrCodGrps[NumGrpTyp],
|
||||||
((Cns_MAX_DECIMAL_DIGITS_LONG + 1) * Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) - 1);
|
((Cns_MAX_DECIMAL_DIGITS_LONG + 1) * Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) - 1);
|
||||||
|
@ -4931,8 +4914,9 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
|
||||||
with all the groups selected (of all the types) *****/
|
with all the groups selected (of all the types) *****/
|
||||||
if (LstGrpsWanted->NumGrps)
|
if (LstGrpsWanted->NumGrps)
|
||||||
{
|
{
|
||||||
if ((LstGrpsWanted->GrpCods = (long *) calloc (LstGrpsWanted->NumGrps,sizeof (long))) == NULL)
|
if ((LstGrpsWanted->GrpCods = calloc (LstGrpsWanted->NumGrps,
|
||||||
Lay_ShowErrorAndExit ("Not enoguh memory to store codes of groups in which a user wants to be enroled.");
|
sizeof (*LstGrpsWanted->GrpCods))) == NULL)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the groups *****/
|
/***** Get the groups *****/
|
||||||
for (NumGrpTyp = 0, NumGrpWanted = 0;
|
for (NumGrpTyp = 0, NumGrpWanted = 0;
|
||||||
|
|
|
@ -599,14 +599,11 @@ void Hie_InitHierarchy (void)
|
||||||
if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected
|
if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected
|
||||||
{
|
{
|
||||||
/***** Paths of course directories *****/
|
/***** Paths of course directories *****/
|
||||||
snprintf (Gbl.Crs.PathPriv,sizeof (Gbl.Crs.PathPriv),
|
snprintf (Gbl.Crs.PathPriv,sizeof (Gbl.Crs.PathPriv),"%s/%ld",
|
||||||
"%s/%ld",
|
|
||||||
Cfg_PATH_CRS_PRIVATE,Gbl.Hierarchy.Crs.CrsCod);
|
Cfg_PATH_CRS_PRIVATE,Gbl.Hierarchy.Crs.CrsCod);
|
||||||
snprintf (Gbl.Crs.PathRelPubl,sizeof (Gbl.Crs.PathRelPubl),
|
snprintf (Gbl.Crs.PathRelPubl,sizeof (Gbl.Crs.PathRelPubl),"%s/%ld",
|
||||||
"%s/%ld",
|
|
||||||
Cfg_PATH_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod);
|
Cfg_PATH_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod);
|
||||||
snprintf (Gbl.Crs.PathURLPubl,sizeof (Gbl.Crs.PathURLPubl),
|
snprintf (Gbl.Crs.PathURLPubl,sizeof (Gbl.Crs.PathURLPubl),"%s/%ld",
|
||||||
"%s/%ld",
|
|
||||||
Cfg_URL_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod);
|
Cfg_URL_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
|
||||||
/***** If any of the course directories does not exist, create it *****/
|
/***** If any of the course directories does not exist, create it *****/
|
||||||
|
|
|
@ -366,9 +366,8 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays)
|
||||||
if (Holidays->Num) // Holidays found...
|
if (Holidays->Num) // Holidays found...
|
||||||
{
|
{
|
||||||
/***** Create list of holidays *****/
|
/***** Create list of holidays *****/
|
||||||
if ((Holidays->Lst = (struct Hld_Holiday *)
|
if ((Holidays->Lst = calloc (Holidays->Num,
|
||||||
calloc ((size_t) Holidays->Num,
|
sizeof (*Holidays->Lst))) == NULL)
|
||||||
sizeof (struct Hld_Holiday))) == NULL)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the holidays *****/
|
/***** Get the holidays *****/
|
||||||
|
@ -390,7 +389,7 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays)
|
||||||
|
|
||||||
/* Get the full name of the place (row[2]) */
|
/* Get the full name of the place (row[2]) */
|
||||||
Str_Copy (Hld->PlaceFullName,row[2],
|
Str_Copy (Hld->PlaceFullName,row[2],
|
||||||
Plc_MAX_BYTES_PLACE_FULL_NAME);
|
sizeof (Hld->PlaceFullName) - 1);
|
||||||
|
|
||||||
/* Get type (row[3]) */
|
/* Get type (row[3]) */
|
||||||
Hld->HldTyp = Hld_GetTypeOfHoliday (row[3]);
|
Hld->HldTyp = Hld_GetTypeOfHoliday (row[3]);
|
||||||
|
@ -414,8 +413,7 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the name of the holiday/non school period (row[6]) */
|
/* Get the name of the holiday/non school period (row[6]) */
|
||||||
Str_Copy (Hld->Name,row[6],
|
Str_Copy (Hld->Name,row[6],sizeof (Hld->Name) - 1);
|
||||||
Hld_MAX_BYTES_HOLIDAY_NAME);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,8 +485,7 @@ static void Hld_GetDataOfHolidayByCod (struct Hld_Holiday *Hld)
|
||||||
Hld->PlcCod = Str_ConvertStrCodToLongCod (row[0]);
|
Hld->PlcCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
|
||||||
/* Get the full name of the place (row[1]) */
|
/* Get the full name of the place (row[1]) */
|
||||||
Str_Copy (Hld->PlaceFullName,row[1],
|
Str_Copy (Hld->PlaceFullName,row[1],sizeof (Hld->PlaceFullName) - 1);
|
||||||
Plc_MAX_BYTES_PLACE_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get type (row[2]) */
|
/* Get type (row[2]) */
|
||||||
Hld->HldTyp = Hld_GetTypeOfHoliday (row[2]);
|
Hld->HldTyp = Hld_GetTypeOfHoliday (row[2]);
|
||||||
|
@ -512,8 +509,7 @@ static void Hld_GetDataOfHolidayByCod (struct Hld_Holiday *Hld)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the name of the holiday/non school period (row[5]) */
|
/* Get the name of the holiday/non school period (row[5]) */
|
||||||
Str_Copy (Hld->Name,row[5],
|
Str_Copy (Hld->Name,row[5],sizeof (Hld->Name) - 1);
|
||||||
Hld_MAX_BYTES_HOLIDAY_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -769,7 +765,7 @@ void Hld_ChangeHolidayPlace (void)
|
||||||
NewPlace.PlcCod,Hld_EditingHld->HldCod);
|
NewPlace.PlcCod,Hld_EditingHld->HldCod);
|
||||||
Hld_EditingHld->PlcCod = NewPlace.PlcCod;
|
Hld_EditingHld->PlcCod = NewPlace.PlcCod;
|
||||||
Str_Copy (Hld_EditingHld->PlaceFullName,NewPlace.FullName,
|
Str_Copy (Hld_EditingHld->PlaceFullName,NewPlace.FullName,
|
||||||
Plc_MAX_BYTES_PLACE_FULL_NAME);
|
sizeof (Hld_EditingHld->PlaceFullName) - 1);
|
||||||
|
|
||||||
/***** Write message to show the change made *****/
|
/***** Write message to show the change made *****/
|
||||||
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
||||||
|
@ -938,7 +934,7 @@ void Hld_RenameHoliday (void)
|
||||||
"UPDATE holidays SET Name='%s' WHERE HldCod=%ld",
|
"UPDATE holidays SET Name='%s' WHERE HldCod=%ld",
|
||||||
NewHldName,Hld_EditingHld->HldCod);
|
NewHldName,Hld_EditingHld->HldCod);
|
||||||
Str_Copy (Hld_EditingHld->Name,NewHldName,
|
Str_Copy (Hld_EditingHld->Name,NewHldName,
|
||||||
Hld_MAX_BYTES_HOLIDAY_NAME);
|
sizeof (Hld_EditingHld->Name) - 1);
|
||||||
|
|
||||||
/***** Write message to show the change made *****/
|
/***** Write message to show the change made *****/
|
||||||
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
||||||
|
@ -1203,8 +1199,8 @@ static void Hld_EditingHolidayConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing holiday.");
|
Lay_ShowErrorAndExit ("Error initializing holiday.");
|
||||||
|
|
||||||
/***** Allocate memory for holiday *****/
|
/***** Allocate memory for holiday *****/
|
||||||
if ((Hld_EditingHld = (struct Hld_Holiday *) malloc (sizeof (struct Hld_Holiday))) == NULL)
|
if ((Hld_EditingHld = malloc (sizeof (*Hld_EditingHld))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for holiday.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset place *****/
|
/***** Reset place *****/
|
||||||
Hld_EditingHld->HldCod = -1L;
|
Hld_EditingHld->HldCod = -1L;
|
||||||
|
|
12
swad_icon.c
12
swad_icon.c
|
@ -91,11 +91,9 @@ const char *Ico_GetIcon (const char *IconWithoutExtension)
|
||||||
NumExt < Ico_NUM_ICON_EXTENSIONS;
|
NumExt < Ico_NUM_ICON_EXTENSIONS;
|
||||||
NumExt++)
|
NumExt++)
|
||||||
{
|
{
|
||||||
snprintf (IconWithExtension,sizeof (IconWithExtension),
|
snprintf (IconWithExtension,sizeof (IconWithExtension),"%s.%s",
|
||||||
"%s.%s",
|
|
||||||
IconWithoutExtension,Ico_IconExtensions[NumExt]);
|
IconWithoutExtension,Ico_IconExtensions[NumExt]);
|
||||||
snprintf (PathIcon,sizeof (PathIcon),
|
snprintf (PathIcon,sizeof (PathIcon),"%s/%s/%s",
|
||||||
"%s/%s/%s",
|
|
||||||
Cfg_PATH_ICON_SETS_PUBLIC,
|
Cfg_PATH_ICON_SETS_PUBLIC,
|
||||||
Ico_IconSetId[Gbl.Prefs.IconSet],
|
Ico_IconSetId[Gbl.Prefs.IconSet],
|
||||||
IconWithExtension);
|
IconWithExtension);
|
||||||
|
@ -131,8 +129,7 @@ void Ico_PutIconsToSelectIconSet (void)
|
||||||
"PREF_OFF");
|
"PREF_OFF");
|
||||||
Frm_StartForm (ActChgIco);
|
Frm_StartForm (ActChgIco);
|
||||||
Par_PutHiddenParamString (NULL,"IconSet",Ico_IconSetId[IconSet]);
|
Par_PutHiddenParamString (NULL,"IconSet",Ico_IconSetId[IconSet]);
|
||||||
snprintf (Icon,sizeof (Icon),
|
snprintf (Icon,sizeof (Icon),"%s/%s/cog.svg",
|
||||||
"%s/%s/cog.svg",
|
|
||||||
Cfg_ICON_FOLDER_SETS,
|
Cfg_ICON_FOLDER_SETS,
|
||||||
Ico_IconSetId[IconSet]);
|
Ico_IconSetId[IconSet]);
|
||||||
Ico_PutSettingIconLink (Icon,Ico_IconSetNames[IconSet]);
|
Ico_PutSettingIconLink (Icon,Ico_IconSetNames[IconSet]);
|
||||||
|
@ -162,8 +159,7 @@ void Ico_ChangeIconSet (void)
|
||||||
{
|
{
|
||||||
/***** Get param with icon set *****/
|
/***** Get param with icon set *****/
|
||||||
Gbl.Prefs.IconSet = Ico_GetParamIconSet ();
|
Gbl.Prefs.IconSet = Ico_GetParamIconSet ();
|
||||||
snprintf (Gbl.Prefs.URLIconSet,sizeof (Gbl.Prefs.URLIconSet),
|
snprintf (Gbl.Prefs.URLIconSet,sizeof (Gbl.Prefs.URLIconSet),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
Cfg_URL_ICON_SETS_PUBLIC,
|
Cfg_URL_ICON_SETS_PUBLIC,
|
||||||
Ico_IconSetId[Gbl.Prefs.IconSet]);
|
Ico_IconSetId[Gbl.Prefs.IconSet]);
|
||||||
|
|
||||||
|
|
66
swad_info.c
66
swad_info.c
|
@ -754,15 +754,13 @@ static bool Inf_CheckPage (long CrsCod,Inf_InfoType_t InfoType)
|
||||||
|
|
||||||
/***** Open file with web page *****/
|
/***** Open file with web page *****/
|
||||||
/* 1. Check if index.html exists */
|
/* 1. Check if index.html exists */
|
||||||
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
|
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.html",
|
||||||
"%s/index.html",
|
|
||||||
PathRelDirHTML);
|
PathRelDirHTML);
|
||||||
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
|
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* 2. If index.html does not exist, try index.htm */
|
/* 2. If index.html does not exist, try index.htm */
|
||||||
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
|
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.htm",
|
||||||
"%s/index.htm",
|
|
||||||
PathRelDirHTML);
|
PathRelDirHTML);
|
||||||
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
|
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
|
||||||
return true;
|
return true;
|
||||||
|
@ -789,13 +787,11 @@ static bool Inf_CheckAndShowPage (void)
|
||||||
|
|
||||||
/***** Open file with web page *****/
|
/***** Open file with web page *****/
|
||||||
/* 1. Check if index.html exists */
|
/* 1. Check if index.html exists */
|
||||||
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
|
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.html",
|
||||||
"%s/index.html",
|
|
||||||
PathRelDirHTML);
|
PathRelDirHTML);
|
||||||
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
|
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
|
||||||
{
|
{
|
||||||
snprintf (URL,sizeof (URL),
|
snprintf (URL,sizeof (URL),"%s/%ld/%s/index.html",
|
||||||
"%s/%ld/%s/index.html",
|
|
||||||
Cfg_URL_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod,
|
Cfg_URL_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod,
|
||||||
Inf_FileNamesForInfoType[Gbl.Crs.Info.Type]);
|
Inf_FileNamesForInfoType[Gbl.Crs.Info.Type]);
|
||||||
Inf_ShowPage (URL);
|
Inf_ShowPage (URL);
|
||||||
|
@ -804,13 +800,11 @@ static bool Inf_CheckAndShowPage (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 2. If index.html does not exist, try index.htm */
|
/* 2. If index.html does not exist, try index.htm */
|
||||||
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
|
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.htm",
|
||||||
"%s/index.htm",
|
|
||||||
PathRelDirHTML);
|
PathRelDirHTML);
|
||||||
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
|
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
|
||||||
{
|
{
|
||||||
snprintf (URL,sizeof (URL),
|
snprintf (URL,sizeof (URL),"%s/%ld/%s/index.htm",
|
||||||
"%s/%ld/%s/index.htm",
|
|
||||||
Cfg_URL_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod,
|
Cfg_URL_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod,
|
||||||
Inf_FileNamesForInfoType[Gbl.Crs.Info.Type]);
|
Inf_FileNamesForInfoType[Gbl.Crs.Info.Type]);
|
||||||
Inf_ShowPage (URL);
|
Inf_ShowPage (URL);
|
||||||
|
@ -827,10 +821,8 @@ static bool Inf_CheckAndShowPage (void)
|
||||||
|
|
||||||
void Inf_BuildPathPage (long CrsCod,Inf_InfoType_t InfoType,char PathDir[PATH_MAX + 1])
|
void Inf_BuildPathPage (long CrsCod,Inf_InfoType_t InfoType,char PathDir[PATH_MAX + 1])
|
||||||
{
|
{
|
||||||
snprintf (PathDir,PATH_MAX + 1,
|
snprintf (PathDir,PATH_MAX + 1,"%s/%ld/%s",
|
||||||
"%s/%ld/%s",
|
Cfg_PATH_CRS_PUBLIC,CrsCod,Inf_FileNamesForInfoType[InfoType]);
|
||||||
Cfg_PATH_CRS_PUBLIC,CrsCod,
|
|
||||||
Inf_FileNamesForInfoType[InfoType]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -899,10 +891,8 @@ static bool Inf_CheckAndShowURL (void)
|
||||||
static void Inf_BuildPathURL (long CrsCod,Inf_InfoType_t InfoType,
|
static void Inf_BuildPathURL (long CrsCod,Inf_InfoType_t InfoType,
|
||||||
char PathFile[PATH_MAX + 1])
|
char PathFile[PATH_MAX + 1])
|
||||||
{
|
{
|
||||||
snprintf (PathFile,PATH_MAX + 1,
|
snprintf (PathFile,PATH_MAX + 1,"%s/%ld/%s.url",
|
||||||
"%s/%ld/%s.url",
|
Cfg_PATH_CRS_PRIVATE,CrsCod,Inf_FileNamesForInfoType[InfoType]);
|
||||||
Cfg_PATH_CRS_PRIVATE,CrsCod,
|
|
||||||
Inf_FileNamesForInfoType[InfoType]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1669,13 +1659,11 @@ void Inf_GetInfoTxtFromDB (long CrsCod,Inf_InfoType_t InfoType,
|
||||||
|
|
||||||
/* Get text in HTML format (not rigorous) */
|
/* Get text in HTML format (not rigorous) */
|
||||||
if (InfoTxtHTML)
|
if (InfoTxtHTML)
|
||||||
Str_Copy (InfoTxtHTML,row[0],
|
Str_Copy (InfoTxtHTML,row[0],Cns_MAX_BYTES_LONG_TEXT);
|
||||||
Cns_MAX_BYTES_LONG_TEXT);
|
|
||||||
|
|
||||||
/* Get text in Markdown format */
|
/* Get text in Markdown format */
|
||||||
if (InfoTxtMD)
|
if (InfoTxtMD)
|
||||||
Str_Copy (InfoTxtMD,row[1],
|
Str_Copy (InfoTxtMD,row[1],Cns_MAX_BYTES_LONG_TEXT);
|
||||||
Cns_MAX_BYTES_LONG_TEXT);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1843,11 +1831,9 @@ static bool Inf_CheckAndShowRichTxt (void)
|
||||||
/***** Store text into a temporary .md file in HTML output directory *****/
|
/***** Store text into a temporary .md file in HTML output directory *****/
|
||||||
// TODO: change to another directory?
|
// TODO: change to another directory?
|
||||||
/* Create a unique name for the .md file */
|
/* Create a unique name for the .md file */
|
||||||
snprintf (PathFileMD,sizeof (PathFileMD),
|
snprintf (PathFileMD,sizeof (PathFileMD),"%s/%s.md",
|
||||||
"%s/%s.md",
|
|
||||||
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
||||||
snprintf (PathFileHTML,sizeof (PathFileHTML),
|
snprintf (PathFileHTML,sizeof (PathFileHTML),"%s/%s.md.html", // Do not use only .html because that is the output temporary file
|
||||||
"%s/%s.md.html", // Do not use only .html because that is the output temporary file
|
|
||||||
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
||||||
|
|
||||||
/* Open Markdown file for writing */
|
/* Open Markdown file for writing */
|
||||||
|
@ -1875,8 +1861,7 @@ static bool Inf_CheckAndShowRichTxt (void)
|
||||||
/* MathJax 3.0.1 */
|
/* MathJax 3.0.1 */
|
||||||
#ifdef Cfg_MATHJAX_LOCAL
|
#ifdef Cfg_MATHJAX_LOCAL
|
||||||
// Use the local copy of MathJax
|
// Use the local copy of MathJax
|
||||||
snprintf (MathJaxURL,sizeof (MathJaxURL),
|
snprintf (MathJaxURL,sizeof (MathJaxURL),"=%s/mathjax/tex-chtml.js",
|
||||||
"=%s/mathjax/tex-chtml.js",
|
|
||||||
Cfg_URL_SWAD_PUBLIC);
|
Cfg_URL_SWAD_PUBLIC);
|
||||||
#else
|
#else
|
||||||
// Use the MathJax Content Delivery Network (CDN)
|
// Use the MathJax Content Delivery Network (CDN)
|
||||||
|
@ -2052,8 +2037,7 @@ void Inf_RecAndChangePlainTxtInfo (void)
|
||||||
/***** Get text with course information from form *****/
|
/***** Get text with course information from form *****/
|
||||||
Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,
|
Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,
|
||||||
Cns_MAX_BYTES_LONG_TEXT,NULL);
|
Cns_MAX_BYTES_LONG_TEXT,NULL);
|
||||||
Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,
|
Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,sizeof (Txt_MarkdownFormat) - 1);
|
||||||
Cns_MAX_BYTES_LONG_TEXT);
|
|
||||||
Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML,
|
Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML,
|
||||||
Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous)
|
Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous)
|
||||||
Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN,
|
Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN,
|
||||||
|
@ -2092,8 +2076,7 @@ void Inf_RecAndChangeRichTxtInfo (void)
|
||||||
/***** Get text with course information from form *****/
|
/***** Get text with course information from form *****/
|
||||||
Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,
|
Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,
|
||||||
Cns_MAX_BYTES_LONG_TEXT,NULL);
|
Cns_MAX_BYTES_LONG_TEXT,NULL);
|
||||||
Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,
|
Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,sizeof (Txt_MarkdownFormat) - 1);
|
||||||
Cns_MAX_BYTES_LONG_TEXT);
|
|
||||||
Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML,
|
Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML,
|
||||||
Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous)
|
Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous)
|
||||||
Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN,
|
Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN,
|
||||||
|
@ -2231,8 +2214,7 @@ void Inf_ReceivePagInfo (void)
|
||||||
{
|
{
|
||||||
Fil_RemoveTree (PathRelDirHTML);
|
Fil_RemoveTree (PathRelDirHTML);
|
||||||
Fil_CreateDirIfNotExists (PathRelDirHTML);
|
Fil_CreateDirIfNotExists (PathRelDirHTML);
|
||||||
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
|
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.html",
|
||||||
"%s/index.html",
|
|
||||||
PathRelDirHTML);
|
PathRelDirHTML);
|
||||||
if (Fil_EndReceptionOfFile (PathRelFileHTML,Param))
|
if (Fil_EndReceptionOfFile (PathRelFileHTML,Param))
|
||||||
{
|
{
|
||||||
|
@ -2246,8 +2228,7 @@ void Inf_ReceivePagInfo (void)
|
||||||
{
|
{
|
||||||
Fil_RemoveTree (PathRelDirHTML);
|
Fil_RemoveTree (PathRelDirHTML);
|
||||||
Fil_CreateDirIfNotExists (PathRelDirHTML);
|
Fil_CreateDirIfNotExists (PathRelDirHTML);
|
||||||
snprintf (PathRelFileZIP,sizeof (PathRelFileZIP),
|
snprintf (PathRelFileZIP,sizeof (PathRelFileZIP),"%s/%s.zip",
|
||||||
"%s/%s.zip",
|
|
||||||
Gbl.Crs.PathPriv,
|
Gbl.Crs.PathPriv,
|
||||||
Inf_FileNamesForInfoType[Gbl.Crs.Info.Type]);
|
Inf_FileNamesForInfoType[Gbl.Crs.Info.Type]);
|
||||||
|
|
||||||
|
@ -2256,15 +2237,13 @@ void Inf_ReceivePagInfo (void)
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_received_successfully);
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_received_successfully);
|
||||||
|
|
||||||
/* Uncompress ZIP */
|
/* Uncompress ZIP */
|
||||||
snprintf (StrUnzip,sizeof (StrUnzip),
|
snprintf (StrUnzip,sizeof (StrUnzip),"unzip -qq -o %s -d %s",
|
||||||
"unzip -qq -o %s -d %s",
|
|
||||||
PathRelFileZIP,PathRelDirHTML);
|
PathRelFileZIP,PathRelDirHTML);
|
||||||
if (system (StrUnzip) == 0)
|
if (system (StrUnzip) == 0)
|
||||||
{
|
{
|
||||||
/* Check if uploaded file is index.html or index.htm */
|
/* Check if uploaded file is index.html or index.htm */
|
||||||
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
|
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
|
||||||
"%s/index.html",
|
"%s/index.html",PathRelDirHTML);
|
||||||
PathRelDirHTML);
|
|
||||||
if (Fil_CheckIfPathExists (PathRelFileHTML))
|
if (Fil_CheckIfPathExists (PathRelFileHTML))
|
||||||
{
|
{
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_unzipped_successfully);
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_unzipped_successfully);
|
||||||
|
@ -2274,8 +2253,7 @@ void Inf_ReceivePagInfo (void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
|
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
|
||||||
"%s/index.htm",
|
"%s/index.htm",PathRelDirHTML);
|
||||||
PathRelDirHTML);
|
|
||||||
if (Fil_CheckIfPathExists (PathRelFileHTML))
|
if (Fil_CheckIfPathExists (PathRelFileHTML))
|
||||||
{
|
{
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_unzipped_successfully);
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_unzipped_successfully);
|
||||||
|
|
|
@ -646,8 +646,8 @@ void Ins_GetBasicListOfInstitutions (long CtyCod)
|
||||||
Gbl.Hierarchy.Inss.Num = (unsigned) NumRows;
|
Gbl.Hierarchy.Inss.Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with institutions *****/
|
/***** Create list with institutions *****/
|
||||||
if ((Gbl.Hierarchy.Inss.Lst = (struct Ins_Instit *)
|
if ((Gbl.Hierarchy.Inss.Lst = calloc (NumRows,
|
||||||
calloc (NumRows,sizeof (struct Ins_Instit))) == NULL)
|
sizeof (*Gbl.Hierarchy.Inss.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the institutions *****/
|
/***** Get the institutions *****/
|
||||||
|
@ -730,8 +730,8 @@ void Ins_GetFullListOfInstitutions (long CtyCod)
|
||||||
Gbl.Hierarchy.Inss.Num = (unsigned) NumRows;
|
Gbl.Hierarchy.Inss.Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with institutions *****/
|
/***** Create list with institutions *****/
|
||||||
if ((Gbl.Hierarchy.Inss.Lst = (struct Ins_Instit *)
|
if ((Gbl.Hierarchy.Inss.Lst = calloc (NumRows,
|
||||||
calloc (NumRows,sizeof (struct Ins_Instit))) == NULL)
|
sizeof (*Gbl.Hierarchy.Inss.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the institutions *****/
|
/***** Get the institutions *****/
|
||||||
|
@ -849,16 +849,13 @@ static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row)
|
||||||
Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]);
|
Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||||
|
|
||||||
/***** Get the short name of the institution (row[4]) *****/
|
/***** Get the short name of the institution (row[4]) *****/
|
||||||
Str_Copy (Ins->ShrtName,row[4],
|
Str_Copy (Ins->ShrtName,row[4],sizeof (Ins->ShrtName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
|
||||||
|
|
||||||
/***** Get the full name of the institution (row[5]) *****/
|
/***** Get the full name of the institution (row[5]) *****/
|
||||||
Str_Copy (Ins->FullName,row[5],
|
Str_Copy (Ins->FullName,row[5],sizeof (Ins->FullName) - 1);
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
|
||||||
|
|
||||||
/***** Get the URL of the institution (row[6]) *****/
|
/***** Get the URL of the institution (row[6]) *****/
|
||||||
Str_Copy (Ins->WWW,row[6],
|
Str_Copy (Ins->WWW ,row[6],sizeof (Ins->WWW ) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -887,7 +884,7 @@ void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins)
|
||||||
if (Ins->InsCod == Gbl.Cache.InstitutionShrtName.InsCod)
|
if (Ins->InsCod == Gbl.Cache.InstitutionShrtName.InsCod)
|
||||||
{
|
{
|
||||||
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtName.ShrtName,
|
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtName.ShrtName,
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
sizeof (Ins->ShrtName) - 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,7 +901,7 @@ void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins)
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
Str_Copy (Gbl.Cache.InstitutionShrtName.ShrtName,row[0],
|
Str_Copy (Gbl.Cache.InstitutionShrtName.ShrtName,row[0],
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
sizeof (Gbl.Cache.InstitutionShrtName.ShrtName) - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Gbl.Cache.InstitutionShrtName.ShrtName[0] = '\0';
|
Gbl.Cache.InstitutionShrtName.ShrtName[0] = '\0';
|
||||||
|
@ -913,7 +910,7 @@ void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins)
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtName.ShrtName,
|
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtName.ShrtName,
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
sizeof (Ins->ShrtName) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -946,7 +943,7 @@ static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins,
|
||||||
if (Ins->InsCod == Gbl.Cache.InstitutionShrtNameAndCty.InsCod)
|
if (Ins->InsCod == Gbl.Cache.InstitutionShrtNameAndCty.InsCod)
|
||||||
{
|
{
|
||||||
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,
|
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
sizeof (Ins->ShrtName) - 1);
|
||||||
Str_Copy (CtyName,Gbl.Cache.InstitutionShrtNameAndCty.CtyName,
|
Str_Copy (CtyName,Gbl.Cache.InstitutionShrtNameAndCty.CtyName,
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
||||||
return;
|
return;
|
||||||
|
@ -968,11 +965,11 @@ static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins,
|
||||||
|
|
||||||
/* Get the short name of this institution (row[0]) */
|
/* Get the short name of this institution (row[0]) */
|
||||||
Str_Copy (Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,row[0],
|
Str_Copy (Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,row[0],
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
sizeof (Gbl.Cache.InstitutionShrtNameAndCty.ShrtName) - 1);
|
||||||
|
|
||||||
/* Get the name of the country (row[1]) */
|
/* Get the name of the country (row[1]) */
|
||||||
Str_Copy (Gbl.Cache.InstitutionShrtNameAndCty.CtyName,row[1],
|
Str_Copy (Gbl.Cache.InstitutionShrtNameAndCty.CtyName,row[1],
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
sizeof (Gbl.Cache.InstitutionShrtNameAndCty.CtyName) - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -984,7 +981,7 @@ static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins,
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,
|
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
sizeof (Ins->ShrtName) - 1);
|
||||||
Str_Copy (CtyName,Gbl.Cache.InstitutionShrtNameAndCty.CtyName,
|
Str_Copy (CtyName,Gbl.Cache.InstitutionShrtNameAndCty.CtyName,
|
||||||
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
||||||
}
|
}
|
||||||
|
@ -1176,8 +1173,7 @@ static void Ins_ListInstitutionsForEdition (void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Str_Copy (WWW,Ins->WWW,
|
Str_Copy (WWW,Ins->WWW,sizeof (WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\"");
|
HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\"");
|
||||||
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\"",
|
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\"",
|
||||||
Ins->WWW,Ins->WWW);
|
Ins->WWW,Ins->WWW);
|
||||||
|
@ -1393,11 +1389,10 @@ void Ins_RemoveInstitution (void)
|
||||||
Brw_RemoveInsFilesFromDB (Ins_EditingIns->InsCod);
|
Brw_RemoveInsFilesFromDB (Ins_EditingIns->InsCod);
|
||||||
|
|
||||||
/***** Remove directories of the institution *****/
|
/***** Remove directories of the institution *****/
|
||||||
snprintf (PathIns,sizeof (PathIns),
|
snprintf (PathIns,sizeof (PathIns),"%s/%02u/%u",
|
||||||
"%s/%02u/%u",
|
|
||||||
Cfg_PATH_INS_PUBLIC,
|
Cfg_PATH_INS_PUBLIC,
|
||||||
(unsigned) (Ins_EditingIns->InsCod % 100),
|
(unsigned) (Ins_EditingIns->InsCod % 100),
|
||||||
(unsigned) Ins_EditingIns->InsCod);
|
(unsigned) Ins_EditingIns->InsCod);
|
||||||
Fil_RemoveTree (PathIns);
|
Fil_RemoveTree (PathIns);
|
||||||
|
|
||||||
/***** Remove institution *****/
|
/***** Remove institution *****/
|
||||||
|
@ -1508,8 +1503,7 @@ void Ins_RenameInstitution (struct Ins_Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFu
|
||||||
CurrentInsName,NewInsName);
|
CurrentInsName,NewInsName);
|
||||||
|
|
||||||
/* Change current institution name in order to display it properly */
|
/* Change current institution name in order to display it properly */
|
||||||
Str_Copy (CurrentInsName,NewInsName,
|
Str_Copy (CurrentInsName,NewInsName,MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // The same name
|
else // The same name
|
||||||
|
@ -1581,8 +1575,7 @@ void Ins_ChangeInsWWW (void)
|
||||||
{
|
{
|
||||||
/***** Update database changing old WWW by new WWW *****/
|
/***** Update database changing old WWW by new WWW *****/
|
||||||
Ins_UpdateInsWWWDB (Ins_EditingIns->InsCod,NewWWW);
|
Ins_UpdateInsWWWDB (Ins_EditingIns->InsCod,NewWWW);
|
||||||
Str_Copy (Ins_EditingIns->WWW,NewWWW,
|
Str_Copy (Ins_EditingIns->WWW,NewWWW,sizeof (Ins_EditingIns->WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
|
|
||||||
/***** Write message to show the change made
|
/***** Write message to show the change made
|
||||||
and put button to go to institution changed *****/
|
and put button to go to institution changed *****/
|
||||||
|
@ -2178,8 +2171,8 @@ static void Ins_EditingInstitutionConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing institution.");
|
Lay_ShowErrorAndExit ("Error initializing institution.");
|
||||||
|
|
||||||
/***** Allocate memory for institution *****/
|
/***** Allocate memory for institution *****/
|
||||||
if ((Ins_EditingIns = (struct Ins_Instit *) malloc (sizeof (struct Ins_Instit))) == NULL)
|
if ((Ins_EditingIns = malloc (sizeof (*Ins_EditingIns))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for institution.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset institution *****/
|
/***** Reset institution *****/
|
||||||
Ins_EditingIns->InsCod = -1L;
|
Ins_EditingIns->InsCod = -1L;
|
||||||
|
|
|
@ -663,8 +663,7 @@ void InsCfg_ChangeInsWWW (void)
|
||||||
{
|
{
|
||||||
/***** Update database changing old WWW by new WWW *****/
|
/***** Update database changing old WWW by new WWW *****/
|
||||||
Ins_UpdateInsWWWDB (Gbl.Hierarchy.Ins.InsCod,NewWWW);
|
Ins_UpdateInsWWWDB (Gbl.Hierarchy.Ins.InsCod,NewWWW);
|
||||||
Str_Copy (Gbl.Hierarchy.Ins.WWW,NewWWW,
|
Str_Copy (Gbl.Hierarchy.Ins.WWW,NewWWW,sizeof (Gbl.Hierarchy.Ins.WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
|
|
||||||
/***** Write message to show the change made *****/
|
/***** Write message to show the change made *****/
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X,
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X,
|
||||||
|
|
|
@ -909,7 +909,7 @@ static void Lay_WriteScriptParamsAJAX (void)
|
||||||
HTM_TxtF ("var RefreshParamNxtActOldPub = \"act=%ld\";\n"
|
HTM_TxtF ("var RefreshParamNxtActOldPub = \"act=%ld\";\n"
|
||||||
"var RefreshParamUsr = \"OtherUsrCod=%s\";\n",
|
"var RefreshParamUsr = \"OtherUsrCod=%s\";\n",
|
||||||
Act_GetActCod (ActRefOldTL_PubUsr),
|
Act_GetActCod (ActRefOldTL_PubUsr),
|
||||||
Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
break;
|
break;
|
||||||
/* Parameters related with match refreshing (for students) */
|
/* Parameters related with match refreshing (for students) */
|
||||||
case ActJoiMch:
|
case ActJoiMch:
|
||||||
|
|
44
swad_link.c
44
swad_link.c
|
@ -303,7 +303,7 @@ void Lnk_GetListLinks (void)
|
||||||
Gbl.Links.Num = (unsigned) NumRows;
|
Gbl.Links.Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with places *****/
|
/***** Create list with places *****/
|
||||||
if ((Gbl.Links.Lst = (struct Link *) calloc (NumRows,sizeof (struct Link))) == NULL)
|
if ((Gbl.Links.Lst = calloc (NumRows,sizeof (*Gbl.Links.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the links *****/
|
/***** Get the links *****/
|
||||||
|
@ -320,17 +320,11 @@ void Lnk_GetListLinks (void)
|
||||||
if ((Lnk->LnkCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
if ((Lnk->LnkCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of institutional link.");
|
Lay_ShowErrorAndExit ("Wrong code of institutional link.");
|
||||||
|
|
||||||
/* Get the short name of the link (row[1]) */
|
/* Get the short name (row[0]), the full name (row[1])
|
||||||
Str_Copy (Lnk->ShrtName,row[1],
|
and de URL (row[2]) of the link */
|
||||||
Lnk_MAX_BYTES_LINK_SHRT_NAME);
|
Str_Copy (Lnk->ShrtName,row[1],sizeof (Lnk->ShrtName) - 1);
|
||||||
|
Str_Copy (Lnk->FullName,row[2],sizeof (Lnk->FullName) - 1);
|
||||||
/* Get the full name of the link (row[2]) */
|
Str_Copy (Lnk->WWW ,row[3],sizeof (Lnk->WWW ) - 1);
|
||||||
Str_Copy (Lnk->FullName,row[2],
|
|
||||||
Lnk_MAX_BYTES_LINK_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get the URL of the link (row[3]) */
|
|
||||||
Str_Copy (Lnk->WWW,row[3],
|
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -369,17 +363,11 @@ void Lnk_GetDataOfLinkByCod (struct Link *Lnk)
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get the short name of the link (row[0]) */
|
/* Get the short name (row[0]), the full name (row[1])
|
||||||
Str_Copy (Lnk->ShrtName,row[0],
|
and de URL (row[2]) of the link */
|
||||||
Lnk_MAX_BYTES_LINK_SHRT_NAME);
|
Str_Copy (Lnk->ShrtName,row[0],sizeof (Lnk->ShrtName) - 1);
|
||||||
|
Str_Copy (Lnk->FullName,row[1],sizeof (Lnk->FullName) - 1);
|
||||||
/* Get the full name of the link (row[1]) */
|
Str_Copy (Lnk->WWW ,row[2],sizeof (Lnk->WWW ) - 1);
|
||||||
Str_Copy (Lnk->FullName,row[1],
|
|
||||||
Lnk_MAX_BYTES_LINK_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get the URL of the link (row[2]) */
|
|
||||||
Str_Copy (Lnk->WWW,row[2],
|
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -622,8 +610,7 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update name *****/
|
/***** Update name *****/
|
||||||
Str_Copy (CurrentLnkName,NewLnkName,
|
Str_Copy (CurrentLnkName,NewLnkName,MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -692,8 +679,7 @@ void Lnk_ChangeLinkWWW (void)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update web *****/
|
/***** Update web *****/
|
||||||
Str_Copy (Lnk_EditingLnk->WWW,NewWWW,
|
Str_Copy (Lnk_EditingLnk->WWW,NewWWW,sizeof (Lnk_EditingLnk->WWW) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -870,8 +856,8 @@ static void Lnk_EditingLinkConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing link.");
|
Lay_ShowErrorAndExit ("Error initializing link.");
|
||||||
|
|
||||||
/***** Allocate memory for link *****/
|
/***** Allocate memory for link *****/
|
||||||
if ((Lnk_EditingLnk = (struct Link *) malloc (sizeof (struct Link))) == NULL)
|
if ((Lnk_EditingLnk = malloc (sizeof (*Lnk_EditingLnk))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for link.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset link *****/
|
/***** Reset link *****/
|
||||||
Lnk_EditingLnk->LnkCod = -1L;
|
Lnk_EditingLnk->LnkCod = -1L;
|
||||||
|
|
|
@ -132,10 +132,9 @@ void Log_LogAccess (const char *Comments)
|
||||||
if (Comments)
|
if (Comments)
|
||||||
{
|
{
|
||||||
MaxLength = strlen (Comments) * Str_MAX_BYTES_PER_CHAR;
|
MaxLength = strlen (Comments) * Str_MAX_BYTES_PER_CHAR;
|
||||||
if ((CommentsDB = (char *) malloc (MaxLength + 1)) != NULL)
|
if ((CommentsDB = malloc (MaxLength + 1)) != NULL)
|
||||||
{
|
{
|
||||||
Str_Copy (CommentsDB,Comments,
|
Str_Copy (CommentsDB,Comments,MaxLength);
|
||||||
MaxLength);
|
|
||||||
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_TEXT,
|
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_TEXT,
|
||||||
CommentsDB,MaxLength,true); // Avoid SQL injection
|
CommentsDB,MaxLength,true); // Avoid SQL injection
|
||||||
DB_QueryINSERT ("can not log access (comments)",
|
DB_QueryINSERT ("can not log access (comments)",
|
||||||
|
|
69
swad_logo.c
69
swad_logo.c
|
@ -106,12 +106,11 @@ void Lgo_DrawLogo (Hie_Lvl_Level_t Scope,long Cod,const char *AltText,
|
||||||
{
|
{
|
||||||
Folder = Cfg_FOLDER_DEG;
|
Folder = Cfg_FOLDER_DEG;
|
||||||
DegCod = Cod;
|
DegCod = Cod;
|
||||||
snprintf (PathLogo,sizeof (PathLogo),
|
snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png",
|
||||||
"%s/%02u/%u/logo/%u.png",
|
|
||||||
Cfg_PATH_DEG_PUBLIC,
|
Cfg_PATH_DEG_PUBLIC,
|
||||||
(unsigned) (DegCod % 100),
|
(unsigned) (DegCod % 100),
|
||||||
(unsigned) DegCod,
|
(unsigned) DegCod,
|
||||||
(unsigned) DegCod);
|
(unsigned) DegCod);
|
||||||
LogoFound = Fil_CheckIfPathExists (PathLogo);
|
LogoFound = Fil_CheckIfPathExists (PathLogo);
|
||||||
if (LogoFound)
|
if (LogoFound)
|
||||||
Cod = DegCod;
|
Cod = DegCod;
|
||||||
|
@ -125,12 +124,11 @@ void Lgo_DrawLogo (Hie_Lvl_Level_t Scope,long Cod,const char *AltText,
|
||||||
CtrCod = Deg_GetCtrCodOfDegreeByCod (Cod);
|
CtrCod = Deg_GetCtrCodOfDegreeByCod (Cod);
|
||||||
else
|
else
|
||||||
CtrCod = Cod;
|
CtrCod = Cod;
|
||||||
snprintf (PathLogo,sizeof (PathLogo),
|
snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png",
|
||||||
"%s/%02u/%u/logo/%u.png",
|
|
||||||
Cfg_PATH_CTR_PUBLIC,
|
Cfg_PATH_CTR_PUBLIC,
|
||||||
(unsigned) (CtrCod % 100),
|
(unsigned) (CtrCod % 100),
|
||||||
(unsigned) CtrCod,
|
(unsigned) CtrCod,
|
||||||
(unsigned) CtrCod);
|
(unsigned) CtrCod);
|
||||||
LogoFound = Fil_CheckIfPathExists (PathLogo);
|
LogoFound = Fil_CheckIfPathExists (PathLogo);
|
||||||
if (LogoFound)
|
if (LogoFound)
|
||||||
Cod = CtrCod;
|
Cod = CtrCod;
|
||||||
|
@ -146,12 +144,11 @@ void Lgo_DrawLogo (Hie_Lvl_Level_t Scope,long Cod,const char *AltText,
|
||||||
InsCod = Ctr_GetInsCodOfCentreByCod (Cod);
|
InsCod = Ctr_GetInsCodOfCentreByCod (Cod);
|
||||||
else
|
else
|
||||||
InsCod = Cod;
|
InsCod = Cod;
|
||||||
snprintf (PathLogo,sizeof (PathLogo),
|
snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png",
|
||||||
"%s/%02u/%u/logo/%u.png",
|
|
||||||
Cfg_PATH_INS_PUBLIC,
|
Cfg_PATH_INS_PUBLIC,
|
||||||
(unsigned) (InsCod % 100),
|
(unsigned) (InsCod % 100),
|
||||||
(unsigned) InsCod,
|
(unsigned) InsCod,
|
||||||
(unsigned) InsCod);
|
(unsigned) InsCod);
|
||||||
LogoFound = Fil_CheckIfPathExists (PathLogo);
|
LogoFound = Fil_CheckIfPathExists (PathLogo);
|
||||||
if (LogoFound)
|
if (LogoFound)
|
||||||
Cod = InsCod;
|
Cod = InsCod;
|
||||||
|
@ -233,12 +230,11 @@ void Lgo_PutIconToChangeLogo (Hie_Lvl_Level_t Scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Check if logo exists *****/
|
/***** Check if logo exists *****/
|
||||||
snprintf (PathLogo,sizeof (PathLogo),
|
snprintf (PathLogo,sizeof (PathLogo),"%s/%s/%02u/%u/logo/%u.png",
|
||||||
"%s/%s/%02u/%u/logo/%u.png",
|
|
||||||
Cfg_PATH_SWAD_PUBLIC,Folder,
|
Cfg_PATH_SWAD_PUBLIC,Folder,
|
||||||
(unsigned) (Cod % 100),
|
(unsigned) (Cod % 100),
|
||||||
(unsigned) Cod,
|
(unsigned) Cod,
|
||||||
(unsigned) Cod);
|
(unsigned) Cod);
|
||||||
LogoExists = Fil_CheckIfPathExists (PathLogo);
|
LogoExists = Fil_CheckIfPathExists (PathLogo);
|
||||||
|
|
||||||
/***** Link for changing / uploading the logo *****/
|
/***** Link for changing / uploading the logo *****/
|
||||||
|
@ -291,12 +287,11 @@ void Lgo_RequestLogo (Hie_Lvl_Level_t Scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Check if logo exists *****/
|
/***** Check if logo exists *****/
|
||||||
snprintf (PathLogo,sizeof (PathLogo),
|
snprintf (PathLogo,sizeof (PathLogo),"%s/%s/%02u/%u/logo/%u.png",
|
||||||
"%s/%s/%02u/%u/logo/%u.png",
|
|
||||||
Cfg_PATH_SWAD_PUBLIC,Folder,
|
Cfg_PATH_SWAD_PUBLIC,Folder,
|
||||||
(unsigned) (Cod % 100),
|
(unsigned) (Cod % 100),
|
||||||
(unsigned) Cod,
|
(unsigned) Cod,
|
||||||
(unsigned) Cod);
|
(unsigned) Cod);
|
||||||
if (!Fil_CheckIfPathExists (PathLogo))
|
if (!Fil_CheckIfPathExists (PathLogo))
|
||||||
FunctionToDrawContextualIcons = NULL;
|
FunctionToDrawContextualIcons = NULL;
|
||||||
|
|
||||||
|
@ -393,26 +388,18 @@ void Lgo_ReceiveLogo (Hie_Lvl_Level_t Scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Creates directories if not exist *****/
|
/***** Creates directories if not exist *****/
|
||||||
snprintf (Path,sizeof (Path),
|
snprintf (Path,sizeof (Path),"%s/%s",Cfg_PATH_SWAD_PUBLIC,Folder);
|
||||||
"%s/%s",
|
|
||||||
Cfg_PATH_SWAD_PUBLIC,Folder);
|
|
||||||
Fil_CreateDirIfNotExists (Path);
|
Fil_CreateDirIfNotExists (Path);
|
||||||
snprintf (Path,sizeof (Path),
|
snprintf (Path,sizeof (Path),"%s/%s/%02u",Cfg_PATH_SWAD_PUBLIC,Folder,
|
||||||
"%s/%s/%02u",
|
|
||||||
Cfg_PATH_SWAD_PUBLIC,Folder,
|
|
||||||
(unsigned) (Cod % 100));
|
(unsigned) (Cod % 100));
|
||||||
Fil_CreateDirIfNotExists (Path);
|
Fil_CreateDirIfNotExists (Path);
|
||||||
snprintf (Path,sizeof (Path),
|
snprintf (Path,sizeof (Path),"%s/%s/%02u/%u",Cfg_PATH_SWAD_PUBLIC,Folder,
|
||||||
"%s/%s/%02u/%u",
|
|
||||||
Cfg_PATH_SWAD_PUBLIC,Folder,
|
|
||||||
(unsigned) (Cod % 100),
|
(unsigned) (Cod % 100),
|
||||||
(unsigned) Cod);
|
(unsigned) Cod);
|
||||||
Fil_CreateDirIfNotExists (Path);
|
Fil_CreateDirIfNotExists (Path);
|
||||||
snprintf (Path,sizeof (Path),
|
snprintf (Path,sizeof (Path),"%s/%s/%02u/%u/logo",Cfg_PATH_SWAD_PUBLIC,Folder,
|
||||||
"%s/%s/%02u/%u/logo",
|
|
||||||
Cfg_PATH_SWAD_PUBLIC,Folder,
|
|
||||||
(unsigned) (Cod % 100),
|
(unsigned) (Cod % 100),
|
||||||
(unsigned) Cod);
|
(unsigned) Cod);
|
||||||
Fil_CreateDirIfNotExists (Path);
|
Fil_CreateDirIfNotExists (Path);
|
||||||
|
|
||||||
/***** Copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/
|
/***** Copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/
|
||||||
|
@ -432,12 +419,11 @@ void Lgo_ReceiveLogo (Hie_Lvl_Level_t Scope)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* End the reception of logo in a temporary file */
|
/* End the reception of logo in a temporary file */
|
||||||
snprintf (FileNameLogo,sizeof (FileNameLogo),
|
snprintf (FileNameLogo,sizeof (FileNameLogo),"%s/%s/%02u/%u/logo/%u.png",
|
||||||
"%s/%s/%02u/%u/logo/%u.png",
|
|
||||||
Cfg_PATH_SWAD_PUBLIC,Folder,
|
Cfg_PATH_SWAD_PUBLIC,Folder,
|
||||||
(unsigned) (Cod % 100),
|
(unsigned) (Cod % 100),
|
||||||
(unsigned) Cod,
|
(unsigned) Cod,
|
||||||
(unsigned) Cod);
|
(unsigned) Cod);
|
||||||
if (!Fil_EndReceptionOfFile (FileNameLogo,Param))
|
if (!Fil_EndReceptionOfFile (FileNameLogo,Param))
|
||||||
Ale_ShowAlert (Ale_ERROR,"Error copying file.");
|
Ale_ShowAlert (Ale_ERROR,"Error copying file.");
|
||||||
}
|
}
|
||||||
|
@ -473,11 +459,10 @@ void Lgo_RemoveLogo (Hie_Lvl_Level_t Scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Remove logo *****/
|
/***** Remove logo *****/
|
||||||
snprintf (FileNameLogo,sizeof (FileNameLogo),
|
snprintf (FileNameLogo,sizeof (FileNameLogo),"%s/%s/%02u/%u/logo/%u.png",
|
||||||
"%s/%s/%02u/%u/logo/%u.png",
|
|
||||||
Cfg_PATH_SWAD_PUBLIC,Folder,
|
Cfg_PATH_SWAD_PUBLIC,Folder,
|
||||||
(unsigned) (Cod % 100),
|
(unsigned) (Cod % 100),
|
||||||
(unsigned) Cod,
|
(unsigned) Cod,
|
||||||
(unsigned) Cod);
|
(unsigned) Cod);
|
||||||
Fil_RemoveTree (FileNameLogo);
|
Fil_RemoveTree (FileNameLogo);
|
||||||
}
|
}
|
||||||
|
|
65
swad_mail.c
65
swad_mail.c
|
@ -301,7 +301,7 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
||||||
Gbl.Mails.Num = (unsigned) NumRows;
|
Gbl.Mails.Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with places *****/
|
/***** Create list with places *****/
|
||||||
if ((Gbl.Mails.Lst = (struct Mail *) calloc (NumRows,sizeof (struct Mail))) == NULL)
|
if ((Gbl.Mails.Lst = calloc (NumRows,sizeof (*Gbl.Mails.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the mail domains *****/
|
/***** Get the mail domains *****/
|
||||||
|
@ -318,13 +318,9 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
||||||
if ((Mai->MaiCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
if ((Mai->MaiCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of mail domain.");
|
Lay_ShowErrorAndExit ("Wrong code of mail domain.");
|
||||||
|
|
||||||
/* Get the mail domain (row[1]) */
|
/* Get the mail domain (row[1]) and the mail domain info (row[2]) */
|
||||||
Str_Copy (Mai->Domain,row[1],
|
Str_Copy (Mai->Domain,row[1],sizeof (Mai->Domain) - 1);
|
||||||
Cns_MAX_BYTES_EMAIL_ADDRESS);
|
Str_Copy (Mai->Info ,row[2],sizeof (Mai->Info ) - 1);
|
||||||
|
|
||||||
/* Get the mail domain info (row[2]) */
|
|
||||||
Str_Copy (Mai->Info,row[2],
|
|
||||||
Mai_MAX_BYTES_MAIL_INFO);
|
|
||||||
|
|
||||||
/* Get number of users (row[3]) */
|
/* Get number of users (row[3]) */
|
||||||
if (sscanf (row[3],"%u",&(Mai->NumUsrs)) != 1)
|
if (sscanf (row[3],"%u",&(Mai->NumUsrs)) != 1)
|
||||||
|
@ -374,8 +370,7 @@ static void Mai_GetMailDomain (const char *Email,char MailDomain[Cns_MAX_BYTES_E
|
||||||
{
|
{
|
||||||
Ptr++; // Skip '@'
|
Ptr++; // Skip '@'
|
||||||
if (strchr (Ptr,(int) '@') == NULL) // No more '@' found
|
if (strchr (Ptr,(int) '@') == NULL) // No more '@' found
|
||||||
Str_Copy (MailDomain,Ptr,
|
Str_Copy (MailDomain,Ptr,Cns_MAX_BYTES_EMAIL_ADDRESS);
|
||||||
Cns_MAX_BYTES_EMAIL_ADDRESS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,13 +437,9 @@ void Mai_GetDataOfMailDomainByCod (struct Mail *Mai)
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get the short name of the mail (row[0]) */
|
/* Get the short & full name of the mail (row[0], row[1]) */
|
||||||
Str_Copy (Mai->Domain,row[0],
|
Str_Copy (Mai->Domain,row[0],sizeof (Mai->Domain) - 1);
|
||||||
Cns_MAX_BYTES_EMAIL_ADDRESS);
|
Str_Copy (Mai->Info ,row[1],sizeof (Mai->Info ) - 1);
|
||||||
|
|
||||||
/* Get the full name of the mail (row[1]) */
|
|
||||||
Str_Copy (Mai->Info,row[1],
|
|
||||||
Mai_MAX_BYTES_MAIL_INFO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -691,8 +682,7 @@ static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update name *****/
|
/***** Update name *****/
|
||||||
Str_Copy (CurrentMaiName,NewMaiName,
|
Str_Copy (CurrentMaiName,NewMaiName,MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -944,7 +934,7 @@ static void Mai_ListEmails (__attribute__((unused)) void *Args)
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
/* Get next user */
|
/* Get next user */
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
||||||
|
|
||||||
|
@ -966,14 +956,12 @@ static void Mai_ListEmails (__attribute__((unused)) void *Args)
|
||||||
LengthStrAddr ++;
|
LengthStrAddr ++;
|
||||||
if (LengthStrAddr > Mai_MAX_BYTES_STR_ADDR)
|
if (LengthStrAddr > Mai_MAX_BYTES_STR_ADDR)
|
||||||
Lay_ShowErrorAndExit ("The space allocated to store email addresses is full.");
|
Lay_ShowErrorAndExit ("The space allocated to store email addresses is full.");
|
||||||
Str_Concat (StrAddresses,",",
|
Str_Concat (StrAddresses,",",sizeof (StrAddresses) - 1);
|
||||||
Mai_MAX_BYTES_STR_ADDR);
|
|
||||||
}
|
}
|
||||||
LengthStrAddr += strlen (UsrDat.Email);
|
LengthStrAddr += strlen (UsrDat.Email);
|
||||||
if (LengthStrAddr > Mai_MAX_BYTES_STR_ADDR)
|
if (LengthStrAddr > Mai_MAX_BYTES_STR_ADDR)
|
||||||
Lay_ShowErrorAndExit ("The space allocated to store email addresses is full.");
|
Lay_ShowErrorAndExit ("The space allocated to store email addresses is full.");
|
||||||
Str_Concat (StrAddresses,UsrDat.Email,
|
Str_Concat (StrAddresses,UsrDat.Email,sizeof (StrAddresses) - 1);
|
||||||
Mai_MAX_BYTES_STR_ADDR);
|
|
||||||
HTM_A_Begin ("href=\"mailto:%s?subject=%s\"",
|
HTM_A_Begin ("href=\"mailto:%s?subject=%s\"",
|
||||||
UsrDat.Email,Gbl.Hierarchy.Crs.FullName);
|
UsrDat.Email,Gbl.Hierarchy.Crs.FullName);
|
||||||
HTM_Txt (UsrDat.Email);
|
HTM_Txt (UsrDat.Email);
|
||||||
|
@ -1099,8 +1087,7 @@ bool Mai_GetEmailFromUsrCod (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
/* Get email */
|
/* Get email */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (UsrDat->Email,row[0],
|
Str_Copy (UsrDat->Email,row[0],sizeof (UsrDat->Email) - 1);
|
||||||
Cns_MAX_BYTES_EMAIL_ADDRESS);
|
|
||||||
UsrDat->EmailConfirmed = (row[1][0] == 'Y');
|
UsrDat->EmailConfirmed = (row[1][0] == 'Y');
|
||||||
Found = true;
|
Found = true;
|
||||||
}
|
}
|
||||||
|
@ -1169,9 +1156,7 @@ void Mai_ShowFormChangeMyEmail (bool IMustFillInEmail,bool IShouldConfirmEmail)
|
||||||
HTM_SECTION_Begin (Mai_EMAIL_SECTION_ID);
|
HTM_SECTION_Begin (Mai_EMAIL_SECTION_ID);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
|
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
|
||||||
"%upx",
|
|
||||||
Rec_RECORD_WIDTH);
|
|
||||||
Box_BoxBegin (StrRecordWidth,Txt_Email,
|
Box_BoxBegin (StrRecordWidth,Txt_Email,
|
||||||
Acc_PutLinkToRemoveMyAccount,NULL,
|
Acc_PutLinkToRemoveMyAccount,NULL,
|
||||||
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
|
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
|
||||||
|
@ -1202,9 +1187,7 @@ void Mai_ShowFormChangeOtherUsrEmail (void)
|
||||||
HTM_SECTION_Begin (Mai_EMAIL_SECTION_ID);
|
HTM_SECTION_Begin (Mai_EMAIL_SECTION_ID);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
|
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
|
||||||
"%upx",
|
|
||||||
Rec_RECORD_WIDTH);
|
|
||||||
Box_BoxBegin (StrRecordWidth,Txt_Email,
|
Box_BoxBegin (StrRecordWidth,Txt_Email,
|
||||||
NULL,NULL,
|
NULL,NULL,
|
||||||
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
|
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
|
||||||
|
@ -1359,7 +1342,7 @@ static void Mai_ShowFormChangeUsrEmail (bool ItsMe,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Frm_StartFormAnchor (NextAction,Mai_EMAIL_SECTION_ID);
|
Frm_StartFormAnchor (NextAction,Mai_EMAIL_SECTION_ID);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
}
|
}
|
||||||
Par_PutHiddenParamString (NULL,"NewEmail",row[0]);
|
Par_PutHiddenParamString (NULL,"NewEmail",row[0]);
|
||||||
Btn_PutConfirmButtonInline ((ItsMe && NumEmail == 1) ? Txt_Confirm_email :
|
Btn_PutConfirmButtonInline ((ItsMe && NumEmail == 1) ? Txt_Confirm_email :
|
||||||
|
@ -1405,7 +1388,7 @@ static void Mai_ShowFormChangeUsrEmail (bool ItsMe,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Frm_StartFormAnchor (NextAction,Mai_EMAIL_SECTION_ID);
|
Frm_StartFormAnchor (NextAction,Mai_EMAIL_SECTION_ID);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
}
|
}
|
||||||
HTM_INPUT_EMAIL ("NewEmail",Cns_MAX_CHARS_EMAIL_ADDRESS,Gbl.Usrs.Me.UsrDat.Email,
|
HTM_INPUT_EMAIL ("NewEmail",Cns_MAX_CHARS_EMAIL_ADDRESS,Gbl.Usrs.Me.UsrDat.Email,
|
||||||
"id=\"NewEmail\" size=\"18\"");
|
"id=\"NewEmail\" size=\"18\"");
|
||||||
|
@ -1431,7 +1414,7 @@ static void Mai_PutParamsRemoveOtherEmail (void *Email)
|
||||||
{
|
{
|
||||||
if (Email)
|
if (Email)
|
||||||
{
|
{
|
||||||
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
Par_PutHiddenParamString (NULL,"Email",Email);
|
Par_PutHiddenParamString (NULL,"Email",Email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1792,8 +1775,7 @@ void Mai_ConfirmEmail (void)
|
||||||
UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
|
||||||
/* Get user's email */
|
/* Get user's email */
|
||||||
Str_Copy (Email,row[1],
|
Str_Copy (Email,row[1],sizeof (Email) - 1);
|
||||||
Cns_MAX_BYTES_EMAIL_ADDRESS);
|
|
||||||
|
|
||||||
KeyIsCorrect = true;
|
KeyIsCorrect = true;
|
||||||
}
|
}
|
||||||
|
@ -1861,8 +1843,7 @@ void Mai_ConfirmEmail (void)
|
||||||
|
|
||||||
void Mai_CreateFileNameMail (char FileNameMail[PATH_MAX + 1],FILE **FileMail)
|
void Mai_CreateFileNameMail (char FileNameMail[PATH_MAX + 1],FILE **FileMail)
|
||||||
{
|
{
|
||||||
snprintf (FileNameMail,PATH_MAX + 1,
|
snprintf (FileNameMail,PATH_MAX + 1,"%s/%s_mail.txt",
|
||||||
"%s/%s_mail.txt",
|
|
||||||
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
||||||
if ((*FileMail = fopen (FileNameMail,"wb")) == NULL)
|
if ((*FileMail = fopen (FileNameMail,"wb")) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Can not open file to send email.");
|
Lay_ShowErrorAndExit ("Can not open file to send email.");
|
||||||
|
@ -1879,7 +1860,7 @@ void Mai_WriteWelcomeNoteEMail (FILE *FileMail,struct UsrData *UsrDat)
|
||||||
|
|
||||||
fprintf (FileMail,"%s %s:\n",
|
fprintf (FileMail,"%s %s:\n",
|
||||||
Txt_Dear_NO_HTML[UsrDat->Sex][UsrDat->Prefs.Language],
|
Txt_Dear_NO_HTML[UsrDat->Sex][UsrDat->Prefs.Language],
|
||||||
UsrDat->FirstName[0] ? UsrDat->FirstName :
|
UsrDat->FrstName[0] ? UsrDat->FrstName :
|
||||||
Txt_user_NO_HTML[UsrDat->Sex][UsrDat->Prefs.Language]);
|
Txt_user_NO_HTML[UsrDat->Sex][UsrDat->Prefs.Language]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1958,8 +1939,8 @@ static void Mai_EditingMailDomainConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing mail domain.");
|
Lay_ShowErrorAndExit ("Error initializing mail domain.");
|
||||||
|
|
||||||
/***** Allocate memory for mail domain *****/
|
/***** Allocate memory for mail domain *****/
|
||||||
if ((Mai_EditingMai = (struct Mail *) malloc (sizeof (struct Mail))) == NULL)
|
if ((Mai_EditingMai = malloc (sizeof (*Mai_EditingMai))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for mail domain.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset place *****/
|
/***** Reset place *****/
|
||||||
Mai_EditingMai->MaiCod = -1L;
|
Mai_EditingMai->MaiCod = -1L;
|
||||||
|
|
36
swad_mark.c
36
swad_mark.c
|
@ -130,9 +130,7 @@ void Mrk_GetAndWriteNumRowsHeaderAndFooter (void)
|
||||||
Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk);
|
Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk);
|
||||||
HTM_LABEL_Begin (NULL);
|
HTM_LABEL_Begin (NULL);
|
||||||
HTM_TxtF (" %s: ",Txt_TABLE_Header);
|
HTM_TxtF (" %s: ",Txt_TABLE_Header);
|
||||||
snprintf (StrHeadOrFoot,sizeof (StrHeadOrFoot),
|
snprintf (StrHeadOrFoot,sizeof (StrHeadOrFoot),"%u",Marks.Header);
|
||||||
"%u",
|
|
||||||
Marks.Header);
|
|
||||||
HTM_INPUT_TEXT (Mrk_HeadOrFootStr[Brw_HEADER],Cns_MAX_DECIMAL_DIGITS_UINT,StrHeadOrFoot,
|
HTM_INPUT_TEXT (Mrk_HeadOrFootStr[Brw_HEADER],Cns_MAX_DECIMAL_DIGITS_UINT,StrHeadOrFoot,
|
||||||
HTM_SUBMIT_ON_CHANGE,
|
HTM_SUBMIT_ON_CHANGE,
|
||||||
"size=\"1\" class=\"LST_EDIT_ROWS COLOR%u\"",
|
"size=\"1\" class=\"LST_EDIT_ROWS COLOR%u\"",
|
||||||
|
@ -150,9 +148,7 @@ void Mrk_GetAndWriteNumRowsHeaderAndFooter (void)
|
||||||
Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk);
|
Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk);
|
||||||
HTM_LABEL_Begin (NULL);
|
HTM_LABEL_Begin (NULL);
|
||||||
HTM_TxtF (" %s: ",Txt_TABLE_Footer);
|
HTM_TxtF (" %s: ",Txt_TABLE_Footer);
|
||||||
snprintf (StrHeadOrFoot,sizeof (StrHeadOrFoot),
|
snprintf (StrHeadOrFoot,sizeof (StrHeadOrFoot),"%u",Marks.Footer);
|
||||||
"%u",
|
|
||||||
Marks.Footer);
|
|
||||||
HTM_INPUT_TEXT (Mrk_HeadOrFootStr[Brw_FOOTER],Cns_MAX_DECIMAL_DIGITS_UINT,StrHeadOrFoot,
|
HTM_INPUT_TEXT (Mrk_HeadOrFootStr[Brw_FOOTER],Cns_MAX_DECIMAL_DIGITS_UINT,StrHeadOrFoot,
|
||||||
HTM_SUBMIT_ON_CHANGE,
|
HTM_SUBMIT_ON_CHANGE,
|
||||||
"size=\"1\" class=\"LST_EDIT_ROWS COLOR%u\"",
|
"size=\"1\" class=\"LST_EDIT_ROWS COLOR%u\"",
|
||||||
|
@ -599,8 +595,7 @@ void Mrk_ShowMyMarks (void)
|
||||||
|
|
||||||
/***** Get the path of the file of marks *****/
|
/***** Get the path of the file of marks *****/
|
||||||
Brw_SetFullPathInTree ();
|
Brw_SetFullPathInTree ();
|
||||||
snprintf (PathPrivate,sizeof (PathPrivate),
|
snprintf (PathPrivate,sizeof (PathPrivate),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
Gbl.FileBrowser.Priv.PathAboveRootFolder,
|
Gbl.FileBrowser.Priv.PathAboveRootFolder,
|
||||||
Gbl.FileBrowser.FilFolLnk.Full);
|
Gbl.FileBrowser.FilFolLnk.Full);
|
||||||
|
|
||||||
|
@ -646,8 +641,7 @@ void Mrk_ShowMyMarks (void)
|
||||||
Fil_CreateDirIfNotExists (Cfg_PATH_MARK_PRIVATE);
|
Fil_CreateDirIfNotExists (Cfg_PATH_MARK_PRIVATE);
|
||||||
|
|
||||||
/* Create a new temporary file *****/
|
/* Create a new temporary file *****/
|
||||||
snprintf (FileNameUsrMarks,sizeof (FileNameUsrMarks),
|
snprintf (FileNameUsrMarks,sizeof (FileNameUsrMarks),"%s/%s.html",
|
||||||
"%s/%s.html",
|
|
||||||
Cfg_PATH_MARK_PRIVATE,Gbl.UniqueNameEncrypted);
|
Cfg_PATH_MARK_PRIVATE,Gbl.UniqueNameEncrypted);
|
||||||
if ((FileUsrMarks = fopen (FileNameUsrMarks,"wb")) == NULL)
|
if ((FileUsrMarks = fopen (FileNameUsrMarks,"wb")) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Can not open file for my marks.");
|
Lay_ShowErrorAndExit ("Can not open file for my marks.");
|
||||||
|
@ -752,12 +746,11 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
|
|
||||||
/* Path (row[2]) */
|
/* Path (row[2]) */
|
||||||
Str_Copy (FullPathInTreeFromDBMarksTable,row[2],
|
Str_Copy (FullPathInTreeFromDBMarksTable,row[2],
|
||||||
PATH_MAX);
|
sizeof (FullPathInTreeFromDBMarksTable) - 1);
|
||||||
Str_SplitFullPathIntoPathAndFileName (FullPathInTreeFromDBMarksTable,
|
Str_SplitFullPathIntoPathAndFileName (FullPathInTreeFromDBMarksTable,
|
||||||
PathUntilFileName,
|
PathUntilFileName,
|
||||||
FileName);
|
FileName);
|
||||||
Str_Copy (SummaryStr,FileName,
|
Str_Copy (SummaryStr,FileName,Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
|
|
||||||
if (GetContent)
|
if (GetContent)
|
||||||
{
|
{
|
||||||
|
@ -772,13 +765,11 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
if (UsrDat.IDs.Num)
|
if (UsrDat.IDs.Num)
|
||||||
{
|
{
|
||||||
if (GrpCod > 0)
|
if (GrpCod > 0)
|
||||||
snprintf (PathMarks,sizeof (PathMarks),
|
snprintf (PathMarks,sizeof (PathMarks),"%s/%ld/grp/%ld/%s",
|
||||||
"%s/%ld/grp/%ld/%s",
|
|
||||||
Cfg_PATH_CRS_PRIVATE,CrsCod,GrpCod,
|
Cfg_PATH_CRS_PRIVATE,CrsCod,GrpCod,
|
||||||
FullPathInTreeFromDBMarksTable);
|
FullPathInTreeFromDBMarksTable);
|
||||||
else
|
else
|
||||||
snprintf (PathMarks,sizeof (PathMarks),
|
snprintf (PathMarks,sizeof (PathMarks),"%s/%ld/%s",
|
||||||
"%s/%ld/%s",
|
|
||||||
Cfg_PATH_CRS_PRIVATE,CrsCod,
|
Cfg_PATH_CRS_PRIVATE,CrsCod,
|
||||||
FullPathInTreeFromDBMarksTable);
|
FullPathInTreeFromDBMarksTable);
|
||||||
|
|
||||||
|
@ -787,8 +778,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
Fil_CreateDirIfNotExists (Cfg_PATH_MARK_PRIVATE);
|
Fil_CreateDirIfNotExists (Cfg_PATH_MARK_PRIVATE);
|
||||||
|
|
||||||
/* Create a new temporary file *****/
|
/* Create a new temporary file *****/
|
||||||
snprintf (FileNameUsrMarks,sizeof (FileNameUsrMarks),
|
snprintf (FileNameUsrMarks,sizeof (FileNameUsrMarks),"%s/%s.html",
|
||||||
"%s/%s.html",
|
|
||||||
Cfg_PATH_MARK_PRIVATE,Gbl.UniqueNameEncrypted);
|
Cfg_PATH_MARK_PRIVATE,Gbl.UniqueNameEncrypted);
|
||||||
if ((FileUsrMarks = fopen (FileNameUsrMarks,"wb")))
|
if ((FileUsrMarks = fopen (FileNameUsrMarks,"wb")))
|
||||||
{
|
{
|
||||||
|
@ -799,11 +789,10 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
fclose (FileUsrMarks);
|
fclose (FileUsrMarks);
|
||||||
|
|
||||||
Length = 9 + SizeOfMyMarks + 3;
|
Length = 9 + SizeOfMyMarks + 3;
|
||||||
if ((*ContentStr = (char *) malloc (Length + 1)))
|
if ((*ContentStr = malloc (Length + 1)))
|
||||||
{
|
{
|
||||||
/* 9 starting chars */
|
/* 9 starting chars */
|
||||||
Str_Copy (*ContentStr,"<![CDATA[",
|
Str_Copy (*ContentStr,"<![CDATA[",9);
|
||||||
9);
|
|
||||||
|
|
||||||
/* Content */
|
/* Content */
|
||||||
Ptr = (*ContentStr) + 9;
|
Ptr = (*ContentStr) + 9;
|
||||||
|
@ -817,8 +806,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 3 ending chars */
|
/* 3 ending chars */
|
||||||
Str_Copy (Ptr,"]]>",
|
Str_Copy (Ptr,"]]>",3);
|
||||||
3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
23
swad_match.c
23
swad_match.c
|
@ -29,7 +29,6 @@
|
||||||
#include <linux/limits.h> // For PATH_MAX
|
#include <linux/limits.h> // For PATH_MAX
|
||||||
#include <stddef.h> // For NULL
|
#include <stddef.h> // For NULL
|
||||||
#include <stdio.h> // For asprintf
|
#include <stdio.h> // For asprintf
|
||||||
#include <stdlib.h> // For calloc
|
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
|
@ -1022,8 +1021,7 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res,
|
||||||
|
|
||||||
/* Get the title of the match (row[5]) */
|
/* Get the title of the match (row[5]) */
|
||||||
if (row[5])
|
if (row[5])
|
||||||
Str_Copy (Match->Title,row[5],
|
Str_Copy (Match->Title,row[5],sizeof (Match->Title) - 1);
|
||||||
Mch_MAX_BYTES_TITLE);
|
|
||||||
else
|
else
|
||||||
Match->Title[0] = '\0';
|
Match->Title[0] = '\0';
|
||||||
|
|
||||||
|
@ -1878,15 +1876,12 @@ static void Mch_ReorderAnswer (long MchCod,unsigned QstInd,
|
||||||
if ((LongNum = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
if ((LongNum = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||||
Lay_ShowErrorAndExit ("Wrong answer index.");
|
Lay_ShowErrorAndExit ("Wrong answer index.");
|
||||||
AnsInd = (unsigned) LongNum;
|
AnsInd = (unsigned) LongNum;
|
||||||
snprintf (StrOneAnswer,sizeof (StrOneAnswer),
|
snprintf (StrOneAnswer,sizeof (StrOneAnswer),"%u",AnsInd);
|
||||||
"%u",AnsInd);
|
|
||||||
|
|
||||||
/* Concatenate answer index to list of answers */
|
/* Concatenate answer index to list of answers */
|
||||||
if (NumAns)
|
if (NumAns)
|
||||||
Str_Concat (StrAnswersOneQst,",",
|
Str_Concat (StrAnswersOneQst,",",sizeof (StrAnswersOneQst) - 1);
|
||||||
Tst_MAX_BYTES_ANSWERS_ONE_QST);
|
Str_Concat (StrAnswersOneQst,StrOneAnswer,sizeof (StrAnswersOneQst) - 1);
|
||||||
Str_Concat (StrAnswersOneQst,StrOneAnswer,
|
|
||||||
Tst_MAX_BYTES_ANSWERS_ONE_QST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -1922,8 +1917,7 @@ void Mch_GetIndexes (long MchCod,unsigned QstInd,
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get indexes (row[0]) */
|
/* Get indexes (row[0]) */
|
||||||
Str_Copy (StrIndexesOneQst,row[0],
|
Str_Copy (StrIndexesOneQst,row[0],sizeof (StrIndexesOneQst) - 1);
|
||||||
Tst_MAX_BYTES_INDEXES_ONE_QST);
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -4283,14 +4277,15 @@ void Mch_GetMatchQuestionsFromDB (struct MchPrn_Print *Print)
|
||||||
|
|
||||||
/* Get indexes for this question (row[2]) */
|
/* Get indexes for this question (row[2]) */
|
||||||
Str_Copy (Print->PrintedQuestions[NumQst].StrIndexes,row[2],
|
Str_Copy (Print->PrintedQuestions[NumQst].StrIndexes,row[2],
|
||||||
Tst_MAX_BYTES_INDEXES_ONE_QST);
|
sizeof (Print->PrintedQuestions[NumQst].StrIndexes) - 1);
|
||||||
|
|
||||||
/* Get answers selected by user for this question */
|
/* Get answers selected by user for this question */
|
||||||
Mch_GetQstAnsFromDB (Print->MchCod,Print->UsrCod,QstInd,&UsrAnswer);
|
Mch_GetQstAnsFromDB (Print->MchCod,Print->UsrCod,QstInd,&UsrAnswer);
|
||||||
if (UsrAnswer.AnsInd >= 0) // UsrAnswer.AnsInd >= 0 ==> answer selected
|
if (UsrAnswer.AnsInd >= 0) // UsrAnswer.AnsInd >= 0 ==> answer selected
|
||||||
{
|
{
|
||||||
snprintf (Print->PrintedQuestions[NumQst].StrAnswers,Tst_MAX_BYTES_ANSWERS_ONE_QST + 1,
|
snprintf (Print->PrintedQuestions[NumQst].StrAnswers,
|
||||||
"%d",UsrAnswer.AnsInd);
|
sizeof (Print->PrintedQuestions[NumQst].StrAnswers),
|
||||||
|
"%d",UsrAnswer.AnsInd);
|
||||||
Print->NumQsts.NotBlank++;
|
Print->NumQsts.NotBlank++;
|
||||||
}
|
}
|
||||||
else // UsrAnswer.AnsInd < 0 ==> no answer selected
|
else // UsrAnswer.AnsInd < 0 ==> no answer selected
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <linux/limits.h> // For PATH_MAX
|
#include <linux/limits.h> // For PATH_MAX
|
||||||
#include <stddef.h> // For NULL
|
#include <stddef.h> // For NULL
|
||||||
#include <stdio.h> // For asprintf
|
#include <stdio.h> // For asprintf
|
||||||
#include <stdlib.h> // For calloc
|
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_action.h"
|
#include "swad_action.h"
|
||||||
|
@ -308,7 +307,7 @@ static void MchRes_ListAllMchResultsInSelectedGames (struct Gam_Games *Games)
|
||||||
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
||||||
|
@ -735,7 +734,7 @@ static void MchRes_BuildGamesSelectedCommas (struct Gam_Games *Games,
|
||||||
|
|
||||||
/***** Allocate memory for subquery of games selected *****/
|
/***** Allocate memory for subquery of games selected *****/
|
||||||
MaxLength = (size_t) Games->NumSelected * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
MaxLength = (size_t) Games->NumSelected * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
||||||
if ((*GamesSelectedCommas = (char *) malloc (MaxLength + 1)) == NULL)
|
if ((*GamesSelectedCommas = malloc (MaxLength + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Build subquery with list of selected games *****/
|
/***** Build subquery with list of selected games *****/
|
||||||
|
@ -1018,7 +1017,7 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games,
|
||||||
case Usr_OTHER:
|
case Usr_OTHER:
|
||||||
Frm_StartForm (ActSeeOneMchResOth);
|
Frm_StartForm (ActSeeOneMchResOth);
|
||||||
Mch_PutParamsEdit (Games);
|
Mch_PutParamsEdit (Games);
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Ico_PutIconLink ("tasks.svg",Txt_Result);
|
Ico_PutIconLink ("tasks.svg",Txt_Result);
|
||||||
|
@ -1233,8 +1232,8 @@ void MchRes_ShowOneMchResult (void)
|
||||||
HTM_TxtF (" %s",UsrDat->Surname1);
|
HTM_TxtF (" %s",UsrDat->Surname1);
|
||||||
if (UsrDat->Surname2[0])
|
if (UsrDat->Surname2[0])
|
||||||
HTM_TxtF (" %s",UsrDat->Surname2);
|
HTM_TxtF (" %s",UsrDat->Surname2);
|
||||||
if (UsrDat->FirstName[0])
|
if (UsrDat->FrstName[0])
|
||||||
HTM_TxtF (", %s",UsrDat->FirstName);
|
HTM_TxtF (", %s",UsrDat->FrstName);
|
||||||
HTM_BR ();
|
HTM_BR ();
|
||||||
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
|
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
|
||||||
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
|
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
|
||||||
|
|
194
swad_media.c
194
swad_media.c
|
@ -292,8 +292,7 @@ void Med_GetMediaDataByCod (struct Med_Media *Media)
|
||||||
Med_STATUS_NONE;
|
Med_STATUS_NONE;
|
||||||
|
|
||||||
/***** Copy media name (row[1]) to struct *****/
|
/***** Copy media name (row[1]) to struct *****/
|
||||||
Str_Copy (Media->Name,row[1],
|
Str_Copy (Media->Name,row[1],sizeof (Media->Name) - 1);
|
||||||
Med_BYTES_NAME);
|
|
||||||
|
|
||||||
/***** Copy media URL (row[2]) to struct *****/
|
/***** Copy media URL (row[2]) to struct *****/
|
||||||
// Media->URL can be empty or filled with previous value
|
// Media->URL can be empty or filled with previous value
|
||||||
|
@ -306,10 +305,9 @@ void Med_GetMediaDataByCod (struct Med_Media *Media)
|
||||||
if (Length > Cns_MAX_BYTES_WWW)
|
if (Length > Cns_MAX_BYTES_WWW)
|
||||||
Length = Cns_MAX_BYTES_WWW;
|
Length = Cns_MAX_BYTES_WWW;
|
||||||
|
|
||||||
if ((Media->URL = (char *) malloc (Length + 1)) == NULL)
|
if ((Media->URL = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for media URL.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (Media->URL,row[2],
|
Str_Copy (Media->URL,row[2],Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Copy media title (row[3]) to struct *****/
|
/***** Copy media title (row[3]) to struct *****/
|
||||||
|
@ -323,10 +321,9 @@ void Med_GetMediaDataByCod (struct Med_Media *Media)
|
||||||
if (Length > Med_MAX_BYTES_TITLE)
|
if (Length > Med_MAX_BYTES_TITLE)
|
||||||
Length = Med_MAX_BYTES_TITLE;
|
Length = Med_MAX_BYTES_TITLE;
|
||||||
|
|
||||||
if ((Media->Title = (char *) malloc (Length + 1)) == NULL)
|
if ((Media->Title = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for media title.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (Media->Title,row[3],
|
Str_Copy (Media->Title,row[3],Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -340,7 +337,7 @@ void Med_GetMediaDataByCod (struct Med_Media *Media)
|
||||||
/********* Draw input fields to upload an image/video inside a form **********/
|
/********* Draw input fields to upload an image/video inside a form **********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Med_PutMediaUploader (int NumMediaInForm,const char *ClassInput)
|
void Med_PutMediaUploader (int NumMedia,const char *ClassInput)
|
||||||
{
|
{
|
||||||
extern const char *Hlp_Multimedia;
|
extern const char *Hlp_Multimedia;
|
||||||
extern const char *Txt_Multimedia;
|
extern const char *Txt_Multimedia;
|
||||||
|
@ -380,7 +377,7 @@ void Med_PutMediaUploader (int NumMediaInForm,const char *ClassInput)
|
||||||
};
|
};
|
||||||
|
|
||||||
/***** Set names of parameters depending on number of media in form *****/
|
/***** Set names of parameters depending on number of media in form *****/
|
||||||
Med_SetParamNames (&ParamUploadMedia,NumMediaInForm);
|
Med_SetParamNames (&ParamUploadMedia,NumMedia);
|
||||||
|
|
||||||
/***** Create unique id for this media uploader *****/
|
/***** Create unique id for this media uploader *****/
|
||||||
Frm_SetUniqueId (Id);
|
Frm_SetUniqueId (Id);
|
||||||
|
@ -507,11 +504,11 @@ static void Med_PutHiddenFormTypeMediaUploader (const char UniqueId[Frm_MAX_BYTE
|
||||||
/******************** Get media (image/video) from form **********************/
|
/******************** Get media (image/video) from form **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Media constructor must be called before calling this function
|
// Media constructor must be called before calling this function
|
||||||
// If NumMediaInForm < 0, params have no suffix
|
// If NumMedia < 0, params have no suffix
|
||||||
// If NumMediaInForm >= 0, the number is a suffix of the params
|
// If NumMedia >= 0, the number is a suffix of the params
|
||||||
|
|
||||||
void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Med_Media *Media,
|
void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMedia,struct Med_Media *Media,
|
||||||
void (*GetMediaFromDB) (long CrsCod,long QstCod,int NumMediaInForm,struct Med_Media *Media),
|
void (*GetMediaFromDB) (long CrsCod,long QstCod,int NumMedia,struct Med_Media *Media),
|
||||||
const char *SectionForAlerts)
|
const char *SectionForAlerts)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Error_sending_or_processing_image_video;
|
extern const char *Txt_Error_sending_or_processing_image_video;
|
||||||
|
@ -520,7 +517,7 @@ void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Med
|
||||||
Med_FormType_t FormType;
|
Med_FormType_t FormType;
|
||||||
|
|
||||||
/***** Set names of parameters depending on number of media in form *****/
|
/***** Set names of parameters depending on number of media in form *****/
|
||||||
Med_SetParamNames (&ParamUploadMedia,NumMediaInForm);
|
Med_SetParamNames (&ParamUploadMedia,NumMedia);
|
||||||
|
|
||||||
/***** Get action and initialize media (image/video)
|
/***** Get action and initialize media (image/video)
|
||||||
(except title, that will be get after the media file) *****/
|
(except title, that will be get after the media file) *****/
|
||||||
|
@ -584,7 +581,7 @@ void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Med
|
||||||
|
|
||||||
/***** Get media name *****/
|
/***** Get media name *****/
|
||||||
if (GetMediaFromDB != NULL)
|
if (GetMediaFromDB != NULL)
|
||||||
GetMediaFromDB (CrsCod,QstCod,NumMediaInForm,Media);
|
GetMediaFromDB (CrsCod,QstCod,NumMedia,Media);
|
||||||
break;
|
break;
|
||||||
default: // Unknown action
|
default: // Unknown action
|
||||||
Media->Action = Med_ACTION_NO_MEDIA;
|
Media->Action = Med_ACTION_NO_MEDIA;
|
||||||
|
@ -595,41 +592,26 @@ void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Med
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********* Set parameters names depending on number of media in form *********/
|
/********* Set parameters names depending on number of media in form *********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// If NumMediaInForm < 0, params have no suffix
|
// If NumMedia < 0, params have no suffix
|
||||||
// If NumMediaInForm >= 0, the number is a suffix of the params
|
// If NumMedia >= 0, the number is a suffix of the params
|
||||||
|
|
||||||
void Med_SetParamNames (struct ParamUploadMedia *ParamUploadMedia,int NumMediaInForm)
|
void Med_SetParamNames (struct ParamUploadMedia *ParamUpl,int NumMedia)
|
||||||
{
|
{
|
||||||
if (NumMediaInForm < 0) // One unique media in form ==> no suffix needed
|
if (NumMedia < 0) // One unique media in form ==> no suffix needed
|
||||||
{
|
{
|
||||||
Str_Copy (ParamUploadMedia->Action ,"MedAct",
|
Str_Copy (ParamUpl->Action ,"MedAct",sizeof (ParamUpl->Action ) - 1);
|
||||||
Med_MAX_BYTES_PARAM_UPLOAD_MEDIA);
|
Str_Copy (ParamUpl->FormType,"MedFrm",sizeof (ParamUpl->FormType) - 1);
|
||||||
Str_Copy (ParamUploadMedia->FormType,"MedFrm",
|
Str_Copy (ParamUpl->File ,"MedFil",sizeof (ParamUpl->File ) - 1);
|
||||||
Med_MAX_BYTES_PARAM_UPLOAD_MEDIA);
|
Str_Copy (ParamUpl->Title ,"MedTit",sizeof (ParamUpl->Title ) - 1);
|
||||||
Str_Copy (ParamUploadMedia->File ,"MedFil",
|
Str_Copy (ParamUpl->URL ,"MedURL",sizeof (ParamUpl->URL ) - 1);
|
||||||
Med_MAX_BYTES_PARAM_UPLOAD_MEDIA);
|
|
||||||
Str_Copy (ParamUploadMedia->Title ,"MedTit",
|
|
||||||
Med_MAX_BYTES_PARAM_UPLOAD_MEDIA);
|
|
||||||
Str_Copy (ParamUploadMedia->URL ,"MedURL",
|
|
||||||
Med_MAX_BYTES_PARAM_UPLOAD_MEDIA);
|
|
||||||
}
|
}
|
||||||
else // Several video/images in form ==> add suffix
|
else // Several video/images in form ==> add suffix
|
||||||
{
|
{
|
||||||
snprintf (ParamUploadMedia->Action ,sizeof (ParamUploadMedia->Action),
|
snprintf (ParamUpl->Action ,sizeof (ParamUpl->Action),"MedAct%u",NumMedia);
|
||||||
"MedAct%u",
|
snprintf (ParamUpl->FormType,sizeof (ParamUpl->Action),"MedFrm%u",NumMedia);
|
||||||
NumMediaInForm);
|
snprintf (ParamUpl->File ,sizeof (ParamUpl->File ),"MedFil%u",NumMedia);
|
||||||
snprintf (ParamUploadMedia->FormType,sizeof (ParamUploadMedia->Action),
|
snprintf (ParamUpl->Title ,sizeof (ParamUpl->Title ),"MedTit%u",NumMedia);
|
||||||
"MedFrm%u",
|
snprintf (ParamUpl->URL ,sizeof (ParamUpl->URL ),"MedURL%u",NumMedia);
|
||||||
NumMediaInForm);
|
|
||||||
snprintf (ParamUploadMedia->File ,sizeof (ParamUploadMedia->File),
|
|
||||||
"MedFil%u",
|
|
||||||
NumMediaInForm);
|
|
||||||
snprintf (ParamUploadMedia->Title ,sizeof (ParamUploadMedia->Title),
|
|
||||||
"MedTit%u",
|
|
||||||
NumMediaInForm);
|
|
||||||
snprintf (ParamUploadMedia->URL ,sizeof (ParamUploadMedia->URL),
|
|
||||||
"MedURL%u",
|
|
||||||
NumMediaInForm);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,10 +659,9 @@ static void Usr_GetURLFromForm (const char *ParamName,struct Med_Media *Media)
|
||||||
/* Overwrite current URL (empty or coming from database)
|
/* Overwrite current URL (empty or coming from database)
|
||||||
with the URL coming from the form */
|
with the URL coming from the form */
|
||||||
Med_FreeMediaURL (Media);
|
Med_FreeMediaURL (Media);
|
||||||
if ((Media->URL = (char *) malloc (Length + 1)) == NULL)
|
if ((Media->URL = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for media URL.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (Media->URL,URL,
|
Str_Copy (Media->URL,URL,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,10 +683,9 @@ static void Usr_GetTitleFromForm (const char *ParamName,struct Med_Media *Media)
|
||||||
/* Overwrite current title (empty or coming from database)
|
/* Overwrite current title (empty or coming from database)
|
||||||
with the title coming from the form */
|
with the title coming from the form */
|
||||||
Med_FreeMediaTitle (Media);
|
Med_FreeMediaTitle (Media);
|
||||||
if ((Media->Title = (char *) malloc (Length + 1)) == NULL)
|
if ((Media->Title = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for media title.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (Media->Title,Title,
|
Str_Copy (Media->Title,Title,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,8 +742,7 @@ static void Med_GetAndProcessFileFromForm (const char *ParamFile,
|
||||||
/***** End the reception of original not processed media
|
/***** End the reception of original not processed media
|
||||||
(it may be very big) into a temporary file *****/
|
(it may be very big) into a temporary file *****/
|
||||||
Media->Status = Med_STATUS_NONE;
|
Media->Status = Med_STATUS_NONE;
|
||||||
snprintf (PathFileOrg,sizeof (PathFileOrg),
|
snprintf (PathFileOrg,sizeof (PathFileOrg),"%s/%s_original.%s",
|
||||||
"%s/%s_original.%s",
|
|
||||||
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,PtrExtension);
|
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,PtrExtension);
|
||||||
|
|
||||||
if (Fil_EndReceptionOfFile (PathFileOrg,Param)) // Success
|
if (Fil_EndReceptionOfFile (PathFileOrg,Param)) // Success
|
||||||
|
@ -813,13 +792,12 @@ static bool Med_DetectIfAnimated (struct Med_Media *Media,
|
||||||
int NumFrames = 0;
|
int NumFrames = 0;
|
||||||
|
|
||||||
/***** Build path to temporary text file *****/
|
/***** Build path to temporary text file *****/
|
||||||
snprintf (PathFileTxtTmp,sizeof (PathFileTxtTmp),
|
snprintf (PathFileTxtTmp,sizeof (PathFileTxtTmp),"%s/%s.txt",
|
||||||
"%s/%s.txt",
|
|
||||||
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name);
|
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name);
|
||||||
|
|
||||||
/***** Execute system command to get number of frames in GIF *****/
|
/***** Execute system command to get number of frames in GIF *****/
|
||||||
snprintf (Command,sizeof (Command),
|
snprintf (Command,sizeof (Command),
|
||||||
"identify -format '%%n\n' %s | head -1 > %s",
|
"identify -format '%%n\n' %s | head -1 > %s",
|
||||||
PathFileOrg,PathFileTxtTmp);
|
PathFileOrg,PathFileTxtTmp);
|
||||||
ReturnCode = system (Command);
|
ReturnCode = system (Command);
|
||||||
if (ReturnCode == -1)
|
if (ReturnCode == -1)
|
||||||
|
@ -853,8 +831,7 @@ static void Med_ProcessJPG (struct Med_Media *Media,
|
||||||
|
|
||||||
/***** Convert original media to temporary JPG processed file
|
/***** Convert original media to temporary JPG processed file
|
||||||
by calling to program that makes the conversion *****/
|
by calling to program that makes the conversion *****/
|
||||||
snprintf (PathFileJPGTmp,sizeof (PathFileJPGTmp),
|
snprintf (PathFileJPGTmp,sizeof (PathFileJPGTmp),"%s/%s.%s",
|
||||||
"%s/%s.%s",
|
|
||||||
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,Med_Extensions[Med_JPG]);
|
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,Med_Extensions[Med_JPG]);
|
||||||
if (Med_ResizeImage (Media,PathFileOrg,PathFileJPGTmp) == 0) // On success ==> 0 is returned
|
if (Med_ResizeImage (Media,PathFileOrg,PathFileJPGTmp) == 0) // On success ==> 0 is returned
|
||||||
/* Success */
|
/* Success */
|
||||||
|
@ -893,16 +870,15 @@ static void Med_ProcessGIF (struct Med_Media *Media,
|
||||||
/* File size correct */
|
/* File size correct */
|
||||||
/***** Get first frame of orifinal GIF file
|
/***** Get first frame of orifinal GIF file
|
||||||
and save it on temporary PNG file */
|
and save it on temporary PNG file */
|
||||||
snprintf (PathFilePNGTmp,sizeof (PathFilePNGTmp),
|
snprintf (PathFilePNGTmp,sizeof (PathFilePNGTmp),"%s/%s.png",
|
||||||
"%s/%s.png",
|
|
||||||
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name);
|
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name);
|
||||||
if (Med_GetFirstFrame (PathFileOrg,PathFilePNGTmp) == 0) // On success ==> 0 is returned
|
if (Med_GetFirstFrame (PathFileOrg,PathFilePNGTmp) == 0) // On success ==> 0 is returned
|
||||||
{
|
{
|
||||||
/* Success */
|
/* Success */
|
||||||
/***** Move original GIF file to temporary GIF file *****/
|
/***** Move original GIF file to temporary GIF file *****/
|
||||||
snprintf (PathFileGIFTmp,sizeof (PathFileGIFTmp),
|
snprintf (PathFileGIFTmp,sizeof (PathFileGIFTmp),"%s/%s.%s",
|
||||||
"%s/%s.%s",
|
Cfg_PATH_MEDIA_TMP_PRIVATE,
|
||||||
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,Med_Extensions[Med_GIF]);
|
Media->Name,Med_Extensions[Med_GIF]);
|
||||||
if (rename (PathFileOrg,PathFileGIFTmp)) // Fail
|
if (rename (PathFileOrg,PathFileGIFTmp)) // Fail
|
||||||
{
|
{
|
||||||
/* Remove temporary PNG file */
|
/* Remove temporary PNG file */
|
||||||
|
@ -960,9 +936,9 @@ static void Med_ProcessVideo (struct Med_Media *Media,
|
||||||
{
|
{
|
||||||
/* File size correct */
|
/* File size correct */
|
||||||
/***** Move original video file to temporary MP4 file *****/
|
/***** Move original video file to temporary MP4 file *****/
|
||||||
snprintf (PathFileTmp,sizeof (PathFileTmp),
|
snprintf (PathFileTmp,sizeof (PathFileTmp),"%s/%s.%s",
|
||||||
"%s/%s.%s",
|
Cfg_PATH_MEDIA_TMP_PRIVATE,
|
||||||
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,Med_Extensions[Media->Type]);
|
Media->Name,Med_Extensions[Media->Type]);
|
||||||
if (rename (PathFileOrg,PathFileTmp)) // Fail
|
if (rename (PathFileOrg,PathFileTmp)) // Fail
|
||||||
/* Show error alert */
|
/* Show error alert */
|
||||||
Ale_ShowAlert (Ale_ERROR,Txt_The_file_could_not_be_processed_successfully);
|
Ale_ShowAlert (Ale_ERROR,Txt_The_file_could_not_be_processed_successfully);
|
||||||
|
@ -997,7 +973,7 @@ static int Med_ResizeImage (struct Med_Media *Media,
|
||||||
int ReturnCode;
|
int ReturnCode;
|
||||||
|
|
||||||
snprintf (Command,sizeof (Command),
|
snprintf (Command,sizeof (Command),
|
||||||
"convert %s -resize '%ux%u>' -quality %u %s",
|
"convert %s -resize '%ux%u>' -quality %u %s",
|
||||||
PathFileOriginal,
|
PathFileOriginal,
|
||||||
Media->Width,
|
Media->Width,
|
||||||
Media->Height,
|
Media->Height,
|
||||||
|
@ -1023,8 +999,7 @@ static int Med_GetFirstFrame (const char PathFileOriginal[PATH_MAX + 1],
|
||||||
char Command[128 + PATH_MAX * 2];
|
char Command[128 + PATH_MAX * 2];
|
||||||
int ReturnCode;
|
int ReturnCode;
|
||||||
|
|
||||||
snprintf (Command,sizeof (Command),
|
snprintf (Command,sizeof (Command),"convert '%s[0]' %s",
|
||||||
"convert '%s[0]' %s",
|
|
||||||
PathFileOriginal,
|
PathFileOriginal,
|
||||||
PathFileProcessed);
|
PathFileProcessed);
|
||||||
ReturnCode = system (Command);
|
ReturnCode = system (Command);
|
||||||
|
@ -1314,8 +1289,7 @@ void Med_MoveMediaToDefinitiveDir (struct Med_Media *Media)
|
||||||
case Med_WEBM:
|
case Med_WEBM:
|
||||||
case Med_OGG:
|
case Med_OGG:
|
||||||
/***** Create private subdirectory for media if it does not exist *****/
|
/***** Create private subdirectory for media if it does not exist *****/
|
||||||
snprintf (PathMedPriv,sizeof (PathMedPriv),
|
snprintf (PathMedPriv,sizeof (PathMedPriv),"%s/%c%c",
|
||||||
"%s/%c%c",
|
|
||||||
Cfg_PATH_MEDIA_PRIVATE,
|
Cfg_PATH_MEDIA_PRIVATE,
|
||||||
Media->Name[0],
|
Media->Name[0],
|
||||||
Media->Name[1]);
|
Media->Name[1]);
|
||||||
|
@ -1380,13 +1354,11 @@ static bool Med_MoveTmpFileToDefDir (struct Med_Media *Media,
|
||||||
char PathFile[PATH_MAX + 1]; // Full name of definitive processed file
|
char PathFile[PATH_MAX + 1]; // Full name of definitive processed file
|
||||||
|
|
||||||
/***** Temporary processed media file *****/
|
/***** Temporary processed media file *****/
|
||||||
snprintf (PathFileTmp,sizeof (PathFileTmp),
|
snprintf (PathFileTmp,sizeof (PathFileTmp),"%s/%s.%s",
|
||||||
"%s/%s.%s",
|
|
||||||
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,Extension);
|
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,Extension);
|
||||||
|
|
||||||
/***** Definitive processed media file *****/
|
/***** Definitive processed media file *****/
|
||||||
snprintf (PathFile,sizeof (PathFile),
|
snprintf (PathFile,sizeof (PathFile),"%s/%s.%s",
|
||||||
"%s/%s.%s",
|
|
||||||
PathMedPriv,Media->Name,Extension);
|
PathMedPriv,Media->Name,Extension);
|
||||||
|
|
||||||
/***** Move JPG file *****/
|
/***** Move JPG file *****/
|
||||||
|
@ -1459,8 +1431,7 @@ void Med_ShowMedia (const struct Med_Media *Media,
|
||||||
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",Media->URL);
|
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",Media->URL);
|
||||||
|
|
||||||
/* Build path to private directory with the media */
|
/* Build path to private directory with the media */
|
||||||
snprintf (PathMedPriv,sizeof (PathMedPriv),
|
snprintf (PathMedPriv,sizeof (PathMedPriv),"%s/%c%c",
|
||||||
"%s/%c%c",
|
|
||||||
Cfg_PATH_MEDIA_PRIVATE,
|
Cfg_PATH_MEDIA_PRIVATE,
|
||||||
Media->Name[0],
|
Media->Name[0],
|
||||||
Media->Name[1]);
|
Media->Name[1]);
|
||||||
|
@ -1519,8 +1490,7 @@ static void Med_ShowJPG (const struct Med_Media *Media,
|
||||||
bool Cached;
|
bool Cached;
|
||||||
|
|
||||||
/***** Build private path to JPG *****/
|
/***** Build private path to JPG *****/
|
||||||
snprintf (FileNameJPG,sizeof (FileNameJPG),
|
snprintf (FileNameJPG,sizeof (FileNameJPG),"%s.%s",
|
||||||
"%s.%s",
|
|
||||||
Media->Name,Med_Extensions[Med_JPG]);
|
Media->Name,Med_Extensions[Med_JPG]);
|
||||||
if (asprintf (&FullPathJPGPriv,"%s/%s",
|
if (asprintf (&FullPathJPGPriv,"%s/%s",
|
||||||
PathMedPriv,FileNameJPG) < 0)
|
PathMedPriv,FileNameJPG) < 0)
|
||||||
|
@ -1539,8 +1509,7 @@ static void Med_ShowJPG (const struct Med_Media *Media,
|
||||||
Brw_CreateDirDownloadTmp ();
|
Brw_CreateDirDownloadTmp ();
|
||||||
Brw_CreateTmpPublicLinkToPrivateFile (FullPathJPGPriv,FileNameJPG);
|
Brw_CreateTmpPublicLinkToPrivateFile (FullPathJPGPriv,FileNameJPG);
|
||||||
|
|
||||||
snprintf (TmpPubDir,sizeof (TmpPubDir),
|
snprintf (TmpPubDir,sizeof (TmpPubDir),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
Gbl.FileBrowser.TmpPubDir.L,Gbl.FileBrowser.TmpPubDir.R);
|
Gbl.FileBrowser.TmpPubDir.L,Gbl.FileBrowser.TmpPubDir.R);
|
||||||
Ses_AddPublicDirToCache (FullPathJPGPriv,TmpPubDir);
|
Ses_AddPublicDirToCache (FullPathJPGPriv,TmpPubDir);
|
||||||
}
|
}
|
||||||
|
@ -1579,17 +1548,14 @@ static void Med_ShowGIF (const struct Med_Media *Media,
|
||||||
bool Cached;
|
bool Cached;
|
||||||
|
|
||||||
/***** Build private path to animated GIF image *****/
|
/***** Build private path to animated GIF image *****/
|
||||||
snprintf (FileNameGIF,sizeof (FileNameGIF),
|
snprintf (FileNameGIF,sizeof (FileNameGIF),"%s.%s",
|
||||||
"%s.%s",
|
|
||||||
Media->Name,Med_Extensions[Med_GIF]);
|
Media->Name,Med_Extensions[Med_GIF]);
|
||||||
if (asprintf (&FullPathGIFPriv,"%s/%s", // The animated GIF image
|
if (asprintf (&FullPathGIFPriv,"%s/%s", // The animated GIF image
|
||||||
PathMedPriv,FileNameGIF) < 0)
|
PathMedPriv,FileNameGIF) < 0)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Build private path to static PNG image *****/
|
/***** Build private path to static PNG image *****/
|
||||||
snprintf (FileNamePNG,sizeof (FileNamePNG),
|
snprintf (FileNamePNG,sizeof (FileNamePNG),"%s.png",Media->Name);
|
||||||
"%s.png",
|
|
||||||
Media->Name);
|
|
||||||
if (asprintf (&FullPathPNGPriv,"%s/%s",
|
if (asprintf (&FullPathPNGPriv,"%s/%s",
|
||||||
PathMedPriv,FileNamePNG) < 0)
|
PathMedPriv,FileNamePNG) < 0)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
@ -1608,8 +1574,7 @@ static void Med_ShowGIF (const struct Med_Media *Media,
|
||||||
Brw_CreateTmpPublicLinkToPrivateFile (FullPathGIFPriv,FileNameGIF);
|
Brw_CreateTmpPublicLinkToPrivateFile (FullPathGIFPriv,FileNameGIF);
|
||||||
Brw_CreateTmpPublicLinkToPrivateFile (FullPathPNGPriv,FileNamePNG);
|
Brw_CreateTmpPublicLinkToPrivateFile (FullPathPNGPriv,FileNamePNG);
|
||||||
|
|
||||||
snprintf (TmpPubDir,sizeof (TmpPubDir),
|
snprintf (TmpPubDir,sizeof (TmpPubDir),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
Gbl.FileBrowser.TmpPubDir.L,Gbl.FileBrowser.TmpPubDir.R);
|
Gbl.FileBrowser.TmpPubDir.L,Gbl.FileBrowser.TmpPubDir.R);
|
||||||
Ses_AddPublicDirToCache (FullPathGIFPriv,TmpPubDir);
|
Ses_AddPublicDirToCache (FullPathGIFPriv,TmpPubDir);
|
||||||
}
|
}
|
||||||
|
@ -1675,8 +1640,7 @@ static void Med_ShowVideo (const struct Med_Media *Media,
|
||||||
bool Cached;
|
bool Cached;
|
||||||
|
|
||||||
/***** Build private path to video *****/
|
/***** Build private path to video *****/
|
||||||
snprintf (FileNameVideo,sizeof (FileNameVideo),
|
snprintf (FileNameVideo,sizeof (FileNameVideo),"%s.%s",
|
||||||
"%s.%s",
|
|
||||||
Media->Name,Med_Extensions[Media->Type]);
|
Media->Name,Med_Extensions[Media->Type]);
|
||||||
if (asprintf (&FullPathVideoPriv,"%s/%s",
|
if (asprintf (&FullPathVideoPriv,"%s/%s",
|
||||||
PathMedPriv,FileNameVideo) < 0)
|
PathMedPriv,FileNameVideo) < 0)
|
||||||
|
@ -1695,8 +1659,7 @@ static void Med_ShowVideo (const struct Med_Media *Media,
|
||||||
Brw_CreateDirDownloadTmp ();
|
Brw_CreateDirDownloadTmp ();
|
||||||
Brw_CreateTmpPublicLinkToPrivateFile (FullPathVideoPriv,FileNameVideo);
|
Brw_CreateTmpPublicLinkToPrivateFile (FullPathVideoPriv,FileNameVideo);
|
||||||
|
|
||||||
snprintf (TmpPubDir,sizeof (TmpPubDir),
|
snprintf (TmpPubDir,sizeof (TmpPubDir),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
Gbl.FileBrowser.TmpPubDir.L,Gbl.FileBrowser.TmpPubDir.R);
|
Gbl.FileBrowser.TmpPubDir.L,Gbl.FileBrowser.TmpPubDir.R);
|
||||||
Ses_AddPublicDirToCache (FullPathVideoPriv,TmpPubDir);
|
Ses_AddPublicDirToCache (FullPathVideoPriv,TmpPubDir);
|
||||||
}
|
}
|
||||||
|
@ -1876,10 +1839,9 @@ long Med_CloneMedia (const struct Med_Media *MediaSrc)
|
||||||
Length = strlen (MediaSrc->URL);
|
Length = strlen (MediaSrc->URL);
|
||||||
if (Length > Cns_MAX_BYTES_WWW)
|
if (Length > Cns_MAX_BYTES_WWW)
|
||||||
Length = Cns_MAX_BYTES_WWW;
|
Length = Cns_MAX_BYTES_WWW;
|
||||||
if ((MediaDst.URL = (char *) malloc (Length + 1)) == NULL)
|
if ((MediaDst.URL = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for media URL.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (MediaDst.URL,MediaSrc->URL,
|
Str_Copy (MediaDst.URL,MediaSrc->URL,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Copy media title *****/
|
/***** Copy media title *****/
|
||||||
|
@ -1890,10 +1852,9 @@ long Med_CloneMedia (const struct Med_Media *MediaSrc)
|
||||||
Length = strlen (MediaSrc->Title);
|
Length = strlen (MediaSrc->Title);
|
||||||
if (Length > Cns_MAX_BYTES_WWW)
|
if (Length > Cns_MAX_BYTES_WWW)
|
||||||
Length = Cns_MAX_BYTES_WWW;
|
Length = Cns_MAX_BYTES_WWW;
|
||||||
if ((MediaDst.Title = (char *) malloc (Length + 1)) == NULL)
|
if ((MediaDst.Title = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for media title.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (MediaDst.Title,MediaSrc->Title,
|
Str_Copy (MediaDst.Title,MediaSrc->Title,Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Create duplicate of files *****/
|
/***** Create duplicate of files *****/
|
||||||
|
@ -1918,12 +1879,14 @@ long Med_CloneMedia (const struct Med_Media *MediaSrc)
|
||||||
Fil_CreateDirIfNotExists (MediaPriv[Med_DST].Path);
|
Fil_CreateDirIfNotExists (MediaPriv[Med_DST].Path);
|
||||||
|
|
||||||
/* Build paths to private files */
|
/* Build paths to private files */
|
||||||
snprintf (MediaPriv[Med_SRC].FullPath,sizeof (MediaPriv[Med_SRC].FullPath),
|
snprintf (MediaPriv[Med_SRC].FullPath,
|
||||||
"%s/%s.%s",
|
sizeof (MediaPriv[Med_SRC].FullPath),"%s/%s.%s",
|
||||||
MediaPriv[Med_SRC].Path,MediaSrc->Name,Med_Extensions[MediaSrc->Type]);
|
MediaPriv[Med_SRC].Path,
|
||||||
snprintf (MediaPriv[Med_DST].FullPath,sizeof (MediaPriv[Med_DST].FullPath),
|
MediaSrc->Name,Med_Extensions[MediaSrc->Type]);
|
||||||
"%s/%s.%s",
|
snprintf (MediaPriv[Med_DST].FullPath,
|
||||||
MediaPriv[Med_DST].Path,MediaDst.Name,Med_Extensions[MediaSrc->Type]);
|
sizeof (MediaPriv[Med_DST].FullPath),"%s/%s.%s",
|
||||||
|
MediaPriv[Med_DST].Path,
|
||||||
|
MediaDst.Name,Med_Extensions[MediaSrc->Type]);
|
||||||
|
|
||||||
/* Copy file */
|
/* Copy file */
|
||||||
Fil_FastCopyOfFiles (MediaPriv[Med_SRC].FullPath,
|
Fil_FastCopyOfFiles (MediaPriv[Med_SRC].FullPath,
|
||||||
|
@ -1932,11 +1895,11 @@ long Med_CloneMedia (const struct Med_Media *MediaSrc)
|
||||||
if (MediaSrc->Type == Med_GIF)
|
if (MediaSrc->Type == Med_GIF)
|
||||||
{
|
{
|
||||||
/* Build private paths to PNG */
|
/* Build private paths to PNG */
|
||||||
snprintf (MediaPriv[Med_SRC].FullPath,sizeof (MediaPriv[Med_SRC].FullPath),
|
snprintf (MediaPriv[Med_SRC].FullPath,
|
||||||
"%s/%s.png",
|
sizeof (MediaPriv[Med_SRC].FullPath),"%s/%s.png",
|
||||||
MediaPriv[Med_SRC].Path,MediaSrc->Name);
|
MediaPriv[Med_SRC].Path,MediaSrc->Name);
|
||||||
snprintf (MediaPriv[Med_DST].FullPath,sizeof (MediaPriv[Med_DST].FullPath),
|
snprintf (MediaPriv[Med_DST].FullPath,
|
||||||
"%s/%s.png",
|
sizeof (MediaPriv[Med_DST].FullPath),"%s/%s.png",
|
||||||
MediaPriv[Med_DST].Path,MediaDst.Name);
|
MediaPriv[Med_DST].Path,MediaDst.Name);
|
||||||
|
|
||||||
/* Copy PNG file */
|
/* Copy PNG file */
|
||||||
|
@ -2014,8 +1977,7 @@ void Med_RemoveMedia (long MedCod)
|
||||||
if (Media.Name[0])
|
if (Media.Name[0])
|
||||||
{
|
{
|
||||||
/***** Build path to private directory with the media *****/
|
/***** Build path to private directory with the media *****/
|
||||||
snprintf (PathMedPriv,sizeof (PathMedPriv),
|
snprintf (PathMedPriv,sizeof (PathMedPriv),"%s/%c%c",
|
||||||
"%s/%c%c",
|
|
||||||
Cfg_PATH_MEDIA_PRIVATE,
|
Cfg_PATH_MEDIA_PRIVATE,
|
||||||
Media.Name[0],
|
Media.Name[0],
|
||||||
Media.Name[1]);
|
Media.Name[1]);
|
||||||
|
|
|
@ -144,11 +144,11 @@ void Med_ResetMedia (struct Med_Media *Media);
|
||||||
|
|
||||||
void Med_GetMediaDataByCod (struct Med_Media *Media);
|
void Med_GetMediaDataByCod (struct Med_Media *Media);
|
||||||
|
|
||||||
void Med_PutMediaUploader (int NumMediaInForm,const char *ClassInput);
|
void Med_PutMediaUploader (int NumMedia,const char *ClassInput);
|
||||||
void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Med_Media *Media,
|
void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMedia,struct Med_Media *Media,
|
||||||
void (*GetMediaFromDB) (long CrsCod,long QstCod,int NumMediaInForm,struct Med_Media *Media),
|
void (*GetMediaFromDB) (long CrsCod,long QstCod,int NumMedia,struct Med_Media *Media),
|
||||||
const char *SectionForAlerts);
|
const char *SectionForAlerts);
|
||||||
void Med_SetParamNames (struct ParamUploadMedia *ParamUploadMedia,int NumMediaInForm);
|
void Med_SetParamNames (struct ParamUploadMedia *ParamUpl,int NumMedia);
|
||||||
|
|
||||||
void Med_RemoveKeepOrStoreMedia (long CurrentMedCodInDB,struct Med_Media *Media);
|
void Med_RemoveKeepOrStoreMedia (long CurrentMedCodInDB,struct Med_Media *Media);
|
||||||
void Med_MoveMediaToDefinitiveDir (struct Med_Media *Media);
|
void Med_MoveMediaToDefinitiveDir (struct Med_Media *Media);
|
||||||
|
|
|
@ -345,7 +345,7 @@ static void Msg_PutFormMsgUsrs (struct Msg_Messages *Messages,
|
||||||
}
|
}
|
||||||
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
||||||
{
|
{
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
if (Messages->ShowOnlyOneRecipient)
|
if (Messages->ShowOnlyOneRecipient)
|
||||||
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
|
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
|
||||||
}
|
}
|
||||||
|
@ -450,7 +450,7 @@ static void Msg_PutParamsShowMorePotentialRecipients (const void *Messages)
|
||||||
Msg_PutHiddenParamMsgCod (((struct Msg_Messages *) Messages)->Reply.OriginalMsgCod);
|
Msg_PutHiddenParamMsgCod (((struct Msg_Messages *) Messages)->Reply.OriginalMsgCod);
|
||||||
}
|
}
|
||||||
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
|
|
||||||
/***** Hidden params to send subject and content *****/
|
/***** Hidden params to send subject and content *****/
|
||||||
Msg_PutHiddenParamsSubjectAndContent ();
|
Msg_PutHiddenParamsSubjectAndContent ();
|
||||||
|
@ -474,7 +474,7 @@ static void Msg_PutParamsWriteMsg (void *Messages)
|
||||||
}
|
}
|
||||||
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
||||||
{
|
{
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
if (((struct Msg_Messages *) Messages)->ShowOnlyOneRecipient)
|
if (((struct Msg_Messages *) Messages)->ShowOnlyOneRecipient)
|
||||||
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
|
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
|
||||||
}
|
}
|
||||||
|
@ -627,13 +627,9 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (struct Msg_Messages *Messag
|
||||||
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get subject */
|
/* Get subject (row[0]) and content (row[1]) */
|
||||||
Str_Copy (Messages->Subject,row[0],
|
Str_Copy (Messages->Subject,row[0],sizeof (Messages->Subject) - 1);
|
||||||
Cns_MAX_BYTES_SUBJECT);
|
Str_Copy (Content ,row[1],Cns_MAX_BYTES_LONG_TEXT);
|
||||||
|
|
||||||
/* Get content */
|
|
||||||
Str_Copy (Content,row[1],
|
|
||||||
Cns_MAX_BYTES_LONG_TEXT);
|
|
||||||
|
|
||||||
/* Free structure that stores the query result */
|
/* Free structure that stores the query result */
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -711,12 +707,10 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (struct Msg_Messages *Messag
|
||||||
|
|
||||||
static void Msg_PutHiddenParamAnotherRecipient (const struct UsrData *UsrDat)
|
static void Msg_PutHiddenParamAnotherRecipient (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
char NickWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
||||||
|
|
||||||
snprintf (NicknameWithArroba,sizeof (NicknameWithArroba),
|
snprintf (NickWithArroba,sizeof (NickWithArroba),"@%s",UsrDat->Nickname);
|
||||||
"@%s",
|
Par_PutHiddenParamString (NULL,"OtherRecipients",NickWithArroba);
|
||||||
UsrDat->Nickname);
|
|
||||||
Par_PutHiddenParamString (NULL,"OtherRecipients",NicknameWithArroba);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -839,7 +833,7 @@ void Msg_RecMsgFromUsr (void)
|
||||||
NumRecipients = 0;
|
NumRecipients = 0;
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDstData.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDstData.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDstData);
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDstData);
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDstData,Usr_DONT_GET_PREFS)) // Get recipient's data from the database
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDstData,Usr_DONT_GET_PREFS)) // Get recipient's data from the database
|
||||||
|
@ -1132,11 +1126,11 @@ static void Msg_GetParamMsgsCrsCod (struct Msg_Messages *Messages)
|
||||||
Crs_GetDataOfCourseByCod (&Crs);
|
Crs_GetDataOfCourseByCod (&Crs);
|
||||||
|
|
||||||
Str_Copy (Messages->FilterCrsShrtName,Crs.ShrtName,
|
Str_Copy (Messages->FilterCrsShrtName,Crs.ShrtName,
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
sizeof (Messages->FilterCrsShrtName) - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Str_Copy (Messages->FilterCrsShrtName,Txt_any_course,
|
Str_Copy (Messages->FilterCrsShrtName,Txt_any_course,
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
sizeof (Messages->FilterCrsShrtName) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1184,13 +1178,10 @@ static void Msg_MakeFilterFromToSubquery (const struct Msg_Messages *Messages,
|
||||||
if (strlen (FilterFromToSubquery) + strlen (SearchWord) + 512 >
|
if (strlen (FilterFromToSubquery) + strlen (SearchWord) + 512 >
|
||||||
Msg_MAX_BYTES_MESSAGES_QUERY) // Prevent string overflow
|
Msg_MAX_BYTES_MESSAGES_QUERY) // Prevent string overflow
|
||||||
break;
|
break;
|
||||||
Str_Concat (FilterFromToSubquery,"%",
|
Str_Concat (FilterFromToSubquery,"%",Msg_MAX_BYTES_MESSAGES_QUERY);
|
||||||
Msg_MAX_BYTES_MESSAGES_QUERY);
|
Str_Concat (FilterFromToSubquery,SearchWord,Msg_MAX_BYTES_MESSAGES_QUERY);
|
||||||
Str_Concat (FilterFromToSubquery,SearchWord,
|
|
||||||
Msg_MAX_BYTES_MESSAGES_QUERY);
|
|
||||||
}
|
}
|
||||||
Str_Concat (FilterFromToSubquery,"%'",
|
Str_Concat (FilterFromToSubquery,"%'",Msg_MAX_BYTES_MESSAGES_QUERY);
|
||||||
Msg_MAX_BYTES_MESSAGES_QUERY);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
FilterFromToSubquery[0] = '\0';
|
FilterFromToSubquery[0] = '\0';
|
||||||
|
@ -2797,7 +2788,7 @@ static void Msg_GetDistinctCoursesInMyMessages (struct Msg_Messages *Messages)
|
||||||
{
|
{
|
||||||
Messages->Courses[Messages->NumCourses].CrsCod = Crs.CrsCod;
|
Messages->Courses[Messages->NumCourses].CrsCod = Crs.CrsCod;
|
||||||
Str_Copy (Messages->Courses[Messages->NumCourses].ShrtName,Crs.ShrtName,
|
Str_Copy (Messages->Courses[Messages->NumCourses].ShrtName,Crs.ShrtName,
|
||||||
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
sizeof (Messages->Courses[Messages->NumCourses].ShrtName) - 1);
|
||||||
Messages->NumCourses++;
|
Messages->NumCourses++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2992,8 +2983,7 @@ static void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT +
|
||||||
{
|
{
|
||||||
/***** Get subject *****/
|
/***** Get subject *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Subject,row[0],
|
Str_Copy (Subject,row[0],Cns_MAX_BYTES_SUBJECT);
|
||||||
Cns_MAX_BYTES_SUBJECT);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Subject[0] = '\0';
|
Subject[0] = '\0';
|
||||||
|
@ -3028,8 +3018,7 @@ static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/****** Get content (row[0]) *****/
|
/****** Get content (row[0]) *****/
|
||||||
Str_Copy (Content,row[0],
|
Str_Copy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT);
|
||||||
Cns_MAX_BYTES_LONG_TEXT);
|
|
||||||
|
|
||||||
/***** Get media (row[1]) *****/
|
/***** Get media (row[1]) *****/
|
||||||
Media->MedCod = Str_ConvertStrCodToLongCod (row[1]);
|
Media->MedCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
|
@ -3324,17 +3313,15 @@ void Msg_GetNotifMessage (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0';
|
SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Str_Copy (SummaryStr,row[0],
|
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
|
||||||
Ntf_MAX_BYTES_SUMMARY);
|
|
||||||
|
|
||||||
/***** Copy subject *****/
|
/***** Copy subject *****/
|
||||||
if (GetContent)
|
if (GetContent)
|
||||||
{
|
{
|
||||||
Length = strlen (row[1]);
|
Length = strlen (row[1]);
|
||||||
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
|
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (*ContentStr,row[1],
|
Str_Copy (*ContentStr,row[1],Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3546,7 +3533,7 @@ static void Msg_WriteFormToReply (long MsgCod,long CrsCod,
|
||||||
Grp_PutParamAllGroups ();
|
Grp_PutParamAllGroups ();
|
||||||
Par_PutHiddenParamChar ("IsReply",'Y');
|
Par_PutHiddenParamChar ("IsReply",'Y');
|
||||||
Msg_PutHiddenParamMsgCod (MsgCod);
|
Msg_PutHiddenParamMsgCod (MsgCod);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
|
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
|
||||||
|
|
||||||
/****** Link and form end *****/
|
/****** Link and form end *****/
|
||||||
|
@ -3887,7 +3874,7 @@ static void Msg_PutFormToBanSender (struct Msg_Messages *Messages,
|
||||||
Frm_StartForm (ActBanUsrMsg);
|
Frm_StartForm (ActBanUsrMsg);
|
||||||
Pag_PutHiddenParamPagNum (Msg_WhatPaginate[Messages->TypeOfMessages],
|
Pag_PutHiddenParamPagNum (Msg_WhatPaginate[Messages->TypeOfMessages],
|
||||||
Messages->CurrentPage);
|
Messages->CurrentPage);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
Msg_PutHiddenParamsMsgsFilters (Messages);
|
Msg_PutHiddenParamsMsgsFilters (Messages);
|
||||||
Ico_PutIconLink ("unlock.svg",Txt_Sender_permitted_click_to_ban_him);
|
Ico_PutIconLink ("unlock.svg",Txt_Sender_permitted_click_to_ban_him);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
|
@ -3905,7 +3892,7 @@ static void Msg_PutFormToUnbanSender (struct Msg_Messages *Messages,
|
||||||
Frm_StartForm (ActUnbUsrMsg);
|
Frm_StartForm (ActUnbUsrMsg);
|
||||||
Pag_PutHiddenParamPagNum (Msg_WhatPaginate[Messages->TypeOfMessages],
|
Pag_PutHiddenParamPagNum (Msg_WhatPaginate[Messages->TypeOfMessages],
|
||||||
Messages->CurrentPage);
|
Messages->CurrentPage);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
Msg_PutHiddenParamsMsgsFilters (Messages);
|
Msg_PutHiddenParamsMsgsFilters (Messages);
|
||||||
Ico_PutIconLink ("lock.svg",Txt_Sender_banned_click_to_unban_him);
|
Ico_PutIconLink ("lock.svg",Txt_Sender_banned_click_to_unban_him);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
|
@ -4078,7 +4065,7 @@ void Msg_ListBannedUsrs (void)
|
||||||
/* Put form to unban user */
|
/* Put form to unban user */
|
||||||
HTM_TD_Begin ("class=\"BM\"");
|
HTM_TD_Begin ("class=\"BM\"");
|
||||||
Frm_StartForm (ActUnbUsrLst);
|
Frm_StartForm (ActUnbUsrLst);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat.EnUsrCod);
|
||||||
Ico_PutIconLink ("lock.svg",Txt_Sender_banned_click_to_unban_him);
|
Ico_PutIconLink ("lock.svg",Txt_Sender_banned_click_to_unban_him);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
|
@ -231,8 +231,7 @@ void Net_ShowWebsAndSocialNets (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
/* Get URL */
|
/* Get URL */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (URL,row[0],
|
Str_Copy (URL,row[0],sizeof (URL) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
|
|
||||||
/* Show the web / social network */
|
/* Show the web / social network */
|
||||||
Net_ShowAWebOrSocialNet (URL,
|
Net_ShowAWebOrSocialNet (URL,
|
||||||
|
@ -284,9 +283,7 @@ void Net_ShowFormMyWebsAndSocialNets (void)
|
||||||
HTM_SECTION_Begin (Net_MY_WEBS_ID);
|
HTM_SECTION_Begin (Net_MY_WEBS_ID);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
|
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
|
||||||
"%upx",
|
|
||||||
Rec_RECORD_WIDTH);
|
|
||||||
Box_BoxBegin (StrRecordWidth,Txt_Webs_social_networks,
|
Box_BoxBegin (StrRecordWidth,Txt_Webs_social_networks,
|
||||||
Net_PutIconsWebsSocialNetworks,NULL,
|
Net_PutIconsWebsSocialNetworks,NULL,
|
||||||
Hlp_PROFILE_Webs,Box_NOT_CLOSABLE);
|
Hlp_PROFILE_Webs,Box_NOT_CLOSABLE);
|
||||||
|
@ -313,8 +310,7 @@ void Net_ShowFormMyWebsAndSocialNets (void)
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get URL */
|
/* Get URL */
|
||||||
Str_Copy (URL,row[0],
|
Str_Copy (URL,row[0],sizeof (URL) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
URL[0] = '\0';
|
URL[0] = '\0';
|
||||||
|
@ -323,9 +319,7 @@ void Net_ShowFormMyWebsAndSocialNets (void)
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
/***** Row for this web / social network *****/
|
/***** Row for this web / social network *****/
|
||||||
snprintf (StrName,sizeof (StrName),
|
snprintf (StrName,sizeof (StrName),"URL%u",(unsigned) NumURL);
|
||||||
"URL%u",
|
|
||||||
(unsigned) NumURL);
|
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"REC_C1_BOT LM\"");
|
HTM_TD_Begin ("class=\"REC_C1_BOT LM\"");
|
||||||
|
@ -400,9 +394,7 @@ static void Net_GetMyWebsAndSocialNetsFromForm (void)
|
||||||
NumURL++)
|
NumURL++)
|
||||||
{
|
{
|
||||||
/***** Get URL from the form *****/
|
/***** Get URL from the form *****/
|
||||||
snprintf (ParamName,sizeof (ParamName),
|
snprintf (ParamName,sizeof (ParamName),"URL%u",(unsigned) NumURL);
|
||||||
"URL%u",
|
|
||||||
(unsigned) NumURL);
|
|
||||||
Par_GetParToText (ParamName,URL,Cns_MAX_BYTES_WWW);
|
Par_GetParToText (ParamName,URL,Cns_MAX_BYTES_WWW);
|
||||||
|
|
||||||
if (URL[0])
|
if (URL[0])
|
||||||
|
@ -573,8 +565,7 @@ void Net_ShowWebAndSocialNetworksStats (void)
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get web / social network (row[0]) */
|
/* Get web / social network (row[0]) */
|
||||||
Str_Copy (NetName,row[0],
|
Str_Copy (NetName,row[0],sizeof (NetName) - 1);
|
||||||
Net_MAX_BYTES_NETWORK_NAME);
|
|
||||||
for (Web = (Net_WebsAndSocialNetworks_t) 0;
|
for (Web = (Net_WebsAndSocialNetworks_t) 0;
|
||||||
Web <= (Net_WebsAndSocialNetworks_t) (Net_NUM_WEBS_AND_SOCIAL_NETWORKS - 1);
|
Web <= (Net_WebsAndSocialNetworks_t) (Net_NUM_WEBS_AND_SOCIAL_NETWORKS - 1);
|
||||||
Web++)
|
Web++)
|
||||||
|
|
104
swad_nickname.c
104
swad_nickname.c
|
@ -74,21 +74,20 @@ static void Nck_UpdateUsrNick (struct UsrData *UsrDat);
|
||||||
/********* Check whether a nickname (with initial arroba) if valid ***********/
|
/********* Check whether a nickname (with initial arroba) if valid ***********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba)
|
bool Nck_CheckIfNickWithArrobaIsValid (const char *NickWithArroba)
|
||||||
{
|
{
|
||||||
char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
char NickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
||||||
unsigned Length;
|
unsigned Length;
|
||||||
const char *Ptr;
|
const char *Ptr;
|
||||||
|
|
||||||
/***** A nickname must start by '@' *****/
|
/***** A nickname must start by '@' *****/
|
||||||
if (NicknameWithArroba[0] != '@') // It's not a nickname
|
if (NickWithArroba[0] != '@') // It's not a nickname
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/***** Make a copy of nickname *****/
|
/***** Make a copy of nickname *****/
|
||||||
Str_Copy (NicknameWithoutArroba,NicknameWithArroba,
|
Str_Copy (NickWithoutArroba,NickWithArroba,sizeof (NickWithoutArroba) - 1);
|
||||||
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
|
Str_RemoveLeadingArrobas (NickWithoutArroba);
|
||||||
Str_RemoveLeadingArrobas (NicknameWithoutArroba);
|
Length = strlen (NickWithoutArroba);
|
||||||
Length = strlen (NicknameWithoutArroba);
|
|
||||||
|
|
||||||
/***** A nick (without arroba) must have a number of characters
|
/***** A nick (without arroba) must have a number of characters
|
||||||
Nck_MIN_BYTES_NICKNAME_WITHOUT_ARROBA <= Length <= Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA *****/
|
Nck_MIN_BYTES_NICKNAME_WITHOUT_ARROBA <= Length <= Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA *****/
|
||||||
|
@ -97,7 +96,7 @@ bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/***** A nick can have digits, letters and '_' *****/
|
/***** A nick can have digits, letters and '_' *****/
|
||||||
for (Ptr = NicknameWithoutArroba;
|
for (Ptr = NickWithoutArroba;
|
||||||
*Ptr;
|
*Ptr;
|
||||||
Ptr++)
|
Ptr++)
|
||||||
if (!((*Ptr >= 'a' && *Ptr <= 'z') ||
|
if (!((*Ptr >= 'a' && *Ptr <= 'z') ||
|
||||||
|
@ -128,8 +127,7 @@ bool Nck_GetNicknameFromUsrCod (long UsrCod,
|
||||||
{
|
{
|
||||||
/* Get nickname */
|
/* Get nickname */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Nickname,row[0],
|
Str_Copy (Nickname,row[0],Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
|
||||||
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
|
|
||||||
Found = true;
|
Found = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -152,7 +150,7 @@ bool Nck_GetNicknameFromUsrCod (long UsrCod,
|
||||||
|
|
||||||
long Nck_GetUsrCodFromNickname (const char *Nickname)
|
long Nck_GetUsrCodFromNickname (const char *Nickname)
|
||||||
{
|
{
|
||||||
char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
char NickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
long UsrCod = -1L;
|
long UsrCod = -1L;
|
||||||
|
@ -161,9 +159,8 @@ long Nck_GetUsrCodFromNickname (const char *Nickname)
|
||||||
if (Nickname[0])
|
if (Nickname[0])
|
||||||
{
|
{
|
||||||
/***** Make a copy without possible starting arrobas *****/
|
/***** Make a copy without possible starting arrobas *****/
|
||||||
Str_Copy (NicknameWithoutArroba,Nickname,
|
Str_Copy (NickWithoutArroba,Nickname,sizeof (NickWithoutArroba) - 1);
|
||||||
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
|
Str_RemoveLeadingArrobas (NickWithoutArroba);
|
||||||
Str_RemoveLeadingArrobas (NicknameWithoutArroba);
|
|
||||||
|
|
||||||
/***** Get user's code from database *****/
|
/***** Get user's code from database *****/
|
||||||
/* Check if user code from table usr_nicknames is also in table usr_data */
|
/* Check if user code from table usr_nicknames is also in table usr_data */
|
||||||
|
@ -172,7 +169,7 @@ long Nck_GetUsrCodFromNickname (const char *Nickname)
|
||||||
" FROM usr_nicknames,usr_data"
|
" FROM usr_nicknames,usr_data"
|
||||||
" WHERE usr_nicknames.Nickname='%s'"
|
" WHERE usr_nicknames.Nickname='%s'"
|
||||||
" AND usr_nicknames.UsrCod=usr_data.UsrCod",
|
" AND usr_nicknames.UsrCod=usr_data.UsrCod",
|
||||||
NicknameWithoutArroba))
|
NickWithoutArroba))
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -230,7 +227,7 @@ static void Nck_ShowFormChangeUsrNickname (bool ItsMe,
|
||||||
unsigned NumNicks;
|
unsigned NumNicks;
|
||||||
unsigned NumNick;
|
unsigned NumNick;
|
||||||
Act_Action_t NextAction;
|
Act_Action_t NextAction;
|
||||||
char NicknameWithArroba[1 + Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
|
char NickWithArroba[1 + Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
|
||||||
const struct UsrData *UsrDat = (ItsMe ? &Gbl.Usrs.Me.UsrDat :
|
const struct UsrData *UsrDat = (ItsMe ? &Gbl.Usrs.Me.UsrDat :
|
||||||
&Gbl.Usrs.Other.UsrDat);
|
&Gbl.Usrs.Other.UsrDat);
|
||||||
|
|
||||||
|
@ -246,9 +243,7 @@ static void Nck_ShowFormChangeUsrNickname (bool ItsMe,
|
||||||
UsrDat->UsrCod);
|
UsrDat->UsrCod);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
|
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
|
||||||
"%upx",
|
|
||||||
Rec_RECORD_WIDTH);
|
|
||||||
Box_BoxBegin (StrRecordWidth,Txt_Nickname,
|
Box_BoxBegin (StrRecordWidth,Txt_Nickname,
|
||||||
Acc_PutLinkToRemoveMyAccount,NULL,
|
Acc_PutLinkToRemoveMyAccount,NULL,
|
||||||
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
|
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
|
||||||
|
@ -325,7 +320,7 @@ static void Nck_ShowFormChangeUsrNickname (bool ItsMe,
|
||||||
/* Link to QR code */
|
/* Link to QR code */
|
||||||
if (NumNick == 1 && UsrDat->Nickname[0])
|
if (NumNick == 1 && UsrDat->Nickname[0])
|
||||||
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
|
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
|
||||||
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
|
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod);
|
||||||
|
|
||||||
/* Form to change the nickname */
|
/* Form to change the nickname */
|
||||||
if (NumNick > 1)
|
if (NumNick > 1)
|
||||||
|
@ -349,13 +344,11 @@ static void Nck_ShowFormChangeUsrNickname (bool ItsMe,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Frm_StartFormAnchor (NextAction,Nck_NICKNAME_SECTION_ID);
|
Frm_StartFormAnchor (NextAction,Nck_NICKNAME_SECTION_ID);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf (NicknameWithArroba,sizeof (NicknameWithArroba),
|
snprintf (NickWithArroba,sizeof (NickWithArroba),"@%s",row[0]);
|
||||||
"@%s",
|
Par_PutHiddenParamString (NULL,"NewNick",NickWithArroba); // Nickname
|
||||||
row[0]);
|
|
||||||
Par_PutHiddenParamString (NULL,"NewNick",NicknameWithArroba); // Nickname
|
|
||||||
Btn_PutConfirmButtonInline (Txt_Use_this_nickname);
|
Btn_PutConfirmButtonInline (Txt_Use_this_nickname);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
}
|
}
|
||||||
|
@ -398,13 +391,12 @@ static void Nck_ShowFormChangeUsrNickname (bool ItsMe,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Frm_StartFormAnchor (NextAction,Nck_NICKNAME_SECTION_ID);
|
Frm_StartFormAnchor (NextAction,Nck_NICKNAME_SECTION_ID);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
}
|
}
|
||||||
snprintf (NicknameWithArroba,sizeof (NicknameWithArroba),
|
snprintf (NickWithArroba,sizeof (NickWithArroba),"@%s",
|
||||||
"@%s",
|
|
||||||
Gbl.Usrs.Me.UsrDat.Nickname);
|
Gbl.Usrs.Me.UsrDat.Nickname);
|
||||||
HTM_INPUT_TEXT ("NewNick",1 + Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA,
|
HTM_INPUT_TEXT ("NewNick",1 + Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA,
|
||||||
NicknameWithArroba,HTM_DONT_SUBMIT_ON_CHANGE,
|
NickWithArroba,HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"id=\"NewNick\" size=\"18\"");
|
"id=\"NewNick\" size=\"18\"");
|
||||||
HTM_BR ();
|
HTM_BR ();
|
||||||
Btn_PutCreateButtonInline (NumNicks ? Txt_Change_nickname : // I already have a nickname
|
Btn_PutCreateButtonInline (NumNicks ? Txt_Change_nickname : // I already have a nickname
|
||||||
|
@ -431,7 +423,7 @@ static void Nck_PutParamsRemoveOtherNick (void *Nick)
|
||||||
{
|
{
|
||||||
if (Nick)
|
if (Nick)
|
||||||
{
|
{
|
||||||
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
Par_PutHiddenParamString (NULL,"Nick",Nick);
|
Par_PutHiddenParamString (NULL,"Nick",Nick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,21 +436,21 @@ void Nck_RemoveMyNick (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Nickname_X_removed;
|
extern const char *Txt_Nickname_X_removed;
|
||||||
extern const char *Txt_You_can_not_delete_your_current_nickname;
|
extern const char *Txt_You_can_not_delete_your_current_nickname;
|
||||||
char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
|
char NickWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
|
||||||
|
|
||||||
/***** Get nickname from form *****/
|
/***** Get nickname from form *****/
|
||||||
Par_GetParToText ("Nick",NicknameWithoutArroba,
|
Par_GetParToText ("Nick",NickWithoutArroba,
|
||||||
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
|
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
|
||||||
|
|
||||||
if (strcasecmp (NicknameWithoutArroba,Gbl.Usrs.Me.UsrDat.Nickname)) // Only if not my current nickname
|
if (strcasecmp (NickWithoutArroba,Gbl.Usrs.Me.UsrDat.Nickname)) // Only if not my current nickname
|
||||||
{
|
{
|
||||||
/***** Remove one of my old nicknames *****/
|
/***** Remove one of my old nicknames *****/
|
||||||
Nck_RemoveNicknameFromDB (Gbl.Usrs.Me.UsrDat.UsrCod,NicknameWithoutArroba);
|
Nck_RemoveNicknameFromDB (Gbl.Usrs.Me.UsrDat.UsrCod,NickWithoutArroba);
|
||||||
|
|
||||||
/***** Show message *****/
|
/***** Show message *****/
|
||||||
Ale_CreateAlert (Ale_SUCCESS,Nck_NICKNAME_SECTION_ID,
|
Ale_CreateAlert (Ale_SUCCESS,Nck_NICKNAME_SECTION_ID,
|
||||||
Txt_Nickname_X_removed,
|
Txt_Nickname_X_removed,
|
||||||
NicknameWithoutArroba);
|
NickWithoutArroba);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
|
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
|
||||||
|
@ -475,7 +467,7 @@ void Nck_RemoveMyNick (void)
|
||||||
void Nck_RemoveOtherUsrNick (void)
|
void Nck_RemoveOtherUsrNick (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Nickname_X_removed;
|
extern const char *Txt_Nickname_X_removed;
|
||||||
char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
|
char NickWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
|
||||||
|
|
||||||
/***** Get user whose nick must be removed *****/
|
/***** Get user whose nick must be removed *****/
|
||||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||||
|
@ -483,16 +475,16 @@ void Nck_RemoveOtherUsrNick (void)
|
||||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||||
{
|
{
|
||||||
/***** Get nickname from form *****/
|
/***** Get nickname from form *****/
|
||||||
Par_GetParToText ("Nick",NicknameWithoutArroba,
|
Par_GetParToText ("Nick",NickWithoutArroba,
|
||||||
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
|
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
|
||||||
|
|
||||||
/***** Remove one of the old nicknames *****/
|
/***** Remove one of the old nicknames *****/
|
||||||
Nck_RemoveNicknameFromDB (Gbl.Usrs.Other.UsrDat.UsrCod,NicknameWithoutArroba);
|
Nck_RemoveNicknameFromDB (Gbl.Usrs.Other.UsrDat.UsrCod,NickWithoutArroba);
|
||||||
|
|
||||||
/***** Show message *****/
|
/***** Show message *****/
|
||||||
Ale_CreateAlert (Ale_SUCCESS,Nck_NICKNAME_SECTION_ID,
|
Ale_CreateAlert (Ale_SUCCESS,Nck_NICKNAME_SECTION_ID,
|
||||||
Txt_Nickname_X_removed,
|
Txt_Nickname_X_removed,
|
||||||
NicknameWithoutArroba);
|
NickWithoutArroba);
|
||||||
|
|
||||||
/***** Show user's account again *****/
|
/***** Show user's account again *****/
|
||||||
Acc_ShowFormChgOtherUsrAccount ();
|
Acc_ShowFormChgOtherUsrAccount ();
|
||||||
|
@ -564,57 +556,55 @@ static void Nck_UpdateUsrNick (struct UsrData *UsrDat)
|
||||||
extern const char *Txt_The_nickname_X_had_been_registered_by_another_user;
|
extern const char *Txt_The_nickname_X_had_been_registered_by_another_user;
|
||||||
extern const char *Txt_The_nickname_X_has_been_registered_successfully;
|
extern const char *Txt_The_nickname_X_has_been_registered_successfully;
|
||||||
extern const char *Txt_The_nickname_entered_X_is_not_valid_;
|
extern const char *Txt_The_nickname_entered_X_is_not_valid_;
|
||||||
char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
char NewNickWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
||||||
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
||||||
|
|
||||||
/***** Get new nickname from form *****/
|
/***** Get new nickname from form *****/
|
||||||
Par_GetParToText ("NewNick",NewNicknameWithArroba,
|
Par_GetParToText ("NewNick",NewNickWithArroba,
|
||||||
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
|
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
|
||||||
if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid
|
if (Nck_CheckIfNickWithArrobaIsValid (NewNickWithArroba)) // If new nickname is valid
|
||||||
{
|
{
|
||||||
/***** Remove arrobas at the beginning *****/
|
/***** Remove arrobas at the beginning *****/
|
||||||
Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
|
Str_Copy (NewNickWithoutArroba,NewNickWithArroba,sizeof (NewNickWithoutArroba) - 1);
|
||||||
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
|
Str_RemoveLeadingArrobas (NewNickWithoutArroba);
|
||||||
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
|
|
||||||
|
|
||||||
/***** Check if new nickname exists in database *****/
|
/***** Check if new nickname exists in database *****/
|
||||||
if (!strcmp (UsrDat->Nickname,NewNicknameWithoutArroba)) // User's nickname match exactly the new nickname
|
if (!strcmp (UsrDat->Nickname,NewNickWithoutArroba)) // User's nickname match exactly the new nickname
|
||||||
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
|
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
|
||||||
Txt_The_nickname_X_matches_the_one_you_had_previously_registered,
|
Txt_The_nickname_X_matches_the_one_you_had_previously_registered,
|
||||||
NewNicknameWithoutArroba);
|
NewNickWithoutArroba);
|
||||||
else if (strcasecmp (UsrDat->Nickname,NewNicknameWithoutArroba)) // User's nickname does not match, not even case insensitive, the new nickname
|
else if (strcasecmp (UsrDat->Nickname,NewNickWithoutArroba)) // User's nickname does not match, not even case insensitive, the new nickname
|
||||||
{
|
{
|
||||||
/***** Check if the new nickname matches any of my old nicknames *****/
|
/***** Check if the new nickname matches any of my old nicknames *****/
|
||||||
if (!DB_QueryCOUNT ("can not check if nickname already existed",
|
if (!DB_QueryCOUNT ("can not check if nickname already existed",
|
||||||
"SELECT COUNT(*) FROM usr_nicknames"
|
"SELECT COUNT(*) FROM usr_nicknames"
|
||||||
" WHERE UsrCod=%ld AND Nickname='%s'",
|
" WHERE UsrCod=%ld AND Nickname='%s'",
|
||||||
UsrDat->UsrCod,NewNicknameWithoutArroba)) // No matches
|
UsrDat->UsrCod,NewNickWithoutArroba)) // No matches
|
||||||
/***** Check if the new nickname matches any of the nicknames of other users *****/
|
/***** Check if the new nickname matches any of the nicknames of other users *****/
|
||||||
if (DB_QueryCOUNT ("can not check if nickname already existed",
|
if (DB_QueryCOUNT ("can not check if nickname already existed",
|
||||||
"SELECT COUNT(*) FROM usr_nicknames"
|
"SELECT COUNT(*) FROM usr_nicknames"
|
||||||
" WHERE Nickname='%s' AND UsrCod<>%ld",
|
" WHERE Nickname='%s' AND UsrCod<>%ld",
|
||||||
NewNicknameWithoutArroba,UsrDat->UsrCod)) // A nickname of another user is the same that user's nickname
|
NewNickWithoutArroba,UsrDat->UsrCod)) // A nickname of another user is the same that user's nickname
|
||||||
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
|
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
|
||||||
Txt_The_nickname_X_had_been_registered_by_another_user,
|
Txt_The_nickname_X_had_been_registered_by_another_user,
|
||||||
NewNicknameWithoutArroba);
|
NewNickWithoutArroba);
|
||||||
}
|
}
|
||||||
if (Ale_GetNumAlerts () == 0) // No problems
|
if (Ale_GetNumAlerts () == 0) // No problems
|
||||||
{
|
{
|
||||||
// Now we know the new nickname is not already in database
|
// Now we know the new nickname is not already in database
|
||||||
// and is diffent to the current one
|
// and is diffent to the current one
|
||||||
Nck_UpdateNickInDB (UsrDat->UsrCod,NewNicknameWithoutArroba);
|
Nck_UpdateNickInDB (UsrDat->UsrCod,NewNickWithoutArroba);
|
||||||
Str_Copy (UsrDat->Nickname,NewNicknameWithoutArroba,
|
Str_Copy (UsrDat->Nickname,NewNickWithoutArroba,sizeof (UsrDat->Nickname) - 1);
|
||||||
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
|
|
||||||
|
|
||||||
Ale_CreateAlert (Ale_SUCCESS,Nck_NICKNAME_SECTION_ID,
|
Ale_CreateAlert (Ale_SUCCESS,Nck_NICKNAME_SECTION_ID,
|
||||||
Txt_The_nickname_X_has_been_registered_successfully,
|
Txt_The_nickname_X_has_been_registered_successfully,
|
||||||
NewNicknameWithoutArroba);
|
NewNickWithoutArroba);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // New nickname is not valid
|
else // New nickname is not valid
|
||||||
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
|
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
|
||||||
Txt_The_nickname_entered_X_is_not_valid_,
|
Txt_The_nickname_entered_X_is_not_valid_,
|
||||||
NewNicknameWithArroba,
|
NewNickWithArroba,
|
||||||
Nck_MIN_CHARS_NICKNAME_WITHOUT_ARROBA,
|
Nck_MIN_CHARS_NICKNAME_WITHOUT_ARROBA,
|
||||||
Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA);
|
Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
/***************************** Public prototypes *****************************/
|
/***************************** Public prototypes *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba);
|
bool Nck_CheckIfNickWithArrobaIsValid (const char *NickWithArroba);
|
||||||
|
|
||||||
bool Nck_GetNicknameFromUsrCod (long UsrCod,
|
bool Nck_GetNicknameFromUsrCod (long UsrCod,
|
||||||
char Nickname[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1]);
|
char Nickname[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1]);
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <linux/limits.h> // For PATH_MAX
|
#include <linux/limits.h> // For PATH_MAX
|
||||||
#include <stddef.h> // For NULL
|
#include <stddef.h> // For NULL
|
||||||
#include <stdio.h> // For sscanf, asprintf, etc.
|
#include <stdio.h> // For sscanf, asprintf, etc.
|
||||||
#include <stdlib.h> // For exit, system, malloc, calloc, free, etc.
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "swad_box.h"
|
#include "swad_box.h"
|
||||||
|
@ -407,8 +406,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
|
||||||
if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
|
if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
|
||||||
{
|
{
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
snprintf (StrWidth,sizeof (StrWidth),
|
snprintf (StrWidth,sizeof (StrWidth),"%upx",
|
||||||
"%upx",
|
|
||||||
Not_ContainerWidth[Not_LIST_FULL_NOTICES] + 50);
|
Not_ContainerWidth[Not_LIST_FULL_NOTICES] + 50);
|
||||||
Box_BoxBegin (StrWidth,Txt_Notices,
|
Box_BoxBegin (StrWidth,Txt_Notices,
|
||||||
Not_PutIconsListNotices,NULL,
|
Not_PutIconsListNotices,NULL,
|
||||||
|
@ -435,8 +433,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
|
||||||
UsrCod = Str_ConvertStrCodToLongCod (row[2]);
|
UsrCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||||
|
|
||||||
/* Get the content (row[3]) and insert links */
|
/* Get the content (row[3]) and insert links */
|
||||||
Str_Copy (Content,row[3],
|
Str_Copy (Content,row[3],sizeof (Content) - 1);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
|
|
||||||
/* Inserting links is incompatible with limiting the length
|
/* Inserting links is incompatible with limiting the length
|
||||||
==> don't insert links when limiting length */
|
==> don't insert links when limiting length */
|
||||||
|
@ -469,8 +466,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
|
||||||
case Not_LIST_BRIEF_NOTICES:
|
case Not_LIST_BRIEF_NOTICES:
|
||||||
/***** Link to RSS file *****/
|
/***** Link to RSS file *****/
|
||||||
/* Create RSS file if not exists */
|
/* Create RSS file if not exists */
|
||||||
snprintf (PathRelRSSFile,sizeof (PathRelRSSFile),
|
snprintf (PathRelRSSFile,sizeof (PathRelRSSFile),"%s/%ld/%s/%s",
|
||||||
"%s/%ld/%s/%s",
|
|
||||||
Cfg_PATH_CRS_PUBLIC,
|
Cfg_PATH_CRS_PUBLIC,
|
||||||
Gbl.Hierarchy.Crs.CrsCod,Cfg_RSS_FOLDER,Cfg_RSS_FILE);
|
Gbl.Hierarchy.Crs.CrsCod,Cfg_RSS_FOLDER,Cfg_RSS_FILE);
|
||||||
if (!Fil_CheckIfPathExists (PathRelRSSFile))
|
if (!Fil_CheckIfPathExists (PathRelRSSFile))
|
||||||
|
@ -586,8 +582,7 @@ static void Not_GetDataAndShowNotice (long NotCod)
|
||||||
UsrCod = Str_ConvertStrCodToLongCod (row[1]);
|
UsrCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
|
|
||||||
/* Get the content (row[2]) and insert links*/
|
/* Get the content (row[2]) and insert links*/
|
||||||
Str_Copy (Content,row[2],
|
Str_Copy (Content,row[2],sizeof (Content) - 1);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,
|
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,
|
||||||
Not_MaxCharsURLOnScreen[Not_LIST_FULL_NOTICES]);
|
Not_MaxCharsURLOnScreen[Not_LIST_FULL_NOTICES]);
|
||||||
|
|
||||||
|
@ -794,17 +789,15 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0';
|
SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Str_Copy (SummaryStr,row[0],
|
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
|
||||||
Ntf_MAX_BYTES_SUMMARY);
|
|
||||||
|
|
||||||
/***** Copy content *****/
|
/***** Copy content *****/
|
||||||
if (GetContent)
|
if (GetContent)
|
||||||
{
|
{
|
||||||
Length = strlen (row[0]);
|
Length = strlen (row[0]);
|
||||||
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
|
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (*ContentStr,row[0],
|
Str_Copy (*ContentStr,row[0],Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -726,16 +726,16 @@ static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
|
||||||
// Cod is the code of the social publishing
|
// Cod is the code of the social publishing
|
||||||
Frm_StartForm (ActSeeTmlGbl);
|
Frm_StartForm (ActSeeTmlGbl);
|
||||||
TL_Pub_PutHiddenParamPubCod (Cod);
|
TL_Pub_PutHiddenParamPubCod (Cod);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
Ntf_PutHiddenParamNotifyEvent (NotifyEvent);
|
Ntf_PutHiddenParamNotifyEvent (NotifyEvent);
|
||||||
break;
|
break;
|
||||||
case Ntf_EVENT_FOLLOWER:
|
case Ntf_EVENT_FOLLOWER:
|
||||||
if (UsrDat->EncryptedUsrCod[0]) // User's code found ==>
|
if (UsrDat->EnUsrCod[0]) // User's code found ==>
|
||||||
// go to user's public profile
|
// go to user's public profile
|
||||||
{
|
{
|
||||||
Frm_StartForm (ActSeeOthPubPrf);
|
Frm_StartForm (ActSeeOthPubPrf);
|
||||||
/* Put param to go to follower's profile */
|
/* Put param to go to follower's profile */
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
}
|
}
|
||||||
else // No user's code found ==> go to see my followers
|
else // No user's code found ==> go to see my followers
|
||||||
Frm_StartForm (ActSeeFlr);
|
Frm_StartForm (ActSeeFlr);
|
||||||
|
|
|
@ -263,7 +263,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
||||||
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
|
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
|
||||||
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
|
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
|
||||||
Pag_PutHiddenParamPagNum (WhatPaginate,1);
|
Pag_PutHiddenParamPagNum (WhatPaginate,1);
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -390,7 +390,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
||||||
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
|
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
|
||||||
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
|
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
|
||||||
Pag_PutHiddenParamPagNum (WhatPaginate,1);
|
Pag_PutHiddenParamPagNum (WhatPaginate,1);
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -503,7 +503,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
||||||
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
|
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
|
||||||
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
|
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
|
||||||
Pag_PutHiddenParamPagNum (WhatPaginate,Pagination->LeftPage);
|
Pag_PutHiddenParamPagNum (WhatPaginate,Pagination->LeftPage);
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -628,7 +628,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
||||||
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
|
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
|
||||||
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
|
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
|
||||||
Pag_PutHiddenParamPagNum (WhatPaginate,NumPage);
|
Pag_PutHiddenParamPagNum (WhatPaginate,NumPage);
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -740,7 +740,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
||||||
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
|
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
|
||||||
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
|
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
|
||||||
Pag_PutHiddenParamPagNum (WhatPaginate,Pagination->RightPage);
|
Pag_PutHiddenParamPagNum (WhatPaginate,Pagination->RightPage);
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -853,7 +853,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
||||||
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
|
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
|
||||||
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
|
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
|
||||||
Pag_PutHiddenParamPagNum (WhatPaginate,Pagination->NumPags);
|
Pag_PutHiddenParamPagNum (WhatPaginate,Pagination->NumPags);
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -86,8 +86,7 @@ bool Par_GetQueryString (void)
|
||||||
char UnsignedLongStr[Cns_MAX_DECIMAL_DIGITS_ULONG + 1];
|
char UnsignedLongStr[Cns_MAX_DECIMAL_DIGITS_ULONG + 1];
|
||||||
unsigned long UnsignedLong;
|
unsigned long UnsignedLong;
|
||||||
|
|
||||||
Str_Copy (Method,getenv ("REQUEST_METHOD"),
|
Str_Copy (Method,getenv ("REQUEST_METHOD"),sizeof (Method) - 1);
|
||||||
Par_MAX_BYTES_METHOD);
|
|
||||||
|
|
||||||
if (!strcmp (Method,"GET"))
|
if (!strcmp (Method,"GET"))
|
||||||
{
|
{
|
||||||
|
@ -99,7 +98,7 @@ bool Par_GetQueryString (void)
|
||||||
Gbl.Params.ContentLength = strlen (getenv ("QUERY_STRING"));
|
Gbl.Params.ContentLength = strlen (getenv ("QUERY_STRING"));
|
||||||
|
|
||||||
/* Allocate memory for query string */
|
/* Allocate memory for query string */
|
||||||
if ((Gbl.Params.QueryString = (char *) malloc (Gbl.Params.ContentLength + 1)) == NULL)
|
if ((Gbl.Params.QueryString = malloc (Gbl.Params.ContentLength + 1)) == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Copy query string from environment variable */
|
/* Copy query string from environment variable */
|
||||||
|
@ -113,7 +112,7 @@ bool Par_GetQueryString (void)
|
||||||
if (getenv ("CONTENT_LENGTH"))
|
if (getenv ("CONTENT_LENGTH"))
|
||||||
{
|
{
|
||||||
Str_Copy (UnsignedLongStr,getenv ("CONTENT_LENGTH"),
|
Str_Copy (UnsignedLongStr,getenv ("CONTENT_LENGTH"),
|
||||||
Cns_MAX_DECIMAL_DIGITS_ULONG);
|
sizeof (UnsignedLongStr) - 1);
|
||||||
if (sscanf (UnsignedLongStr,"%lu",&UnsignedLong) != 1)
|
if (sscanf (UnsignedLongStr,"%lu",&UnsignedLong) != 1)
|
||||||
return false;
|
return false;
|
||||||
Gbl.Params.ContentLength = (size_t) UnsignedLong;
|
Gbl.Params.ContentLength = (size_t) UnsignedLong;
|
||||||
|
@ -127,8 +126,7 @@ bool Par_GetQueryString (void)
|
||||||
if (getenv ("CONTENT_TYPE") == NULL)
|
if (getenv ("CONTENT_TYPE") == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Str_Copy (ContentType,getenv ("CONTENT_TYPE"),
|
Str_Copy (ContentType,getenv ("CONTENT_TYPE"),sizeof (ContentType) - 1);
|
||||||
Par_MAX_BYTES_CONTENT_TYPE);
|
|
||||||
|
|
||||||
if (!strncmp (ContentType,"multipart/form-data",strlen ("multipart/form-data")))
|
if (!strncmp (ContentType,"multipart/form-data",strlen ("multipart/form-data")))
|
||||||
{
|
{
|
||||||
|
@ -145,7 +143,7 @@ bool Par_GetQueryString (void)
|
||||||
Gbl.ContentReceivedByCGI = Act_CONT_NORM;
|
Gbl.ContentReceivedByCGI = Act_CONT_NORM;
|
||||||
|
|
||||||
/* Allocate memory for query string */
|
/* Allocate memory for query string */
|
||||||
if ((Gbl.Params.QueryString = (char *) malloc (Gbl.Params.ContentLength + 1)) == NULL)
|
if ((Gbl.Params.QueryString = malloc (Gbl.Params.ContentLength + 1)) == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Copy query string from stdin */
|
/* Copy query string from stdin */
|
||||||
|
@ -185,11 +183,9 @@ static void Par_GetBoundary (void)
|
||||||
|
|
||||||
/***** Create boundary strings *****/
|
/***** Create boundary strings *****/
|
||||||
snprintf (Gbl.Boundary.StrWithoutCRLF,sizeof (Gbl.Boundary.StrWithoutCRLF),
|
snprintf (Gbl.Boundary.StrWithoutCRLF,sizeof (Gbl.Boundary.StrWithoutCRLF),
|
||||||
"--%s",
|
"--%s",PtrToBoundary);
|
||||||
PtrToBoundary);
|
|
||||||
snprintf (Gbl.Boundary.StrWithCRLF,sizeof (Gbl.Boundary.StrWithCRLF),
|
snprintf (Gbl.Boundary.StrWithCRLF,sizeof (Gbl.Boundary.StrWithCRLF),
|
||||||
"%c%c%s",
|
"%c%c%s",0x0D,0x0A,Gbl.Boundary.StrWithoutCRLF);
|
||||||
0x0D,0x0A,Gbl.Boundary.StrWithoutCRLF);
|
|
||||||
|
|
||||||
/***** Compute lengths *****/
|
/***** Compute lengths *****/
|
||||||
Gbl.Boundary.LengthWithoutCRLF = strlen (Gbl.Boundary.StrWithoutCRLF);
|
Gbl.Boundary.LengthWithoutCRLF = strlen (Gbl.Boundary.StrWithoutCRLF);
|
||||||
|
@ -261,8 +257,8 @@ static void Par_CreateListOfParamsFromQueryString (void)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* Allocate space for a new parameter initialized to 0 */
|
/* Allocate space for a new parameter initialized to 0 */
|
||||||
if ((NewParam = (struct Param *) calloc (1,sizeof (struct Param))) == NULL)
|
if ((NewParam = calloc (1,sizeof (*NewParam))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for parameter");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/* Link the previous element in list with the current element */
|
/* Link the previous element in list with the current element */
|
||||||
if (CurPos == 0)
|
if (CurPos == 0)
|
||||||
|
@ -337,8 +333,8 @@ static void Par_CreateListOfParamsFromTmpFile (void)
|
||||||
if (!strcasecmp (StrAux,StringBeforeParam)) // Start of a parameter
|
if (!strcasecmp (StrAux,StringBeforeParam)) // Start of a parameter
|
||||||
{
|
{
|
||||||
/* Allocate space for a new parameter initialized to 0 */
|
/* Allocate space for a new parameter initialized to 0 */
|
||||||
if ((NewParam = (struct Param *) calloc (1,sizeof (struct Param))) == NULL)
|
if ((NewParam = calloc (1,sizeof (*NewParam))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for parameter");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/* Link the previous element in list with the current element */
|
/* Link the previous element in list with the current element */
|
||||||
if (CurPos == 0)
|
if (CurPos == 0)
|
||||||
|
@ -699,7 +695,7 @@ void Par_GetMainParameters (void)
|
||||||
/* Set another user's nickname */
|
/* Set another user's nickname */
|
||||||
Str_RemoveLeadingArrobas (Nickname);
|
Str_RemoveLeadingArrobas (Nickname);
|
||||||
Str_Copy (Gbl.Usrs.Other.UsrDat.Nickname,Nickname, // without arroba
|
Str_Copy (Gbl.Usrs.Other.UsrDat.Nickname,Nickname, // without arroba
|
||||||
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
|
sizeof (Gbl.Usrs.Other.UsrDat.Nickname) - 1);
|
||||||
|
|
||||||
// This user's code is used to go to public profile
|
// This user's code is used to go to public profile
|
||||||
// and to refresh old publishings in user's timeline
|
// and to refresh old publishings in user's timeline
|
||||||
|
@ -715,7 +711,7 @@ void Par_GetMainParameters (void)
|
||||||
/* Set another user's nickname */
|
/* Set another user's nickname */
|
||||||
Str_RemoveLeadingArrobas (Nickname);
|
Str_RemoveLeadingArrobas (Nickname);
|
||||||
Str_Copy (Gbl.Usrs.Other.UsrDat.Nickname,Nickname, // without arroba
|
Str_Copy (Gbl.Usrs.Other.UsrDat.Nickname,Nickname, // without arroba
|
||||||
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
|
sizeof (Gbl.Usrs.Other.UsrDat.Nickname) - 1);
|
||||||
|
|
||||||
// This user's code is used to go to public agenda
|
// This user's code is used to go to public agenda
|
||||||
// If user does not exist ==> UsrCod = -1
|
// If user does not exist ==> UsrCod = -1
|
||||||
|
@ -801,18 +797,14 @@ void Par_GetMainParameters (void)
|
||||||
Gbl.Prefs.Theme = The_THEME_DEFAULT;
|
Gbl.Prefs.Theme = The_THEME_DEFAULT;
|
||||||
|
|
||||||
/***** Set path of theme *****/
|
/***** Set path of theme *****/
|
||||||
snprintf (URL,sizeof (URL),
|
snprintf (URL,sizeof (URL),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Gbl.Prefs.Theme]);
|
Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Gbl.Prefs.Theme]);
|
||||||
Str_Copy (Gbl.Prefs.URLTheme,URL,
|
Str_Copy (Gbl.Prefs.URLTheme,URL,sizeof (Gbl.Prefs.URLTheme) - 1);
|
||||||
PATH_MAX);
|
|
||||||
|
|
||||||
/***** Set path of icon set *****/
|
/***** Set path of icon set *****/
|
||||||
snprintf (URL,sizeof (URL),
|
snprintf (URL,sizeof (URL),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
Cfg_URL_ICON_SETS_PUBLIC,Ico_IconSetId[Gbl.Prefs.IconSet]);
|
Cfg_URL_ICON_SETS_PUBLIC,Ico_IconSetId[Gbl.Prefs.IconSet]);
|
||||||
Str_Copy (Gbl.Prefs.URLIconSet,URL,
|
Str_Copy (Gbl.Prefs.URLIconSet,URL,sizeof (Gbl.Prefs.URLIconSet) - 1);
|
||||||
PATH_MAX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get country if exists (from menu) *****/
|
/***** Get country if exists (from menu) *****/
|
||||||
|
|
|
@ -127,7 +127,7 @@ bool Pwd_CheckPendingPassword (void)
|
||||||
/* Get encrypted pending password */
|
/* Get encrypted pending password */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Gbl.Usrs.Me.PendingPassword,row[0],
|
Str_Copy (Gbl.Usrs.Me.PendingPassword,row[0],
|
||||||
Pwd_BYTES_ENCRYPTED_PASSWORD);
|
sizeof (Gbl.Usrs.Me.PendingPassword) - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Gbl.Usrs.Me.PendingPassword[0] = '\0';
|
Gbl.Usrs.Me.PendingPassword[0] = '\0';
|
||||||
|
@ -155,7 +155,7 @@ void Pwd_AssignMyPendingPasswordToMyCurrentPassword (void)
|
||||||
|
|
||||||
/***** Update my current password *****/
|
/***** Update my current password *****/
|
||||||
Str_Copy (Gbl.Usrs.Me.UsrDat.Password,Gbl.Usrs.Me.PendingPassword,
|
Str_Copy (Gbl.Usrs.Me.UsrDat.Password,Gbl.Usrs.Me.PendingPassword,
|
||||||
Pwd_BYTES_ENCRYPTED_PASSWORD);
|
sizeof (Gbl.Usrs.Me.UsrDat.Password) - 1);
|
||||||
|
|
||||||
/***** Remove my pending password from database
|
/***** Remove my pending password from database
|
||||||
since it is not longer necessary *****/
|
since it is not longer necessary *****/
|
||||||
|
@ -235,7 +235,7 @@ static void Pwd_CheckAndUpdateNewPwd (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
/* Update user's data */
|
/* Update user's data */
|
||||||
Str_Copy (UsrDat->Password,NewEncryptedPassword,
|
Str_Copy (UsrDat->Password,NewEncryptedPassword,
|
||||||
Pwd_BYTES_ENCRYPTED_PASSWORD);
|
sizeof (UsrDat->Password) - 1);
|
||||||
Ses_UpdateSessionDataInDB ();
|
Ses_UpdateSessionDataInDB ();
|
||||||
Enr_UpdateUsrData (UsrDat);
|
Enr_UpdateUsrData (UsrDat);
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ void Pwd_ChkIdLoginAndSendNewPwd (void)
|
||||||
|
|
||||||
// User has typed a user's ID
|
// User has typed a user's ID
|
||||||
Str_Copy (Gbl.Usrs.Me.UsrDat.IDs.List[0].ID,Gbl.Usrs.Me.UsrIdLogin,
|
Str_Copy (Gbl.Usrs.Me.UsrDat.IDs.List[0].ID,Gbl.Usrs.Me.UsrIdLogin,
|
||||||
ID_MAX_BYTES_USR_ID);
|
sizeof (Gbl.Usrs.Me.UsrDat.IDs.List[0].ID) - 1);
|
||||||
Str_ConvertToUpperText (Gbl.Usrs.Me.UsrDat.IDs.List[0].ID);
|
Str_ConvertToUpperText (Gbl.Usrs.Me.UsrDat.IDs.List[0].ID);
|
||||||
|
|
||||||
/* Get users' codes for this ID */
|
/* Get users' codes for this ID */
|
||||||
|
@ -669,9 +669,7 @@ void Pwd_ShowFormChgMyPwd (void)
|
||||||
Frm_StartFormAnchor (ActChgMyPwd,Pwd_PASSWORD_SECTION_ID);
|
Frm_StartFormAnchor (ActChgMyPwd,Pwd_PASSWORD_SECTION_ID);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
|
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
|
||||||
"%upx",
|
|
||||||
Rec_RECORD_WIDTH);
|
|
||||||
Box_BoxBegin (StrRecordWidth,Txt_Password,
|
Box_BoxBegin (StrRecordWidth,Txt_Password,
|
||||||
NULL,NULL,
|
NULL,NULL,
|
||||||
Hlp_PROFILE_Password,Box_NOT_CLOSABLE);
|
Hlp_PROFILE_Password,Box_NOT_CLOSABLE);
|
||||||
|
@ -833,7 +831,7 @@ void Pwd_ShowFormChgOtherUsrPwd (void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Frm_StartFormAnchor (NextAction,Pwd_PASSWORD_SECTION_ID);
|
Frm_StartFormAnchor (NextAction,Pwd_PASSWORD_SECTION_ID);
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
|
|
||||||
/* New password */
|
/* New password */
|
||||||
HTM_TABLE_BeginWidePadding (2);
|
HTM_TABLE_BeginWidePadding (2);
|
||||||
|
|
96
swad_photo.c
96
swad_photo.c
|
@ -271,7 +271,7 @@ static void Pho_PutIconToRequestRemoveOtherUsrPhoto (__attribute__((unused)) voi
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,
|
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,
|
||||||
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EnUsrCod,
|
||||||
"trash.svg",
|
"trash.svg",
|
||||||
Txt_Remove_photo);
|
Txt_Remove_photo);
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ static void Pho_ReqPhoto (const struct UsrData *UsrDat)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Frm_StartForm (NextAction);
|
Frm_StartForm (NextAction);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Show help message *****/
|
/***** Show help message *****/
|
||||||
|
@ -531,7 +531,7 @@ void Pho_ReqRemoveUsrPhoto (void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Ale_ShowAlertAndButton2 (NextAction,NULL,NULL,
|
Ale_ShowAlertAndButton2 (NextAction,NULL,NULL,
|
||||||
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EnUsrCod,
|
||||||
Btn_REMOVE_BUTTON,Txt_Remove_photo);
|
Btn_REMOVE_BUTTON,Txt_Remove_photo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -614,10 +614,8 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
|
||||||
|
|
||||||
/***** Creates directories if not exist *****/
|
/***** Creates directories if not exist *****/
|
||||||
Fil_CreateDirIfNotExists (Cfg_PATH_PHOTO_PRIVATE);
|
Fil_CreateDirIfNotExists (Cfg_PATH_PHOTO_PRIVATE);
|
||||||
snprintf (PathPhotosPriv,sizeof (PathPhotosPriv),
|
snprintf (PathPhotosPriv,sizeof (PathPhotosPriv),"%s/%02u",
|
||||||
"%s/%02u",
|
Cfg_PATH_PHOTO_PRIVATE,(unsigned) (UsrDat->UsrCod % 100));
|
||||||
Cfg_PATH_PHOTO_PRIVATE,
|
|
||||||
(unsigned) (UsrDat->UsrCod % 100));
|
|
||||||
Fil_CreateDirIfNotExists (PathPhotosPriv);
|
Fil_CreateDirIfNotExists (PathPhotosPriv);
|
||||||
|
|
||||||
/***** Create directories if not exists
|
/***** Create directories if not exists
|
||||||
|
@ -647,10 +645,8 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End the reception of photo in a temporary file */
|
/* End the reception of photo in a temporary file */
|
||||||
snprintf (FileNamePhotoTmp,sizeof (FileNamePhotoTmp),
|
snprintf (FileNamePhotoTmp,sizeof (FileNamePhotoTmp),"%s/%s.jpg",
|
||||||
"%s/%s.jpg",
|
Cfg_PATH_PHOTO_TMP_PUBLIC,Gbl.UniqueNameEncrypted);
|
||||||
Cfg_PATH_PHOTO_TMP_PUBLIC,
|
|
||||||
Gbl.UniqueNameEncrypted);
|
|
||||||
if (!Fil_EndReceptionOfFile (FileNamePhotoTmp,Param))
|
if (!Fil_EndReceptionOfFile (FileNamePhotoTmp,Param))
|
||||||
{
|
{
|
||||||
Ale_ShowAlert (Ale_ERROR,"Error copying file.");
|
Ale_ShowAlert (Ale_ERROR,"Error copying file.");
|
||||||
|
@ -659,15 +655,13 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
|
||||||
|
|
||||||
/* Copy the original photo received to private directory.
|
/* Copy the original photo received to private directory.
|
||||||
The purpose of this copy is only to have a backup used for researching better methods to detect faces in images */
|
The purpose of this copy is only to have a backup used for researching better methods to detect faces in images */
|
||||||
snprintf (PathRelPhoto,sizeof (PathRelPhoto),
|
snprintf (PathRelPhoto,sizeof (PathRelPhoto),"%s/%02u/%ld_original.jpg",
|
||||||
"%s/%02u/%ld_original.jpg",
|
|
||||||
Cfg_PATH_PHOTO_PRIVATE,
|
Cfg_PATH_PHOTO_PRIVATE,
|
||||||
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
|
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
|
||||||
Fil_FastCopyOfFiles (FileNamePhotoTmp,PathRelPhoto);
|
Fil_FastCopyOfFiles (FileNamePhotoTmp,PathRelPhoto);
|
||||||
|
|
||||||
/***** Call to program that makes photo processing / face detection *****/
|
/***** Call to program that makes photo processing / face detection *****/
|
||||||
snprintf (Command,sizeof (Command),
|
snprintf (Command,sizeof (Command),Cfg_COMMAND_FACE_DETECTION,
|
||||||
Cfg_COMMAND_FACE_DETECTION,
|
|
||||||
FileNamePhotoTmp);
|
FileNamePhotoTmp);
|
||||||
ReturnCode = system (Command);
|
ReturnCode = system (Command);
|
||||||
if (ReturnCode == -1)
|
if (ReturnCode == -1)
|
||||||
|
@ -679,10 +673,8 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
|
||||||
{
|
{
|
||||||
case 0: // Faces detected
|
case 0: // Faces detected
|
||||||
/***** Open text file with text for image map *****/
|
/***** Open text file with text for image map *****/
|
||||||
snprintf (FileNameTxtMap,sizeof (FileNameTxtMap),
|
snprintf (FileNameTxtMap,sizeof (FileNameTxtMap),"%s/%s_map.txt",
|
||||||
"%s/%s_map.txt",
|
Cfg_PATH_PHOTO_TMP_PUBLIC,Gbl.UniqueNameEncrypted);
|
||||||
Cfg_PATH_PHOTO_TMP_PUBLIC,
|
|
||||||
Gbl.UniqueNameEncrypted);
|
|
||||||
if ((FileTxtMap = fopen (FileNameTxtMap,"rb")) == NULL)
|
if ((FileTxtMap = fopen (FileNameTxtMap,"rb")) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Can not read text file with coordinates of detected faces.");
|
Lay_ShowErrorAndExit ("Can not read text file with coordinates of detected faces.");
|
||||||
|
|
||||||
|
@ -714,7 +706,7 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Frm_StartForm (NextAction);
|
Frm_StartForm (NextAction);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
}
|
}
|
||||||
Par_PutHiddenParamString (NULL,"FileName",StrFileName);
|
Par_PutHiddenParamString (NULL,"FileName",StrFileName);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
|
@ -778,9 +770,7 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
|
||||||
if (BackgroundCode == 1)
|
if (BackgroundCode == 1)
|
||||||
{
|
{
|
||||||
NumFace++;
|
NumFace++;
|
||||||
snprintf (FormId,sizeof (FormId),
|
snprintf (FormId,sizeof (FormId),"form_%d",NumLastForm + NumFace);
|
||||||
"form_%d",
|
|
||||||
NumLastForm + NumFace);
|
|
||||||
HTM_TxtF ("<area shape=\"circle\""
|
HTM_TxtF ("<area shape=\"circle\""
|
||||||
" href=\"\""
|
" href=\"\""
|
||||||
" onclick=\"javascript:document.getElementById('%s').submit();return false;\""
|
" onclick=\"javascript:document.getElementById('%s').submit();return false;\""
|
||||||
|
@ -794,10 +784,8 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
|
||||||
HTM_Txt ("</map>\n");
|
HTM_Txt ("</map>\n");
|
||||||
|
|
||||||
/***** Show map photo *****/
|
/***** Show map photo *****/
|
||||||
snprintf (FileNamePhotoMap,sizeof (FileNamePhotoMap),
|
snprintf (FileNamePhotoMap,sizeof (FileNamePhotoMap),"%s/%s_map.jpg",
|
||||||
"%s/%s_map.jpg",
|
Cfg_PATH_PHOTO_TMP_PUBLIC,Gbl.UniqueNameEncrypted);
|
||||||
Cfg_PATH_PHOTO_TMP_PUBLIC,
|
|
||||||
Gbl.UniqueNameEncrypted);
|
|
||||||
HTM_DIV_Begin ("class=\"TIT CM\"");
|
HTM_DIV_Begin ("class=\"TIT CM\"");
|
||||||
HTM_IMG (Cfg_URL_PHOTO_TMP_PUBLIC,
|
HTM_IMG (Cfg_URL_PHOTO_TMP_PUBLIC,
|
||||||
Str_BuildStringStr ("%s_map.jpg",Gbl.UniqueNameEncrypted),
|
Str_BuildStringStr ("%s_map.jpg",Gbl.UniqueNameEncrypted),
|
||||||
|
@ -870,15 +858,12 @@ static void Pho_UpdatePhoto1 (struct UsrData *UsrDat)
|
||||||
Par_GetParToText ("FileName",Gbl.Usrs.FileNamePhoto,NAME_MAX); // Example of FileNamePhoto: "4924a838630e_016"
|
Par_GetParToText ("FileName",Gbl.Usrs.FileNamePhoto,NAME_MAX); // Example of FileNamePhoto: "4924a838630e_016"
|
||||||
|
|
||||||
/***** Convert the temporary photo resulting of the processing to the current photo of the user *****/
|
/***** Convert the temporary photo resulting of the processing to the current photo of the user *****/
|
||||||
snprintf (PathPhotoTmp,sizeof (PathPhotoTmp),
|
snprintf (PathPhotoTmp,sizeof (PathPhotoTmp),"%s/%s_paso3.jpg",
|
||||||
"%s/%s_paso3.jpg",
|
Cfg_PATH_PHOTO_TMP_PUBLIC,Gbl.Usrs.FileNamePhoto);
|
||||||
Cfg_PATH_PHOTO_TMP_PUBLIC,
|
|
||||||
Gbl.Usrs.FileNamePhoto);
|
|
||||||
if (Fil_CheckIfPathExists (PathPhotoTmp)) // The file with the selected photo exists
|
if (Fil_CheckIfPathExists (PathPhotoTmp)) // The file with the selected photo exists
|
||||||
{
|
{
|
||||||
/* Copy the temporary file of the third (last) step resulting of the processing to the directory of private photos */
|
/* Copy the temporary file of the third (last) step resulting of the processing to the directory of private photos */
|
||||||
snprintf (PathRelPhoto,sizeof (PathRelPhoto),
|
snprintf (PathRelPhoto,sizeof (PathRelPhoto),"%s/%02u/%ld.jpg",
|
||||||
"%s/%02u/%ld.jpg",
|
|
||||||
Cfg_PATH_PHOTO_PRIVATE,
|
Cfg_PATH_PHOTO_PRIVATE,
|
||||||
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
|
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
|
||||||
Fil_FastCopyOfFiles (PathPhotoTmp,PathRelPhoto);
|
Fil_FastCopyOfFiles (PathPhotoTmp,PathRelPhoto);
|
||||||
|
@ -1030,13 +1015,11 @@ bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char PhotoURL[PATH_MAX +
|
||||||
if (UsrDat->Photo[0])
|
if (UsrDat->Photo[0])
|
||||||
{
|
{
|
||||||
/***** Make path to public photo *****/
|
/***** Make path to public photo *****/
|
||||||
snprintf (PathPublPhoto,sizeof (PathPublPhoto),
|
snprintf (PathPublPhoto,sizeof (PathPublPhoto),"%s/%s.jpg",
|
||||||
"%s/%s.jpg",
|
|
||||||
Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo);
|
Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo);
|
||||||
|
|
||||||
/***** Make path to private photo from public directory *****/
|
/***** Make path to private photo from public directory *****/
|
||||||
snprintf (PathPrivPhoto,sizeof (PathPrivPhoto),
|
snprintf (PathPrivPhoto,sizeof (PathPrivPhoto),"%s/%02u/%ld.jpg",
|
||||||
"%s/%02u/%ld.jpg",
|
|
||||||
Cfg_PATH_PHOTO_PRIVATE,
|
Cfg_PATH_PHOTO_PRIVATE,
|
||||||
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
|
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
|
||||||
|
|
||||||
|
@ -1047,8 +1030,7 @@ bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char PhotoURL[PATH_MAX +
|
||||||
" to access to user's private photo");
|
" to access to user's private photo");
|
||||||
|
|
||||||
/***** Create the public URL of the photo *****/
|
/***** Create the public URL of the photo *****/
|
||||||
snprintf (PhotoURL,PATH_MAX + 1,
|
snprintf (PhotoURL,PATH_MAX + 1,"%s/%s.jpg",
|
||||||
"%s/%s.jpg",
|
|
||||||
Cfg_URL_PHOTO_PUBLIC,UsrDat->Photo);
|
Cfg_URL_PHOTO_PUBLIC,UsrDat->Photo);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1069,10 +1051,8 @@ bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char PhotoURL[PATH_MAX +
|
||||||
bool Pho_CheckIfPrivPhotoExists (long UsrCod,char PathPrivRelPhoto[PATH_MAX + 1])
|
bool Pho_CheckIfPrivPhotoExists (long UsrCod,char PathPrivRelPhoto[PATH_MAX + 1])
|
||||||
{
|
{
|
||||||
/***** Make path to private photo *****/
|
/***** Make path to private photo *****/
|
||||||
snprintf (PathPrivRelPhoto,PATH_MAX + 1,
|
snprintf (PathPrivRelPhoto,PATH_MAX + 1,"%s/%02u/%ld.jpg",
|
||||||
"%s/%02u/%ld.jpg",
|
Cfg_PATH_PHOTO_PRIVATE,(unsigned) (UsrCod % 100),UsrCod);
|
||||||
Cfg_PATH_PHOTO_PRIVATE,
|
|
||||||
(unsigned) (UsrCod % 100),UsrCod);
|
|
||||||
|
|
||||||
return Fil_CheckIfPathExists (PathPrivRelPhoto);
|
return Fil_CheckIfPathExists (PathPrivRelPhoto);
|
||||||
}
|
}
|
||||||
|
@ -1095,16 +1075,14 @@ bool Pho_RemovePhoto (struct UsrData *UsrDat)
|
||||||
Pho_ClearPhotoName (UsrDat->UsrCod);
|
Pho_ClearPhotoName (UsrDat->UsrCod);
|
||||||
|
|
||||||
/***** Remove public link *****/
|
/***** Remove public link *****/
|
||||||
snprintf (PathPublPhoto,sizeof (PathPublPhoto),
|
snprintf (PathPublPhoto,sizeof (PathPublPhoto),"%s/%s.jpg",
|
||||||
"%s/%s.jpg",
|
|
||||||
Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo);
|
Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo);
|
||||||
if (Fil_CheckIfPathExists (PathPublPhoto)) // Public link exists
|
if (Fil_CheckIfPathExists (PathPublPhoto)) // Public link exists
|
||||||
if (unlink (PathPublPhoto)) // Remove public link
|
if (unlink (PathPublPhoto)) // Remove public link
|
||||||
NumErrors++;
|
NumErrors++;
|
||||||
|
|
||||||
/***** Remove photo *****/
|
/***** Remove photo *****/
|
||||||
snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto),
|
snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto),"%s/%02u/%ld.jpg",
|
||||||
"%s/%02u/%ld.jpg",
|
|
||||||
Cfg_PATH_PHOTO_PRIVATE,
|
Cfg_PATH_PHOTO_PRIVATE,
|
||||||
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
|
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
|
||||||
if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Photo exists
|
if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Photo exists
|
||||||
|
@ -1115,7 +1093,7 @@ bool Pho_RemovePhoto (struct UsrData *UsrDat)
|
||||||
|
|
||||||
/***** Remove original photo *****/
|
/***** Remove original photo *****/
|
||||||
snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto),
|
snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto),
|
||||||
"%s/%02u/%ld_original.jpg",
|
"%s/%02u/%ld_original.jpg",
|
||||||
Cfg_PATH_PHOTO_PRIVATE,
|
Cfg_PATH_PHOTO_PRIVATE,
|
||||||
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
|
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
|
||||||
if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Original photo exists
|
if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Original photo exists
|
||||||
|
@ -1166,14 +1144,12 @@ void Pho_UpdatePhotoName (struct UsrData *UsrDat)
|
||||||
Gbl.UniqueNameEncrypted,UsrDat->UsrCod);
|
Gbl.UniqueNameEncrypted,UsrDat->UsrCod);
|
||||||
|
|
||||||
/***** Remove the old symbolic link to photo *****/
|
/***** Remove the old symbolic link to photo *****/
|
||||||
snprintf (PathPublPhoto,sizeof (PathPublPhoto),
|
snprintf (PathPublPhoto,sizeof (PathPublPhoto),"%s/%s.jpg",
|
||||||
"%s/%s.jpg",
|
|
||||||
Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo);
|
Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo);
|
||||||
unlink (PathPublPhoto); // Remove public link
|
unlink (PathPublPhoto); // Remove public link
|
||||||
|
|
||||||
/***** Update photo name in user's data *****/
|
/***** Update photo name in user's data *****/
|
||||||
Str_Copy (UsrDat->Photo,Gbl.UniqueNameEncrypted,
|
Str_Copy (UsrDat->Photo,Gbl.UniqueNameEncrypted,sizeof (UsrDat->Photo) - 1);
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1209,7 +1185,7 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
|
||||||
Frm_StartFormUnique (ActSeeOthPubPrf);
|
Frm_StartFormUnique (ActSeeOthPubPrf);
|
||||||
else
|
else
|
||||||
Frm_StartForm (ActSeeOthPubPrf);
|
Frm_StartForm (ActSeeOthPubPrf);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_LINK",NULL);
|
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_LINK",NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1368,8 +1344,7 @@ void Pho_CalcPhotoDegree (void)
|
||||||
TypeOfAverage++)
|
TypeOfAverage++)
|
||||||
{
|
{
|
||||||
snprintf (DirAvgPhotosRelPath[TypeOfAverage],
|
snprintf (DirAvgPhotosRelPath[TypeOfAverage],
|
||||||
sizeof (DirAvgPhotosRelPath[TypeOfAverage]),
|
sizeof (DirAvgPhotosRelPath[TypeOfAverage]),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
Cfg_PATH_PHOTO_PUBLIC,Pho_StrAvgPhotoDirs[TypeOfAverage]);
|
Cfg_PATH_PHOTO_PUBLIC,Pho_StrAvgPhotoDirs[TypeOfAverage]);
|
||||||
Fil_CreateDirIfNotExists (DirAvgPhotosRelPath[TypeOfAverage]);
|
Fil_CreateDirIfNotExists (DirAvgPhotosRelPath[TypeOfAverage]);
|
||||||
}
|
}
|
||||||
|
@ -1656,8 +1631,7 @@ static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,Rol_Role_t Role,
|
||||||
/***** Call to program to calculate average photo *****/
|
/***** Call to program to calculate average photo *****/
|
||||||
if (*NumStdsWithPhoto)
|
if (*NumStdsWithPhoto)
|
||||||
{
|
{
|
||||||
snprintf (StrCallToProgram,sizeof (StrCallToProgram),
|
snprintf (StrCallToProgram,sizeof (StrCallToProgram),"%s %s %s",
|
||||||
"%s %s %s",
|
|
||||||
Pho_StrAvgPhotoPrograms[TypeOfAverage],
|
Pho_StrAvgPhotoPrograms[TypeOfAverage],
|
||||||
FileNamePhotoNames,PathRelAvgPhoto);
|
FileNamePhotoNames,PathRelAvgPhoto);
|
||||||
ReturnCode = system (StrCallToProgram);
|
ReturnCode = system (StrCallToProgram);
|
||||||
|
@ -2058,7 +2032,7 @@ static void Pho_PutLinkToCalculateDegreeStats (const struct Pho_DegPhotos *DegPh
|
||||||
EstimatedTimeToComputeAvgPhotoInMicroseconds = Pho_GetTimeToComputeAvgPhoto (Degs.Lst[NumDeg].DegCod);
|
EstimatedTimeToComputeAvgPhotoInMicroseconds = Pho_GetTimeToComputeAvgPhoto (Degs.Lst[NumDeg].DegCod);
|
||||||
if (EstimatedTimeToComputeAvgPhotoInMicroseconds == -1L)
|
if (EstimatedTimeToComputeAvgPhotoInMicroseconds == -1L)
|
||||||
Str_Copy (StrEstimatedTimeToComputeAvgPhoto,Txt_unknown_TIME,
|
Str_Copy (StrEstimatedTimeToComputeAvgPhoto,Txt_unknown_TIME,
|
||||||
Dat_MAX_BYTES_TIME);
|
sizeof (StrEstimatedTimeToComputeAvgPhoto) - 1);
|
||||||
else
|
else
|
||||||
Sta_WriteTime (StrEstimatedTimeToComputeAvgPhoto,
|
Sta_WriteTime (StrEstimatedTimeToComputeAvgPhoto,
|
||||||
EstimatedTimeToComputeAvgPhotoInMicroseconds);
|
EstimatedTimeToComputeAvgPhotoInMicroseconds);
|
||||||
|
@ -2502,15 +2476,13 @@ static void Pho_ShowDegreeAvgPhotoAndStat (const struct Deg_Degree *Deg,
|
||||||
|
|
||||||
if (ShowDegPhoto)
|
if (ShowDegPhoto)
|
||||||
{
|
{
|
||||||
snprintf (PathRelAvgPhoto,sizeof (PathRelAvgPhoto),
|
snprintf (PathRelAvgPhoto,sizeof (PathRelAvgPhoto),"%s/%s/%ld_%s.jpg",
|
||||||
"%s/%s/%ld_%s.jpg",
|
|
||||||
Cfg_PATH_PHOTO_PUBLIC,
|
Cfg_PATH_PHOTO_PUBLIC,
|
||||||
Pho_StrAvgPhotoDirs[DegPhotos->TypeOfAverage],
|
Pho_StrAvgPhotoDirs[DegPhotos->TypeOfAverage],
|
||||||
Deg->DegCod,Usr_StringsSexDB[Sex]);
|
Deg->DegCod,Usr_StringsSexDB[Sex]);
|
||||||
if (Fil_CheckIfPathExists (PathRelAvgPhoto))
|
if (Fil_CheckIfPathExists (PathRelAvgPhoto))
|
||||||
{
|
{
|
||||||
snprintf (PhotoURL,sizeof (PhotoURL),
|
snprintf (PhotoURL,sizeof (PhotoURL),"%s/%s/%ld_%s.jpg",
|
||||||
"%s/%s/%ld_%s.jpg",
|
|
||||||
Cfg_URL_PHOTO_PUBLIC,
|
Cfg_URL_PHOTO_PUBLIC,
|
||||||
Pho_StrAvgPhotoDirs[DegPhotos->TypeOfAverage],
|
Pho_StrAvgPhotoDirs[DegPhotos->TypeOfAverage],
|
||||||
Deg->DegCod,Usr_StringsSexDB[Sex]);
|
Deg->DegCod,Usr_StringsSexDB[Sex]);
|
||||||
|
|
43
swad_place.c
43
swad_place.c
|
@ -397,8 +397,8 @@ void Plc_GetListPlaces (struct Plc_Places *Places)
|
||||||
Places->Num = (unsigned) NumRows;
|
Places->Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with courses in centre *****/
|
/***** Create list with courses in centre *****/
|
||||||
if ((Places->Lst = (struct Plc_Place *) calloc (NumRows,sizeof (struct Plc_Place))) == NULL)
|
if ((Places->Lst = calloc (NumRows,sizeof (*Places->Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the places *****/
|
/***** Get the places *****/
|
||||||
for (NumPlc = 0;
|
for (NumPlc = 0;
|
||||||
|
@ -414,13 +414,9 @@ void Plc_GetListPlaces (struct Plc_Places *Places)
|
||||||
if ((Plc->PlcCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
if ((Plc->PlcCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of place.");
|
Lay_ShowErrorAndExit ("Wrong code of place.");
|
||||||
|
|
||||||
/* Get the short name of the place (row[1]) */
|
/* Get the short (row[1]) and full (row[2]) names of the place */
|
||||||
Str_Copy (Plc->ShrtName,row[1],
|
Str_Copy (Plc->ShrtName,row[1],sizeof (Plc->ShrtName) - 1);
|
||||||
Plc_MAX_BYTES_PLACE_SHRT_NAME);
|
Str_Copy (Plc->FullName,row[2],sizeof (Plc->FullName) - 1);
|
||||||
|
|
||||||
/* Get the full name of the place (row[2]) */
|
|
||||||
Str_Copy (Plc->FullName,row[2],
|
|
||||||
Plc_MAX_BYTES_PLACE_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get number of centres in this place (row[3]) */
|
/* Get number of centres in this place (row[3]) */
|
||||||
if (sscanf (row[3],"%u",&Plc->NumCtrs) != 1)
|
if (sscanf (row[3],"%u",&Plc->NumCtrs) != 1)
|
||||||
|
@ -454,17 +450,13 @@ void Plc_GetDataOfPlaceByCod (struct Plc_Place *Plc)
|
||||||
/***** Check if place code is correct *****/
|
/***** Check if place code is correct *****/
|
||||||
if (Plc->PlcCod < 0)
|
if (Plc->PlcCod < 0)
|
||||||
{
|
{
|
||||||
Str_Copy (Plc->ShrtName,Txt_Place_unspecified,
|
Str_Copy (Plc->ShrtName,Txt_Place_unspecified,sizeof (Plc->ShrtName) - 1);
|
||||||
Plc_MAX_BYTES_PLACE_SHRT_NAME);
|
Str_Copy (Plc->FullName,Txt_Place_unspecified,sizeof (Plc->FullName) - 1);
|
||||||
Str_Copy (Plc->FullName,Txt_Place_unspecified,
|
|
||||||
Plc_MAX_BYTES_PLACE_FULL_NAME);
|
|
||||||
}
|
}
|
||||||
else if (Plc->PlcCod == 0)
|
else if (Plc->PlcCod == 0)
|
||||||
{
|
{
|
||||||
Str_Copy (Plc->ShrtName,Txt_Another_place,
|
Str_Copy (Plc->ShrtName,Txt_Another_place,sizeof (Plc->ShrtName) - 1);
|
||||||
Plc_MAX_BYTES_PLACE_SHRT_NAME);
|
Str_Copy (Plc->FullName,Txt_Another_place,sizeof (Plc->FullName) - 1);
|
||||||
Str_Copy (Plc->FullName,Txt_Another_place,
|
|
||||||
Plc_MAX_BYTES_PLACE_FULL_NAME);
|
|
||||||
}
|
}
|
||||||
else if (Plc->PlcCod > 0)
|
else if (Plc->PlcCod > 0)
|
||||||
{
|
{
|
||||||
|
@ -496,13 +488,9 @@ void Plc_GetDataOfPlaceByCod (struct Plc_Place *Plc)
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get the short name of the place (row[0]) */
|
/* Get the short (row[0]) and full (row[1]) names of the place */
|
||||||
Str_Copy (Plc->ShrtName,row[0],
|
Str_Copy (Plc->ShrtName,row[0],sizeof (Plc->ShrtName) - 1);
|
||||||
Plc_MAX_BYTES_PLACE_SHRT_NAME);
|
Str_Copy (Plc->FullName,row[1],sizeof (Plc->FullName) - 1);
|
||||||
|
|
||||||
/* Get the full name of the place (row[1]) */
|
|
||||||
Str_Copy (Plc->FullName,row[1],
|
|
||||||
Plc_MAX_BYTES_PLACE_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get number of centres in this place (row[2]) */
|
/* Get number of centres in this place (row[2]) */
|
||||||
if (sscanf (row[2],"%u",&Plc->NumCtrs) != 1)
|
if (sscanf (row[2],"%u",&Plc->NumCtrs) != 1)
|
||||||
|
@ -754,8 +742,7 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update place name *****/
|
/***** Update place name *****/
|
||||||
Str_Copy (CurrentPlcName,NewPlcName,
|
Str_Copy (CurrentPlcName,NewPlcName,MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -952,8 +939,8 @@ static void Plc_EditingPlaceConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing place.");
|
Lay_ShowErrorAndExit ("Error initializing place.");
|
||||||
|
|
||||||
/***** Allocate memory for place *****/
|
/***** Allocate memory for place *****/
|
||||||
if ((Plc_EditingPlc = (struct Plc_Place *) malloc (sizeof (struct Plc_Place))) == NULL)
|
if ((Plc_EditingPlc = malloc (sizeof (*Plc_EditingPlc))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for place.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset place *****/
|
/***** Reset place *****/
|
||||||
Plc_EditingPlc->PlcCod = -1L;
|
Plc_EditingPlc->PlcCod = -1L;
|
||||||
|
|
|
@ -131,9 +131,7 @@ void Plg_ListPlugins (void)
|
||||||
{
|
{
|
||||||
Plg = &(Gbl.Plugins.Lst[NumPlg]);
|
Plg = &(Gbl.Plugins.Lst[NumPlg]);
|
||||||
|
|
||||||
snprintf (URL,sizeof (URL),
|
snprintf (URL,sizeof (URL),"%s%s",Plg->URL,Gbl.Session.Id);
|
||||||
"%s%s",
|
|
||||||
Plg->URL,Gbl.Session.Id);
|
|
||||||
|
|
||||||
/* Plugin logo */
|
/* Plugin logo */
|
||||||
// TODO: Change plugin icons to 32x32
|
// TODO: Change plugin icons to 32x32
|
||||||
|
@ -242,7 +240,8 @@ static void Plg_GetListPlugins (void)
|
||||||
Gbl.Plugins.Num = (unsigned) NumRows;
|
Gbl.Plugins.Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with plugins *****/
|
/***** Create list with plugins *****/
|
||||||
if ((Gbl.Plugins.Lst = (struct Plugin *) calloc ((size_t) Gbl.Plugins.Num,sizeof (struct Plugin))) == NULL)
|
if ((Gbl.Plugins.Lst = calloc (Gbl.Plugins.Num,
|
||||||
|
sizeof (*Gbl.Plugins.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the plugins *****/
|
/***** Get the plugins *****/
|
||||||
|
@ -259,29 +258,14 @@ static void Plg_GetListPlugins (void)
|
||||||
if ((Plg->PlgCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
if ((Plg->PlgCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of plugin.");
|
Lay_ShowErrorAndExit ("Wrong code of plugin.");
|
||||||
|
|
||||||
/* Get the name of the plugin (row[1]) */
|
/* Get name (row[1]), description (row[2), logo (row[3]),
|
||||||
Str_Copy (Plg->Name,row[1],
|
* application key (row[4]), URL (row[5]) and IP (row[6]) of the plugin */
|
||||||
Plg_MAX_BYTES_PLUGIN_NAME);
|
Str_Copy (Plg->Name ,row[1],sizeof (Plg->Name ) - 1);
|
||||||
|
Str_Copy (Plg->Description,row[2],sizeof (Plg->Description) - 1);
|
||||||
/* Get the description of the plugin (row[2]) */
|
Str_Copy (Plg->Logo ,row[3],sizeof (Plg->Logo ) - 1);
|
||||||
Str_Copy (Plg->Description,row[2],
|
Str_Copy (Plg->AppKey ,row[4],sizeof (Plg->AppKey ) - 1);
|
||||||
Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
|
Str_Copy (Plg->URL ,row[5],sizeof (Plg->URL ) - 1);
|
||||||
|
Str_Copy (Plg->IP ,row[6],sizeof (Plg->IP ) - 1);
|
||||||
/* Get the logo of the plugin (row[3]) */
|
|
||||||
Str_Copy (Plg->Logo,row[3],
|
|
||||||
Plg_MAX_BYTES_PLUGIN_LOGO);
|
|
||||||
|
|
||||||
/* Get the application key of the plugin (row[4]) */
|
|
||||||
Str_Copy (Plg->AppKey,row[4],
|
|
||||||
Plg_MAX_BYTES_PLUGIN_APP_KEY);
|
|
||||||
|
|
||||||
/* Get the URL of the plugin (row[5]) */
|
|
||||||
Str_Copy (Plg->URL,row[5],
|
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
|
|
||||||
/* Get the IP of the plugin (row[6]) */
|
|
||||||
Str_Copy (Plg->IP,row[6],
|
|
||||||
Cns_MAX_BYTES_IP);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -329,29 +313,14 @@ bool Plg_GetDataOfPluginByCod (struct Plugin *Plg)
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get the name of the plugin (row[0]) */
|
/* Get name (row[0]), description (row[1]), logo (row[2]),
|
||||||
Str_Copy (Plg->Name,row[0],
|
application key (row[3]), URL (row[4]) and IP (row[5]) of the plugin */
|
||||||
Plg_MAX_BYTES_PLUGIN_NAME);
|
Str_Copy (Plg->Name ,row[0],sizeof (Plg->Name ) - 1);
|
||||||
|
Str_Copy (Plg->Description,row[1],sizeof (Plg->Description) - 1);
|
||||||
/* Get the description of the plugin (row[1]) */
|
Str_Copy (Plg->Logo ,row[2],sizeof (Plg->Logo ) - 1);
|
||||||
Str_Copy (Plg->Description,row[1],
|
Str_Copy (Plg->AppKey ,row[3],sizeof (Plg->AppKey ) - 1);
|
||||||
Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
|
Str_Copy (Plg->URL ,row[4],sizeof (Plg->URL ) - 1);
|
||||||
|
Str_Copy (Plg->IP ,row[5],sizeof (Plg->IP ) - 1);
|
||||||
/* Get the logo of the plugin (row[2]) */
|
|
||||||
Str_Copy (Plg->Logo,row[2],
|
|
||||||
Plg_MAX_BYTES_PLUGIN_LOGO);
|
|
||||||
|
|
||||||
/* Get the application key of the plugin (row[3]) */
|
|
||||||
Str_Copy (Plg->AppKey,row[3],
|
|
||||||
Plg_MAX_BYTES_PLUGIN_APP_KEY);
|
|
||||||
|
|
||||||
/* Get the URL of the plugin (row[4]) */
|
|
||||||
Str_Copy (Plg->URL,row[4],
|
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
|
|
||||||
/* Get the IP of the plugin (row[5]) */
|
|
||||||
Str_Copy (Plg->IP,row[5],
|
|
||||||
Cns_MAX_BYTES_IP);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PluginFound = false;
|
PluginFound = false;
|
||||||
|
@ -595,8 +564,7 @@ void Plg_RenamePlugin (void)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update name *****/
|
/***** Update name *****/
|
||||||
Str_Copy (Plg_EditingPlg->Name,NewPlgName,
|
Str_Copy (Plg_EditingPlg->Name,NewPlgName,sizeof (Plg_EditingPlg->Name) - 1);
|
||||||
Plg_MAX_BYTES_PLUGIN_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -654,7 +622,7 @@ void Plg_ChangePlgDescription (void)
|
||||||
|
|
||||||
/***** Update description *****/
|
/***** Update description *****/
|
||||||
Str_Copy (Plg_EditingPlg->Description,NewDescription,
|
Str_Copy (Plg_EditingPlg->Description,NewDescription,
|
||||||
Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
|
sizeof (Plg_EditingPlg->Description) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -697,8 +665,7 @@ void Plg_ChangePlgLogo (void)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update logo *****/
|
/***** Update logo *****/
|
||||||
Str_Copy (Plg_EditingPlg->Logo,NewLogo,
|
Str_Copy (Plg_EditingPlg->Logo,NewLogo,sizeof (Plg_EditingPlg->Logo) - 1);
|
||||||
Plg_MAX_BYTES_PLUGIN_LOGO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -742,7 +709,7 @@ void Plg_ChangePlgAppKey (void)
|
||||||
|
|
||||||
/***** Update app key *****/
|
/***** Update app key *****/
|
||||||
Str_Copy (Plg_EditingPlg->AppKey,NewAppKey,
|
Str_Copy (Plg_EditingPlg->AppKey,NewAppKey,
|
||||||
Plg_MAX_BYTES_PLUGIN_APP_KEY);
|
sizeof (Plg_EditingPlg->AppKey) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -785,8 +752,7 @@ void Plg_ChangePlgURL (void)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update URL *****/
|
/***** Update URL *****/
|
||||||
Str_Copy (Plg_EditingPlg->URL,NewURL,
|
Str_Copy (Plg_EditingPlg->URL,NewURL,sizeof (Plg_EditingPlg->URL) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -829,8 +795,7 @@ void Plg_ChangePlgIP (void)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update IP *****/
|
/***** Update IP *****/
|
||||||
Str_Copy (Plg_EditingPlg->IP,NewIP,
|
Str_Copy (Plg_EditingPlg->IP,NewIP,sizeof (Plg_EditingPlg->IP) - 1);
|
||||||
Cns_MAX_BYTES_IP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1059,8 +1024,8 @@ static void Plg_EditingPluginConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing plugin.");
|
Lay_ShowErrorAndExit ("Error initializing plugin.");
|
||||||
|
|
||||||
/***** Allocate memory for plugin *****/
|
/***** Allocate memory for plugin *****/
|
||||||
if ((Plg_EditingPlg = (struct Plugin *) malloc (sizeof (struct Plugin))) == NULL)
|
if ((Plg_EditingPlg = malloc (sizeof (*Plg_EditingPlg))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for plugin.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset plugin *****/
|
/***** Reset plugin *****/
|
||||||
Plg_EditingPlg->PlgCod = -1L;
|
Plg_EditingPlg->PlgCod = -1L;
|
||||||
|
|
|
@ -139,16 +139,14 @@ void Prf_SeeSocialProfiles (void)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
char *Prf_GetURLPublicProfile (char URL[Cns_MAX_BYTES_WWW + 1],
|
char *Prf_GetURLPublicProfile (char URL[Cns_MAX_BYTES_WWW + 1],
|
||||||
const char *NicknameWithoutArroba)
|
const char *NickWithoutArroba)
|
||||||
{
|
{
|
||||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||||
|
|
||||||
/***** Build URL using nickname *****/
|
/***** Build URL using nickname *****/
|
||||||
snprintf (URL,Cns_MAX_BYTES_WWW + 1,
|
snprintf (URL,Cns_MAX_BYTES_WWW + 1,"%s/%s?usr=@%s",
|
||||||
"%s/%s?usr=@%s",
|
Cfg_URL_SWAD_CGI,Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
||||||
Cfg_URL_SWAD_CGI,
|
NickWithoutArroba);
|
||||||
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
|
||||||
NicknameWithoutArroba);
|
|
||||||
|
|
||||||
return URL;
|
return URL;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +160,7 @@ void Prf_PutLinkMyPublicProfile (void)
|
||||||
extern const char *Txt_My_public_profile;
|
extern const char *Txt_My_public_profile;
|
||||||
|
|
||||||
Lay_PutContextualLinkIconText (ActSeeOthPubPrf,NULL,
|
Lay_PutContextualLinkIconText (ActSeeOthPubPrf,NULL,
|
||||||
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod,
|
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod,
|
||||||
"user-circle.svg",
|
"user-circle.svg",
|
||||||
Txt_My_public_profile);
|
Txt_My_public_profile);
|
||||||
}
|
}
|
||||||
|
@ -192,7 +190,7 @@ void Prf_RequestUserProfile (void)
|
||||||
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
||||||
extern const char *Txt_Nickname;
|
extern const char *Txt_Nickname;
|
||||||
extern const char *Txt_Continue;
|
extern const char *Txt_Continue;
|
||||||
char NicknameWithArroba[1 + Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
|
char NickWithArroba[1 + Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
|
||||||
|
|
||||||
if (Gbl.Usrs.Me.Logged)
|
if (Gbl.Usrs.Me.Logged)
|
||||||
{
|
{
|
||||||
|
@ -217,10 +215,9 @@ void Prf_RequestUserProfile (void)
|
||||||
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
||||||
HTM_TxtColonNBSP (Txt_Nickname);
|
HTM_TxtColonNBSP (Txt_Nickname);
|
||||||
|
|
||||||
snprintf (NicknameWithArroba,sizeof (NicknameWithArroba),
|
snprintf (NickWithArroba,sizeof (NickWithArroba),"@%s",
|
||||||
"@%s",
|
|
||||||
Gbl.Usrs.Me.UsrDat.Nickname);
|
Gbl.Usrs.Me.UsrDat.Nickname);
|
||||||
HTM_INPUT_TEXT ("usr",Nck_MAX_BYTES_NICKNAME_FROM_FORM,NicknameWithArroba,
|
HTM_INPUT_TEXT ("usr",Nck_MAX_BYTES_NICKNAME_FROM_FORM,NickWithArroba,
|
||||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"size=\"18\"");
|
"size=\"18\"");
|
||||||
HTM_LABEL_End ();
|
HTM_LABEL_End ();
|
||||||
|
@ -522,7 +519,7 @@ static void Prf_ShowTimeSinceFirstClick (const struct UsrData *UsrDat,
|
||||||
}
|
}
|
||||||
else // First click time is unknown or user never logged
|
else // First click time is unknown or user never logged
|
||||||
/***** Button to fetch and store user's figures *****/
|
/***** Button to fetch and store user's figures *****/
|
||||||
Prf_PutLinkCalculateFigures (UsrDat->EncryptedUsrCod);
|
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
|
||||||
|
|
||||||
Prf_EndListItem ();
|
Prf_EndListItem ();
|
||||||
}
|
}
|
||||||
|
@ -625,7 +622,7 @@ static void Prf_ShowNumClicks (const struct UsrData *UsrDat,
|
||||||
}
|
}
|
||||||
else // Number of clicks is unknown
|
else // Number of clicks is unknown
|
||||||
/***** Button to fetch and store user's figures *****/
|
/***** Button to fetch and store user's figures *****/
|
||||||
Prf_PutLinkCalculateFigures (UsrDat->EncryptedUsrCod);
|
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
|
||||||
|
|
||||||
Prf_EndListItem ();
|
Prf_EndListItem ();
|
||||||
}
|
}
|
||||||
|
@ -662,7 +659,7 @@ static void Prf_ShowNumFileViews (const struct UsrData *UsrDat,
|
||||||
}
|
}
|
||||||
else // Number of file views is unknown
|
else // Number of file views is unknown
|
||||||
/***** Button to fetch and store user's figures *****/
|
/***** Button to fetch and store user's figures *****/
|
||||||
Prf_PutLinkCalculateFigures (UsrDat->EncryptedUsrCod);
|
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
|
||||||
|
|
||||||
Prf_EndListItem ();
|
Prf_EndListItem ();
|
||||||
}
|
}
|
||||||
|
@ -699,7 +696,7 @@ static void Prf_ShowNumSocialPublications (const struct UsrData *UsrDat,
|
||||||
}
|
}
|
||||||
else // Number of social publications is unknown
|
else // Number of social publications is unknown
|
||||||
/***** Button to fetch and store user's figures *****/
|
/***** Button to fetch and store user's figures *****/
|
||||||
Prf_PutLinkCalculateFigures (UsrDat->EncryptedUsrCod);
|
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
|
||||||
|
|
||||||
Prf_EndListItem ();
|
Prf_EndListItem ();
|
||||||
}
|
}
|
||||||
|
@ -736,7 +733,7 @@ static void Prf_ShowNumForumPosts (const struct UsrData *UsrDat,
|
||||||
}
|
}
|
||||||
else // Number of forum posts is unknown
|
else // Number of forum posts is unknown
|
||||||
/***** Button to fetch and store user's figures *****/
|
/***** Button to fetch and store user's figures *****/
|
||||||
Prf_PutLinkCalculateFigures (UsrDat->EncryptedUsrCod);
|
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
|
||||||
|
|
||||||
Prf_EndListItem ();
|
Prf_EndListItem ();
|
||||||
}
|
}
|
||||||
|
@ -773,7 +770,7 @@ static void Prf_ShowNumMessagesSent (const struct UsrData *UsrDat,
|
||||||
}
|
}
|
||||||
else // Number of messages sent is unknown
|
else // Number of messages sent is unknown
|
||||||
/***** Button to fetch and store user's figures *****/
|
/***** Button to fetch and store user's figures *****/
|
||||||
Prf_PutLinkCalculateFigures (UsrDat->EncryptedUsrCod);
|
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
|
||||||
|
|
||||||
Prf_EndListItem ();
|
Prf_EndListItem ();
|
||||||
}
|
}
|
||||||
|
@ -1272,8 +1269,7 @@ static void Prf_CreateUsrFigures (long UsrCod,const struct UsrFigures *UsrFigure
|
||||||
|
|
||||||
if (CreatingMyOwnAccount)
|
if (CreatingMyOwnAccount)
|
||||||
// This is the first click
|
// This is the first click
|
||||||
Str_Copy (SubQueryFirstClickTime,"NOW()",
|
Str_Copy (SubQueryFirstClickTime,"NOW()",sizeof (SubQueryFirstClickTime) - 1);
|
||||||
Prf_MAX_BYTES_SUBQUERY_FIRST_CLICK_TIME);
|
|
||||||
else
|
else
|
||||||
sprintf (SubQueryFirstClickTime,"FROM_UNIXTIME(%ld)",
|
sprintf (SubQueryFirstClickTime,"FROM_UNIXTIME(%ld)",
|
||||||
(long) UsrFigures->FirstClickTimeUTC); // 0 ==> unknown first click time or user never logged
|
(long) UsrFigures->FirstClickTimeUTC); // 0 ==> unknown first click time or user never logged
|
||||||
|
@ -1788,7 +1784,7 @@ static void Prf_ShowUsrInRanking (struct UsrData *UsrDat,unsigned Rank,bool ItsM
|
||||||
if (Visible)
|
if (Visible)
|
||||||
{
|
{
|
||||||
Frm_StartForm (ActSeeOthPubPrf);
|
Frm_StartForm (ActSeeOthPubPrf);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile,
|
HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile,
|
||||||
ItsMe ? "BT_LINK RANK_USR DAT_SMALL_N" :
|
ItsMe ? "BT_LINK RANK_USR DAT_SMALL_N" :
|
||||||
"BT_LINK RANK_USR DAT_SMALL",
|
"BT_LINK RANK_USR DAT_SMALL",
|
||||||
|
|
|
@ -53,7 +53,7 @@ struct UsrFigures
|
||||||
void Prf_SeeSocialProfiles (void);
|
void Prf_SeeSocialProfiles (void);
|
||||||
|
|
||||||
char *Prf_GetURLPublicProfile (char URL[Cns_MAX_BYTES_WWW + 1],
|
char *Prf_GetURLPublicProfile (char URL[Cns_MAX_BYTES_WWW + 1],
|
||||||
const char *NicknameWithoutArroba);
|
const char *NickWithoutArroba);
|
||||||
void Prf_PutLinkMyPublicProfile (void);
|
void Prf_PutLinkMyPublicProfile (void);
|
||||||
void Prf_PutLinkRequestAnotherUserProfile (void);
|
void Prf_PutLinkRequestAnotherUserProfile (void);
|
||||||
void Prf_RequestUserProfile (void);
|
void Prf_RequestUserProfile (void);
|
||||||
|
|
|
@ -666,8 +666,8 @@ static void Prg_CreateLevels (void)
|
||||||
4 1
|
4 1
|
||||||
5 0 <--- Used to create a new item
|
5 0 <--- Used to create a new item
|
||||||
*/
|
*/
|
||||||
if ((Prg_Gbl.Levels = (struct Level *) calloc ((size_t) (1 + MaxLevel + 1),
|
if ((Prg_Gbl.Levels = calloc (1 + MaxLevel + 1,
|
||||||
sizeof (struct Level))) == NULL)
|
sizeof (*Prg_Gbl.Levels))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -778,9 +778,7 @@ static void Prg_PutFormsToRemEditOneItem (unsigned NumItem,
|
||||||
char StrItemIndex[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
char StrItemIndex[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
||||||
|
|
||||||
/***** Initialize item index string *****/
|
/***** Initialize item index string *****/
|
||||||
snprintf (StrItemIndex,sizeof (StrItemIndex),
|
snprintf (StrItemIndex,sizeof (StrItemIndex),"%u",Item->Hierarchy.Index);
|
||||||
"%u",
|
|
||||||
Item->Hierarchy.Index);
|
|
||||||
|
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
|
@ -992,9 +990,8 @@ static void Prg_GetListItems (void)
|
||||||
if (Prg_Gbl.List.NumItems) // Items found...
|
if (Prg_Gbl.List.NumItems) // Items found...
|
||||||
{
|
{
|
||||||
/***** Create list of program items *****/
|
/***** Create list of program items *****/
|
||||||
if ((Prg_Gbl.List.Items =
|
if ((Prg_Gbl.List.Items = calloc (Prg_Gbl.List.NumItems,
|
||||||
(struct ProgramItemHierarchy *) calloc ((size_t) Prg_Gbl.List.NumItems,
|
sizeof (*Prg_Gbl.List.Items))) == NULL)
|
||||||
sizeof (struct ProgramItemHierarchy))) == NULL)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the program items codes *****/
|
/***** Get the program items codes *****/
|
||||||
|
@ -1116,8 +1113,7 @@ static void Prg_GetDataOfItem (struct ProgramItem *Item,
|
||||||
Item->Open = (row[7][0] == '1');
|
Item->Open = (row[7][0] == '1');
|
||||||
|
|
||||||
/* Get the title of the program item (row[8]) */
|
/* Get the title of the program item (row[8]) */
|
||||||
Str_Copy (Item->Title,row[8],
|
Str_Copy (Item->Title,row[8],sizeof (Item->Title) - 1);
|
||||||
Prg_MAX_BYTES_PROGRAM_ITEM_TITLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -1179,8 +1175,7 @@ static void Prg_GetItemTxtFromDB (long ItmCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
|
||||||
{
|
{
|
||||||
/* Get info text */
|
/* Get info text */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Txt,row[0],
|
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Txt[0] = '\0';
|
Txt[0] = '\0';
|
||||||
|
|
|
@ -814,7 +814,7 @@ void Prj_PutParams (struct Prj_Filter *Filter,
|
||||||
|
|
||||||
/***** Put another user's code *****/
|
/***** Put another user's code *****/
|
||||||
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
|
|
||||||
/***** Put selected users' codes *****/
|
/***** Put selected users' codes *****/
|
||||||
if (Filter->Who == Usr_WHO_SELECTED)
|
if (Filter->Who == Usr_WHO_SELECTED)
|
||||||
|
@ -2236,7 +2236,7 @@ static void Prj_ShowTableAllProjectsMembersWithARole (const struct Prj_Project *
|
||||||
HTM_Txt (Gbl.Usrs.Other.UsrDat.Surname1);
|
HTM_Txt (Gbl.Usrs.Other.UsrDat.Surname1);
|
||||||
if (Gbl.Usrs.Other.UsrDat.Surname2[0])
|
if (Gbl.Usrs.Other.UsrDat.Surname2[0])
|
||||||
HTM_TxtF (" %s",Gbl.Usrs.Other.UsrDat.Surname2);
|
HTM_TxtF (" %s",Gbl.Usrs.Other.UsrDat.Surname2);
|
||||||
HTM_TxtF (", %s",Gbl.Usrs.Other.UsrDat.FirstName);
|
HTM_TxtF (", %s",Gbl.Usrs.Other.UsrDat.FrstName);
|
||||||
HTM_LI_End ();
|
HTM_LI_End ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2506,7 +2506,7 @@ static void Prj_AddUsrsToProject (Prj_RoleInProject_t RoleInProject)
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
/* Get next user */
|
/* Get next user */
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
||||||
|
|
||||||
|
@ -3072,7 +3072,8 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
||||||
NumPrjsFromDB = (unsigned) NumRows;
|
NumPrjsFromDB = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list of projects *****/
|
/***** Create list of projects *****/
|
||||||
if ((Projects->LstPrjCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
|
if ((Projects->LstPrjCods = calloc (NumRows,
|
||||||
|
sizeof (*Projects->LstPrjCods))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the projects codes *****/
|
/***** Get the projects codes *****/
|
||||||
|
@ -3226,25 +3227,13 @@ void Prj_GetDataOfProjectByCod (struct Prj_Project *Prj)
|
||||||
/* Get modification date/time (row[9] holds the modification UTC time) */
|
/* Get modification date/time (row[9] holds the modification UTC time) */
|
||||||
Prj->ModifTime = Dat_GetUNIXTimeFromStr (row[9]);
|
Prj->ModifTime = Dat_GetUNIXTimeFromStr (row[9]);
|
||||||
|
|
||||||
/* Get the title of the project (row[10]) */
|
/* Get title (row[10]), description (row[11]), required knowledge (row[12]),
|
||||||
Str_Copy (Prj->Title,row[10],
|
required materials (row[13]) and URL (row[14]) of the project */
|
||||||
Prj_MAX_BYTES_PROJECT_TITLE);
|
Str_Copy (Prj->Title ,row[10],sizeof (Prj->Title ) - 1);
|
||||||
|
Str_Copy (Prj->Description,row[11],Cns_MAX_BYTES_TEXT);
|
||||||
/* Get the description of the project (row[11]) */
|
Str_Copy (Prj->Knowledge ,row[12],Cns_MAX_BYTES_TEXT);
|
||||||
Str_Copy (Prj->Description,row[11],
|
Str_Copy (Prj->Materials ,row[13],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
Str_Copy (Prj->URL ,row[14],sizeof (Prj->URL ) - 1);
|
||||||
|
|
||||||
/* Get the required knowledge for the project (row[12]) */
|
|
||||||
Str_Copy (Prj->Knowledge,row[12],
|
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
|
|
||||||
/* Get the required materials for the project (row[13]) */
|
|
||||||
Str_Copy (Prj->Materials,row[13],
|
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
|
|
||||||
/* Get the URL of the project (row[14]) */
|
|
||||||
Str_Copy (Prj->URL,row[14],
|
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -3409,8 +3398,7 @@ void Prj_RemoveProject (void)
|
||||||
Brw_RemovePrjFilesFromDB (Prj.PrjCod);
|
Brw_RemovePrjFilesFromDB (Prj.PrjCod);
|
||||||
|
|
||||||
/***** Remove directory of the project *****/
|
/***** Remove directory of the project *****/
|
||||||
snprintf (PathRelPrj,sizeof (PathRelPrj),
|
snprintf (PathRelPrj,sizeof (PathRelPrj),"%s/%ld/%s/%02u/%ld",
|
||||||
"%s/%ld/%s/%02u/%ld",
|
|
||||||
Cfg_PATH_CRS_PRIVATE,Prj.CrsCod,Cfg_FOLDER_PRJ,
|
Cfg_PATH_CRS_PRIVATE,Prj.CrsCod,Cfg_FOLDER_PRJ,
|
||||||
(unsigned) (Prj.PrjCod % 100),Prj.PrjCod);
|
(unsigned) (Prj.PrjCod % 100),Prj.PrjCod);
|
||||||
Fil_RemoveTree (PathRelPrj);
|
Fil_RemoveTree (PathRelPrj);
|
||||||
|
@ -3815,13 +3803,13 @@ static void Prj_EditOneProjectTxtArea (const char *Id,
|
||||||
|
|
||||||
void Prj_AllocMemProject (struct Prj_Project *Prj)
|
void Prj_AllocMemProject (struct Prj_Project *Prj)
|
||||||
{
|
{
|
||||||
if ((Prj->Description = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((Prj->Description = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
if ((Prj->Knowledge = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((Prj->Knowledge = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
if ((Prj->Materials = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((Prj->Materials = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,8 @@ void Rec_GetListRecordFieldsInCurrentCrs (void)
|
||||||
if (Gbl.Crs.Records.LstFields.Num)
|
if (Gbl.Crs.Records.LstFields.Num)
|
||||||
{
|
{
|
||||||
/***** Create a list of fields *****/
|
/***** Create a list of fields *****/
|
||||||
if ((Gbl.Crs.Records.LstFields.Lst = (struct RecordField *) calloc (Gbl.Crs.Records.LstFields.Num,sizeof (struct RecordField))) == NULL)
|
if ((Gbl.Crs.Records.LstFields.Lst = calloc (Gbl.Crs.Records.LstFields.Num,
|
||||||
|
sizeof (*Gbl.Crs.Records.LstFields.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the fields *****/
|
/***** Get the fields *****/
|
||||||
|
@ -229,7 +230,7 @@ void Rec_GetListRecordFieldsInCurrentCrs (void)
|
||||||
|
|
||||||
/* Name of the field (row[1]) */
|
/* Name of the field (row[1]) */
|
||||||
Str_Copy (Gbl.Crs.Records.LstFields.Lst[NumRow].Name,row[1],
|
Str_Copy (Gbl.Crs.Records.LstFields.Lst[NumRow].Name,row[1],
|
||||||
Rec_MAX_BYTES_NAME_FIELD);
|
sizeof (Gbl.Crs.Records.LstFields.Lst[NumRow].Name) - 1);
|
||||||
|
|
||||||
/* Number of lines (row[2]) */
|
/* Number of lines (row[2]) */
|
||||||
Gbl.Crs.Records.LstFields.Lst[NumRow].NumLines = Rec_ConvertToNumLinesField (row[2]);
|
Gbl.Crs.Records.LstFields.Lst[NumRow].NumLines = Rec_ConvertToNumLinesField (row[2]);
|
||||||
|
@ -291,8 +292,7 @@ void Rec_ListFieldsRecordsForEdition (void)
|
||||||
HTM_TD_Begin ("class=\"CM\"");
|
HTM_TD_Begin ("class=\"CM\"");
|
||||||
Frm_StartForm (ActChgRowFie);
|
Frm_StartForm (ActChgRowFie);
|
||||||
Rec_PutParamFieldCod (&Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
|
Rec_PutParamFieldCod (&Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
|
||||||
snprintf (StrNumLines,sizeof (StrNumLines),
|
snprintf (StrNumLines,sizeof (StrNumLines),"%u",
|
||||||
"%u",
|
|
||||||
Gbl.Crs.Records.LstFields.Lst[NumField].NumLines);
|
Gbl.Crs.Records.LstFields.Lst[NumField].NumLines);
|
||||||
HTM_INPUT_TEXT ("NumLines",Cns_MAX_DECIMAL_DIGITS_UINT,StrNumLines,
|
HTM_INPUT_TEXT ("NumLines",Cns_MAX_DECIMAL_DIGITS_UINT,StrNumLines,
|
||||||
HTM_SUBMIT_ON_CHANGE,
|
HTM_SUBMIT_ON_CHANGE,
|
||||||
|
@ -362,8 +362,7 @@ void Rec_ShowFormCreateRecordField (void)
|
||||||
|
|
||||||
/***** Number of lines in form ******/
|
/***** Number of lines in form ******/
|
||||||
HTM_TD_Begin ("class=\"CM\"");
|
HTM_TD_Begin ("class=\"CM\"");
|
||||||
snprintf (StrNumLines,sizeof (StrNumLines),
|
snprintf (StrNumLines,sizeof (StrNumLines),"%u",
|
||||||
"%u",
|
|
||||||
Gbl.Crs.Records.Field.NumLines);
|
Gbl.Crs.Records.Field.NumLines);
|
||||||
HTM_INPUT_TEXT ("NumLines",Cns_MAX_DECIMAL_DIGITS_UINT,StrNumLines,
|
HTM_INPUT_TEXT ("NumLines",Cns_MAX_DECIMAL_DIGITS_UINT,StrNumLines,
|
||||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
|
@ -692,8 +691,7 @@ static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Name of the field */
|
/* Name of the field */
|
||||||
Str_Copy (Name,row[0],
|
Str_Copy (Name,row[0],Rec_MAX_BYTES_NAME_FIELD);
|
||||||
Rec_MAX_BYTES_NAME_FIELD);
|
|
||||||
|
|
||||||
/* Number of lines of the field (row[1]) */
|
/* Number of lines of the field (row[1]) */
|
||||||
*NumLines = Rec_ConvertToNumLinesField (row[1]);
|
*NumLines = Rec_ConvertToNumLinesField (row[1]);
|
||||||
|
@ -782,7 +780,7 @@ void Rec_RenameField (void)
|
||||||
|
|
||||||
/***** Show the form again *****/
|
/***** Show the form again *****/
|
||||||
Str_Copy (Gbl.Crs.Records.Field.Name,NewFieldName,
|
Str_Copy (Gbl.Crs.Records.Field.Name,NewFieldName,
|
||||||
Rec_MAX_BYTES_NAME_FIELD);
|
sizeof (Gbl.Crs.Records.Field.Name) - 1);
|
||||||
Rec_ReqEditRecordFields ();
|
Rec_ReqEditRecordFields ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -971,15 +969,13 @@ static void Rec_ListRecordsGsts (Rec_SharedRecordViewType_t TypeOfView)
|
||||||
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
|
||||||
{
|
{
|
||||||
/* Start container for this user */
|
/* Start container for this user */
|
||||||
snprintf (RecordSectionId,sizeof (RecordSectionId),
|
snprintf (RecordSectionId,sizeof (RecordSectionId),"record_%u",NumUsr);
|
||||||
"record_%u",
|
|
||||||
NumUsr);
|
|
||||||
HTM_SECTION_Begin (RecordSectionId);
|
HTM_SECTION_Begin (RecordSectionId);
|
||||||
|
|
||||||
if (Gbl.Action.Act == ActPrnRecSevGst &&
|
if (Gbl.Action.Act == ActPrnRecSevGst &&
|
||||||
|
@ -1171,7 +1167,7 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
|
||||||
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
|
||||||
|
@ -1182,9 +1178,7 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
|
||||||
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
|
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
|
||||||
|
|
||||||
/* Start container for this user */
|
/* Start container for this user */
|
||||||
snprintf (RecordSectionId,sizeof (RecordSectionId),
|
snprintf (RecordSectionId,sizeof (RecordSectionId),"record_%u",NumUsr);
|
||||||
"record_%u",
|
|
||||||
NumUsr);
|
|
||||||
HTM_SECTION_Begin (RecordSectionId);
|
HTM_SECTION_Begin (RecordSectionId);
|
||||||
|
|
||||||
if (Gbl.Action.Act == ActPrnRecSevStd &&
|
if (Gbl.Action.Act == ActPrnRecSevStd &&
|
||||||
|
@ -1265,9 +1259,7 @@ static void Rec_ShowRecordOneTchCrs (void)
|
||||||
bool ShowOfficeHours;
|
bool ShowOfficeHours;
|
||||||
|
|
||||||
/***** Width for office hours *****/
|
/***** Width for office hours *****/
|
||||||
snprintf (Width,sizeof (Width),
|
snprintf (Width,sizeof (Width),"%upx",Rec_RECORD_WIDTH);
|
||||||
"%upx",
|
|
||||||
Rec_RECORD_WIDTH);
|
|
||||||
|
|
||||||
/***** Get if teacher has accepted enrolment in current course *****/
|
/***** Get if teacher has accepted enrolment in current course *****/
|
||||||
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
||||||
|
@ -1354,9 +1346,7 @@ static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView)
|
||||||
Usr_GetListsSelectedEncryptedUsrsCods (&Gbl.Usrs.Selected);
|
Usr_GetListsSelectedEncryptedUsrsCods (&Gbl.Usrs.Selected);
|
||||||
|
|
||||||
/***** Width for office hours *****/
|
/***** Width for office hours *****/
|
||||||
snprintf (Width,sizeof (Width),
|
snprintf (Width,sizeof (Width),"%upx",Rec_RECORD_WIDTH);
|
||||||
"%upx",
|
|
||||||
Rec_RECORD_WIDTH);
|
|
||||||
|
|
||||||
/***** Assign users listing type depending on current action *****/
|
/***** Assign users listing type depending on current action *****/
|
||||||
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_TEACHERS;
|
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_TEACHERS;
|
||||||
|
@ -1396,7 +1386,7 @@ static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView)
|
||||||
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
|
||||||
|
@ -1407,9 +1397,7 @@ static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView)
|
||||||
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
|
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
|
||||||
|
|
||||||
/* Start container for this user */
|
/* Start container for this user */
|
||||||
snprintf (RecordSectionId,sizeof (RecordSectionId),
|
snprintf (RecordSectionId,sizeof (RecordSectionId),"record_%u",NumUsr);
|
||||||
"record_%u",
|
|
||||||
NumUsr);
|
|
||||||
HTM_SECTION_Begin (RecordSectionId);
|
HTM_SECTION_Begin (RecordSectionId);
|
||||||
|
|
||||||
if (Gbl.Action.Act == ActPrnRecSevTch &&
|
if (Gbl.Action.Act == ActPrnRecSevTch &&
|
||||||
|
@ -1530,7 +1518,7 @@ static void Rec_WriteFormShowOfficeHoursSeveralTchs (bool ShowOfficeHours)
|
||||||
|
|
||||||
static void Rec_PutParamsShowOfficeHoursOneTch (void)
|
static void Rec_PutParamsShowOfficeHoursOneTch (void)
|
||||||
{
|
{
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
|
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1707,7 +1695,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
Frm_StartFormAnchor (ActRcvRecOthUsr,Anchor);
|
Frm_StartFormAnchor (ActRcvRecOthUsr,Anchor);
|
||||||
Par_PutHiddenParamLong (NULL,"OriginalActCod",
|
Par_PutHiddenParamLong (NULL,"OriginalActCod",
|
||||||
Act_GetActCod (ActSeeRecSevStd)); // Original action, used to know where we came from
|
Act_GetActCod (ActSeeRecSevStd)); // Original action, used to know where we came from
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
if (TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS)
|
if (TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS)
|
||||||
Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected);
|
Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected);
|
||||||
}
|
}
|
||||||
|
@ -1717,9 +1705,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Begin box and table *****/
|
/***** Begin box and table *****/
|
||||||
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
|
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
|
||||||
"%upx",
|
|
||||||
Rec_RECORD_WIDTH);
|
|
||||||
Box_BoxTableBegin (StrRecordWidth,NULL,
|
Box_BoxTableBegin (StrRecordWidth,NULL,
|
||||||
NULL,NULL,
|
NULL,NULL,
|
||||||
Rec_RecordHelp[TypeOfView],Box_NOT_CLOSABLE,2);
|
Rec_RecordHelp[TypeOfView],Box_NOT_CLOSABLE,2);
|
||||||
|
@ -1821,8 +1807,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
{
|
{
|
||||||
if (ThisFieldHasText)
|
if (ThisFieldHasText)
|
||||||
{
|
{
|
||||||
Str_Copy (Text,row[0],
|
Str_Copy (Text,row[0],sizeof (Text));
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
||||||
Text,Cns_MAX_BYTES_TEXT,false);
|
Text,Cns_MAX_BYTES_TEXT,false);
|
||||||
HTM_Txt (Text);
|
HTM_Txt (Text);
|
||||||
|
@ -1881,8 +1866,7 @@ void Rec_GetFieldsCrsRecordFromForm (void)
|
||||||
if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility))
|
if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility))
|
||||||
{
|
{
|
||||||
/* Get text from the form */
|
/* Get text from the form */
|
||||||
snprintf (FieldParamName,sizeof (FieldParamName),
|
snprintf (FieldParamName,sizeof (FieldParamName),"Field%ld",
|
||||||
"Field%ld",
|
|
||||||
Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
|
Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
|
||||||
Par_GetParToHTML (FieldParamName,Gbl.Crs.Records.LstFields.Lst[NumField].Text,Cns_MAX_BYTES_TEXT);
|
Par_GetParToHTML (FieldParamName,Gbl.Crs.Records.LstFields.Lst[NumField].Text,Cns_MAX_BYTES_TEXT);
|
||||||
}
|
}
|
||||||
|
@ -1994,7 +1978,7 @@ void Rec_AllocMemFieldsRecordsCrs (void)
|
||||||
NumField++)
|
NumField++)
|
||||||
if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility))
|
if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility))
|
||||||
/* Allocate memory for the texts of the fields */
|
/* Allocate memory for the texts of the fields */
|
||||||
if ((Gbl.Crs.Records.LstFields.Lst[NumField].Text = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((Gbl.Crs.Records.LstFields.Lst[NumField].Text = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2300,7 +2284,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Frm_StartForm (NextAction);
|
Frm_StartForm (NextAction);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); // Existing user
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); // Existing user
|
||||||
break;
|
break;
|
||||||
case Rec_SHA_OTHER_NEW_USR_FORM:
|
case Rec_SHA_OTHER_NEW_USR_FORM:
|
||||||
switch (Gbl.Action.Act)
|
switch (Gbl.Action.Act)
|
||||||
|
@ -2635,7 +2619,7 @@ static void Rec_PutIconsCommands (__attribute__((unused)) void *Args)
|
||||||
|
|
||||||
void Rec_PutParamUsrCodEncrypted (__attribute__((unused)) void *Args)
|
void Rec_PutParamUsrCodEncrypted (__attribute__((unused)) void *Args)
|
||||||
{
|
{
|
||||||
Usr_PutParamUsrCodEncrypted (Gbl.Record.UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (Gbl.Record.UsrDat->EnUsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Rec_PutParamsMyTsts (__attribute__((unused)) void *Args)
|
static void Rec_PutParamsMyTsts (__attribute__((unused)) void *Args)
|
||||||
|
@ -2661,7 +2645,7 @@ static void Rec_PutParamsWorks (__attribute__((unused)) void *Args)
|
||||||
|
|
||||||
static void Rec_PutParamsStudent (__attribute__((unused)) void *Args)
|
static void Rec_PutParamsStudent (__attribute__((unused)) void *Args)
|
||||||
{
|
{
|
||||||
Par_PutHiddenParamString (NULL,"UsrCodStd",Gbl.Record.UsrDat->EncryptedUsrCod);
|
Par_PutHiddenParamString (NULL,"UsrCodStd",Gbl.Record.UsrDat->EnUsrCod);
|
||||||
Grp_PutParamAllGroups ();
|
Grp_PutParamAllGroups ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2747,7 +2731,7 @@ static void Rec_ShowFullName (struct UsrData *UsrDat)
|
||||||
HTM_DIV_Begin ("class=\"REC_NAME\"");
|
HTM_DIV_Begin ("class=\"REC_NAME\"");
|
||||||
|
|
||||||
/***** First name *****/
|
/***** First name *****/
|
||||||
HTM_Txt (UsrDat->FirstName);
|
HTM_Txt (UsrDat->FrstName);
|
||||||
HTM_BR ();
|
HTM_BR ();
|
||||||
|
|
||||||
/***** Surname 1 *****/
|
/***** Surname 1 *****/
|
||||||
|
@ -2780,7 +2764,7 @@ static void Rec_ShowNickname (struct UsrData *UsrDat,bool PutFormLinks)
|
||||||
/* Put form to go to public profile */
|
/* Put form to go to public profile */
|
||||||
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
||||||
Frm_StartForm (ActSeeOthPubPrf);
|
Frm_StartForm (ActSeeOthPubPrf);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
|
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
|
||||||
Txt_Another_user_s_profile,
|
Txt_Another_user_s_profile,
|
||||||
"BT_LINK REC_NICK",
|
"BT_LINK REC_NICK",
|
||||||
|
@ -3236,14 +3220,14 @@ static void Rec_ShowFirstName (struct UsrData *UsrDat,bool PutForm)
|
||||||
HTM_TD_Begin ("colspan=\"2\" class=\"REC_C2_BOT DAT_N LM\"");
|
HTM_TD_Begin ("colspan=\"2\" class=\"REC_C2_BOT DAT_N LM\"");
|
||||||
if (PutForm)
|
if (PutForm)
|
||||||
HTM_INPUT_TEXT ("FirstName",Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
|
HTM_INPUT_TEXT ("FirstName",Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
|
||||||
UsrDat->FirstName,
|
UsrDat->FrstName,
|
||||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"id=\"FirstName\" class=\"REC_C2_BOT_INPUT\""
|
"id=\"FirstName\" class=\"REC_C2_BOT_INPUT\""
|
||||||
" required=\"required\"");
|
" required=\"required\"");
|
||||||
else if (UsrDat->FirstName[0])
|
else if (UsrDat->FrstName[0])
|
||||||
{
|
{
|
||||||
HTM_STRONG_Begin ();
|
HTM_STRONG_Begin ();
|
||||||
HTM_Txt (UsrDat->FirstName);
|
HTM_Txt (UsrDat->FrstName);
|
||||||
HTM_STRONG_End ();
|
HTM_STRONG_End ();
|
||||||
}
|
}
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
@ -3700,8 +3684,7 @@ void Rec_GetUsrNameFromRecordForm (struct UsrData *UsrDat)
|
||||||
Str_ConvertToTitleType (Surname1);
|
Str_ConvertToTitleType (Surname1);
|
||||||
// Surname 1 is mandatory, so avoid overwriting surname 1 with empty string
|
// Surname 1 is mandatory, so avoid overwriting surname 1 with empty string
|
||||||
if (Surname1[0]) // New surname 1 not empty
|
if (Surname1[0]) // New surname 1 not empty
|
||||||
Str_Copy (UsrDat->Surname1,Surname1,
|
Str_Copy (UsrDat->Surname1,Surname1,sizeof (UsrDat->Surname1) - 1);
|
||||||
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
|
||||||
|
|
||||||
/***** Get surname 2 *****/
|
/***** Get surname 2 *****/
|
||||||
Par_GetParToText ("Surname2",UsrDat->Surname2,
|
Par_GetParToText ("Surname2",UsrDat->Surname2,
|
||||||
|
@ -3714,8 +3697,7 @@ void Rec_GetUsrNameFromRecordForm (struct UsrData *UsrDat)
|
||||||
Str_ConvertToTitleType (FirstName);
|
Str_ConvertToTitleType (FirstName);
|
||||||
// First name is mandatory, so avoid overwriting first name with empty string
|
// First name is mandatory, so avoid overwriting first name with empty string
|
||||||
if (FirstName[0]) // New first name not empty
|
if (FirstName[0]) // New first name not empty
|
||||||
Str_Copy (UsrDat->FirstName,FirstName,
|
Str_Copy (UsrDat->FrstName,FirstName,sizeof (UsrDat->FrstName) - 1);
|
||||||
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
|
||||||
|
|
||||||
/***** Build full name *****/
|
/***** Build full name *****/
|
||||||
Usr_BuildFullName (UsrDat);
|
Usr_BuildFullName (UsrDat);
|
||||||
|
@ -3782,7 +3764,7 @@ void Rec_ShowMySharedRecordAndMore (void)
|
||||||
(1 << Rol_TCH))); // ...or a teacher in any course
|
(1 << Rol_TCH))); // ...or a teacher in any course
|
||||||
|
|
||||||
/***** If user has no name and surname, sex... *****/
|
/***** If user has no name and surname, sex... *****/
|
||||||
if (!Gbl.Usrs.Me.UsrDat.FirstName[0] ||
|
if (!Gbl.Usrs.Me.UsrDat.FrstName[0] ||
|
||||||
!Gbl.Usrs.Me.UsrDat.Surname1[0]) // 1. No name
|
!Gbl.Usrs.Me.UsrDat.Surname1[0]) // 1. No name
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_name);
|
Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_name);
|
||||||
else if (Gbl.Usrs.Me.UsrDat.Sex == Usr_SEX_UNKNOWN) // 2. No sex
|
else if (Gbl.Usrs.Me.UsrDat.Sex == Usr_SEX_UNKNOWN) // 2. No sex
|
||||||
|
|
|
@ -343,14 +343,12 @@ static void Rep_GetCurrentDateTimeUTC (struct Rep_Report *Report)
|
||||||
{
|
{
|
||||||
/* Date and time as strings */
|
/* Date and time as strings */
|
||||||
snprintf (Report->CurrentTimeUTC.StrDate,
|
snprintf (Report->CurrentTimeUTC.StrDate,
|
||||||
sizeof (Report->CurrentTimeUTC.StrDate),
|
sizeof (Report->CurrentTimeUTC.StrDate),"%04d-%02d-%02d",
|
||||||
"%04d-%02d-%02d",
|
|
||||||
1900 + Report->tm_CurrentTime.tm_year, // year
|
1900 + Report->tm_CurrentTime.tm_year, // year
|
||||||
1 + Report->tm_CurrentTime.tm_mon, // month
|
1 + Report->tm_CurrentTime.tm_mon, // month
|
||||||
Report->tm_CurrentTime.tm_mday); // day of the month
|
Report->tm_CurrentTime.tm_mday); // day of the month
|
||||||
snprintf (Report->CurrentTimeUTC.StrTime,
|
snprintf (Report->CurrentTimeUTC.StrTime,
|
||||||
sizeof (Report->CurrentTimeUTC.StrTime),
|
sizeof (Report->CurrentTimeUTC.StrTime),"%02d:%02d:%02d",
|
||||||
"%02d:%02d:%02d",
|
|
||||||
Report->tm_CurrentTime.tm_hour, // hours
|
Report->tm_CurrentTime.tm_hour, // hours
|
||||||
Report->tm_CurrentTime.tm_min, // minutes
|
Report->tm_CurrentTime.tm_min, // minutes
|
||||||
Report->tm_CurrentTime.tm_sec); // seconds
|
Report->tm_CurrentTime.tm_sec); // seconds
|
||||||
|
@ -383,16 +381,14 @@ static void Rep_CreateNewReportFile (struct Rep_Report *Report)
|
||||||
|
|
||||||
/***** Unique directory for the file with the report *****/
|
/***** Unique directory for the file with the report *****/
|
||||||
/* 1. Create a directory using the leftmost 2 chars of a unique name */
|
/* 1. Create a directory using the leftmost 2 chars of a unique name */
|
||||||
snprintf (PathUniqueDirL,sizeof (PathUniqueDirL),
|
snprintf (PathUniqueDirL,sizeof (PathUniqueDirL),"%s/%c%c",
|
||||||
"%s/%c%c",
|
|
||||||
Cfg_PATH_REP_PUBLIC,
|
Cfg_PATH_REP_PUBLIC,
|
||||||
Gbl.UniqueNameEncrypted[0],
|
Gbl.UniqueNameEncrypted[0],
|
||||||
Gbl.UniqueNameEncrypted[1]);
|
Gbl.UniqueNameEncrypted[1]);
|
||||||
Fil_CreateDirIfNotExists (PathUniqueDirL);
|
Fil_CreateDirIfNotExists (PathUniqueDirL);
|
||||||
|
|
||||||
/* 2. Create a directory using the rightmost 41 chars of a unique name */
|
/* 2. Create a directory using the rightmost 41 chars of a unique name */
|
||||||
snprintf (PathUniqueDirR,sizeof (PathUniqueDirR),
|
snprintf (PathUniqueDirR,sizeof (PathUniqueDirR),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
PathUniqueDirL,
|
PathUniqueDirL,
|
||||||
&Gbl.UniqueNameEncrypted[2]);
|
&Gbl.UniqueNameEncrypted[2]);
|
||||||
if (mkdir (PathUniqueDirR,(mode_t) 0xFFF))
|
if (mkdir (PathUniqueDirR,(mode_t) 0xFFF))
|
||||||
|
@ -402,22 +398,19 @@ static void Rep_CreateNewReportFile (struct Rep_Report *Report)
|
||||||
snprintf (Report->FilenameReport,sizeof (Report->FilenameReport),
|
snprintf (Report->FilenameReport,sizeof (Report->FilenameReport),
|
||||||
"%s_%06u_%06u.html",
|
"%s_%06u_%06u.html",
|
||||||
Rep_FILENAME_ROOT,Report->CurrentTimeUTC.Date,Report->CurrentTimeUTC.Time);
|
Rep_FILENAME_ROOT,Report->CurrentTimeUTC.Date,Report->CurrentTimeUTC.Time);
|
||||||
snprintf (PathFileReport,sizeof (PathFileReport),
|
snprintf (PathFileReport,sizeof (PathFileReport),"%s/%s",
|
||||||
"%s/%s",
|
|
||||||
PathUniqueDirR,Report->FilenameReport);
|
PathUniqueDirR,Report->FilenameReport);
|
||||||
if ((Gbl.F.Rep = fopen (PathFileReport,"wb")) == NULL)
|
if ((Gbl.F.Rep = fopen (PathFileReport,"wb")) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Can not create report file.");
|
Lay_ShowErrorAndExit ("Can not create report file.");
|
||||||
|
|
||||||
/***** Permalink *****/
|
/***** Permalink *****/
|
||||||
snprintf (Permalink,sizeof (Permalink),
|
snprintf (Permalink,sizeof (Permalink),"%s/%c%c/%s/%s",
|
||||||
"%s/%c%c/%s/%s",
|
|
||||||
Cfg_URL_REP_PUBLIC,
|
Cfg_URL_REP_PUBLIC,
|
||||||
Gbl.UniqueNameEncrypted[0],
|
Gbl.UniqueNameEncrypted[0],
|
||||||
Gbl.UniqueNameEncrypted[1],
|
Gbl.UniqueNameEncrypted[1],
|
||||||
&Gbl.UniqueNameEncrypted[2],
|
&Gbl.UniqueNameEncrypted[2],
|
||||||
Report->FilenameReport);
|
Report->FilenameReport);
|
||||||
Str_Copy (Report->Permalink,Permalink,
|
Str_Copy (Report->Permalink,Permalink,sizeof (Report->Permalink) - 1);
|
||||||
Cns_MAX_BYTES_WWW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1439,8 +1432,7 @@ static void Rep_RemoveUsrReportsFiles (long UsrCod)
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Remove report directory and file */
|
/* Remove report directory and file */
|
||||||
snprintf (PathUniqueDirReport,sizeof (PathUniqueDirReport),
|
snprintf (PathUniqueDirReport,sizeof (PathUniqueDirReport),"%s/%s/%s",
|
||||||
"%s/%s/%s",
|
|
||||||
Cfg_PATH_REP_PUBLIC,row[0],row[1]);
|
Cfg_PATH_REP_PUBLIC,row[0],row[1]);
|
||||||
Fil_RemoveTree (PathUniqueDirReport);
|
Fil_RemoveTree (PathUniqueDirReport);
|
||||||
}
|
}
|
||||||
|
|
44
swad_room.c
44
swad_room.c
|
@ -585,9 +585,7 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,
|
||||||
Rooms->Num = (unsigned) NumRows;
|
Rooms->Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list with courses in centre *****/
|
/***** Create list with courses in centre *****/
|
||||||
if ((Rooms->Lst = (struct Roo_Room *)
|
if ((Rooms->Lst = calloc (NumRows,sizeof (*Rooms->Lst))) == NULL)
|
||||||
calloc (NumRows,
|
|
||||||
sizeof (struct Roo_Room))) == NULL)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the rooms *****/
|
/***** Get the rooms *****/
|
||||||
|
@ -619,13 +617,9 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,
|
||||||
/* Get type (row[4]) */
|
/* Get type (row[4]) */
|
||||||
Room->Type = Roo_GetTypeFromString (row[4]);
|
Room->Type = Roo_GetTypeFromString (row[4]);
|
||||||
|
|
||||||
/* Get the short name of the room (row[5]) */
|
/* Get the short (row[5]) and full (row[6]) names of the room */
|
||||||
Str_Copy (Room->ShrtName,row[5],
|
Str_Copy (Room->ShrtName,row[5],sizeof (Room->ShrtName) - 1);
|
||||||
Roo_MAX_BYTES_SHRT_NAME);
|
Str_Copy (Room->FullName,row[6],sizeof (Room->FullName) - 1);
|
||||||
|
|
||||||
/* Get the full name of the room (row[6]) */
|
|
||||||
Str_Copy (Room->FullName,row[6],
|
|
||||||
Roo_MAX_BYTES_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get seating capacity in this room (row[7]) */
|
/* Get seating capacity in this room (row[7]) */
|
||||||
if (sscanf (row[7],"%u",&Room->Capacity) != 1)
|
if (sscanf (row[7],"%u",&Room->Capacity) != 1)
|
||||||
|
@ -634,8 +628,7 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,
|
||||||
case Roo_ONLY_SHRT_NAME:
|
case Roo_ONLY_SHRT_NAME:
|
||||||
default:
|
default:
|
||||||
/* Get the short name of the room (row[1]) */
|
/* Get the short name of the room (row[1]) */
|
||||||
Str_Copy (Room->ShrtName,row[1],
|
Str_Copy (Room->ShrtName,row[1],sizeof (Room->ShrtName) - 1);
|
||||||
Roo_MAX_BYTES_SHRT_NAME);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -693,13 +686,9 @@ static void Roo_GetDataOfRoomByCod (struct Roo_Room *Room)
|
||||||
/* Get type (row[3]) */
|
/* Get type (row[3]) */
|
||||||
Room->Type = Roo_GetTypeFromString (row[3]);
|
Room->Type = Roo_GetTypeFromString (row[3]);
|
||||||
|
|
||||||
/* Get the short name of the room (row[4]) */
|
/* Get the short (row[4]) and full (row[5]) names of the room */
|
||||||
Str_Copy (Room->ShrtName,row[4],
|
Str_Copy (Room->ShrtName,row[4],sizeof (Room->ShrtName) - 1);
|
||||||
Roo_MAX_BYTES_SHRT_NAME);
|
Str_Copy (Room->FullName,row[5],sizeof (Room->FullName) - 1);
|
||||||
|
|
||||||
/* Get the full name of the room (row[5]) */
|
|
||||||
Str_Copy (Room->FullName,row[5],
|
|
||||||
Roo_MAX_BYTES_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get seating capacity in this room (row[6]) */
|
/* Get seating capacity in this room (row[6]) */
|
||||||
if (sscanf (row[6],"%u",&Room->Capacity) != 1)
|
if (sscanf (row[6],"%u",&Room->Capacity) != 1)
|
||||||
|
@ -721,16 +710,16 @@ static void Roo_GetBldShrtName (struct Roo_Room *Room,const char *BldShrtNameFro
|
||||||
|
|
||||||
if (Room->BldCod < 0)
|
if (Room->BldCod < 0)
|
||||||
Str_Copy (Room->BldShrtName,Txt_No_assigned_building,
|
Str_Copy (Room->BldShrtName,Txt_No_assigned_building,
|
||||||
Bld_MAX_BYTES_SHRT_NAME);
|
sizeof (Room->BldShrtName) - 1);
|
||||||
else if (Room->BldCod == 0)
|
else if (Room->BldCod == 0)
|
||||||
Str_Copy (Room->BldShrtName,Txt_Another_building,
|
Str_Copy (Room->BldShrtName,Txt_Another_building,
|
||||||
Bld_MAX_BYTES_SHRT_NAME);
|
sizeof (Room->BldShrtName) - 1);
|
||||||
else // Room->BldCod > 0
|
else // Room->BldCod > 0
|
||||||
{
|
{
|
||||||
Room->BldShrtName[0] = '\0';
|
Room->BldShrtName[0] = '\0';
|
||||||
if (BldShrtNameFromDB)
|
if (BldShrtNameFromDB)
|
||||||
Str_Copy (Room->BldShrtName,BldShrtNameFromDB,
|
Str_Copy (Room->BldShrtName,BldShrtNameFromDB,
|
||||||
Bld_MAX_BYTES_SHRT_NAME);
|
sizeof (Room->BldShrtName) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1288,8 +1277,7 @@ static void Roo_RenameRoom (Cns_ShrtOrFullName_t ShrtOrFullName)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
|
|
||||||
/***** Update room name *****/
|
/***** Update room name *****/
|
||||||
Str_Copy (CurrentClaName,NewClaName,
|
Str_Copy (CurrentClaName,NewClaName,MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1383,9 +1371,7 @@ void Roo_ChangeCapacity (void)
|
||||||
static void Roo_WriteCapacity (char Str[Cns_MAX_DECIMAL_DIGITS_UINT + 1],unsigned Capacity)
|
static void Roo_WriteCapacity (char Str[Cns_MAX_DECIMAL_DIGITS_UINT + 1],unsigned Capacity)
|
||||||
{
|
{
|
||||||
if (Capacity <= Roo_MAX_CAPACITY)
|
if (Capacity <= Roo_MAX_CAPACITY)
|
||||||
snprintf (Str,Cns_MAX_DECIMAL_DIGITS_UINT + 1,
|
snprintf (Str,Cns_MAX_DECIMAL_DIGITS_UINT + 1,"%u",Capacity);
|
||||||
"%u",
|
|
||||||
Capacity);
|
|
||||||
else
|
else
|
||||||
Str[0] = '\0';
|
Str[0] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -1638,8 +1624,8 @@ static void Roo_EditingRoomConstructor (void)
|
||||||
Lay_ShowErrorAndExit ("Error initializing room.");
|
Lay_ShowErrorAndExit ("Error initializing room.");
|
||||||
|
|
||||||
/***** Allocate memory for room *****/
|
/***** Allocate memory for room *****/
|
||||||
if ((Roo_EditingRoom = (struct Roo_Room *) malloc (sizeof (struct Roo_Room))) == NULL)
|
if ((Roo_EditingRoom = malloc (sizeof (*Roo_EditingRoom))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for room.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Reset room *****/
|
/***** Reset room *****/
|
||||||
Roo_EditingRoom->RooCod = -1L;
|
Roo_EditingRoom->RooCod = -1L;
|
||||||
|
|
|
@ -459,8 +459,7 @@ static unsigned Sch_SearchCountriesInDB (const char *RangeQuery)
|
||||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_COUNTRIES))
|
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_COUNTRIES))
|
||||||
{
|
{
|
||||||
/***** Split countries string into words *****/
|
/***** Split countries string into words *****/
|
||||||
snprintf (FieldName,sizeof (FieldName),
|
snprintf (FieldName,sizeof (FieldName),"Name_%s",
|
||||||
"Name_%s",
|
|
||||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||||
if (Sch_BuildSearchQuery (SearchQuery,FieldName,NULL,NULL))
|
if (Sch_BuildSearchQuery (SearchQuery,FieldName,NULL,NULL))
|
||||||
{
|
{
|
||||||
|
@ -1111,26 +1110,18 @@ bool Sch_BuildSearchQuery (char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1],
|
||||||
Sch_MAX_BYTES_SEARCH_QUERY) // Prevent string overflow
|
Sch_MAX_BYTES_SEARCH_QUERY) // Prevent string overflow
|
||||||
break;
|
break;
|
||||||
if (NumWords)
|
if (NumWords)
|
||||||
Str_Concat (SearchQuery," AND ",
|
Str_Concat (SearchQuery," AND ",Sch_MAX_BYTES_SEARCH_QUERY);
|
||||||
Sch_MAX_BYTES_SEARCH_QUERY);
|
Str_Concat (SearchQuery,FieldName,Sch_MAX_BYTES_SEARCH_QUERY);
|
||||||
Str_Concat (SearchQuery,FieldName,
|
Str_Concat (SearchQuery," LIKE ",Sch_MAX_BYTES_SEARCH_QUERY);
|
||||||
Sch_MAX_BYTES_SEARCH_QUERY);
|
|
||||||
Str_Concat (SearchQuery," LIKE ",
|
|
||||||
Sch_MAX_BYTES_SEARCH_QUERY);
|
|
||||||
if (CharSet)
|
if (CharSet)
|
||||||
if (CharSet[0])
|
if (CharSet[0])
|
||||||
Str_Concat (SearchQuery,CharSet,
|
Str_Concat (SearchQuery,CharSet,Sch_MAX_BYTES_SEARCH_QUERY);
|
||||||
Sch_MAX_BYTES_SEARCH_QUERY);
|
Str_Concat (SearchQuery,"'%",Sch_MAX_BYTES_SEARCH_QUERY);
|
||||||
Str_Concat (SearchQuery,"'%",
|
Str_Concat (SearchQuery,SearchWords[NumWords],Sch_MAX_BYTES_SEARCH_QUERY);
|
||||||
Sch_MAX_BYTES_SEARCH_QUERY);
|
Str_Concat (SearchQuery,"%'",Sch_MAX_BYTES_SEARCH_QUERY);
|
||||||
Str_Concat (SearchQuery,SearchWords[NumWords],
|
|
||||||
Sch_MAX_BYTES_SEARCH_QUERY);
|
|
||||||
Str_Concat (SearchQuery,"%'",
|
|
||||||
Sch_MAX_BYTES_SEARCH_QUERY);
|
|
||||||
if (Collate)
|
if (Collate)
|
||||||
if (Collate[0])
|
if (Collate[0])
|
||||||
Str_Concat (SearchQuery,Collate,
|
Str_Concat (SearchQuery,Collate,Sch_MAX_BYTES_SEARCH_QUERY);
|
||||||
Sch_MAX_BYTES_SEARCH_QUERY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include <mysql/mysql.h> // To access MySQL databases
|
#include <mysql/mysql.h> // To access MySQL databases
|
||||||
#include <stddef.h> // For NULL
|
#include <stddef.h> // For NULL
|
||||||
#include <stdio.h> // For sprintf
|
#include <stdio.h> // For sprintf
|
||||||
#include <stdlib.h> // For malloc and free
|
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_connected.h"
|
#include "swad_connected.h"
|
||||||
|
@ -80,8 +79,7 @@ void Ses_GetNumSessions (void)
|
||||||
void Ses_CreateSession (void)
|
void Ses_CreateSession (void)
|
||||||
{
|
{
|
||||||
/***** Create a unique name for the session *****/
|
/***** Create a unique name for the session *****/
|
||||||
Str_Copy (Gbl.Session.Id,Gbl.UniqueNameEncrypted,
|
Str_Copy (Gbl.Session.Id,Gbl.UniqueNameEncrypted,sizeof (Gbl.Session.Id) - 1);
|
||||||
Cns_BYTES_SESSION_ID);
|
|
||||||
|
|
||||||
/***** Check that session is not open *****/
|
/***** Check that session is not open *****/
|
||||||
if (Ses_CheckIfSessionExists (Gbl.Session.Id))
|
if (Ses_CheckIfSessionExists (Gbl.Session.Id))
|
||||||
|
@ -288,7 +286,7 @@ bool Ses_GetSessionData (void)
|
||||||
|
|
||||||
/***** Get password (row[1]) *****/
|
/***** Get password (row[1]) *****/
|
||||||
Str_Copy (Gbl.Usrs.Me.LoginEncryptedPassword,row[1],
|
Str_Copy (Gbl.Usrs.Me.LoginEncryptedPassword,row[1],
|
||||||
Pwd_BYTES_ENCRYPTED_PASSWORD);
|
sizeof (Gbl.Usrs.Me.LoginEncryptedPassword) - 1);
|
||||||
|
|
||||||
/***** Get logged user type (row[2]) *****/
|
/***** Get logged user type (row[2]) *****/
|
||||||
if (sscanf (row[2],"%u",&Gbl.Usrs.Me.Role.FromSession) != 1)
|
if (sscanf (row[2],"%u",&Gbl.Usrs.Me.Role.FromSession) != 1)
|
||||||
|
@ -321,8 +319,7 @@ bool Ses_GetSessionData (void)
|
||||||
Gbl.Search.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
|
Gbl.Search.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
|
||||||
|
|
||||||
/* Get search string (row[9]) */
|
/* Get search string (row[9]) */
|
||||||
Str_Copy (Gbl.Search.Str,row[9],
|
Str_Copy (Gbl.Search.Str,row[9],sizeof (Gbl.Search.Str) - 1);
|
||||||
Sch_MAX_BYTES_STRING_TO_FIND);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result = true;
|
Result = true;
|
||||||
|
@ -440,8 +437,7 @@ void Ses_GetHiddenParFromDB (const char *ParamName,char *ParamValue,
|
||||||
|
|
||||||
ParameterIsTooBig = (strlen (row[0]) > MaxBytes);
|
ParameterIsTooBig = (strlen (row[0]) > MaxBytes);
|
||||||
if (!ParameterIsTooBig)
|
if (!ParameterIsTooBig)
|
||||||
Str_Copy (ParamValue,row[0],
|
Str_Copy (ParamValue,row[0],MaxBytes);
|
||||||
MaxBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
|
|
@ -262,8 +262,7 @@ static void Set_PutIconsToSelectSideCols (void)
|
||||||
"PREF_OFF");
|
"PREF_OFF");
|
||||||
Frm_StartForm (ActChgCol);
|
Frm_StartForm (ActChgCol);
|
||||||
Par_PutHiddenParamUnsigned (NULL,"SideCols",SideCols);
|
Par_PutHiddenParamUnsigned (NULL,"SideCols",SideCols);
|
||||||
snprintf (Icon,sizeof (Icon),
|
snprintf (Icon,sizeof (Icon),"layout%u%u_32x20.gif",
|
||||||
"layout%u%u_32x20.gif",
|
|
||||||
SideCols >> 1,SideCols & 1);
|
SideCols >> 1,SideCols & 1);
|
||||||
Ico_PutSettingIconLink (Icon,Txt_LAYOUT_SIDE_COLUMNS[SideCols]);
|
Ico_PutSettingIconLink (Icon,Txt_LAYOUT_SIDE_COLUMNS[SideCols]);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
|
|
110
swad_statistic.c
110
swad_statistic.c
|
@ -201,8 +201,7 @@ The IP address of the remote host making the request.
|
||||||
void Sta_GetRemoteAddr (void)
|
void Sta_GetRemoteAddr (void)
|
||||||
{
|
{
|
||||||
if (getenv ("REMOTE_ADDR"))
|
if (getenv ("REMOTE_ADDR"))
|
||||||
Str_Copy (Gbl.IP,getenv ("REMOTE_ADDR"),
|
Str_Copy (Gbl.IP,getenv ("REMOTE_ADDR"),sizeof (Gbl.IP) - 1);
|
||||||
Cns_MAX_BYTES_IP);
|
|
||||||
else
|
else
|
||||||
Gbl.IP[0] = '\0';
|
Gbl.IP[0] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -920,8 +919,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
switch (Stats.CountType)
|
switch (Stats.CountType)
|
||||||
{
|
{
|
||||||
case Sta_TOTAL_CLICKS:
|
case Sta_TOTAL_CLICKS:
|
||||||
Str_Copy (StrQueryCountType,"COUNT(*)",
|
Str_Copy (StrQueryCountType,"COUNT(*)",sizeof (StrQueryCountType) - 1);
|
||||||
Sta_MAX_BYTES_COUNT_TYPE);
|
|
||||||
break;
|
break;
|
||||||
case Sta_DISTINCT_USRS:
|
case Sta_DISTINCT_USRS:
|
||||||
sprintf (StrQueryCountType,"COUNT(DISTINCT(%s.UsrCod))",LogTable);
|
sprintf (StrQueryCountType,"COUNT(DISTINCT(%s.UsrCod))",LogTable);
|
||||||
|
@ -939,7 +937,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
|
|
||||||
/***** Select clicks from the table of log *****/
|
/***** Select clicks from the table of log *****/
|
||||||
/* Allocate memory for the query */
|
/* Allocate memory for the query */
|
||||||
if ((Query = (char *) malloc (Sta_MAX_BYTES_QUERY_ACCESS + 1)) == NULL)
|
if ((Query = malloc (Sta_MAX_BYTES_QUERY_ACCESS + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/* Start the query */
|
/* Start the query */
|
||||||
|
@ -1079,8 +1077,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
LogTable,
|
LogTable,
|
||||||
(long) Gbl.DateRange.TimeUTC[Dat_START_TIME],
|
(long) Gbl.DateRange.TimeUTC[Dat_START_TIME],
|
||||||
(long) Gbl.DateRange.TimeUTC[Dat_END_TIME ]);
|
(long) Gbl.DateRange.TimeUTC[Dat_END_TIME ]);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
|
|
||||||
switch (GlobalOrCourse)
|
switch (GlobalOrCourse)
|
||||||
{
|
{
|
||||||
|
@ -1096,8 +1093,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
{
|
{
|
||||||
sprintf (QueryAux," AND %s.CtyCod=%ld",
|
sprintf (QueryAux," AND %s.CtyCod=%ld",
|
||||||
LogTable,Gbl.Hierarchy.Cty.CtyCod);
|
LogTable,Gbl.Hierarchy.Cty.CtyCod);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_INS:
|
case Hie_Lvl_INS:
|
||||||
|
@ -1105,8 +1101,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
{
|
{
|
||||||
sprintf (QueryAux," AND %s.InsCod=%ld",
|
sprintf (QueryAux," AND %s.InsCod=%ld",
|
||||||
LogTable,Gbl.Hierarchy.Ins.InsCod);
|
LogTable,Gbl.Hierarchy.Ins.InsCod);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CTR:
|
case Hie_Lvl_CTR:
|
||||||
|
@ -1114,8 +1109,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
{
|
{
|
||||||
sprintf (QueryAux," AND %s.CtrCod=%ld",
|
sprintf (QueryAux," AND %s.CtrCod=%ld",
|
||||||
LogTable,Gbl.Hierarchy.Ctr.CtrCod);
|
LogTable,Gbl.Hierarchy.Ctr.CtrCod);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_DEG:
|
case Hie_Lvl_DEG:
|
||||||
|
@ -1123,8 +1117,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
{
|
{
|
||||||
sprintf (QueryAux," AND %s.DegCod=%ld",
|
sprintf (QueryAux," AND %s.DegCod=%ld",
|
||||||
LogTable,Gbl.Hierarchy.Deg.DegCod);
|
LogTable,Gbl.Hierarchy.Deg.DegCod);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CRS:
|
case Hie_Lvl_CRS:
|
||||||
|
@ -1132,8 +1125,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
{
|
{
|
||||||
sprintf (QueryAux," AND %s.CrsCod=%ld",
|
sprintf (QueryAux," AND %s.CrsCod=%ld",
|
||||||
LogTable,Gbl.Hierarchy.Crs.CrsCod);
|
LogTable,Gbl.Hierarchy.Crs.CrsCod);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1201,8 +1193,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
LogTable,Gbl.Usrs.Me.UsrDat.UsrCod);
|
LogTable,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Str_Concat (Query,StrRole,
|
Str_Concat (Query,StrRole,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
|
|
||||||
switch (Stats.ClicksGroupedBy)
|
switch (Stats.ClicksGroupedBy)
|
||||||
{
|
{
|
||||||
|
@ -1210,14 +1201,12 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
case Sta_CLICKS_GBL_PER_API_FUNCTION:
|
case Sta_CLICKS_GBL_PER_API_FUNCTION:
|
||||||
sprintf (QueryAux," AND %s.LogCod=log_ws.LogCod",
|
sprintf (QueryAux," AND %s.LogCod=log_ws.LogCod",
|
||||||
LogTable);
|
LogTable);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_GBL_PER_BANNER:
|
case Sta_CLICKS_GBL_PER_BANNER:
|
||||||
sprintf (QueryAux," AND %s.LogCod=log_banners.LogCod",
|
sprintf (QueryAux," AND %s.LogCod=log_banners.LogCod",
|
||||||
LogTable);
|
LogTable);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1226,8 +1215,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
case Sta_SHOW_COURSE_ACCESSES:
|
case Sta_SHOW_COURSE_ACCESSES:
|
||||||
sprintf (QueryAux," AND %s.CrsCod=%ld",
|
sprintf (QueryAux," AND %s.CrsCod=%ld",
|
||||||
LogTable,Gbl.Hierarchy.Crs.CrsCod);
|
LogTable,Gbl.Hierarchy.Crs.CrsCod);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
|
|
||||||
/***** Initialize data structure of the user *****/
|
/***** Initialize data structure of the user *****/
|
||||||
Usr_UsrDataConstructor (&UsrDat);
|
Usr_UsrDataConstructor (&UsrDat);
|
||||||
|
@ -1237,7 +1225,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
|
||||||
if (UsrDat.UsrCod > 0)
|
if (UsrDat.UsrCod > 0)
|
||||||
|
@ -1249,13 +1237,11 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
NumUsr ? " OR %s.UsrCod=%ld" :
|
NumUsr ? " OR %s.UsrCod=%ld" :
|
||||||
" AND (%s.UsrCod=%ld",
|
" AND (%s.UsrCod=%ld",
|
||||||
LogTable,UsrDat.UsrCod);
|
LogTable,UsrDat.UsrCod);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
NumUsr++;
|
NumUsr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Str_Concat (Query,")",
|
Str_Concat (Query,")",Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
|
|
||||||
/***** Free memory used by the data of the user *****/
|
/***** Free memory used by the data of the user *****/
|
||||||
Usr_UsrDataDestructor (&UsrDat);
|
Usr_UsrDataDestructor (&UsrDat);
|
||||||
|
@ -1267,62 +1253,51 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
{
|
{
|
||||||
sprintf (QueryAux," AND %s.ActCod=%ld",
|
sprintf (QueryAux," AND %s.ActCod=%ld",
|
||||||
LogTable,Act_GetActCod (Stats.NumAction));
|
LogTable,Act_GetActCod (Stats.NumAction));
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End the query */
|
/* End the query */
|
||||||
switch (Stats.ClicksGroupedBy)
|
switch (Stats.ClicksGroupedBy)
|
||||||
{
|
{
|
||||||
case Sta_CLICKS_CRS_DETAILED_LIST:
|
case Sta_CLICKS_CRS_DETAILED_LIST:
|
||||||
Str_Concat (Query," ORDER BY F",
|
Str_Concat (Query," ORDER BY F",Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_CRS_PER_USR:
|
case Sta_CLICKS_CRS_PER_USR:
|
||||||
sprintf (QueryAux," GROUP BY %s.UsrCod ORDER BY Num DESC",LogTable);
|
sprintf (QueryAux," GROUP BY %s.UsrCod ORDER BY Num DESC",LogTable);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_CRS_PER_DAY:
|
case Sta_CLICKS_CRS_PER_DAY:
|
||||||
case Sta_CLICKS_GBL_PER_DAY:
|
case Sta_CLICKS_GBL_PER_DAY:
|
||||||
Str_Concat (Query," GROUP BY Day DESC",
|
Str_Concat (Query," GROUP BY Day DESC",Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_CRS_PER_DAY_AND_HOUR:
|
case Sta_CLICKS_CRS_PER_DAY_AND_HOUR:
|
||||||
case Sta_CLICKS_GBL_PER_DAY_AND_HOUR:
|
case Sta_CLICKS_GBL_PER_DAY_AND_HOUR:
|
||||||
Str_Concat (Query," GROUP BY Day DESC,Hour",
|
Str_Concat (Query," GROUP BY Day DESC,Hour",Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_CRS_PER_WEEK:
|
case Sta_CLICKS_CRS_PER_WEEK:
|
||||||
case Sta_CLICKS_GBL_PER_WEEK:
|
case Sta_CLICKS_GBL_PER_WEEK:
|
||||||
Str_Concat (Query," GROUP BY Week DESC",
|
Str_Concat (Query," GROUP BY Week DESC",Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_CRS_PER_MONTH:
|
case Sta_CLICKS_CRS_PER_MONTH:
|
||||||
case Sta_CLICKS_GBL_PER_MONTH:
|
case Sta_CLICKS_GBL_PER_MONTH:
|
||||||
Str_Concat (Query," GROUP BY Month DESC",
|
Str_Concat (Query," GROUP BY Month DESC",Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_CRS_PER_YEAR:
|
case Sta_CLICKS_CRS_PER_YEAR:
|
||||||
case Sta_CLICKS_GBL_PER_YEAR:
|
case Sta_CLICKS_GBL_PER_YEAR:
|
||||||
Str_Concat (Query," GROUP BY Year DESC",
|
Str_Concat (Query," GROUP BY Year DESC",Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_CRS_PER_HOUR:
|
case Sta_CLICKS_CRS_PER_HOUR:
|
||||||
case Sta_CLICKS_GBL_PER_HOUR:
|
case Sta_CLICKS_GBL_PER_HOUR:
|
||||||
Str_Concat (Query," GROUP BY Hour",
|
Str_Concat (Query," GROUP BY Hour",Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_CRS_PER_MINUTE:
|
case Sta_CLICKS_CRS_PER_MINUTE:
|
||||||
case Sta_CLICKS_GBL_PER_MINUTE:
|
case Sta_CLICKS_GBL_PER_MINUTE:
|
||||||
Str_Concat (Query," GROUP BY Minute",
|
Str_Concat (Query," GROUP BY Minute",Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_CRS_PER_ACTION:
|
case Sta_CLICKS_CRS_PER_ACTION:
|
||||||
case Sta_CLICKS_GBL_PER_ACTION:
|
case Sta_CLICKS_GBL_PER_ACTION:
|
||||||
sprintf (QueryAux," GROUP BY %s.ActCod ORDER BY Num DESC",LogTable);
|
sprintf (QueryAux," GROUP BY %s.ActCod ORDER BY Num DESC",LogTable);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_GBL_PER_PLUGIN:
|
case Sta_CLICKS_GBL_PER_PLUGIN:
|
||||||
Str_Concat (Query," GROUP BY log_ws.PlgCod ORDER BY Num DESC",
|
Str_Concat (Query," GROUP BY log_ws.PlgCod ORDER BY Num DESC",
|
||||||
|
@ -1338,28 +1313,23 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_GBL_PER_COUNTRY:
|
case Sta_CLICKS_GBL_PER_COUNTRY:
|
||||||
sprintf (QueryAux," GROUP BY %s.CtyCod ORDER BY Num DESC",LogTable);
|
sprintf (QueryAux," GROUP BY %s.CtyCod ORDER BY Num DESC",LogTable);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_GBL_PER_INSTITUTION:
|
case Sta_CLICKS_GBL_PER_INSTITUTION:
|
||||||
sprintf (QueryAux," GROUP BY %s.InsCod ORDER BY Num DESC",LogTable);
|
sprintf (QueryAux," GROUP BY %s.InsCod ORDER BY Num DESC",LogTable);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_GBL_PER_CENTRE:
|
case Sta_CLICKS_GBL_PER_CENTRE:
|
||||||
sprintf (QueryAux," GROUP BY %s.CtrCod ORDER BY Num DESC",LogTable);
|
sprintf (QueryAux," GROUP BY %s.CtrCod ORDER BY Num DESC",LogTable);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_GBL_PER_DEGREE:
|
case Sta_CLICKS_GBL_PER_DEGREE:
|
||||||
sprintf (QueryAux," GROUP BY %s.DegCod ORDER BY Num DESC",LogTable);
|
sprintf (QueryAux," GROUP BY %s.DegCod ORDER BY Num DESC",LogTable);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
case Sta_CLICKS_GBL_PER_COURSE:
|
case Sta_CLICKS_GBL_PER_COURSE:
|
||||||
sprintf (QueryAux," GROUP BY %s.CrsCod ORDER BY Num DESC",LogTable);
|
sprintf (QueryAux," GROUP BY %s.CrsCod ORDER BY Num DESC",LogTable);
|
||||||
Str_Concat (Query,QueryAux,
|
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
|
||||||
Sta_MAX_BYTES_QUERY_ACCESS);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/***** Write query for debug *****/
|
/***** Write query for debug *****/
|
||||||
|
@ -3913,20 +3883,14 @@ void Sta_WriteTimeToGenerateAndSendPage (void)
|
||||||
void Sta_WriteTime (char Str[Dat_MAX_BYTES_TIME],long TimeInMicroseconds)
|
void Sta_WriteTime (char Str[Dat_MAX_BYTES_TIME],long TimeInMicroseconds)
|
||||||
{
|
{
|
||||||
if (TimeInMicroseconds < 1000L)
|
if (TimeInMicroseconds < 1000L)
|
||||||
snprintf (Str,Dat_MAX_BYTES_TIME + 1,
|
snprintf (Str,Dat_MAX_BYTES_TIME + 1,"%ld µs",TimeInMicroseconds);
|
||||||
"%ld µs",
|
|
||||||
TimeInMicroseconds);
|
|
||||||
else if (TimeInMicroseconds < 1000000L)
|
else if (TimeInMicroseconds < 1000000L)
|
||||||
snprintf (Str,Dat_MAX_BYTES_TIME + 1,
|
snprintf (Str,Dat_MAX_BYTES_TIME + 1,"%ld ms",TimeInMicroseconds / 1000);
|
||||||
"%ld ms",
|
|
||||||
TimeInMicroseconds / 1000);
|
|
||||||
else if (TimeInMicroseconds < (60 * 1000000L))
|
else if (TimeInMicroseconds < (60 * 1000000L))
|
||||||
snprintf (Str,Dat_MAX_BYTES_TIME + 1,
|
snprintf (Str,Dat_MAX_BYTES_TIME + 1,"%.1f s",
|
||||||
"%.1f s",
|
(double) TimeInMicroseconds / 1E6);
|
||||||
(double) TimeInMicroseconds / 1E6);
|
|
||||||
else
|
else
|
||||||
snprintf (Str,Dat_MAX_BYTES_TIME + 1,
|
snprintf (Str,Dat_MAX_BYTES_TIME + 1,"%ld min, %ld s",
|
||||||
"%ld min, %ld s",
|
|
||||||
TimeInMicroseconds / (60 * 1000000L),
|
TimeInMicroseconds / (60 * 1000000L),
|
||||||
(TimeInMicroseconds / 1000000L) % 60);
|
(TimeInMicroseconds / 1000000L) % 60);
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,12 +305,10 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
|
||||||
Gbl.Form.Num++;
|
Gbl.Form.Num++;
|
||||||
if (Gbl.Usrs.Me.Logged)
|
if (Gbl.Usrs.Me.Logged)
|
||||||
snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),
|
snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),
|
||||||
"form_%s_%d",
|
"form_%s_%d",Gbl.UniqueNameEncrypted,Gbl.Form.Num);
|
||||||
Gbl.UniqueNameEncrypted,Gbl.Form.Num);
|
|
||||||
else
|
else
|
||||||
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),
|
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),
|
||||||
"form_%d",
|
"form_%d",Gbl.Form.Num);
|
||||||
Gbl.Form.Num);
|
|
||||||
|
|
||||||
/* Store first part of anchor */
|
/* Store first part of anchor */
|
||||||
Frm_SetParamsForm (ParamsStr,ActSeeOthPubPrf,true);
|
Frm_SetParamsForm (ParamsStr,ActSeeOthPubPrf,true);
|
||||||
|
@ -324,7 +322,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
|
||||||
Gbl.Form.Id,
|
Gbl.Form.Id,
|
||||||
ParamsStr);
|
ParamsStr);
|
||||||
Anchor1NickLength = strlen (Anchor1Nick);
|
Anchor1NickLength = strlen (Anchor1Nick);
|
||||||
if ((Links[NumLinks].Anchor1Nick = (char *) malloc (Anchor1NickLength + 1)) == NULL)
|
if ((Links[NumLinks].Anchor1Nick = malloc (Anchor1NickLength + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
strcpy (Links[NumLinks].Anchor1Nick,Anchor1Nick);
|
strcpy (Links[NumLinks].Anchor1Nick,Anchor1Nick);
|
||||||
Links[NumLinks].Anchor1NickLength = Anchor1NickLength;
|
Links[NumLinks].Anchor1NickLength = Anchor1NickLength;
|
||||||
|
@ -337,7 +335,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
|
||||||
Gbl.Usrs.Me.Logged ? Gbl.Form.UniqueId :
|
Gbl.Usrs.Me.Logged ? Gbl.Form.UniqueId :
|
||||||
Gbl.Form.Id);
|
Gbl.Form.Id);
|
||||||
Anchor2NickLength = strlen (Anchor2Nick);
|
Anchor2NickLength = strlen (Anchor2Nick);
|
||||||
if ((Links[NumLinks].Anchor2Nick = (char *) malloc (Anchor2NickLength + 1)) == NULL)
|
if ((Links[NumLinks].Anchor2Nick = malloc (Anchor2NickLength + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
strcpy (Links[NumLinks].Anchor2Nick,Anchor2Nick);
|
strcpy (Links[NumLinks].Anchor2Nick,Anchor2Nick);
|
||||||
Links[NumLinks].Anchor2NickLength = Anchor2NickLength;
|
Links[NumLinks].Anchor2NickLength = Anchor2NickLength;
|
||||||
|
@ -1148,7 +1146,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
|
||||||
if (ChangeTo != Str_DONT_CHANGE)
|
if (ChangeTo != Str_DONT_CHANGE)
|
||||||
{
|
{
|
||||||
/***** Allocate memory for a destination string where to do the changes *****/
|
/***** Allocate memory for a destination string where to do the changes *****/
|
||||||
if ((StrDst = (char *) malloc (MaxLengthStr + 1)) == NULL)
|
if ((StrDst = malloc (MaxLengthStr + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Make the change *****/
|
/***** Make the change *****/
|
||||||
|
@ -1287,12 +1285,12 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
|
||||||
Str_Concat (StrSpecialChar,
|
Str_Concat (StrSpecialChar,
|
||||||
ThereIsSpaceChar ? " " :
|
ThereIsSpaceChar ? " " :
|
||||||
" ", // The first space
|
" ", // The first space
|
||||||
Str_MAX_BYTES_SPECIAL_CHAR);
|
sizeof (StrSpecialChar) - 1);
|
||||||
for (i = 1;
|
for (i = 1;
|
||||||
i < NumSpacesTab;
|
i < NumSpacesTab;
|
||||||
i++) // Rest of spaces, except the first
|
i++) // Rest of spaces, except the first
|
||||||
Str_Concat (StrSpecialChar," ", // Add a space
|
Str_Concat (StrSpecialChar," ", // Add a space
|
||||||
Str_MAX_BYTES_SPECIAL_CHAR);
|
sizeof (StrSpecialChar) - 1);
|
||||||
NumPrintableCharsFromReturn += NumSpacesTab;
|
NumPrintableCharsFromReturn += NumSpacesTab;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1305,7 +1303,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
|
||||||
case 0x0A: /* \n */
|
case 0x0A: /* \n */
|
||||||
if (ChangeTo == Str_TO_RIGOROUS_HTML)
|
if (ChangeTo == Str_TO_RIGOROUS_HTML)
|
||||||
Str_Copy (StrSpecialChar,"<br />",
|
Str_Copy (StrSpecialChar,"<br />",
|
||||||
Str_MAX_BYTES_SPECIAL_CHAR);
|
sizeof (StrSpecialChar) - 1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StrSpecialChar[0] = Str_LF[0];
|
StrSpecialChar[0] = Str_LF[0];
|
||||||
|
@ -1328,7 +1326,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
|
||||||
case 0x20: /* Space */
|
case 0x20: /* Space */
|
||||||
if (ChangeTo == Str_TO_RIGOROUS_HTML && ThereIsSpaceChar)
|
if (ChangeTo == Str_TO_RIGOROUS_HTML && ThereIsSpaceChar)
|
||||||
Str_Copy (StrSpecialChar," ",
|
Str_Copy (StrSpecialChar," ",
|
||||||
Str_MAX_BYTES_SPECIAL_CHAR);
|
sizeof (StrSpecialChar) - 1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StrSpecialChar[0] = ' ';
|
StrSpecialChar[0] = ' ';
|
||||||
|
@ -1346,7 +1344,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Str_Copy (StrSpecialChar,""", // Double comilla is stored as HTML code to avoid problems when displaying it
|
Str_Copy (StrSpecialChar,""", // Double comilla is stored as HTML code to avoid problems when displaying it
|
||||||
Str_MAX_BYTES_SPECIAL_CHAR);
|
sizeof (StrSpecialChar) - 1);
|
||||||
NumPrintableCharsFromReturn++;
|
NumPrintableCharsFromReturn++;
|
||||||
ThereIsSpaceChar = false;
|
ThereIsSpaceChar = false;
|
||||||
break;
|
break;
|
||||||
|
@ -1371,7 +1369,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Str_Copy (StrSpecialChar,"'", // Single comilla is stored as HTML entity to avoid problem when querying database (SQL code injection)
|
Str_Copy (StrSpecialChar,"'", // Single comilla is stored as HTML entity to avoid problem when querying database (SQL code injection)
|
||||||
Str_MAX_BYTES_SPECIAL_CHAR);
|
sizeof (StrSpecialChar) - 1);
|
||||||
NumPrintableCharsFromReturn++;
|
NumPrintableCharsFromReturn++;
|
||||||
ThereIsSpaceChar = false;
|
ThereIsSpaceChar = false;
|
||||||
break;
|
break;
|
||||||
|
@ -1407,7 +1405,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Str_Copy (StrSpecialChar,"<", // "<" is stored as HTML code to avoid problems when displaying it
|
Str_Copy (StrSpecialChar,"<", // "<" is stored as HTML code to avoid problems when displaying it
|
||||||
Str_MAX_BYTES_SPECIAL_CHAR);
|
sizeof (StrSpecialChar) - 1);
|
||||||
NumPrintableCharsFromReturn++;
|
NumPrintableCharsFromReturn++;
|
||||||
ThereIsSpaceChar = false;
|
ThereIsSpaceChar = false;
|
||||||
break;
|
break;
|
||||||
|
@ -1419,7 +1417,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Str_Copy (StrSpecialChar,">", // ">" is stored as HTML code to avoid problems when displaying it
|
Str_Copy (StrSpecialChar,">", // ">" is stored as HTML code to avoid problems when displaying it
|
||||||
Str_MAX_BYTES_SPECIAL_CHAR);
|
sizeof (StrSpecialChar) - 1);
|
||||||
NumPrintableCharsFromReturn++;
|
NumPrintableCharsFromReturn++;
|
||||||
ThereIsSpaceChar = false;
|
ThereIsSpaceChar = false;
|
||||||
break;
|
break;
|
||||||
|
@ -1444,7 +1442,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Str_Copy (StrSpecialChar,"\", // "\" is stored as HTML code to avoid problems when displaying it
|
Str_Copy (StrSpecialChar,"\", // "\" is stored as HTML code to avoid problems when displaying it
|
||||||
Str_MAX_BYTES_SPECIAL_CHAR);
|
sizeof (StrSpecialChar) - 1);
|
||||||
NumPrintableCharsFromReturn++;
|
NumPrintableCharsFromReturn++;
|
||||||
ThereIsSpaceChar = false;
|
ThereIsSpaceChar = false;
|
||||||
break;
|
break;
|
||||||
|
@ -2579,16 +2577,14 @@ void Str_SplitFullPathIntoPathAndFileName (const char FullPath[PATH_MAX + 1],
|
||||||
LengthUntilFileName = (size_t) (PtrFileName - FullPath); // Last slash included
|
LengthUntilFileName = (size_t) (PtrFileName - FullPath); // Last slash included
|
||||||
if (LengthUntilFileName > 1)
|
if (LengthUntilFileName > 1)
|
||||||
{
|
{
|
||||||
Str_Copy (PathWithoutFileName,FullPath,
|
Str_Copy (PathWithoutFileName,FullPath,PATH_MAX);
|
||||||
PATH_MAX);
|
|
||||||
PathWithoutFileName[LengthUntilFileName - 1] = '\0'; // Do not copy ending slash
|
PathWithoutFileName[LengthUntilFileName - 1] = '\0'; // Do not copy ending slash
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PathWithoutFileName[0] = '\0';
|
PathWithoutFileName[0] = '\0';
|
||||||
|
|
||||||
/***** Get FileName *****/
|
/***** Get FileName *****/
|
||||||
Str_Copy (FileName,PtrFileName,
|
Str_Copy (FileName,PtrFileName,NAME_MAX);
|
||||||
NAME_MAX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3043,8 +3039,7 @@ void Str_Concat (char *Dst,const char *Src,size_t DstSize)
|
||||||
DstLength = strlen (Dst);
|
DstLength = strlen (Dst);
|
||||||
if (DstLength > DstSize)
|
if (DstLength > DstSize)
|
||||||
{
|
{
|
||||||
snprintf (ErrorTxt,sizeof (ErrorTxt),
|
snprintf (ErrorTxt,sizeof (ErrorTxt),"%lu-chars buffer has %lu chars!",
|
||||||
"%lu-chars buffer has %lu chars!",
|
|
||||||
DstSize,DstLength);
|
DstSize,DstLength);
|
||||||
Lay_ShowErrorAndExit (ErrorTxt);
|
Lay_ShowErrorAndExit (ErrorTxt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1055,7 +1055,8 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys)
|
||||||
Surveys->Num = (unsigned) NumRows;
|
Surveys->Num = (unsigned) NumRows;
|
||||||
|
|
||||||
/***** Create list of surveys *****/
|
/***** Create list of surveys *****/
|
||||||
if ((Surveys->LstSvyCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
|
if ((Surveys->LstSvyCods = calloc (NumRows,
|
||||||
|
sizeof (*Surveys->LstSvyCods))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the surveys codes *****/
|
/***** Get the surveys codes *****/
|
||||||
|
@ -1301,8 +1302,7 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy)
|
||||||
Svy->Status.Open = (row[8][0] == '1');
|
Svy->Status.Open = (row[8][0] == '1');
|
||||||
|
|
||||||
/* Get the title of the survey (row[9]) */
|
/* Get the title of the survey (row[9]) */
|
||||||
Str_Copy (Svy->Title,row[9],
|
Str_Copy (Svy->Title,row[9],strlen (Svy->Title) - 1);
|
||||||
Svy_MAX_BYTES_SURVEY_TITLE);
|
|
||||||
|
|
||||||
/* Get number of questions and number of users who have already answer this survey */
|
/* Get number of questions and number of users who have already answer this survey */
|
||||||
Svy->NumQsts = Svy_GetNumQstsSvy (Svy->SvyCod);
|
Svy->NumQsts = Svy_GetNumQstsSvy (Svy->SvyCod);
|
||||||
|
@ -1493,8 +1493,7 @@ static void Svy_GetSurveyTxtFromDB (long SvyCod,char Txt[Cns_MAX_BYTES_TEXT + 1]
|
||||||
{
|
{
|
||||||
/* Get info text */
|
/* Get info text */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Txt,row[0],
|
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Txt[0] = '\0';
|
Txt[0] = '\0';
|
||||||
|
@ -1532,17 +1531,15 @@ void Svy_GetNotifSurvey (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/***** Get summary *****/
|
/***** Get summary *****/
|
||||||
Str_Copy (SummaryStr,row[0],
|
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
|
||||||
Ntf_MAX_BYTES_SUMMARY);
|
|
||||||
|
|
||||||
/***** Get content *****/
|
/***** Get content *****/
|
||||||
if (GetContent)
|
if (GetContent)
|
||||||
{
|
{
|
||||||
Length = strlen (row[1]);
|
Length = strlen (row[1]);
|
||||||
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
|
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (*ContentStr,row[1],
|
Str_Copy (*ContentStr,row[1],Length);
|
||||||
Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2708,8 +2705,7 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
|
||||||
SvyQst->AnswerType = Svy_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
|
SvyQst->AnswerType = Svy_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
|
||||||
|
|
||||||
/* Get the stem of the question from the database (row[2]) */
|
/* Get the stem of the question from the database (row[2]) */
|
||||||
Str_Copy (Txt,row[2],
|
Str_Copy (Txt,row[2],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
|
|
||||||
/* Free structure that stores the query result */
|
/* Free structure that stores the query result */
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -2728,8 +2724,7 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
|
||||||
/* Abort on error */
|
/* Abort on error */
|
||||||
Ale_ShowAlertsAndExit ();
|
Ale_ShowAlertsAndExit ();
|
||||||
|
|
||||||
Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],
|
Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],Svy_MAX_BYTES_ANSWER);
|
||||||
Svy_MAX_BYTES_ANSWER);
|
|
||||||
}
|
}
|
||||||
/* Free structure that stores the query result */
|
/* Free structure that stores the query result */
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -2968,7 +2963,7 @@ static bool Svy_AllocateTextChoiceAnswer (struct Svy_Question *SvyQst,
|
||||||
unsigned NumAns)
|
unsigned NumAns)
|
||||||
{
|
{
|
||||||
Svy_FreeTextChoiceAnswer (SvyQst,NumAns);
|
Svy_FreeTextChoiceAnswer (SvyQst,NumAns);
|
||||||
if ((SvyQst->AnsChoice[NumAns].Text = (char *) malloc (Svy_MAX_BYTES_ANSWER + 1)) == NULL)
|
if ((SvyQst->AnsChoice[NumAns].Text = malloc (Svy_MAX_BYTES_ANSWER + 1)) == NULL)
|
||||||
{
|
{
|
||||||
Ale_CreateAlert (Ale_ERROR,NULL,
|
Ale_CreateAlert (Ale_ERROR,NULL,
|
||||||
"Not enough memory to store answer.");
|
"Not enough memory to store answer.");
|
||||||
|
@ -3057,9 +3052,7 @@ void Svy_ReceiveQst (void)
|
||||||
if (!Svy_AllocateTextChoiceAnswer (&SvyQst,NumAns))
|
if (!Svy_AllocateTextChoiceAnswer (&SvyQst,NumAns))
|
||||||
/* Abort on error */
|
/* Abort on error */
|
||||||
Ale_ShowAlertsAndExit ();
|
Ale_ShowAlertsAndExit ();
|
||||||
snprintf (AnsStr,sizeof (AnsStr),
|
snprintf (AnsStr,sizeof (AnsStr),"AnsStr%u",NumAns);
|
||||||
"AnsStr%u",
|
|
||||||
NumAns);
|
|
||||||
Par_GetParToHTML (AnsStr,SvyQst.AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER);
|
Par_GetParToHTML (AnsStr,SvyQst.AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3438,10 +3431,9 @@ static void Svy_WriteQstStem (const char *Stem)
|
||||||
|
|
||||||
/* Convert the stem, that is in HTML, to rigorous HTML */
|
/* Convert the stem, that is in HTML, to rigorous HTML */
|
||||||
Length = strlen (Stem) * Str_MAX_BYTES_PER_CHAR;
|
Length = strlen (Stem) * Str_MAX_BYTES_PER_CHAR;
|
||||||
if ((HeadingRigorousHTML = (char *) malloc (Length + 1)) == NULL)
|
if ((HeadingRigorousHTML = malloc (Length + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (HeadingRigorousHTML,Stem,
|
Str_Copy (HeadingRigorousHTML,Stem,Length);
|
||||||
Length);
|
|
||||||
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
||||||
HeadingRigorousHTML,Length,false);
|
HeadingRigorousHTML,Length,false);
|
||||||
|
|
||||||
|
@ -3495,8 +3487,7 @@ static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy,
|
||||||
/* Abort on error */
|
/* Abort on error */
|
||||||
Ale_ShowAlertsAndExit ();
|
Ale_ShowAlertsAndExit ();
|
||||||
|
|
||||||
Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],
|
Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],Svy_MAX_BYTES_ANSWER);
|
||||||
Svy_MAX_BYTES_ANSWER);
|
|
||||||
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
||||||
SvyQst->AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER,false);
|
SvyQst->AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER,false);
|
||||||
|
|
||||||
|
@ -3507,9 +3498,8 @@ static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy,
|
||||||
{
|
{
|
||||||
/* Write selector to choice this answer */
|
/* Write selector to choice this answer */
|
||||||
HTM_TD_Begin ("class=\"LT\"");
|
HTM_TD_Begin ("class=\"LT\"");
|
||||||
snprintf (StrAns,sizeof (StrAns),
|
snprintf (StrAns,sizeof (StrAns),"Ans%010u",
|
||||||
"Ans%010u",
|
(unsigned) SvyQst->QstCod);
|
||||||
(unsigned) SvyQst->QstCod);
|
|
||||||
if (SvyQst->AnswerType == Svy_ANS_UNIQUE_CHOICE)
|
if (SvyQst->AnswerType == Svy_ANS_UNIQUE_CHOICE)
|
||||||
HTM_INPUT_RADIO (StrAns,false,
|
HTM_INPUT_RADIO (StrAns,false,
|
||||||
"id=\"Ans%010u_%010u\" value=\"%u\""
|
"id=\"Ans%010u_%010u\" value=\"%u\""
|
||||||
|
@ -3799,9 +3789,7 @@ static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod)
|
||||||
Lay_ShowErrorAndExit ("Error: wrong question code.");
|
Lay_ShowErrorAndExit ("Error: wrong question code.");
|
||||||
|
|
||||||
/* Get possible parameter with the user's answer */
|
/* Get possible parameter with the user's answer */
|
||||||
snprintf (ParamName,sizeof (ParamName),
|
snprintf (ParamName,sizeof (ParamName),"Ans%010u",(unsigned) QstCod);
|
||||||
"Ans%010u",
|
|
||||||
(unsigned) QstCod);
|
|
||||||
// Lay_ShowAlert (Lay_INFO,ParamName);
|
// Lay_ShowAlert (Lay_INFO,ParamName);
|
||||||
Par_GetParMultiToText (ParamName,StrAnswersIndexes,
|
Par_GetParMultiToText (ParamName,StrAnswersIndexes,
|
||||||
Svy_MAX_ANSWERS_PER_QUESTION * (Cns_MAX_DECIMAL_DIGITS_UINT + 1));
|
Svy_MAX_ANSWERS_PER_QUESTION * (Cns_MAX_DECIMAL_DIGITS_UINT + 1));
|
||||||
|
|
|
@ -118,7 +118,7 @@ static void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos);
|
||||||
static void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreaseLevel);
|
static void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreaseLevel);
|
||||||
|
|
||||||
static void Syl_OpenSyllabusFile (const struct Syl_Syllabus *Syllabus,
|
static void Syl_OpenSyllabusFile (const struct Syl_Syllabus *Syllabus,
|
||||||
char *PathFile);
|
char PathFile[PATH_MAX + 1]);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************************** Reset syllabus context ***************************/
|
/************************** Reset syllabus context ***************************/
|
||||||
|
@ -371,8 +371,7 @@ void Syl_LoadListItemsSyllabusIntoMemory (struct Syl_Syllabus *Syllabus,
|
||||||
unsigned NumItemsWithChildren = 0;
|
unsigned NumItemsWithChildren = 0;
|
||||||
|
|
||||||
/* Path of the private directory for the XML file with the syllabus */
|
/* Path of the private directory for the XML file with the syllabus */
|
||||||
snprintf (Syllabus->PathDir,sizeof (Syllabus->PathDir),
|
snprintf (Syllabus->PathDir,sizeof (Syllabus->PathDir),"%s/%ld/%s",
|
||||||
"%s/%ld/%s",
|
|
||||||
Cfg_PATH_CRS_PRIVATE,CrsCod,
|
Cfg_PATH_CRS_PRIVATE,CrsCod,
|
||||||
Syllabus->WhichSyllabus == Syl_LECTURES ? Cfg_SYLLABUS_FOLDER_LECTURES :
|
Syllabus->WhichSyllabus == Syl_LECTURES ? Cfg_SYLLABUS_FOLDER_LECTURES :
|
||||||
Cfg_SYLLABUS_FOLDER_PRACTICALS);
|
Cfg_SYLLABUS_FOLDER_PRACTICALS);
|
||||||
|
@ -393,8 +392,8 @@ void Syl_LoadListItemsSyllabusIntoMemory (struct Syl_Syllabus *Syllabus,
|
||||||
Syl_LstItemsSyllabus.NumItems++);
|
Syl_LstItemsSyllabus.NumItems++);
|
||||||
|
|
||||||
/***** Allocate memory for the list of items *****/
|
/***** Allocate memory for the list of items *****/
|
||||||
if ((Syl_LstItemsSyllabus.Lst = (struct ItemSyllabus *) calloc (Syl_LstItemsSyllabus.NumItems + 1,
|
if ((Syl_LstItemsSyllabus.Lst = calloc (Syl_LstItemsSyllabus.NumItems + 1,
|
||||||
sizeof (struct ItemSyllabus))) == NULL)
|
sizeof (*Syl_LstItemsSyllabus.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Return to the start of the list *****/
|
/***** Return to the start of the list *****/
|
||||||
|
@ -907,17 +906,13 @@ static void Syl_WriteNumItem (char *StrDst,FILE *FileTgt,int Level,int *CodItem)
|
||||||
if (N > 1)
|
if (N > 1)
|
||||||
{
|
{
|
||||||
if (StrDst)
|
if (StrDst)
|
||||||
Str_Concat (StrDst,".",
|
Str_Concat (StrDst,".",Syl_MAX_BYTES_ITEM_COD);
|
||||||
Syl_MAX_BYTES_ITEM_COD);
|
|
||||||
if (FileTgt)
|
if (FileTgt)
|
||||||
fprintf (FileTgt,".");
|
fprintf (FileTgt,".");
|
||||||
}
|
}
|
||||||
snprintf (InStr,sizeof (InStr),
|
snprintf (InStr,sizeof (InStr),"%d",CodItem[N]);
|
||||||
"%d",
|
|
||||||
CodItem[N]);
|
|
||||||
if (StrDst)
|
if (StrDst)
|
||||||
Str_Concat (StrDst,InStr,
|
Str_Concat (StrDst,InStr,Syl_MAX_BYTES_ITEM_COD);
|
||||||
Syl_MAX_BYTES_ITEM_COD);
|
|
||||||
if (FileTgt)
|
if (FileTgt)
|
||||||
fprintf (FileTgt,"%s",InStr);
|
fprintf (FileTgt,"%s",InStr);
|
||||||
}
|
}
|
||||||
|
@ -1379,15 +1374,12 @@ void Syl_ModifyItemSyllabus (void)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Syl_BuildPathFileSyllabus (const struct Syl_Syllabus *Syllabus,
|
void Syl_BuildPathFileSyllabus (const struct Syl_Syllabus *Syllabus,
|
||||||
char *PathFile)
|
char PathFile[PATH_MAX + 1])
|
||||||
{
|
{
|
||||||
char Path[PATH_MAX + 1 + NAME_MAX + 1];
|
char Path[PATH_MAX + 1 + NAME_MAX + 1];
|
||||||
|
|
||||||
snprintf (Path,sizeof (Path),
|
snprintf (Path,sizeof (Path),"%s/%s",Syllabus->PathDir,Cfg_SYLLABUS_FILENAME);
|
||||||
"%s/%s",
|
Str_Copy (PathFile,Path,PATH_MAX);
|
||||||
Syllabus->PathDir,Cfg_SYLLABUS_FILENAME);
|
|
||||||
Str_Copy (PathFile,Path,
|
|
||||||
PATH_MAX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1395,7 +1387,7 @@ void Syl_BuildPathFileSyllabus (const struct Syl_Syllabus *Syllabus,
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Syl_OpenSyllabusFile (const struct Syl_Syllabus *Syllabus,
|
static void Syl_OpenSyllabusFile (const struct Syl_Syllabus *Syllabus,
|
||||||
char *PathFile)
|
char PathFile[PATH_MAX + 1])
|
||||||
{
|
{
|
||||||
if (Gbl.F.XML == NULL) // If it's not open in this moment...
|
if (Gbl.F.XML == NULL) // If it's not open in this moment...
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,7 +111,7 @@ void Syl_LeftItemSyllabus (void);
|
||||||
void Syl_InsertItemSyllabus (void);
|
void Syl_InsertItemSyllabus (void);
|
||||||
void Syl_ModifyItemSyllabus (void);
|
void Syl_ModifyItemSyllabus (void);
|
||||||
void Syl_BuildPathFileSyllabus (const struct Syl_Syllabus *Syllabus,
|
void Syl_BuildPathFileSyllabus (const struct Syl_Syllabus *Syllabus,
|
||||||
char *PathFile);
|
char PathFile[PATH_MAX + 1]);
|
||||||
void Syl_WriteStartFileSyllabus (FILE *FileSyllabus);
|
void Syl_WriteStartFileSyllabus (FILE *FileSyllabus);
|
||||||
void Syl_WriteAllItemsFileSyllabus (FILE *FileSyllabus);
|
void Syl_WriteAllItemsFileSyllabus (FILE *FileSyllabus);
|
||||||
void Syl_WriteItemFileSyllabus (FILE *FileSyllabus,int Level,const char *Text);
|
void Syl_WriteItemFileSyllabus (FILE *FileSyllabus,int Level,const char *Text);
|
||||||
|
|
186
swad_test.c
186
swad_test.c
|
@ -124,7 +124,7 @@ static void TstPrn_GetAnswersFromForm (struct TstPrn_Print *Print);
|
||||||
static bool Tst_CheckIfNextTstAllowed (void);
|
static bool Tst_CheckIfNextTstAllowed (void);
|
||||||
static unsigned Tst_GetNumExamsGeneratedByMe (void);
|
static unsigned Tst_GetNumExamsGeneratedByMe (void);
|
||||||
|
|
||||||
static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMediaInForm,
|
static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedia,
|
||||||
bool OptionsDisabled);
|
bool OptionsDisabled);
|
||||||
static void Tst_IncreaseMyNumAccessTst (void);
|
static void Tst_IncreaseMyNumAccessTst (void);
|
||||||
static void Tst_UpdateLastAccTst (unsigned NumQsts);
|
static void Tst_UpdateLastAccTst (unsigned NumQsts);
|
||||||
|
@ -572,9 +572,7 @@ static void TstPrn_GetAnswersFromForm (struct TstPrn_Print *Print)
|
||||||
NumQst++)
|
NumQst++)
|
||||||
{
|
{
|
||||||
/* Get answers selected by user for this question */
|
/* Get answers selected by user for this question */
|
||||||
snprintf (StrAns,sizeof (StrAns),
|
snprintf (StrAns,sizeof (StrAns),"Ans%010u",NumQst);
|
||||||
"Ans%010u",
|
|
||||||
NumQst);
|
|
||||||
Par_GetParMultiToText (StrAns,Print->PrintedQuestions[NumQst].StrAnswers,
|
Par_GetParMultiToText (StrAns,Print->PrintedQuestions[NumQst].StrAnswers,
|
||||||
Tst_MAX_BYTES_ANSWERS_ONE_QST); /* If answer type == T/F ==> " ", "T", "F"; if choice ==> "0", "2",... */
|
Tst_MAX_BYTES_ANSWERS_ONE_QST); /* If answer type == T/F ==> " ", "T", "F"; if choice ==> "0", "2",... */
|
||||||
Par_ReplaceSeparatorMultipleByComma (Print->PrintedQuestions[NumQst].StrAnswers);
|
Par_ReplaceSeparatorMultipleByComma (Print->PrintedQuestions[NumQst].StrAnswers);
|
||||||
|
@ -816,10 +814,9 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible)
|
||||||
{
|
{
|
||||||
/* Convert the stem, that is in HTML, to rigorous HTML */
|
/* Convert the stem, that is in HTML, to rigorous HTML */
|
||||||
StemLength = strlen (Stem) * Str_MAX_BYTES_PER_CHAR;
|
StemLength = strlen (Stem) * Str_MAX_BYTES_PER_CHAR;
|
||||||
if ((StemRigorousHTML = (char *) malloc (StemLength + 1)) == NULL)
|
if ((StemRigorousHTML = malloc (StemLength + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (StemRigorousHTML,Stem,
|
Str_Copy (StemRigorousHTML,Stem,StemLength);
|
||||||
StemLength);
|
|
||||||
|
|
||||||
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
||||||
StemRigorousHTML,StemLength,false);
|
StemRigorousHTML,StemLength,false);
|
||||||
|
@ -842,7 +839,7 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible)
|
||||||
/************* Put form to upload a new image for a test question ************/
|
/************* Put form to upload a new image for a test question ************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMediaInForm,
|
static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedia,
|
||||||
bool OptionsDisabled)
|
bool OptionsDisabled)
|
||||||
{
|
{
|
||||||
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
||||||
|
@ -855,7 +852,7 @@ static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedi
|
||||||
if (Media->Name[0])
|
if (Media->Name[0])
|
||||||
{
|
{
|
||||||
/***** Set names of parameters depending on number of image in form *****/
|
/***** Set names of parameters depending on number of image in form *****/
|
||||||
Med_SetParamNames (&ParamUploadMedia,NumMediaInForm);
|
Med_SetParamNames (&ParamUploadMedia,NumMedia);
|
||||||
|
|
||||||
/***** Start container *****/
|
/***** Start container *****/
|
||||||
HTM_DIV_Begin ("class=\"TEST_MED_EDIT_FORM\"");
|
HTM_DIV_Begin ("class=\"TEST_MED_EDIT_FORM\"");
|
||||||
|
@ -892,14 +889,14 @@ static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedi
|
||||||
OptionsDisabled ? " disabled=\"disabled\"" : "");
|
OptionsDisabled ? " disabled=\"disabled\"" : "");
|
||||||
HTM_TxtColonNBSP (Txt_Change_image_video);
|
HTM_TxtColonNBSP (Txt_Change_image_video);
|
||||||
HTM_LABEL_End ();
|
HTM_LABEL_End ();
|
||||||
Med_PutMediaUploader (NumMediaInForm,"TEST_MED_INPUT");
|
Med_PutMediaUploader (NumMedia,"TEST_MED_INPUT");
|
||||||
|
|
||||||
/***** End container *****/
|
/***** End container *****/
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
}
|
}
|
||||||
else // No current image
|
else // No current image
|
||||||
/***** Attached media *****/
|
/***** Attached media *****/
|
||||||
Med_PutMediaUploader (NumMediaInForm,"TEST_MED_INPUT");
|
Med_PutMediaUploader (NumMedia,"TEST_MED_INPUT");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -916,10 +913,9 @@ void Tst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback)
|
||||||
{
|
{
|
||||||
/***** Convert the feedback, that is in HTML, to rigorous HTML *****/
|
/***** Convert the feedback, that is in HTML, to rigorous HTML *****/
|
||||||
FeedbackLength = strlen (Feedback) * Str_MAX_BYTES_PER_CHAR;
|
FeedbackLength = strlen (Feedback) * Str_MAX_BYTES_PER_CHAR;
|
||||||
if ((FeedbackRigorousHTML = (char *) malloc (FeedbackLength + 1)) == NULL)
|
if ((FeedbackRigorousHTML = malloc (FeedbackLength + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (FeedbackRigorousHTML,Feedback,
|
Str_Copy (FeedbackRigorousHTML,Feedback,FeedbackLength);
|
||||||
FeedbackLength);
|
|
||||||
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
||||||
FeedbackRigorousHTML,FeedbackLength,false);
|
FeedbackRigorousHTML,FeedbackLength,false);
|
||||||
|
|
||||||
|
@ -1481,9 +1477,8 @@ static void Tst_ShowFormConfigTst (void)
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
HTM_TD_Begin ("class=\"LB\"");
|
HTM_TD_Begin ("class=\"LB\"");
|
||||||
snprintf (StrMinTimeNxtTstPerQst,sizeof (StrMinTimeNxtTstPerQst),
|
snprintf (StrMinTimeNxtTstPerQst,sizeof (StrMinTimeNxtTstPerQst),"%lu",
|
||||||
"%lu",
|
TstCfg_GetConfigMinTimeNxtTstPerQst ());
|
||||||
TstCfg_GetConfigMinTimeNxtTstPerQst ());
|
|
||||||
HTM_INPUT_TEXT ("MinTimeNxtTstPerQst",Cns_MAX_DECIMAL_DIGITS_ULONG,StrMinTimeNxtTstPerQst,
|
HTM_INPUT_TEXT ("MinTimeNxtTstPerQst",Cns_MAX_DECIMAL_DIGITS_ULONG,StrMinTimeNxtTstPerQst,
|
||||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"id=\"MinTimeNxtTstPerQst\" size=\"7\" required=\"required\"");
|
"id=\"MinTimeNxtTstPerQst\" size=\"7\" required=\"required\"");
|
||||||
|
@ -1537,9 +1532,7 @@ static void Tst_PutInputFieldNumQst (const char *Field,const char *Label,
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"LM\"");
|
HTM_TD_Begin ("class=\"LM\"");
|
||||||
snprintf (StrValue,sizeof (StrValue),
|
snprintf (StrValue,sizeof (StrValue),"%u",Value);
|
||||||
"%u",
|
|
||||||
Value);
|
|
||||||
HTM_INPUT_TEXT (Field,Cns_MAX_DECIMAL_DIGITS_UINT,StrValue,
|
HTM_INPUT_TEXT (Field,Cns_MAX_DECIMAL_DIGITS_UINT,StrValue,
|
||||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"id=\"%s\" size=\"3\" required=\"required\"",Field);
|
"id=\"%s\" size=\"3\" required=\"required\"",Field);
|
||||||
|
@ -1750,41 +1743,30 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
|
||||||
char CrsCodStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
|
char CrsCodStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
|
||||||
|
|
||||||
/***** Allocate space for query *****/
|
/***** Allocate space for query *****/
|
||||||
if ((Query = (char *) malloc (Tst_MAX_BYTES_QUERY_TEST + 1)) == NULL)
|
if ((Query = malloc (Tst_MAX_BYTES_QUERY_TEST + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Select questions *****/
|
/***** Select questions *****/
|
||||||
/* Start query */
|
/* Start query */
|
||||||
snprintf (Query,Tst_MAX_BYTES_QUERY_TEST + 1,
|
Str_Copy (Query,"SELECT tst_questions.QstCod" // row[0]
|
||||||
"SELECT tst_questions.QstCod" // row[0]
|
" FROM tst_questions",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
" FROM tst_questions");
|
|
||||||
if (!Test->Tags.All)
|
if (!Test->Tags.All)
|
||||||
Str_Concat (Query,",tst_question_tags,tst_tags",
|
Str_Concat (Query,",tst_question_tags,tst_tags",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
|
|
||||||
Str_Concat (Query," WHERE tst_questions.CrsCod='",
|
Str_Concat (Query," WHERE tst_questions.CrsCod='",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
snprintf (CrsCodStr,sizeof (CrsCodStr),"%ld",Gbl.Hierarchy.Crs.CrsCod);
|
||||||
snprintf (CrsCodStr,sizeof (CrsCodStr),
|
Str_Concat (Query,CrsCodStr,Tst_MAX_BYTES_QUERY_TEST);
|
||||||
"%ld",
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
|
||||||
Str_Concat (Query,CrsCodStr,
|
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
Str_Concat (Query,"' AND tst_questions.EditTime>=FROM_UNIXTIME('",
|
Str_Concat (Query,"' AND tst_questions.EditTime>=FROM_UNIXTIME('",
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Tst_MAX_BYTES_QUERY_TEST);
|
||||||
snprintf (LongStr,sizeof (LongStr),
|
snprintf (LongStr,sizeof (LongStr),"%ld",
|
||||||
"%ld",
|
(long) Gbl.DateRange.TimeUTC[Dat_START_TIME]);
|
||||||
(long) Gbl.DateRange.TimeUTC[Dat_START_TIME]);
|
Str_Concat (Query,LongStr,Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Str_Concat (Query,LongStr,
|
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
Str_Concat (Query,"') AND tst_questions.EditTime<=FROM_UNIXTIME('",
|
Str_Concat (Query,"') AND tst_questions.EditTime<=FROM_UNIXTIME('",
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Tst_MAX_BYTES_QUERY_TEST);
|
||||||
snprintf (LongStr,sizeof (LongStr),
|
snprintf (LongStr,sizeof (LongStr),"%ld",
|
||||||
"%ld",
|
|
||||||
(long) Gbl.DateRange.TimeUTC[Dat_END_TIME]);
|
(long) Gbl.DateRange.TimeUTC[Dat_END_TIME]);
|
||||||
Str_Concat (Query,LongStr,
|
Str_Concat (Query,LongStr,Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Str_Concat (Query,"')",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Str_Concat (Query,"')",
|
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
|
|
||||||
/* Add the tags selected */
|
/* Add the tags selected */
|
||||||
if (!Test->Tags.All)
|
if (!Test->Tags.All)
|
||||||
|
@ -1793,10 +1775,8 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
|
||||||
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
||||||
" AND tst_tags.CrsCod='",
|
" AND tst_tags.CrsCod='",
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Str_Concat (Query,CrsCodStr,
|
Str_Concat (Query,CrsCodStr,Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Str_Concat (Query,"'",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Str_Concat (Query,"'",
|
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
LengthQuery = strlen (Query);
|
LengthQuery = strlen (Query);
|
||||||
NumItemInList = 0;
|
NumItemInList = 0;
|
||||||
Ptr = Test->Tags.List;
|
Ptr = Test->Tags.List;
|
||||||
|
@ -1810,14 +1790,11 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
|
||||||
NumItemInList ? " OR tst_tags.TagTxt='" :
|
NumItemInList ? " OR tst_tags.TagTxt='" :
|
||||||
" AND (tst_tags.TagTxt='",
|
" AND (tst_tags.TagTxt='",
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Str_Concat (Query,TagText,
|
Str_Concat (Query,TagText,Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Str_Concat (Query,"'",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Str_Concat (Query,"'",
|
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
NumItemInList++;
|
NumItemInList++;
|
||||||
}
|
}
|
||||||
Str_Concat (Query,")",
|
Str_Concat (Query,")",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the types of answer selected */
|
/* Add the types of answer selected */
|
||||||
|
@ -1837,19 +1814,15 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
|
||||||
NumItemInList ? " OR tst_questions.AnsType='" :
|
NumItemInList ? " OR tst_questions.AnsType='" :
|
||||||
" AND (tst_questions.AnsType='",
|
" AND (tst_questions.AnsType='",
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Str_Concat (Query,Tst_StrAnswerTypesDB[AnsType],
|
Str_Concat (Query,Tst_StrAnswerTypesDB[AnsType],Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Str_Concat (Query,"'",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Str_Concat (Query,"'",
|
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
NumItemInList++;
|
NumItemInList++;
|
||||||
}
|
}
|
||||||
Str_Concat (Query,")",
|
Str_Concat (Query,")",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End the query */
|
/* End the query */
|
||||||
Str_Concat (Query," GROUP BY tst_questions.QstCod",
|
Str_Concat (Query," GROUP BY tst_questions.QstCod",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
|
|
||||||
switch (Test->SelectedOrder)
|
switch (Test->SelectedOrder)
|
||||||
{
|
{
|
||||||
|
@ -1915,7 +1888,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
||||||
Lay_ShowErrorAndExit ("Wrong number of questions.");
|
Lay_ShowErrorAndExit ("Wrong number of questions.");
|
||||||
|
|
||||||
/***** Allocate space for query *****/
|
/***** Allocate space for query *****/
|
||||||
if ((Query = (char *) malloc (Tst_MAX_BYTES_QUERY_TEST + 1)) == NULL)
|
if ((Query = malloc (Tst_MAX_BYTES_QUERY_TEST + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Select questions without hidden tags *****/
|
/***** Select questions without hidden tags *****/
|
||||||
|
@ -1957,14 +1930,11 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
||||||
NumItemInList ? " OR tst_tags.TagTxt='" :
|
NumItemInList ? " OR tst_tags.TagTxt='" :
|
||||||
" AND (tst_tags.TagTxt='",
|
" AND (tst_tags.TagTxt='",
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Str_Concat (Query,TagText,
|
Str_Concat (Query,TagText,Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Str_Concat (Query,"'",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Str_Concat (Query,"'",
|
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
NumItemInList++;
|
NumItemInList++;
|
||||||
}
|
}
|
||||||
Str_Concat (Query,")",
|
Str_Concat (Query,")",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add answer types selected */
|
/* Add answer types selected */
|
||||||
|
@ -1984,24 +1954,17 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
||||||
NumItemInList ? " OR tst_questions.AnsType='" :
|
NumItemInList ? " OR tst_questions.AnsType='" :
|
||||||
" AND (tst_questions.AnsType='",
|
" AND (tst_questions.AnsType='",
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Str_Concat (Query,Tst_StrAnswerTypesDB[AnswerType],
|
Str_Concat (Query,Tst_StrAnswerTypesDB[AnswerType],Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
Str_Concat (Query,"'",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Str_Concat (Query,"'",
|
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
NumItemInList++;
|
NumItemInList++;
|
||||||
}
|
}
|
||||||
Str_Concat (Query,")",
|
Str_Concat (Query,")",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End query */
|
/* End query */
|
||||||
Str_Concat (Query," ORDER BY RAND() LIMIT ",
|
Str_Concat (Query," ORDER BY RAND() LIMIT ",Tst_MAX_BYTES_QUERY_TEST);
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
snprintf (StrNumQsts,sizeof (StrNumQsts),"%u",Test->NumQsts);
|
||||||
snprintf (StrNumQsts,sizeof (StrNumQsts),
|
Str_Concat (Query,StrNumQsts,Tst_MAX_BYTES_QUERY_TEST);
|
||||||
"%u",
|
|
||||||
Test->NumQsts);
|
|
||||||
Str_Concat (Query,StrNumQsts,
|
|
||||||
Tst_MAX_BYTES_QUERY_TEST);
|
|
||||||
/*
|
/*
|
||||||
if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
|
if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
|
||||||
Lay_ShowAlert (Lay_INFO,Query);
|
Lay_ShowAlert (Lay_INFO,Query);
|
||||||
|
@ -2115,12 +2078,10 @@ void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||||
if (ErrorInIndex)
|
if (ErrorInIndex)
|
||||||
Lay_ShowErrorAndExit ("Wrong index of answer.");
|
Lay_ShowErrorAndExit ("Wrong index of answer.");
|
||||||
|
|
||||||
if (NumOpt == 0)
|
snprintf (StrInd,sizeof (StrInd),NumOpt ? ",%u" :
|
||||||
snprintf (StrInd,sizeof (StrInd),"%u",Index);
|
"%u",Index);
|
||||||
else
|
|
||||||
snprintf (StrInd,sizeof (StrInd),",%u",Index);
|
|
||||||
Str_Concat (PrintedQuestion->StrIndexes,StrInd,
|
Str_Concat (PrintedQuestion->StrIndexes,StrInd,
|
||||||
Tst_MAX_BYTES_INDEXES_ONE_QST);
|
sizeof (PrintedQuestion->StrIndexes) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -2920,9 +2881,7 @@ void Tst_WriteParamQstCod (unsigned NumQst,long QstCod)
|
||||||
{
|
{
|
||||||
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||||
|
|
||||||
snprintf (StrAns,sizeof (StrAns),
|
snprintf (StrAns,sizeof (StrAns),"Qst%010u",NumQst);
|
||||||
"Qst%010u",
|
|
||||||
NumQst);
|
|
||||||
Par_PutHiddenParamLong (NULL,StrAns,QstCod);
|
Par_PutHiddenParamLong (NULL,StrAns,QstCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3011,7 +2970,7 @@ static bool Tst_GetParamsTst (struct Tst_Test *Test,
|
||||||
Test->Tags.All = Par_GetParToBool ("AllTags");
|
Test->Tags.All = Par_GetParToBool ("AllTags");
|
||||||
|
|
||||||
/* Get the tags */
|
/* Get the tags */
|
||||||
if ((Test->Tags.List = (char *) malloc (Tag_MAX_BYTES_TAGS_LIST + 1)) == NULL)
|
if ((Test->Tags.List = malloc (Tag_MAX_BYTES_TAGS_LIST + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
Par_GetParMultiToText ("ChkTag",Test->Tags.List,Tag_MAX_BYTES_TAGS_LIST);
|
Par_GetParMultiToText ("ChkTag",Test->Tags.List,Tag_MAX_BYTES_TAGS_LIST);
|
||||||
|
|
||||||
|
@ -3044,8 +3003,7 @@ static bool Tst_GetParamsTst (struct Tst_Test *Test,
|
||||||
case Tst_SELECT_QUESTIONS_FOR_GAME:
|
case Tst_SELECT_QUESTIONS_FOR_GAME:
|
||||||
/* The unique allowed type of answer in a game is unique choice */
|
/* The unique allowed type of answer in a game is unique choice */
|
||||||
Test->AnswerTypes.All = false;
|
Test->AnswerTypes.All = false;
|
||||||
snprintf (Test->AnswerTypes.List,sizeof (Test->AnswerTypes.List),
|
snprintf (Test->AnswerTypes.List,sizeof (Test->AnswerTypes.List),"%u",
|
||||||
"%u",
|
|
||||||
(unsigned) Tst_ANS_UNIQUE_CHOICE);
|
(unsigned) Tst_ANS_UNIQUE_CHOICE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -3349,9 +3307,7 @@ static void Tst_PutFormEditOneQst (struct Tst_Question *Question)
|
||||||
|
|
||||||
/***** Input of a new tag *****/
|
/***** Input of a new tag *****/
|
||||||
HTM_TD_Begin ("class=\"RM\"");
|
HTM_TD_Begin ("class=\"RM\"");
|
||||||
snprintf (StrTagTxt,sizeof (StrTagTxt),
|
snprintf (StrTagTxt,sizeof (StrTagTxt),"TagTxt%u",IndTag);
|
||||||
"TagTxt%u",
|
|
||||||
IndTag);
|
|
||||||
HTM_INPUT_TEXT (StrTagTxt,Tag_MAX_CHARS_TAG,Question->Tags.Txt[IndTag],
|
HTM_INPUT_TEXT (StrTagTxt,Tag_MAX_CHARS_TAG,Question->Tags.Txt[IndTag],
|
||||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"id=\"%s\" class=\"TAG_TXT\" onchange=\"changeSelTag('%u')\"",
|
"id=\"%s\" class=\"TAG_TXT\" onchange=\"changeSelTag('%u')\"",
|
||||||
|
@ -3435,9 +3391,7 @@ static void Tst_PutFormEditOneQst (struct Tst_Question *Question)
|
||||||
HTM_TD_Begin ("class=\"LT\"");
|
HTM_TD_Begin ("class=\"LT\"");
|
||||||
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
||||||
HTM_TxtColonNBSP (Txt_Integer_number);
|
HTM_TxtColonNBSP (Txt_Integer_number);
|
||||||
snprintf (StrInteger,sizeof (StrInteger),
|
snprintf (StrInteger,sizeof (StrInteger),"%ld",Question->Answer.Integer);
|
||||||
"%ld",
|
|
||||||
Question->Answer.Integer);
|
|
||||||
HTM_INPUT_TEXT ("AnsInt",Cns_MAX_DECIMAL_DIGITS_LONG,StrInteger,
|
HTM_INPUT_TEXT ("AnsInt",Cns_MAX_DECIMAL_DIGITS_LONG,StrInteger,
|
||||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"size=\"11\" required=\"required\"%s",
|
"size=\"11\" required=\"required\"%s",
|
||||||
|
@ -3643,8 +3597,7 @@ static void Tst_PutFloatInputField (const char *Label,const char *Field,
|
||||||
|
|
||||||
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
||||||
HTM_TxtF ("%s ",Label);
|
HTM_TxtF ("%s ",Label);
|
||||||
snprintf (StrDouble,sizeof (StrDouble),
|
snprintf (StrDouble,sizeof (StrDouble),"%.15lg",
|
||||||
"%.15lg",
|
|
||||||
Question->Answer.FloatingPoint[Index]);
|
Question->Answer.FloatingPoint[Index]);
|
||||||
HTM_INPUT_TEXT (Field,Tst_MAX_BYTES_FLOAT_ANSWER,StrDouble,
|
HTM_INPUT_TEXT (Field,Tst_MAX_BYTES_FLOAT_ANSWER,StrDouble,
|
||||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
|
@ -3690,11 +3643,11 @@ void Tst_QstConstructor (struct Tst_Question *Question)
|
||||||
Question->EditTime = (time_t) 0;
|
Question->EditTime = (time_t) 0;
|
||||||
|
|
||||||
/***** Allocate memory for stem and feedback *****/
|
/***** Allocate memory for stem and feedback *****/
|
||||||
if ((Question->Stem = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((Question->Stem = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
Question->Stem[0] = '\0';
|
Question->Stem[0] = '\0';
|
||||||
|
|
||||||
if ((Question->Feedback = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((Question->Feedback = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
Question->Feedback[0] = '\0';
|
Question->Feedback[0] = '\0';
|
||||||
|
|
||||||
|
@ -3760,14 +3713,14 @@ void Tst_QstDestructor (struct Tst_Question *Question)
|
||||||
bool Tst_AllocateTextChoiceAnswer (struct Tst_Question *Question,unsigned NumOpt)
|
bool Tst_AllocateTextChoiceAnswer (struct Tst_Question *Question,unsigned NumOpt)
|
||||||
{
|
{
|
||||||
if ((Question->Answer.Options[NumOpt].Text =
|
if ((Question->Answer.Options[NumOpt].Text =
|
||||||
(char *) malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL)
|
malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL)
|
||||||
{
|
{
|
||||||
Ale_CreateAlert (Ale_ERROR,NULL,
|
Ale_CreateAlert (Ale_ERROR,NULL,
|
||||||
"Not enough memory to store answer.");
|
"Not enough memory to store answer.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((Question->Answer.Options[NumOpt].Feedback =
|
if ((Question->Answer.Options[NumOpt].Feedback =
|
||||||
(char *) malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL)
|
malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL)
|
||||||
{
|
{
|
||||||
Ale_CreateAlert (Ale_ERROR,NULL,
|
Ale_CreateAlert (Ale_ERROR,NULL,
|
||||||
"Not enough memory to store feedback.");
|
"Not enough memory to store feedback.");
|
||||||
|
@ -3919,15 +3872,13 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question)
|
||||||
Question->Stem[0] = '\0';
|
Question->Stem[0] = '\0';
|
||||||
if (row[3])
|
if (row[3])
|
||||||
if (row[3][0])
|
if (row[3][0])
|
||||||
Str_Copy (Question->Stem,row[3],
|
Str_Copy (Question->Stem,row[3],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
|
|
||||||
/* Get the feedback (row[4]) */
|
/* Get the feedback (row[4]) */
|
||||||
Question->Feedback[0] = '\0';
|
Question->Feedback[0] = '\0';
|
||||||
if (row[4])
|
if (row[4])
|
||||||
if (row[4][0])
|
if (row[4][0])
|
||||||
Str_Copy (Question->Feedback,row[4],
|
Str_Copy (Question->Feedback,row[4],Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
|
|
||||||
/* Get media (row[5]) */
|
/* Get media (row[5]) */
|
||||||
Question->Media.MedCod = Str_ConvertStrCodToLongCod (row[5]);
|
Question->Media.MedCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||||
|
@ -3962,7 +3913,7 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Question->Tags.Txt[NumRow],row[0],
|
Str_Copy (Question->Tags.Txt[NumRow],row[0],
|
||||||
Tag_MAX_BYTES_TAG);
|
sizeof (Question->Tags.Txt[NumRow]) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free structure that stores the query result */
|
/* Free structure that stores the query result */
|
||||||
|
@ -4164,8 +4115,7 @@ void Tst_ReceiveQst (void)
|
||||||
Tst_InsertOrUpdateQstTagsAnsIntoDB (&Test.Question);
|
Tst_InsertOrUpdateQstTagsAnsIntoDB (&Test.Question);
|
||||||
|
|
||||||
/***** Show the question just inserted in the database *****/
|
/***** Show the question just inserted in the database *****/
|
||||||
snprintf (Test.AnswerTypes.List,sizeof (Test.AnswerTypes.List),
|
snprintf (Test.AnswerTypes.List,sizeof (Test.AnswerTypes.List),"%u",
|
||||||
"%u",
|
|
||||||
(unsigned) Test.Question.Answer.Type);
|
(unsigned) Test.Question.Answer.Type);
|
||||||
Tst_ListOneQstToEdit (&Test);
|
Tst_ListOneQstToEdit (&Test);
|
||||||
}
|
}
|
||||||
|
@ -4217,9 +4167,7 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question)
|
||||||
NumTag < Tag_MAX_TAGS_PER_QUESTION;
|
NumTag < Tag_MAX_TAGS_PER_QUESTION;
|
||||||
NumTag++)
|
NumTag++)
|
||||||
{
|
{
|
||||||
snprintf (TagStr,sizeof (TagStr),
|
snprintf (TagStr,sizeof (TagStr),"TagTxt%u",NumTag);
|
||||||
"TagTxt%u",
|
|
||||||
NumTag);
|
|
||||||
Par_GetParToText (TagStr,Question->Tags.Txt[NumTag],Tag_MAX_BYTES_TAG);
|
Par_GetParToText (TagStr,Question->Tags.Txt[NumTag],Tag_MAX_BYTES_TAG);
|
||||||
|
|
||||||
if (Question->Tags.Txt[NumTag][0])
|
if (Question->Tags.Txt[NumTag][0])
|
||||||
|
@ -4303,9 +4251,7 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question)
|
||||||
Ale_ShowAlertsAndExit ();
|
Ale_ShowAlertsAndExit ();
|
||||||
|
|
||||||
/* Get answer */
|
/* Get answer */
|
||||||
snprintf (AnsStr,sizeof (AnsStr),
|
snprintf (AnsStr,sizeof (AnsStr),"AnsStr%u",NumOpt);
|
||||||
"AnsStr%u",
|
|
||||||
NumOpt);
|
|
||||||
Par_GetParToHTML (AnsStr,Question->Answer.Options[NumOpt].Text,
|
Par_GetParToHTML (AnsStr,Question->Answer.Options[NumOpt].Text,
|
||||||
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
|
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
|
||||||
if (Question->Answer.Type == Tst_ANS_TEXT)
|
if (Question->Answer.Type == Tst_ANS_TEXT)
|
||||||
|
@ -4314,9 +4260,7 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question)
|
||||||
Str_ReplaceSeveralSpacesForOne (Question->Answer.Options[NumOpt].Text);
|
Str_ReplaceSeveralSpacesForOne (Question->Answer.Options[NumOpt].Text);
|
||||||
|
|
||||||
/* Get feedback */
|
/* Get feedback */
|
||||||
snprintf (FbStr,sizeof (FbStr),
|
snprintf (FbStr,sizeof (FbStr),"FbStr%u",NumOpt);
|
||||||
"FbStr%u",
|
|
||||||
NumOpt);
|
|
||||||
Par_GetParToHTML (FbStr,Question->Answer.Options[NumOpt].Feedback,
|
Par_GetParToHTML (FbStr,Question->Answer.Options[NumOpt].Feedback,
|
||||||
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
|
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
|
||||||
|
|
||||||
|
|
|
@ -197,8 +197,7 @@ void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res)
|
||||||
Brw_CreateDirDownloadTmp ();
|
Brw_CreateDirDownloadTmp ();
|
||||||
|
|
||||||
/***** Create public XML file with the questions *****/
|
/***** Create public XML file with the questions *****/
|
||||||
snprintf (PathPubFile,sizeof (PathPubFile),
|
snprintf (PathPubFile,sizeof (PathPubFile),"%s/%s/%s/test.xml",
|
||||||
"%s/%s/%s/test.xml",
|
|
||||||
Cfg_PATH_FILE_BROWSER_TMP_PUBLIC,
|
Cfg_PATH_FILE_BROWSER_TMP_PUBLIC,
|
||||||
Gbl.FileBrowser.TmpPubDir.L,
|
Gbl.FileBrowser.TmpPubDir.L,
|
||||||
Gbl.FileBrowser.TmpPubDir.R);
|
Gbl.FileBrowser.TmpPubDir.R);
|
||||||
|
@ -424,8 +423,7 @@ void TsI_ImportQstsFromXML (void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* End the reception of XML in a temporary file */
|
/* End the reception of XML in a temporary file */
|
||||||
snprintf (FileNameXMLTmp,sizeof (FileNameXMLTmp),
|
snprintf (FileNameXMLTmp,sizeof (FileNameXMLTmp),"%s/%s.xml",
|
||||||
"%s/%s.xml",
|
|
||||||
Cfg_PATH_TEST_PRIVATE,Gbl.UniqueNameEncrypted);
|
Cfg_PATH_TEST_PRIVATE,Gbl.UniqueNameEncrypted);
|
||||||
if (Fil_EndReceptionOfFile (FileNameXMLTmp,Param))
|
if (Fil_EndReceptionOfFile (FileNameXMLTmp,Param))
|
||||||
/***** Get questions from XML file and store them in database *****/
|
/***** Get questions from XML file and store them in database *****/
|
||||||
|
@ -455,7 +453,7 @@ static void TsI_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML)
|
||||||
fseek (FileXML,0L,SEEK_SET);
|
fseek (FileXML,0L,SEEK_SET);
|
||||||
|
|
||||||
/***** Allocate memory for XML buffer *****/
|
/***** Allocate memory for XML buffer *****/
|
||||||
if ((XMLBuffer = (char *) malloc (FileSize + 1)) == NULL)
|
if ((XMLBuffer = malloc (FileSize + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -569,7 +567,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
|
||||||
{
|
{
|
||||||
Str_Copy (Question.Tags.Txt[Question.Tags.Num],
|
Str_Copy (Question.Tags.Txt[Question.Tags.Num],
|
||||||
TagElem->Content,
|
TagElem->Content,
|
||||||
Tag_MAX_BYTES_TAG);
|
sizeof (Question.Tags.Txt[Question.Tags.Num]) - 1);
|
||||||
Question.Tags.Num++;
|
Question.Tags.Num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -585,8 +583,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
|
||||||
if (StemElem->Content)
|
if (StemElem->Content)
|
||||||
{
|
{
|
||||||
/* Convert stem from text to HTML (in database stem is stored in HTML) */
|
/* Convert stem from text to HTML (in database stem is stored in HTML) */
|
||||||
Str_Copy (Question.Stem,StemElem->Content,
|
Str_Copy (Question.Stem,StemElem->Content,Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
|
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
|
||||||
Question.Stem,Cns_MAX_BYTES_TEXT,true);
|
Question.Stem,Cns_MAX_BYTES_TEXT,true);
|
||||||
}
|
}
|
||||||
|
@ -602,8 +599,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
|
||||||
if (FeedbackElem->Content)
|
if (FeedbackElem->Content)
|
||||||
{
|
{
|
||||||
/* Convert feedback from text to HTML (in database feedback is stored in HTML) */
|
/* Convert feedback from text to HTML (in database feedback is stored in HTML) */
|
||||||
Str_Copy (Question.Feedback,FeedbackElem->Content,
|
Str_Copy (Question.Feedback,FeedbackElem->Content,Cns_MAX_BYTES_TEXT);
|
||||||
Cns_MAX_BYTES_TEXT);
|
|
||||||
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
|
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
|
||||||
Question.Feedback,Cns_MAX_BYTES_TEXT,true);
|
Question.Feedback,Cns_MAX_BYTES_TEXT,true);
|
||||||
}
|
}
|
||||||
|
@ -1004,7 +1000,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
|
||||||
/* Convert the answer, that is in HTML, to rigorous HTML */
|
/* Convert the answer, that is in HTML, to rigorous HTML */
|
||||||
AnswerTextLength = strlen (Question->Answer.Options[NumOpt].Text) *
|
AnswerTextLength = strlen (Question->Answer.Options[NumOpt].Text) *
|
||||||
Str_MAX_BYTES_PER_CHAR;
|
Str_MAX_BYTES_PER_CHAR;
|
||||||
if ((AnswerText = (char *) malloc (AnswerTextLength + 1)) == NULL)
|
if ((AnswerText = malloc (AnswerTextLength + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (AnswerText,Question->Answer.Options[NumOpt].Text,
|
Str_Copy (AnswerText,Question->Answer.Options[NumOpt].Text,
|
||||||
AnswerTextLength);
|
AnswerTextLength);
|
||||||
|
@ -1019,7 +1015,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
|
||||||
{
|
{
|
||||||
AnswerFeedbackLength = strlen (Question->Answer.Options[NumOpt].Feedback) *
|
AnswerFeedbackLength = strlen (Question->Answer.Options[NumOpt].Feedback) *
|
||||||
Str_MAX_BYTES_PER_CHAR;
|
Str_MAX_BYTES_PER_CHAR;
|
||||||
if ((AnswerFeedback = (char *) malloc (AnswerFeedbackLength + 1)) == NULL)
|
if ((AnswerFeedback = malloc (AnswerFeedbackLength + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
Str_Copy (AnswerFeedback,
|
Str_Copy (AnswerFeedback,
|
||||||
Question->Answer.Options[NumOpt].Feedback,
|
Question->Answer.Options[NumOpt].Feedback,
|
||||||
|
|
|
@ -413,9 +413,7 @@ static void TstPrn_WriteIntAnsToFill (const struct TstPrn_PrintedQuestion *Print
|
||||||
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||||
|
|
||||||
/***** Write input field for the answer *****/
|
/***** Write input field for the answer *****/
|
||||||
snprintf (StrAns,sizeof (StrAns),
|
snprintf (StrAns,sizeof (StrAns),"Ans%010u",NumQst);
|
||||||
"Ans%010u",
|
|
||||||
NumQst);
|
|
||||||
HTM_INPUT_TEXT (StrAns,11,PrintedQuestion->StrAnswers,
|
HTM_INPUT_TEXT (StrAns,11,PrintedQuestion->StrAnswers,
|
||||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"size=\"11\"");
|
"size=\"11\"");
|
||||||
|
@ -432,9 +430,7 @@ static void TstPrn_WriteFltAnsToFill (const struct TstPrn_PrintedQuestion *Print
|
||||||
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||||
|
|
||||||
/***** Write input field for the answer *****/
|
/***** Write input field for the answer *****/
|
||||||
snprintf (StrAns,sizeof (StrAns),
|
snprintf (StrAns,sizeof (StrAns),"Ans%010u",NumQst);
|
||||||
"Ans%010u",
|
|
||||||
NumQst);
|
|
||||||
HTM_INPUT_TEXT (StrAns,Tst_MAX_BYTES_FLOAT_ANSWER,PrintedQuestion->StrAnswers,
|
HTM_INPUT_TEXT (StrAns,Tst_MAX_BYTES_FLOAT_ANSWER,PrintedQuestion->StrAnswers,
|
||||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"size=\"11\"");
|
"size=\"11\"");
|
||||||
|
@ -501,9 +497,7 @@ static void TstPrn_WriteChoAnsToFill (const struct TstPrn_PrintedQuestion *Print
|
||||||
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
|
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
|
||||||
HTM_TD_Begin ("class=\"LT\"");
|
HTM_TD_Begin ("class=\"LT\"");
|
||||||
|
|
||||||
snprintf (StrAns,sizeof (StrAns),
|
snprintf (StrAns,sizeof (StrAns),"Ans%010u",NumQst);
|
||||||
"Ans%010u",
|
|
||||||
NumQst);
|
|
||||||
if (Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE)
|
if (Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE)
|
||||||
HTM_INPUT_RADIO (StrAns,false,
|
HTM_INPUT_RADIO (StrAns,false,
|
||||||
"id=\"Ans%010u_%u\" value=\"%u\"%s"
|
"id=\"Ans%010u_%u\" value=\"%u\"%s"
|
||||||
|
@ -557,9 +551,7 @@ static void TstPrn_WriteTxtAnsToFill (const struct TstPrn_PrintedQuestion *Print
|
||||||
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||||
|
|
||||||
/***** Write input field for the answer *****/
|
/***** Write input field for the answer *****/
|
||||||
snprintf (StrAns,sizeof (StrAns),
|
snprintf (StrAns,sizeof (StrAns),"Ans%010u",NumQst);
|
||||||
"Ans%010u",
|
|
||||||
NumQst);
|
|
||||||
HTM_INPUT_TEXT (StrAns,Tst_MAX_CHARS_ANSWERS_ONE_QST,PrintedQuestion->StrAnswers,
|
HTM_INPUT_TEXT (StrAns,Tst_MAX_CHARS_ANSWERS_ONE_QST,PrintedQuestion->StrAnswers,
|
||||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"size=\"40\"");
|
"size=\"40\"");
|
||||||
|
@ -1214,8 +1206,7 @@ void TstPrn_ComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||||
if (PrintedQuestion->StrAnswers[0]) // If user has answered the answer
|
if (PrintedQuestion->StrAnswers[0]) // If user has answered the answer
|
||||||
{
|
{
|
||||||
/* Filter the user answer */
|
/* Filter the user answer */
|
||||||
Str_Copy (TextAnsUsr,PrintedQuestion->StrAnswers,
|
Str_Copy (TextAnsUsr,PrintedQuestion->StrAnswers,sizeof (TextAnsUsr) - 1);
|
||||||
Tst_MAX_BYTES_ANSWERS_ONE_QST);
|
|
||||||
|
|
||||||
/* In order to compare student answer to stored answer,
|
/* In order to compare student answer to stored answer,
|
||||||
the text answers are stored avoiding two or more consecurive spaces */
|
the text answers are stored avoiding two or more consecurive spaces */
|
||||||
|
@ -1228,8 +1219,7 @@ void TstPrn_ComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||||
NumOpt++)
|
NumOpt++)
|
||||||
{
|
{
|
||||||
/* Filter this correct answer */
|
/* Filter this correct answer */
|
||||||
Str_Copy (TextAnsOK,Question->Answer.Options[NumOpt].Text,
|
Str_Copy (TextAnsOK,Question->Answer.Options[NumOpt].Text,sizeof (TextAnsOK) - 1);
|
||||||
Tst_MAX_BYTES_ANSWERS_ONE_QST);
|
|
||||||
Str_ConvertToComparable (TextAnsOK);
|
Str_ConvertToComparable (TextAnsOK);
|
||||||
|
|
||||||
/* Check is user answer is correct */
|
/* Check is user answer is correct */
|
||||||
|
@ -1728,8 +1718,7 @@ static void TstPrn_WriteTxtAnsPrint (struct UsrData *UsrDat,
|
||||||
if (PrintedQuestion->StrAnswers[0]) // If user has answered the question
|
if (PrintedQuestion->StrAnswers[0]) // If user has answered the question
|
||||||
{
|
{
|
||||||
/* Filter the user answer */
|
/* Filter the user answer */
|
||||||
Str_Copy (TextAnsUsr,PrintedQuestion->StrAnswers,
|
Str_Copy (TextAnsUsr,PrintedQuestion->StrAnswers,sizeof (TextAnsUsr) - 1);
|
||||||
Tst_MAX_BYTES_ANSWERS_ONE_QST);
|
|
||||||
|
|
||||||
/* In order to compare student answer to stored answer,
|
/* In order to compare student answer to stored answer,
|
||||||
the text answers are stored avoiding two or more consecurive spaces */
|
the text answers are stored avoiding two or more consecurive spaces */
|
||||||
|
@ -1742,8 +1731,7 @@ static void TstPrn_WriteTxtAnsPrint (struct UsrData *UsrDat,
|
||||||
NumOpt++)
|
NumOpt++)
|
||||||
{
|
{
|
||||||
/* Filter this correct answer */
|
/* Filter this correct answer */
|
||||||
Str_Copy (TextAnsOK,Question->Answer.Options[NumOpt].Text,
|
Str_Copy (TextAnsOK,Question->Answer.Options[NumOpt].Text,sizeof (TextAnsOK) - 1);
|
||||||
Tst_MAX_BYTES_ANSWERS_ONE_QST);
|
|
||||||
Str_ConvertToComparable (TextAnsOK);
|
Str_ConvertToComparable (TextAnsOK);
|
||||||
|
|
||||||
/* Check is user answer is correct */
|
/* Check is user answer is correct */
|
||||||
|
@ -1976,7 +1964,7 @@ static void TstPrn_ShowUsrsPrints (__attribute__((unused)) void *Args)
|
||||||
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EnUsrCod,
|
||||||
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
||||||
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
||||||
|
@ -2451,8 +2439,8 @@ void TstPrn_ShowOnePrint (void)
|
||||||
HTM_TxtF (" %s",Gbl.Usrs.Other.UsrDat.Surname1);
|
HTM_TxtF (" %s",Gbl.Usrs.Other.UsrDat.Surname1);
|
||||||
if (Gbl.Usrs.Other.UsrDat.Surname2[0])
|
if (Gbl.Usrs.Other.UsrDat.Surname2[0])
|
||||||
HTM_TxtF (" %s",Gbl.Usrs.Other.UsrDat.Surname2);
|
HTM_TxtF (" %s",Gbl.Usrs.Other.UsrDat.Surname2);
|
||||||
if (Gbl.Usrs.Other.UsrDat.FirstName[0])
|
if (Gbl.Usrs.Other.UsrDat.FrstName[0])
|
||||||
HTM_TxtF (", %s",Gbl.Usrs.Other.UsrDat.FirstName);
|
HTM_TxtF (", %s",Gbl.Usrs.Other.UsrDat.FrstName);
|
||||||
HTM_BR ();
|
HTM_BR ();
|
||||||
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
||||||
Pho_ShowUsrPhoto (&Gbl.Usrs.Other.UsrDat,ShowPhoto ? PhotoURL :
|
Pho_ShowUsrPhoto (&Gbl.Usrs.Other.UsrDat,ShowPhoto ? PhotoURL :
|
||||||
|
@ -2799,11 +2787,11 @@ void TstPrn_GetPrintQuestionsFromDB (struct TstPrn_Print *Print)
|
||||||
|
|
||||||
/* Get indexes for this question (row[2]) */
|
/* Get indexes for this question (row[2]) */
|
||||||
Str_Copy (Print->PrintedQuestions[NumQst].StrIndexes,row[2],
|
Str_Copy (Print->PrintedQuestions[NumQst].StrIndexes,row[2],
|
||||||
Tst_MAX_BYTES_INDEXES_ONE_QST);
|
sizeof (Print->PrintedQuestions[NumQst].StrIndexes) - 1);
|
||||||
|
|
||||||
/* Get answers selected by user for this question (row[3]) */
|
/* Get answers selected by user for this question (row[3]) */
|
||||||
Str_Copy (Print->PrintedQuestions[NumQst].StrAnswers,row[3],
|
Str_Copy (Print->PrintedQuestions[NumQst].StrAnswers,row[3],
|
||||||
Tst_MAX_BYTES_ANSWERS_ONE_QST);
|
sizeof (Print->PrintedQuestions[NumQst].StrAnswers) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
|
|
@ -155,7 +155,7 @@ unsigned TstVis_GetVisibilityFromForm (void)
|
||||||
|
|
||||||
/***** Allocate memory for list of attendance events selected *****/
|
/***** Allocate memory for list of attendance events selected *****/
|
||||||
MaxSizeListVisibilitySelected = TstVis_NUM_ITEMS_VISIBILITY * (Cns_MAX_DECIMAL_DIGITS_UINT + 1);
|
MaxSizeListVisibilitySelected = TstVis_NUM_ITEMS_VISIBILITY * (Cns_MAX_DECIMAL_DIGITS_UINT + 1);
|
||||||
if ((StrVisibilitySelected = (char *) malloc (MaxSizeListVisibilitySelected + 1)) == NULL)
|
if ((StrVisibilitySelected = malloc (MaxSizeListVisibilitySelected + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get parameter multiple with list of visibility items selected *****/
|
/***** Get parameter multiple with list of visibility items selected *****/
|
||||||
|
|
15
swad_theme.c
15
swad_theme.c
|
@ -331,10 +331,8 @@ void The_PutIconsToSelectTheme (void)
|
||||||
"PREF_OFF");
|
"PREF_OFF");
|
||||||
Frm_StartForm (ActChgThe);
|
Frm_StartForm (ActChgThe);
|
||||||
Par_PutHiddenParamString (NULL,"Theme",The_ThemeId[Theme]);
|
Par_PutHiddenParamString (NULL,"Theme",The_ThemeId[Theme]);
|
||||||
snprintf (Icon,sizeof (Icon),
|
snprintf (Icon,sizeof (Icon),"%s/%s/theme_32x20.gif",
|
||||||
"%s/%s/theme_32x20.gif",
|
Cfg_ICON_FOLDER_THEMES,The_ThemeId[Theme]);
|
||||||
Cfg_ICON_FOLDER_THEMES,
|
|
||||||
The_ThemeId[Theme]);
|
|
||||||
Ico_PutSettingIconLink (Icon,The_ThemeNames[Theme]);
|
Ico_PutSettingIconLink (Icon,The_ThemeNames[Theme]);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
@ -366,12 +364,9 @@ void The_ChangeTheme (void)
|
||||||
|
|
||||||
/***** Get param theme *****/
|
/***** Get param theme *****/
|
||||||
Gbl.Prefs.Theme = The_GetParamTheme ();
|
Gbl.Prefs.Theme = The_GetParamTheme ();
|
||||||
snprintf (Path,sizeof (Path),
|
snprintf (Path,sizeof (Path),"%s/%s",
|
||||||
"%s/%s",
|
Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Gbl.Prefs.Theme]);
|
||||||
Cfg_URL_ICON_THEMES_PUBLIC,
|
Str_Copy (Gbl.Prefs.URLTheme,Path,sizeof (Gbl.Prefs.URLTheme) - 1);
|
||||||
The_ThemeId[Gbl.Prefs.Theme]);
|
|
||||||
Str_Copy (Gbl.Prefs.URLTheme,Path,
|
|
||||||
PATH_MAX);
|
|
||||||
|
|
||||||
/***** Store theme in database *****/
|
/***** Store theme in database *****/
|
||||||
if (Gbl.Usrs.Me.Logged)
|
if (Gbl.Usrs.Me.Logged)
|
||||||
|
|
|
@ -296,7 +296,7 @@ void TL_ShowTimelineUsrHighlightingNot (struct TL_Timeline *Timeline,
|
||||||
/***** Show timeline *****/
|
/***** Show timeline *****/
|
||||||
TL_ShowTimeline (Timeline,
|
TL_ShowTimeline (Timeline,
|
||||||
Str_BuildStringStr (Txt_Timeline_OF_A_USER,
|
Str_BuildStringStr (Txt_Timeline_OF_A_USER,
|
||||||
Gbl.Usrs.Other.UsrDat.FirstName),
|
Gbl.Usrs.Other.UsrDat.FrstName),
|
||||||
NotCod);
|
NotCod);
|
||||||
Str_FreeString ();
|
Str_FreeString ();
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ void TL_FormStart (const struct TL_Timeline *Timeline,
|
||||||
{
|
{
|
||||||
/***** Start form in user timeline *****/
|
/***** Start form in user timeline *****/
|
||||||
Frm_StartFormAnchor (ActionUsr,"timeline");
|
Frm_StartFormAnchor (ActionUsr,"timeline");
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#define _GNU_SOURCE // For asprintf
|
#define _GNU_SOURCE // For asprintf
|
||||||
#include <linux/limits.h> // For PATH_MAX
|
#include <linux/limits.h> // For PATH_MAX
|
||||||
#include <stdio.h> // For asprintf
|
#include <stdio.h> // For asprintf
|
||||||
#include <stdlib.h> // For malloc and free
|
|
||||||
|
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_forum.h"
|
#include "swad_forum.h"
|
||||||
|
@ -347,7 +346,7 @@ static void TL_Com_FormToShowHiddenComments (Act_Action_t ActionGbl,Act_Action_t
|
||||||
NotCod,
|
NotCod,
|
||||||
IdComments,
|
IdComments,
|
||||||
NumInitialComments,
|
NumInitialComments,
|
||||||
Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0)
|
Gbl.Usrs.Other.UsrDat.EnUsrCod) < 0)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit);
|
Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit);
|
||||||
}
|
}
|
||||||
|
@ -678,7 +677,7 @@ static void TL_Com_WriteAuthorComment (struct UsrData *UsrDat)
|
||||||
|
|
||||||
/***** Show user's name inside form to go to user's public profile *****/
|
/***** Show user's name inside form to go to user's public profile *****/
|
||||||
Frm_StartFormUnique (ActSeeOthPubPrf);
|
Frm_StartFormUnique (ActSeeOthPubPrf);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
|
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
|
||||||
Txt_Another_user_s_profile,
|
Txt_Another_user_s_profile,
|
||||||
"BT_LINK TL_COM_AUTHOR TL_COMM_AUTHOR_WIDTH DAT_BOLD",NULL);
|
"BT_LINK TL_COM_AUTHOR TL_COMM_AUTHOR_WIDTH DAT_BOLD",NULL);
|
||||||
|
@ -915,7 +914,7 @@ static void TL_Com_PutParamsRemoveComment (void *Timeline)
|
||||||
if (Timeline)
|
if (Timeline)
|
||||||
{
|
{
|
||||||
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
else
|
else
|
||||||
Usr_PutHiddenParamWho (((struct TL_Timeline *) Timeline)->Who);
|
Usr_PutHiddenParamWho (((struct TL_Timeline *) Timeline)->Who);
|
||||||
TL_Pub_PutHiddenParamPubCod (((struct TL_Timeline *) Timeline)->PubCod);
|
TL_Pub_PutHiddenParamPubCod (((struct TL_Timeline *) Timeline)->PubCod);
|
||||||
|
@ -1127,8 +1126,7 @@ static void TL_Com_GetDataOfCommentFromRow (MYSQL_ROW row,struct TL_Com_Comment
|
||||||
Com->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[3]);
|
Com->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[3]);
|
||||||
|
|
||||||
/***** Get text content (row[4]) *****/
|
/***** Get text content (row[4]) *****/
|
||||||
Str_Copy (Com->Content.Txt,row[4],
|
Str_Copy (Com->Content.Txt,row[4],sizeof (Com->Content.Txt) - 1);
|
||||||
Cns_MAX_BYTES_LONG_TEXT);
|
|
||||||
|
|
||||||
/***** Get number of times this comment has been favourited *****/
|
/***** Get number of times this comment has been favourited *****/
|
||||||
TL_Fav_GetNumTimesACommHasBeenFav (Com);
|
TL_Fav_GetNumTimesACommHasBeenFav (Com);
|
||||||
|
|
|
@ -389,7 +389,7 @@ static void TL_Not_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod
|
||||||
|
|
||||||
/***** Show user's name inside form to go to user's public profile *****/
|
/***** Show user's name inside form to go to user's public profile *****/
|
||||||
Frm_StartFormUnique (ActSeeOthPubPrf);
|
Frm_StartFormUnique (ActSeeOthPubPrf);
|
||||||
Usr_PutParamUsrCodEncrypted (PublisherDat.EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (PublisherDat.EnUsrCod);
|
||||||
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
|
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
|
||||||
Txt_Another_user_s_profile,
|
Txt_Another_user_s_profile,
|
||||||
"BT_LINK TL_TOP_PUBLISHER",NULL);
|
"BT_LINK TL_TOP_PUBLISHER",NULL);
|
||||||
|
@ -419,7 +419,7 @@ void TL_Not_WriteAuthorNote (const struct UsrData *UsrDat)
|
||||||
|
|
||||||
/***** Show user's name inside form to go to user's public profile *****/
|
/***** Show user's name inside form to go to user's public profile *****/
|
||||||
Frm_StartFormUnique (ActSeeOthPubPrf);
|
Frm_StartFormUnique (ActSeeOthPubPrf);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
|
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
|
||||||
Txt_Another_user_s_profile,
|
Txt_Another_user_s_profile,
|
||||||
"BT_LINK TL_RIGHT_AUTHOR TL_RIGHT_AUTHOR_WIDTH DAT_N_BOLD",
|
"BT_LINK TL_RIGHT_AUTHOR TL_RIGHT_AUTHOR_WIDTH DAT_N_BOLD",
|
||||||
|
@ -1064,7 +1064,7 @@ static void TL_Not_PutParamsRemoveNote (void *Timeline)
|
||||||
if (Timeline)
|
if (Timeline)
|
||||||
{
|
{
|
||||||
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
||||||
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||||
else
|
else
|
||||||
Usr_PutHiddenParamWho (((struct TL_Timeline *) Timeline)->Who);
|
Usr_PutHiddenParamWho (((struct TL_Timeline *) Timeline)->Who);
|
||||||
TL_Not_PutHiddenParamNotCod (((struct TL_Timeline *) Timeline)->NotCod);
|
TL_Not_PutHiddenParamNotCod (((struct TL_Timeline *) Timeline)->NotCod);
|
||||||
|
@ -1350,7 +1350,7 @@ long TL_Not_GetPubCodOfOriginalNote (long NotCod)
|
||||||
/****** Add just retrieved notes to current timeline for this session ********/
|
/****** Add just retrieved notes to current timeline for this session ********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void TL_Not_AddNotesJustRetrievedToTimelineThisSession (void)
|
void TL_Not_AddNotesJustRetrievedToVisibleTimelineThisSession (void)
|
||||||
{
|
{
|
||||||
/* tl_timelines contains the distinct notes in timeline of each open session:
|
/* tl_timelines contains the distinct notes in timeline of each open session:
|
||||||
mysql> SELECT SessionId,COUNT(*) FROM tl_timelines GROUP BY SessionId;
|
mysql> SELECT SessionId,COUNT(*) FROM tl_timelines GROUP BY SessionId;
|
||||||
|
|
|
@ -117,7 +117,7 @@ void TL_Not_RemoveNoteGbl (void);
|
||||||
|
|
||||||
long TL_Not_GetPubCodOfOriginalNote (long NotCod);
|
long TL_Not_GetPubCodOfOriginalNote (long NotCod);
|
||||||
|
|
||||||
void TL_Not_AddNotesJustRetrievedToTimelineThisSession (void);
|
void TL_Not_AddNotesJustRetrievedToVisibleTimelineThisSession (void);
|
||||||
|
|
||||||
void TL_Not_GetDataOfNoteByCod (struct TL_Not_Note *Not);
|
void TL_Not_GetDataOfNoteByCod (struct TL_Not_Note *Not);
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user