diff --git a/swad_account.c b/swad_account.c index 7edc5b6b..eeae7dbd 100644 --- a/swad_account.c +++ b/swad_account.c @@ -785,8 +785,8 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount) Pri_VisibilityDB[UsrDat->BaPrfVisibility], Pri_VisibilityDB[UsrDat->ExPrfVisibility], UsrDat->CtyCod, - UsrDat->Phone1, - UsrDat->Phone2, + UsrDat->Phone[0], + UsrDat->Phone[1], BirthdayStrDB, CommentsLength ? UsrDat->Comments : "", diff --git a/swad_changelog.h b/swad_changelog.h index 59af9e0f..263c225a 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -544,10 +544,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.206 (2020-04-29)" +#define Log_PLATFORM_VERSION "SWAD 19.206.1 (2020-04-29)" #define CSS_FILE "swad19.193.1.css" #define JS_FILE "swad19.193.1.js" /* + Version 19.206.1: Apr 29, 2020 Changes in phones. (? lines) Version 19.206: Apr 29, 2020 Removed addresses in user's data. (300259 lines) Version 19.205: Apr 29, 2020 Removed origin place in user's data. (300399 lines) Version 19.204.5: Apr 28, 2020 Save start and end dates on creation of exam event. (300471 lines) diff --git a/swad_enrolment.c b/swad_enrolment.c index d85c0911..c79626b7 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -564,8 +564,8 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat) UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName, Usr_StringsSexDB[UsrDat->Sex], UsrDat->CtyCod, - UsrDat->Phone1, - UsrDat->Phone2, + UsrDat->Phone[0], + UsrDat->Phone[1], BirthdayStrDB, UsrDat->Comments ? UsrDat->Comments : "", diff --git a/swad_record.c b/swad_record.c index 3758ae06..6ef469f0 100644 --- a/swad_record.c +++ b/swad_record.c @@ -25,8 +25,10 @@ /********************************* Headers ***********************************/ /*****************************************************************************/ +#define _GNU_SOURCE // For asprintf #include // For PATH_MAX #include // For NULL +#include // For asprintf #include // For calloc #include @@ -128,8 +130,8 @@ static void Rec_ShowSurname2 (struct UsrData *UsrDat,bool PutForm); static void Rec_ShowFirstName (struct UsrData *UsrDat,bool PutForm); static void Rec_ShowCountry (struct UsrData *UsrDat,bool PutForm); static void Rec_ShowDateOfBirth (struct UsrData *UsrDat,bool ShowData,bool PutForm); -static void Rec_ShowPhone1 (struct UsrData *UsrDat,bool ShowData,bool PutForm); -static void Rec_ShowPhone2 (struct UsrData *UsrDat,bool ShowData,bool PutForm); +static void Rec_ShowPhone (struct UsrData *UsrDat,bool ShowData,bool PutForm, + unsigned NumPhone); static void Rec_ShowComments (struct UsrData *UsrDat,bool ShowData,bool PutForm); static void Rec_ShowTeacherRows (struct UsrData *UsrDat,struct Instit *Ins, bool ShowData); @@ -2348,11 +2350,9 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, /***** Date of birth *****/ Rec_ShowDateOfBirth (UsrDat,ShowData,ICanEdit); - /***** Phone 1 *****/ - Rec_ShowPhone1 (UsrDat,ShowData,ICanEdit); - - /***** Phone 2 *****/ - Rec_ShowPhone2 (UsrDat,ShowData,ICanEdit); + /***** Phones *****/ + Rec_ShowPhone (UsrDat,ShowData,ICanEdit,0); + Rec_ShowPhone (UsrDat,ShowData,ICanEdit,1); /***** User's comments *****/ Rec_ShowComments (UsrDat,ShowData,ICanEdit); @@ -3310,73 +3310,55 @@ static void Rec_ShowDateOfBirth (struct UsrData *UsrDat,bool ShowData,bool PutFo /*****************************************************************************/ /************************* Show user's local phone ***************************/ /*****************************************************************************/ +// NumPhone can be 0 or 1 -static void Rec_ShowPhone1 (struct UsrData *UsrDat,bool ShowData,bool PutForm) +static void Rec_ShowPhone (struct UsrData *UsrDat,bool ShowData,bool PutForm, + unsigned NumPhone) { extern const char *Txt_Phone; + char *Name; + char *Label; - /***** Local phone *****/ + /***** Internal name / id *****/ + if (asprintf (&Name,"Phone%u",NumPhone) < 0) + Lay_NotEnoughMemoryExit (); + + /***** Label to show *****/ + if (asprintf (&Label,"%s %u",Txt_Phone,NumPhone + 1) < 0) + Lay_NotEnoughMemoryExit (); + + /***** Phone *****/ HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("REC_C1_BOT RM",PutForm ? "Phone1" : + Frm_LabelColumn ("REC_C1_BOT RM",PutForm ? Name : NULL, - Txt_Phone); + Label); /* Data */ HTM_TD_Begin ("class=\"REC_C2_BOT DAT_N LM\""); if (ShowData) { if (PutForm) - HTM_INPUT_TEL ("Phone1",UsrDat->Phone1, + HTM_INPUT_TEL (Name,UsrDat->Phone[NumPhone], HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"Phone1\" class=\"REC_C2_BOT_INPUT\""); - else if (UsrDat->Phone1[0]) + "id=\"%s\" class=\"REC_C2_BOT_INPUT\"",Name); + else if (UsrDat->Phone[NumPhone][0]) { - HTM_A_Begin ("href=\"tel:%s\" class=\"DAT_N\"",UsrDat->Phone1); - HTM_Txt (UsrDat->Phone1); + HTM_A_Begin ("href=\"tel:%s\" class=\"DAT_N\"",UsrDat->Phone[NumPhone]); + HTM_Txt (UsrDat->Phone[NumPhone]); HTM_A_End (); } } HTM_TD_End (); HTM_TR_End (); - } -/*****************************************************************************/ -/************************ Show user's family phone ***************************/ -/*****************************************************************************/ + /***** Free label *****/ + free (Label); -static void Rec_ShowPhone2 (struct UsrData *UsrDat,bool ShowData,bool PutForm) - { - extern const char *Txt_Phone; - - /***** Family phone *****/ - HTM_TR_Begin (NULL); - - /* Label */ - Frm_LabelColumn ("REC_C1_BOT RM",PutForm ? "Phone2" : - NULL, - Txt_Phone); - - /* Data */ - HTM_TD_Begin ("class=\"REC_C2_BOT DAT_N LM\""); - if (ShowData) - { - if (PutForm) - HTM_INPUT_TEL ("Phone2",UsrDat->Phone2, - HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"Phone2\" class=\"REC_C2_BOT_INPUT\""); - else if (UsrDat->Phone2[0]) - { - HTM_A_Begin ("href=\"tel:%s\" class=\"DAT_N\"",UsrDat->Phone2); - HTM_Txt (UsrDat->Phone2); - HTM_A_End (); - } - } - HTM_TD_End (); - - HTM_TR_End (); + /***** Free name / id *****/ + free (Name); } /*****************************************************************************/ @@ -3731,9 +3713,8 @@ static void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat) &(UsrDat->Birthday.Year )); Dat_ConvDateToDateStr (&(UsrDat->Birthday),UsrDat->StrBirthday); - Par_GetParToText ("Phone1",UsrDat->Phone1,Usr_MAX_BYTES_PHONE); - - Par_GetParToText ("Phone2",UsrDat->Phone2,Usr_MAX_BYTES_PHONE); + Par_GetParToText ("Phone0",UsrDat->Phone[0],Usr_MAX_BYTES_PHONE); + Par_GetParToText ("Phone1",UsrDat->Phone[1],Usr_MAX_BYTES_PHONE); Rec_GetUsrCommentsFromForm (UsrDat); } diff --git a/swad_user.c b/swad_user.c index f9c87a08..18c68fdb 100644 --- a/swad_user.c +++ b/swad_user.c @@ -353,8 +353,8 @@ void Usr_ResetUsrDataExceptUsrCodAndIDs (struct UsrData *UsrDat) UsrDat->Birthday.Day = 0; UsrDat->Birthday.Month = 0; UsrDat->Birthday.Year = 0; - UsrDat->Phone1[0] = '\0'; - UsrDat->Phone2[0] = '\0'; + UsrDat->Phone[0][0] = + UsrDat->Phone[1][0] = '\0'; if (UsrDat->Comments) UsrDat->Comments[0] = '\0'; @@ -646,12 +646,10 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat,Usr_GetPrefs_t GetPrefs) Str_Copy (UsrDat->Tch.OfficePhone,row[16], Usr_MAX_BYTES_PHONE); - /* Get phone 1 (row[17]) */ - Str_Copy (UsrDat->Phone1,row[17], + /* Get phones (row[17]) and row[18] */ + Str_Copy (UsrDat->Phone[0],row[17], Usr_MAX_BYTES_PHONE); - - /* Get phone 2 (row[18]) */ - Str_Copy (UsrDat->Phone2,row[18], + Str_Copy (UsrDat->Phone[1],row[18], Usr_MAX_BYTES_PHONE); /* Get birthday (row[19]) */ @@ -3742,12 +3740,12 @@ static void Usr_WriteRowGstAllData (struct UsrData *UsrDat) " ", NULL,true,false); Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], - UsrDat->Phone1[0] ? UsrDat->Phone1 : - " ", + UsrDat->Phone[0][0] ? UsrDat->Phone[0] : + " ", NULL,true,false); Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], - UsrDat->Phone2[0] ? UsrDat->Phone2 : - " ", + UsrDat->Phone[1][0] ? UsrDat->Phone[1] : + " ", NULL,true,false); Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], UsrDat->StrBirthday[0] ? UsrDat->StrBirthday : @@ -3808,14 +3806,14 @@ static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) /***** Write the rest of the data of the student *****/ Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], - UsrDat->Phone1[0] ? (ShowData ? UsrDat->Phone1 : - "********") : - " ", + UsrDat->Phone[0][0] ? (ShowData ? UsrDat->Phone[0] : + "********") : + " ", NULL,true,UsrDat->Accepted); Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], - UsrDat->Phone2[0] ? (ShowData ? UsrDat->Phone2 : - "********") : - " ", + UsrDat->Phone[1][0] ? (ShowData ? UsrDat->Phone[1] : + "********") : + " ", NULL,true,UsrDat->Accepted); Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], UsrDat->StrBirthday[0] ? (ShowData ? UsrDat->StrBirthday : diff --git a/swad_user.h b/swad_user.h index 2a194846..379a05e1 100644 --- a/swad_user.h +++ b/swad_user.h @@ -194,8 +194,7 @@ struct UsrData long CtyCod; // Country struct Date Birthday; char StrBirthday [Cns_MAX_BYTES_DATE + 1]; - char Phone1 [Usr_MAX_BYTES_PHONE + 1]; - char Phone2 [Usr_MAX_BYTES_PHONE + 1]; + char Phone [2][Usr_MAX_BYTES_PHONE + 1]; char *Comments; long InsCtyCod; // Country of the institution long InsCod; // Institution