From 2ad5395d13fe78d785c65e619e4a7aee2bd6fb54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Mon, 8 Oct 2018 12:37:29 +0200 Subject: [PATCH] Version 18.2.1 --- Makefile | 2 +- swad_account.c | 35 +++++++++------- swad_action.c | 44 +++++++++---------- swad_action.h | 2 +- swad_changelog.h | 3 +- swad_enrolment.c | 27 ++++++------ swad_exam.c | 30 ++++++------- swad_forum.c | 12 +++--- swad_menu.c | 2 +- swad_message.c | 10 ++--- swad_project.c | 6 +-- swad_record.c | 102 ++++++++++++++++++++++++--------------------- swad_record.h | 3 +- swad_social.c | 20 ++++----- swad_survey.c | 4 +- swad_test.c | 36 ++++++++-------- swad_test_import.c | 8 ++-- swad_text.c | 4 +- swad_user.c | 9 ++-- swad_user.h | 2 +- swad_xml.c | 8 ++-- 21 files changed, 191 insertions(+), 178 deletions(-) diff --git a/Makefile b/Makefile index 98233bab..c687294a 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ CC = gcc # LIBS when using MariaDB (also valid with MySQL): LIBS = -lssl -lcrypto -lpthread -lrt -lmysqlclient -lz -L/usr/lib64/mysql -lm -lgsoap -CFLAGS = -Wall -Wextra -mtune=native -O2 -s +CFLAGS = -Wall -Wextra -mtune=native -O0 -s all: swad_ca swad_de swad_en swad_es swad_fr swad_gn swad_it swad_pl swad_pt diff --git a/swad_account.c b/swad_account.c index 2f572c18..02b3d18a 100644 --- a/swad_account.c +++ b/swad_account.c @@ -732,19 +732,22 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount) /***** Insert new user in database *****/ /* Insert user's data */ - Usr_CreateBirthdayStrDB (UsrDat,BirthdayStrDB); - CommentsLength = strlen (UsrDat->Comments); - if ((QueryUsrData = malloc (2048 + - Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + // EncryptedUsrCod - Pwd_BYTES_ENCRYPTED_PASSWORD + // Password - Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME * 3 + // Surname1, Surname2, FirstName - Usr_MAX_BYTES_ADDRESS + // LocalAddress - Usr_MAX_BYTES_PHONE + // LocalPhone - Usr_MAX_BYTES_ADDRESS + // FamilyAddress - Usr_MAX_BYTES_PHONE + // FamilyPhone - Usr_MAX_BYTES_ADDRESS + // OriginPlace - Usr_BIRTHDAY_STR_DB_LENGTH + // BirthdayStrDB - CommentsLength)) == NULL) // Comments + Usr_CreateBirthdayStrDB (UsrDat,BirthdayStrDB); // It can include start and ending apostrophes + if (UsrDat->Comments) + CommentsLength = strlen (UsrDat->Comments); + else + CommentsLength = 0; + if ((QueryUsrData = (char *) malloc (2048 + + Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + // EncryptedUsrCod + Pwd_BYTES_ENCRYPTED_PASSWORD + // Password + Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME * 3 + // Surname1, Surname2, FirstName + Usr_MAX_BYTES_ADDRESS + // LocalAddress + Usr_MAX_BYTES_PHONE + // LocalPhone + Usr_MAX_BYTES_ADDRESS + // FamilyAddress + Usr_MAX_BYTES_PHONE + // FamilyPhone + Usr_MAX_BYTES_ADDRESS + // OriginPlace + Usr_BIRTHDAY_STR_DB_LENGTH + // BirthdayStrDB + CommentsLength)) == NULL) // Comments Lay_ShowErrorAndExit ("Not enough memory to store query."); sprintf (QueryUsrData,"INSERT INTO usr_data" " (EncryptedUsrCod,Password," @@ -796,9 +799,9 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount) { Str_ConvertToUpperText (UsrDat->IDs.List[NumID].ID); sprintf (QueryUsrIDs,"INSERT INTO usr_IDs" - " (UsrCod,UsrID,CreatTime,Confirmed)" - " VALUES" - " (%ld,'%s',NOW(),'%c')", + " (UsrCod,UsrID,CreatTime,Confirmed)" + " VALUES" + " (%ld,'%s',NOW(),'%c')", UsrDat->UsrCod, UsrDat->IDs.List[NumID].ID, UsrDat->IDs.List[NumID].Confirmed ? 'Y' : diff --git a/swad_action.c b/swad_action.c index cb20fc4d..af646cd7 100644 --- a/swad_action.c +++ b/swad_action.c @@ -1497,7 +1497,7 @@ Profile: 1278. ActSeeMyTT Show the timetable of all courses of the logged user 1279. ActSeeMyAgd Show my full agenda (personal organizer) 1280. ActFrmMyAcc Show form to the creation or change of user's account - 1281. ActReqEdiRecCom Request the edition of the record with the personal data of the user + 1281. ActReqEdiRecSha Request the edition of the record with the personal data of the user 1282. ActEdiPrf Show forms to edit preferences 1283. ActReqSndNewPwd Show form to send a new password via email @@ -3092,7 +3092,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActSeeMyTT */{ 408, 3,TabPrf,ActSeeMyTT ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,TT_ShowClassTimeTable ,"clock64x64.gif" }, /* ActSeeMyAgd */{1602, 4,TabPrf,ActSeeMyAgd ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Agd_ShowMyAgenda ,"calendar64x64.png" }, /* ActFrmMyAcc */{ 36, 5,TabPrf,ActFrmMyAcc ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Acc_ShowFormMyAccount ,"arroba64x64.gif" }, - /* ActReqEdiRecCom */{ 285, 6,TabPrf,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_ShowFormMySharedRecord ,"card64x64.gif" }, + /* ActReqEdiRecSha */{ 285, 6,TabPrf,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_ShowMySharedRecordAndMyInsCtrDpt,"card64x64.gif" }, /* ActEdiPrf */{ 673, 7,TabPrf,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pre_EditPrefs ,"heart64x64.gif" }, // Actions not in menu: @@ -3137,28 +3137,28 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActReqRemMyAcc */{1430,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Acc_AskIfRemoveMyAccount ,NULL}, /* ActRemMyAcc */{1431,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Acc_RemoveMyAccount ,NULL}, - /* ActChgMyData */{ 298,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Rec_UpdateMyRecord ,Rec_ShowMySharedRecordUpd ,NULL}, + /* ActChgMyData */{ 298,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Rec_UpdateMyRecord ,Rec_ShowMySharedRecordUpd ,NULL}, - /* ActReqMyPho */{ 30,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pho_ReqMyPhoto ,NULL}, - /* ActDetMyPho */{ 693,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,Pho_RecMyPhotoDetFaces ,NULL}, - /* ActUpdMyPho */{ 694,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Pho_UpdateMyPhoto1 ,Pho_UpdateMyPhoto2 ,NULL}, - /* ActReqRemMyPho */{1577,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pho_ReqRemoveMyPhoto ,NULL}, - /* ActRemMyPho */{ 428,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Pho_RemoveMyPhoto1 ,Pho_RemoveMyPhoto2 ,NULL}, + /* ActReqMyPho */{ 30,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pho_ReqMyPhoto ,NULL}, + /* ActDetMyPho */{ 693,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,Pho_RecMyPhotoDetFaces ,NULL}, + /* ActUpdMyPho */{ 694,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Pho_UpdateMyPhoto1 ,Pho_UpdateMyPhoto2 ,NULL}, + /* ActReqRemMyPho */{1577,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pho_ReqRemoveMyPhoto ,NULL}, + /* ActRemMyPho */{ 428,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Pho_RemoveMyPhoto1 ,Pho_RemoveMyPhoto2 ,NULL}, /* ActEdiPri */{1403,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pri_EditMyPrivacy ,NULL}, /* ActChgPriPho */{ 774,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pho_ChangePhotoVisibility ,NULL}, /* ActChgPriPrf */{1404,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Prf_ChangeProfileVisibility ,NULL}, - /* ActReqEdiMyIns */{1165,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_ShowFormMyInsCtrDpt ,NULL}, - /* ActChgCtyMyIns */{1166,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_ChgCountryOfMyInstitution ,NULL}, - /* ActChgMyIns */{1167,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_UpdateMyInstitution ,NULL}, - /* ActChgMyCtr */{1168,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_UpdateMyCentre ,NULL}, - /* ActChgMyDpt */{1169,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_UpdateMyDepartment ,NULL}, - /* ActChgMyOff */{1170,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_UpdateMyOffice ,NULL}, - /* ActChgMyOffPho */{1171,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_UpdateMyOfficePhone ,NULL}, + /* ActReqEdiMyIns */{1165,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_ShowMySharedRecordAndMyInsCtrDpt,NULL}, + /* ActChgCtyMyIns */{1166,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_ChgCountryOfMyInstitution ,NULL}, + /* ActChgMyIns */{1167,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_UpdateMyInstitution ,NULL}, + /* ActChgMyCtr */{1168,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_UpdateMyCentre ,NULL}, + /* ActChgMyDpt */{1169,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_UpdateMyDepartment ,NULL}, + /* ActChgMyOff */{1170,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_UpdateMyOffice ,NULL}, + /* ActChgMyOffPho */{1171,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_UpdateMyOfficePhone ,NULL}, - /* ActReqEdiMyNet */{1172,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Net_ShowFormMyWebsAndSocialNets,NULL}, - /* ActChgMyNet */{1173,-1,TabUnk,ActReqEdiRecCom ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Net_UpdateMyWebsAndSocialNets ,NULL}, + /* ActReqEdiMyNet */{1172,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Net_ShowFormMyWebsAndSocialNets,NULL}, + /* ActChgMyNet */{1173,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Net_UpdateMyWebsAndSocialNets ,NULL}, /* ActChgThe */{ 841,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,The_ChangeTheme ,Pre_EditPrefs ,NULL}, /* ActReqChgLan */{ 992,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Lan_AskChangeLanguage ,NULL}, @@ -3469,7 +3469,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un -1, // #282 (obsolete action) -1, // #283 (obsolete action) ActAdmMrkCrs, // #284 - ActReqEdiRecCom, // #285 + ActReqEdiRecSha, // #285 ActReqRemFilBrf, // #286 -1, // #287 (obsolete action) ActReqRemFilWrkUsr, // #288 @@ -5461,7 +5461,7 @@ void Act_AdjustCurrentAction (void) case ActFrmMyAcc: case ActFrmChgMyPwd: break; default: - Gbl.Action.Act = ActReqEdiRecCom; + Gbl.Action.Act = ActReqEdiRecSha; Tab_SetCurrentTab (); return; } @@ -5481,7 +5481,7 @@ void Act_AdjustCurrentAction (void) { case ActHom: case ActLogOut: case ActFrmMyAcc: case ActFrmChgMyPwd: - case ActReqEdiRecCom: + case ActReqEdiRecSha: break; default: Gbl.Action.Act = ActReqEdiMyIns; @@ -5496,7 +5496,7 @@ void Act_AdjustCurrentAction (void) { case ActHom: case ActLogOut: case ActFrmMyAcc: case ActFrmChgMyPwd: - case ActReqEdiRecCom: case ActReqEdiMyIns: + case ActReqEdiRecSha: case ActReqEdiMyIns: break; default: Gbl.Action.Act = ActEdiPri; @@ -5542,7 +5542,7 @@ void Act_AdjustCurrentAction (void) case ActLogOut: case ActFrmMyAcc: case ActFrmChgMyPwd: - case ActReqEdiRecCom: + case ActReqEdiRecSha: case ActReqEdiMyIns: case ActEdiPri: case ActReqSelGrp: diff --git a/swad_action.h b/swad_action.h index 8aafd2b3..a9d797aa 100644 --- a/swad_action.h +++ b/swad_action.h @@ -1531,7 +1531,7 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to #define ActSeeMyTT (ActSeeMyUsgRep + 4) #define ActSeeMyAgd (ActSeeMyUsgRep + 5) #define ActFrmMyAcc (ActSeeMyUsgRep + 6) -#define ActReqEdiRecCom (ActSeeMyUsgRep + 7) +#define ActReqEdiRecSha (ActSeeMyUsgRep + 7) #define ActEdiPrf (ActSeeMyUsgRep + 8) // Secondary actions #define ActReqSndNewPwd (ActSeeMyUsgRep + 9) diff --git a/swad_changelog.h b/swad_changelog.h index 60f67134..7a6459f1 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -355,10 +355,11 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.2 (2018-10-08)" +#define Log_PLATFORM_VERSION "SWAD 18.2.1 (2018-10-08)" #define CSS_FILE "swad17.25.4.css" #define JS_FILE "swad17.17.1.js" /* + Version 18.2.1: Oct 08, 2018 Changes in edition of user's institution, centre, department... (234989 lines) Version 18.2: Oct 08, 2018 Changes in layout of record card. (234980 lines) Version 18.1.6: Oct 07, 2018 Icon to change user's institution is moved to record card. (234963 lines) Version 18.1.5: Oct 07, 2018 Icon to change user's privacy is moved to record card. (234958 lines) diff --git a/swad_enrolment.c b/swad_enrolment.c index 0668de91..16355126 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -530,18 +530,21 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat) Enr_FilterUsrDat (UsrDat); /***** Update user's common data *****/ - Usr_CreateBirthdayStrDB (UsrDat,BirthdayStrDB); - CommentsLength = strlen (UsrDat->Comments); - if ((Query = malloc (2048 + - Pwd_BYTES_ENCRYPTED_PASSWORD + // Password - Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME * 3 +// Surname1, Surname2, FirstName - Usr_MAX_BYTES_ADDRESS + // LocalAddress - Usr_MAX_BYTES_PHONE + // LocalPhone - Usr_MAX_BYTES_ADDRESS + // FamilyAddress - Usr_MAX_BYTES_PHONE + // FamilyPhone - Usr_MAX_BYTES_ADDRESS + // OriginPlace - Usr_BIRTHDAY_STR_DB_LENGTH + // BirthdayStrDB - CommentsLength)) == NULL) // Comments + Usr_CreateBirthdayStrDB (UsrDat,BirthdayStrDB); // It can include start and ending apostrophes + if (UsrDat->Comments) + CommentsLength = strlen (UsrDat->Comments); + else + CommentsLength = 0; + if ((Query = (char *) malloc (2048 + + Pwd_BYTES_ENCRYPTED_PASSWORD + // Password + Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME * 3 +// Surname1, Surname2, FirstName + Usr_MAX_BYTES_ADDRESS + // LocalAddress + Usr_MAX_BYTES_PHONE + // LocalPhone + Usr_MAX_BYTES_ADDRESS + // FamilyAddress + Usr_MAX_BYTES_PHONE + // FamilyPhone + Usr_MAX_BYTES_ADDRESS + // OriginPlace + Usr_BIRTHDAY_STR_DB_LENGTH + // BirthdayStrDB + CommentsLength)) == NULL) // Comments Lay_ShowErrorAndExit ("Not enough memory to store query."); sprintf (Query,"UPDATE usr_data" " SET Password='%s'," diff --git a/swad_exam.c b/swad_exam.c index 74d7c8a2..cce7693f 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -195,25 +195,25 @@ static long Exa_GetParamsExamAnnouncement (void) static void Exa_AllocMemExamAnnouncement (void) { - if ((Gbl.ExamAnns.ExaDat.Place = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) + if ((Gbl.ExamAnns.ExaDat.Place = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); - if ((Gbl.ExamAnns.ExaDat.Mode = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) + if ((Gbl.ExamAnns.ExaDat.Mode = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); - if ((Gbl.ExamAnns.ExaDat.Structure = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) + if ((Gbl.ExamAnns.ExaDat.Structure = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); - if ((Gbl.ExamAnns.ExaDat.DocRequired = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) + if ((Gbl.ExamAnns.ExaDat.DocRequired = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); - if ((Gbl.ExamAnns.ExaDat.MatRequired = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) + if ((Gbl.ExamAnns.ExaDat.MatRequired = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); - if ((Gbl.ExamAnns.ExaDat.MatAllowed = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) + if ((Gbl.ExamAnns.ExaDat.MatAllowed = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); - if ((Gbl.ExamAnns.ExaDat.OtherInfo = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) + if ((Gbl.ExamAnns.ExaDat.OtherInfo = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); } @@ -736,10 +736,10 @@ static long Exa_AddExamAnnouncementToDB (void) long ExaCod; /***** Add exam announcement *****/ - if ((Query = malloc (512 + - Hie_MAX_BYTES_FULL_NAME + - Exa_MAX_BYTES_SESSION + - 7 * Cns_MAX_BYTES_TEXT)) == NULL) + if ((Query = (char *) malloc (512 + + Hie_MAX_BYTES_FULL_NAME + + Exa_MAX_BYTES_SESSION + + 7 * Cns_MAX_BYTES_TEXT)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to query database."); sprintf (Query,"INSERT INTO exam_announcements " "(CrsCod,Status,NumNotif,CrsFullName,Year,ExamSession," @@ -783,10 +783,10 @@ static void Exa_ModifyExamAnnouncementInDB (void) char *Query; /***** Modify exam announcement *****/ - if ((Query = malloc (512 + - Hie_MAX_BYTES_FULL_NAME + - Exa_MAX_BYTES_SESSION + - 7 * Cns_MAX_BYTES_TEXT)) == NULL) + if ((Query = (char *) malloc (512 + + Hie_MAX_BYTES_FULL_NAME + + Exa_MAX_BYTES_SESSION + + 7 * Cns_MAX_BYTES_TEXT)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to query database."); sprintf (Query,"UPDATE exam_announcements" " SET CrsFullName='%s',Year=%u,ExamSession='%s'," diff --git a/swad_forum.c b/swad_forum.c index 38778e71..b9fcb2c8 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -509,12 +509,12 @@ static long For_InsertForumPst (long ThrCod,long UsrCod, long PstCod; /***** Allocate space for query *****/ - if ((Query = malloc (512 + - strlen (Subject) + - strlen (Content) + - Img_BYTES_NAME + - Img_MAX_BYTES_TITLE + - Cns_MAX_BYTES_WWW)) == NULL) + if ((Query = (char *) malloc (512 + + strlen (Subject) + + strlen (Content) + + Img_BYTES_NAME + + Img_MAX_BYTES_TITLE + + Cns_MAX_BYTES_WWW)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store database query."); /***** Check if image is received and processed *****/ diff --git a/swad_menu.c b/swad_menu.c index 6cb0f9ec..67b5c0c3 100644 --- a/swad_menu.c +++ b/swad_menu.c @@ -285,7 +285,7 @@ const Act_Action_t Mnu_MenuActions[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB ActSeeMyTT, // 3 ActSeeMyAgd, // 4 ActFrmMyAcc, // 5 - ActReqEdiRecCom, // 6 + ActReqEdiRecSha, // 6 ActEdiPrf, // 7 0, // 8 0, // 9 diff --git a/swad_message.c b/swad_message.c index c512747b..e7b54026 100644 --- a/swad_message.c +++ b/swad_message.c @@ -1303,11 +1303,11 @@ static long Msg_InsertNewMsg (const char *Subject,const char *Content, long MsgCod; /***** Allocate space for query *****/ - if ((Query = malloc (512 + - strlen (Subject) + - strlen (Content) + - Img_BYTES_NAME + - Img_MAX_BYTES_TITLE)) == NULL) + if ((Query = (char *) malloc (512 + + strlen (Subject) + + strlen (Content) + + Img_BYTES_NAME + + Img_MAX_BYTES_TITLE)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store database query."); /***** Check if image is received and processed *****/ diff --git a/swad_project.c b/swad_project.c index a1f1f090..17b75300 100644 --- a/swad_project.c +++ b/swad_project.c @@ -3182,13 +3182,13 @@ static void Prj_EditOneProjectTxtArea (const char *Id, void Prj_AllocMemProject (struct Project *Prj) { - if ((Prj->Description = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) + if ((Prj->Description = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store project."); - if ((Prj->Knowledge = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) + if ((Prj->Knowledge = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store project."); - if ((Prj->Materials = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) + if ((Prj->Materials = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store project."); } diff --git a/swad_record.c b/swad_record.c index cb96820f..f9c13676 100644 --- a/swad_record.c +++ b/swad_record.c @@ -68,6 +68,8 @@ extern struct Globals Gbl; #define Rec_SHOW_OFFICE_HOURS_DEFAULT true +#define Rec_MY_INS_CTR_DPT_ID "my_ins_ctr_dpt_section" + /*****************************************************************************/ /***************************** Private prototypes ****************************/ /*****************************************************************************/ @@ -99,6 +101,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView, static void Rec_ShowMyCrsRecordUpdated (void); static bool Rec_CheckIfICanEditField (Rec_VisibilityRecordFields_t Visibility); +static void Rec_ShowFormMySharedRecord (void); static void Rec_PutIconsCommands (void); static void Rec_PutParamsWorks (void); static void Rec_PutParamsStudent (void); @@ -169,7 +172,8 @@ static void Rec_WriteLinkToDataProtectionClause (void); static void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat); static void Rec_GetUsrCommentsFromForm (struct UsrData *UsrDat); -static void Rec_PutLinkToChangeMyInsCtrDpt (void); + +static void Rec_ShowFormMyInsCtrDpt (void); /*****************************************************************************/ /*************** Create, edit and remove fields of records *******************/ @@ -2050,7 +2054,7 @@ void Rec_AllocMemFieldsRecordsCrs (void) NumField++) if (Rec_CheckIfICanEditField (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility)) /* Allocate memory for the texts of the fields */ - if ((Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) + if ((Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store records of the course."); } @@ -2101,24 +2105,23 @@ void Rec_ShowFormSignUpInCrsWithMySharedRecord (void) /***************** Show form to edit my shared record card *******************/ /*****************************************************************************/ -void Rec_ShowFormMySharedRecord (void) +static void Rec_ShowFormMySharedRecord (void) { - extern const char *Txt_Please_fill_in_your_record_card_including_your_country_nationality; - extern const char *Txt_Please_fill_in_your_record_card_including_your_sex; extern const char *Txt_Please_fill_in_your_record_card_including_your_name; + extern const char *Txt_Please_fill_in_your_record_card_including_your_sex; + extern const char *Txt_Please_fill_in_your_record_card_including_your_country_nationality; - /***** If user has no sex, name and surname... *****/ - if (Gbl.Usrs.Me.UsrDat.CtyCod < 0) - Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_country_nationality); + /***** If user has no name and surname, sex... *****/ + if (!Gbl.Usrs.Me.UsrDat.FirstName[0] || + !Gbl.Usrs.Me.UsrDat.Surname1[0]) + Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_name); else if (Gbl.Usrs.Me.UsrDat.Sex == Usr_SEX_UNKNOWN) Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_sex); - else if (!Gbl.Usrs.Me.UsrDat.FirstName[0] || - !Gbl.Usrs.Me.UsrDat.Surname1[0]) - Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_name); + else if (Gbl.Usrs.Me.UsrDat.CtyCod < 0) + Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_country_nationality); /***** My record *****/ Rec_ShowSharedUsrRecord (Rec_SHA_MY_RECORD_FORM,&Gbl.Usrs.Me.UsrDat,NULL); - Rec_WriteLinkToDataProtectionClause (); } /*****************************************************************************/ @@ -2247,7 +2250,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, TeacherInCurrentCrs = UsrDat->Roles.InCurrentCrs.Role == Rol_NET || UsrDat->Roles.InCurrentCrs.Role == Rol_TCH; TeacherInAnyCrs = UsrDat->Roles.InCrss & ((1 << Rol_NET) | - (1 << Rol_TCH)); + (1 << Rol_TCH)); ShowAddressRows = (TypeOfView == Rec_SHA_MY_RECORD_FORM || TypeOfView == Rec_SHA_MY_RECORD_CHECK || @@ -2256,8 +2259,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, IAmLoggedAsTeacherOrSysAdm && StudentInCurrentCrs)); // He/she is a student in the current course Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); // Get user's roles if not got - ShowTeacherRows = (((TypeOfView == Rec_SHA_MY_RECORD_FORM || - TypeOfView == Rec_SHA_MY_RECORD_CHECK) && + ShowTeacherRows = (((TypeOfView == Rec_SHA_MY_RECORD_CHECK) && TeacherInAnyCrs) || // He/she (me, really) is a teacher in any course ((TypeOfView == Rec_SHA_RECORD_LIST || TypeOfView == Rec_SHA_RECORD_PRINT) && @@ -2451,7 +2453,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, } /***** Teacher's rows *****/ - if (ShowTeacherRows && TypeOfView != Rec_SHA_MY_RECORD_FORM) + if (ShowTeacherRows) Rec_ShowTeacherRows (UsrDat,&Ins,ShowData,ClassForm); Tbl_EndTable (); @@ -2503,15 +2505,6 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, /***** End table and box *****/ Box_EndBoxTable (); - - /***** Table with teacher rows *****/ - if (ShowTeacherRows && TypeOfView == Rec_SHA_MY_RECORD_FORM) - { - Box_StartBoxTable (StrRecordWidth,NULL,Rec_PutLinkToChangeMyInsCtrDpt, - NULL,Box_NOT_CLOSABLE,2); - Rec_ShowTeacherRows (UsrDat,&Ins,ShowData,ClassForm); - Box_EndBoxTable (); - } } /*****************************************************************************/ @@ -2550,7 +2543,7 @@ static void Rec_PutIconsCommands (void) if (ItsMe) /***** Button to edit my record card *****/ - Lay_PutContextualLink (ActReqEdiRecCom,NULL,NULL, + Lay_PutContextualLink (ActReqEdiRecSha,NULL,NULL, "edit64x64.png", Txt_Edit_my_personal_data,NULL, NULL); @@ -3953,18 +3946,19 @@ static void Rec_GetUsrCommentsFromForm (struct UsrData *UsrDat) } /*****************************************************************************/ -/*** Put a link to the action to edit my institution, centre, department... **/ +/**** Show my shared record and a form to edit my institution, centre... *****/ /*****************************************************************************/ -static void Rec_PutLinkToChangeMyInsCtrDpt (void) +void Rec_ShowMySharedRecordAndMyInsCtrDpt (void) { - extern const char *Txt_Edit_my_institution; + /***** My shared record *****/ + Rec_ShowFormMySharedRecord (); - /***** Button to edit my institution *****/ - Lay_PutContextualLink (ActReqEdiMyIns,NULL,NULL, - "edit64x64.png", - Txt_Edit_my_institution,NULL, - NULL); + /***** My institution, centre and department *****/ + Rec_ShowFormMyInsCtrDpt (); + + /***** Data protection clause *****/ + Rec_WriteLinkToDataProtectionClause (); } /*****************************************************************************/ @@ -3973,7 +3967,7 @@ static void Rec_PutLinkToChangeMyInsCtrDpt (void) #define COL2_WIDTH 600 -void Rec_ShowFormMyInsCtrDpt (void) +static void Rec_ShowFormMyInsCtrDpt (void) { extern const char *Hlp_PROFILE_Institution; extern const char *The_ClassForm[The_NUM_THEMES]; @@ -3996,12 +3990,15 @@ void Rec_ShowFormMyInsCtrDpt (void) unsigned NumCtr; bool IAmATeacher; + /***** Start section *****/ + Lay_StartSection (Rec_MY_INS_CTR_DPT_ID); + /***** Get my roles if not yet got *****/ Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat); /***** Check if I am a teacher *****/ IAmATeacher = (Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) | // I am a non-editing teacher... - (1 << Rol_TCH))); // ...or a teacher in any course + (1 << Rol_TCH))); // ...or a teacher in any course /***** If there is no country, institution, centre or department *****/ if (Gbl.Usrs.Me.UsrDat.InsCtyCod < 0) @@ -4039,7 +4036,8 @@ void Rec_ShowFormMyInsCtrDpt (void) } /* Start form to select the country of my institution */ - Act_FormGoToStart (ActChgCtyMyIns); + // Act_FormGoToStart (ActChgCtyMyIns); + Act_FormStartAnchor (ActChgCtyMyIns,Rec_MY_INS_CTR_DPT_ID); fprintf (Gbl.F.Out,"" @@ -4126,7 +4125,8 @@ void Rec_ShowFormMyInsCtrDpt (void) Ctr_GetListCentres (Gbl.Usrs.Me.UsrDat.InsCod); /* Start form to select centre */ - Act_FormGoToStart (ActChgMyCtr); + // Act_FormGoToStart (ActChgMyCtr); + Act_FormStartAnchor (ActChgMyCtr,Rec_MY_INS_CTR_DPT_ID); fprintf (Gbl.F.Out,"", ClassForm,Txt_Phone, COL2_WIDTH); - Act_FormGoToStart (ActChgMyOffPho); + // Act_FormGoToStart (ActChgMyOffPho); + Act_FormStartAnchor (ActChgMyOffPho,Rec_MY_INS_CTR_DPT_ID); fprintf (Gbl.F.Out,"AnsChoice[NumAns].Text = malloc (Svy_MAX_BYTES_ANSWER + 1)) == NULL) + if ((SvyQst->AnsChoice[NumAns].Text = (char *) malloc (Svy_MAX_BYTES_ANSWER + 1)) == NULL) { sprintf (Gbl.Alert.Txt,"Not enough memory to store answer."); return false; @@ -3383,7 +3383,7 @@ static void Svy_WriteQstStem (const char *Stem) /* Convert the stem, that is in HTML, to rigorous HTML */ Length = strlen (Stem) * Str_MAX_BYTES_PER_CHAR; - if ((HeadingRigorousHTML = malloc (Length + 1)) == NULL) + if ((HeadingRigorousHTML = (char *) malloc (Length + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store stem of question."); Str_Copy (HeadingRigorousHTML,Stem, Length); diff --git a/swad_test.c b/swad_test.c index 0ee22209..2851f0d3 100644 --- a/swad_test.c +++ b/swad_test.c @@ -1072,7 +1072,7 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem) /***** Convert the stem, that is in HTML, to rigorous HTML *****/ StemLength = strlen (Stem) * Str_MAX_BYTES_PER_CHAR; - if ((StemRigorousHTML = malloc (StemLength + 1)) == NULL) + if ((StemRigorousHTML = (char *) malloc (StemLength + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store stem of question."); Str_Copy (StemRigorousHTML,Stem, StemLength); @@ -1206,7 +1206,7 @@ void Tst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback) { /***** Convert the feedback, that is in HTML, to rigorous HTML *****/ FeedbackLength = strlen (Feedback) * Str_MAX_BYTES_PER_CHAR; - if ((FeedbackRigorousHTML = malloc (FeedbackLength + 1)) == NULL) + if ((FeedbackRigorousHTML = (char *) malloc (FeedbackLength + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store stem of question."); Str_Copy (FeedbackRigorousHTML,Feedback, FeedbackLength); @@ -3385,7 +3385,7 @@ static void Tst_WriteAnswersEdit (long QstCod) /* Convert the answer (row[1]), that is in HTML, to rigorous HTML */ LengthAnswer = strlen (row[1]) * Str_MAX_BYTES_PER_CHAR; - if ((Answer = malloc (LengthAnswer + 1)) == NULL) + if ((Answer = (char *) malloc (LengthAnswer + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store answer."); Str_Copy (Answer,row[1], LengthAnswer); @@ -3399,7 +3399,7 @@ static void Tst_WriteAnswersEdit (long QstCod) if (row[2][0]) { LengthFeedback = strlen (row[2]) * Str_MAX_BYTES_PER_CHAR; - if ((Feedback = malloc (LengthFeedback + 1)) == NULL) + if ((Feedback = (char *) malloc (LengthFeedback + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store feedback."); Str_Copy (Feedback,row[2], LengthFeedback); @@ -4714,7 +4714,7 @@ static bool Tst_GetParamsTst (Tst_ActionToDoWithQuestions_t ActionToDoWithQuesti Gbl.Test.Tags.All = Par_GetParToBool ("AllTags"); /* Get the tags */ - if ((Gbl.Test.Tags.List = malloc (Tst_MAX_BYTES_TAGS_LIST + 1)) == NULL) + if ((Gbl.Test.Tags.List = (char *) malloc (Tst_MAX_BYTES_TAGS_LIST + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store tags."); Par_GetParMultiToText ("ChkTag",Gbl.Test.Tags.List,Tst_MAX_BYTES_TAGS_LIST); @@ -5417,13 +5417,13 @@ int Tst_AllocateTextChoiceAnswer (unsigned NumOpt) Tst_FreeTextChoiceAnswer (NumOpt); if ((Gbl.Test.Answer.Options[NumOpt].Text = - malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL) + (char *) malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL) { sprintf (Gbl.Alert.Txt,"Not enough memory to store answer."); return 0; } if ((Gbl.Test.Answer.Options[NumOpt].Feedback = - malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL) + (char *) malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL) { sprintf (Gbl.Alert.Txt,"Not enough memory to store feedback."); return 0; @@ -6506,12 +6506,12 @@ static void Tst_InsertOrUpdateQstIntoDB (void) char *Query; /***** Allocate space for query *****/ - if ((Query = malloc (512 + - Gbl.Test.Stem.Length + - Gbl.Test.Feedback.Length + - Img_BYTES_NAME + - Img_MAX_BYTES_TITLE + - Cns_MAX_BYTES_WWW)) == NULL) + if ((Query = (char *) malloc (512 + + Gbl.Test.Stem.Length + + Gbl.Test.Feedback.Length + + Img_BYTES_NAME + + Img_MAX_BYTES_TITLE + + Cns_MAX_BYTES_WWW)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store database query."); if (Gbl.Test.QstCod < 0) // It's a new question @@ -6618,11 +6618,11 @@ static void Tst_InsertAnswersIntoDB (void) unsigned i; /***** Allocate space for query *****/ - if ((Query = malloc (256 + - Tst_MAX_BYTES_ANSWER_OR_FEEDBACK * 2 + - Img_BYTES_NAME + - Img_MAX_BYTES_TITLE + - Cns_MAX_BYTES_WWW)) == NULL) + if ((Query = (char *) malloc (256 + + Tst_MAX_BYTES_ANSWER_OR_FEEDBACK * 2 + + Img_BYTES_NAME + + Img_MAX_BYTES_TITLE + + Cns_MAX_BYTES_WWW)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store database query."); /***** Insert answers in the answers table *****/ diff --git a/swad_test_import.c b/swad_test_import.c index 13bd5c6a..e3e4fa62 100644 --- a/swad_test_import.c +++ b/swad_test_import.c @@ -460,7 +460,7 @@ static void TsI_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML) fseek (Gbl.Test.XML.FileXML,0L,SEEK_SET); /***** Allocate memory for XML buffer *****/ - if ((XMLBuffer = malloc (FileSize + 1)) == NULL) + if ((XMLBuffer = (char *) malloc (FileSize + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory for XML buffer."); else { @@ -724,7 +724,7 @@ static bool TsI_CheckIfQuestionExistsInDB (void) /***** Check if stem exists *****/ /* Allocate space for query */ - if ((QueryQst = malloc (256 + Gbl.Test.Stem.Length)) == NULL) + if ((QueryQst = (char *) malloc (256 + Gbl.Test.Stem.Length)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store database query."); /* Make database query */ @@ -1126,7 +1126,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem, /* Convert the answer, that is in HTML, to rigorous HTML */ AnswerTextLength = strlen (Gbl.Test.Answer.Options[NumOpt].Text) * Str_MAX_BYTES_PER_CHAR; - if ((AnswerText = malloc (AnswerTextLength + 1)) == NULL) + if ((AnswerText = (char *) malloc (AnswerTextLength + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store answer."); Str_Copy (AnswerText,Gbl.Test.Answer.Options[NumOpt].Text, AnswerTextLength); @@ -1141,7 +1141,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem, { AnswerFeedbackLength = strlen (Gbl.Test.Answer.Options[NumOpt].Feedback) * Str_MAX_BYTES_PER_CHAR; - if ((AnswerFeedback = malloc (AnswerFeedbackLength + 1)) == NULL) + if ((AnswerFeedback = (char *) malloc (AnswerFeedbackLength + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store feedback."); Str_Copy (AnswerFeedback, Gbl.Test.Answer.Options[NumOpt].Feedback, diff --git a/swad_text.c b/swad_text.c index 75ae5f5e..ad0a6bc7 100644 --- a/swad_text.c +++ b/swad_text.c @@ -20589,7 +20589,7 @@ const char *Txt_MENU_TITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB] = "Conta" #endif , - // 6: ActReqEdiRecCom + // 6: ActReqEdiRecSha #if L==1 "Fitxa" #elif L==2 @@ -22615,7 +22615,7 @@ const char *Txt_MENU_SUBTITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB] = "Criar ou editar minha conta de usuário" #endif , - // 6: ActReqEdiRecCom + // 6: ActReqEdiRecSha #if L==1 "Dades personals, comuns per a totes les assignatures" #elif L==2 diff --git a/swad_user.c b/swad_user.c index b7552259..32c57083 100644 --- a/swad_user.c +++ b/swad_user.c @@ -275,7 +275,7 @@ void Usr_InformAboutNumClicksBeforePhoto (void) void Usr_UsrDataConstructor (struct UsrData *UsrDat) { /***** Allocate memory for the comments *****/ - if ((UsrDat->Comments = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) + if ((UsrDat->Comments = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store user's data."); /***** Initialize to zero the data of the user *****/ @@ -2471,6 +2471,7 @@ void Usr_WelcomeUsr (void) /*****************************************************************************/ /************ Write birthday string to insert or update database *************/ /*****************************************************************************/ +// It can include start and ending apostrophes void Usr_CreateBirthdayStrDB (const struct UsrData *UsrDat, char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH + 1]) @@ -2478,10 +2479,10 @@ void Usr_CreateBirthdayStrDB (const struct UsrData *UsrDat, if (UsrDat->Birthday.Year == 0 || UsrDat->Birthday.Month == 0 || UsrDat->Birthday.Day == 0) - Str_Copy (BirthdayStrDB,"NULL", + Str_Copy (BirthdayStrDB,"NULL", // Without apostrophes Usr_BIRTHDAY_STR_DB_LENGTH); else - sprintf (BirthdayStrDB,"'%04u-%02u-%02u'", + sprintf (BirthdayStrDB,"'%04u-%02u-%02u'", // With apostrophes UsrDat->Birthday.Year, UsrDat->Birthday.Month, UsrDat->Birthday.Day); @@ -5698,7 +5699,7 @@ static void Usr_AllocateListOtherRecipients (void) { if (!Gbl.Usrs.ListOtherRecipients) { - if ((Gbl.Usrs.ListOtherRecipients = malloc (Nck_MAX_BYTES_LIST_NICKS + 1)) == NULL) + if ((Gbl.Usrs.ListOtherRecipients = (char *) malloc (Nck_MAX_BYTES_LIST_NICKS + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store list of recipients."); Gbl.Usrs.ListOtherRecipients[0] = '\0'; } diff --git a/swad_user.h b/swad_user.h index 4b417968..5052c52b 100644 --- a/swad_user.h +++ b/swad_user.h @@ -63,7 +63,7 @@ // Surname1 +' '+ Surname2 + ','+' ' + FirstName // Surname1 +' '+ Surname2 + '
' + FirstName -#define Usr_BIRTHDAY_STR_DB_LENGTH (4 + 1 + 2 + 1 + 2) // "'%04u-%02u-%02u'" +#define Usr_BIRTHDAY_STR_DB_LENGTH (1 + 4 + 1 + 2 + 1 + 2 + 1) // "'%04u-%02u-%02u'" #define Usr_MAX_CHARS_ADDRESS (128 - 1) // 127 #define Usr_MAX_BYTES_ADDRESS ((Usr_MAX_CHARS_ADDRESS + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 diff --git a/swad_xml.c b/swad_xml.c index 6075b07d..b2fc2ca8 100644 --- a/swad_xml.c +++ b/swad_xml.c @@ -178,7 +178,7 @@ static void XML_GetElement (struct XMLElement *ParentElem) /* Copy content */ if (ContentLength) { - if ((ParentElem->Content = malloc (ContentLength + 1)) == NULL) + if ((ParentElem->Content = (char *) malloc (ContentLength + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory."); strncpy (ParentElem->Content,StartContent,ContentLength); ParentElem->Content[ContentLength] = '\0'; @@ -215,7 +215,7 @@ static void XML_GetElement (struct XMLElement *ParentElem) /***** Get child tag name *****/ ChildElem->TagNameLength = strcspn (Gbl.XMLPtr,">/ \t"); - if ((ChildElem->TagName = malloc (ChildElem->TagNameLength + 1)) == NULL) + if ((ChildElem->TagName = (char *) malloc (ChildElem->TagNameLength + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory."); strncpy (ChildElem->TagName,Gbl.XMLPtr,ChildElem->TagNameLength); ChildElem->TagName[ChildElem->TagNameLength] = '\0'; @@ -335,7 +335,7 @@ static void XML_GetAttributes (struct XMLElement *Elem) /***** Get attribute name *****/ Attribute->AttributeNameLength = strcspn (Gbl.XMLPtr,"="); - if ((Attribute->AttributeName = malloc (Attribute->AttributeNameLength + 1)) == NULL) + if ((Attribute->AttributeName = (char *) malloc (Attribute->AttributeNameLength + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory."); strncpy (Attribute->AttributeName,Gbl.XMLPtr,Attribute->AttributeNameLength); Attribute->AttributeName[Attribute->AttributeNameLength] = '\0'; @@ -365,7 +365,7 @@ static void XML_GetAttributes (struct XMLElement *Elem) Lay_ShowErrorAndExit (Gbl.Alert.Txt); } - if ((Attribute->Content = malloc (Attribute->ContentLength + 1)) == NULL) + if ((Attribute->Content = (char *) malloc (Attribute->ContentLength + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory."); strncpy (Attribute->Content,Gbl.XMLPtr,Attribute->ContentLength); Attribute->Content[Attribute->ContentLength] = '\0';