From 23ef5cb1bd2302d4b374fbf953ee2614d371d35e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Fri, 15 Nov 2019 10:48:20 +0100 Subject: [PATCH] Version19.69.1 --- swad_changelog.h | 3 ++- swad_project.c | 8 ++++++-- swad_timeline.c | 7 ++++--- swad_user.c | 48 ++++++++++++++++++++++++++---------------------- swad_user.h | 3 ++- 5 files changed, 40 insertions(+), 29 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 0693278ea..356a6118d 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -488,13 +488,14 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.69 (2019-11-15)" +#define Log_PLATFORM_VERSION "SWAD 19.69.1 (2019-11-15)" #define CSS_FILE "swad19.47.css" #define JS_FILE "swad19.65.js" /* // TODO: Hacer un nuevo rol en los TFG: tutor externo (profesor de áreas no vinculadas con el centro, profesionales de empresas, etc.) // TODO: Impedir la creación y edición de proyectos si no son editables. + Version 19.69.1: Nov 15, 2019 Fixed bugs in lists of users and hidden parameters. (246760 lines) Version 19.69: Nov 15, 2019 Code refactoring related with lists of users and hidden parameters. (246752 lines) Version 19.68.2: Nov 14, 2019 Code refactoring in users and attendance. (246625 lines) Version 19.68.1: Nov 14, 2019 Code refactoring in match results. diff --git a/swad_project.c b/swad_project.c index 2c4bff6c4..c751b46a1 100644 --- a/swad_project.c +++ b/swad_project.c @@ -2276,7 +2276,8 @@ static void Prj_ReqAddUsrs (Prj_RoleInProject_t RoleInProject) }; char TxtButton[Lay_MAX_BYTES_TITLE + 1]; - /***** Get project code *****/ + /***** Get parameters *****/ + Prj_GetParams (); if ((Gbl.Prjs.PrjCod = Prj_GetParamPrjCod ()) == -1L) Lay_ShowErrorAndExit ("Code of project is missing."); @@ -2351,7 +2352,7 @@ static void Prj_AddUsrsToProject (Prj_RoleInProject_t RoleInProject) Lay_ShowErrorAndExit ("Code of project is missing."); /***** Add the selected users to project *****/ - Ptr = Gbl.Usrs.Selected.List[Rol_UNK]; + Ptr = Prj_MembersToAdd.List[Rol_UNK]; while (*Ptr) { /* Get next user */ @@ -2383,6 +2384,9 @@ static void Prj_AddUsrsToProject (Prj_RoleInProject_t RoleInProject) } } + /***** Free memory used by lists of selected encrypted users' codes *****/ + Usr_FreeListsSelectedEncryptedUsrsCods (&Prj_MembersToAdd); + /***** Put form to edit project again *****/ Prj_RequestCreatOrEditPrj (PrjCod); } diff --git a/swad_timeline.c b/swad_timeline.c index 2f1354516..1a806601b 100644 --- a/swad_timeline.c +++ b/swad_timeline.c @@ -2618,14 +2618,15 @@ static void TL_WriteCommentsInNote (const struct TL_Note *SocNot) /***** Link to toggle on/off comments *****/ HTM_DIV_Begin ("id=\"con_%s\" class=\"TL_EXPAND_COM TL_RIGHT_WIDTH\"" - " style=\"display:none;\">", // Initially hidden + " style=\"display:none;\"", // Initially hidden IdComments); TL_PutIconToToggleComments (IdComments,"angle-down.svg", - Txt_See_only_the_latest_COMMENTS); + Txt_See_only_the_latest_COMMENTS); HTM_DIV_End (); /***** First list with comments initially hidden *****/ - HTM_UL_Begin ("id=\"com_%s\" class=\"LIST_LEFT\" style=\"display:none;\"", // Initially hidden + HTM_UL_Begin ("id=\"com_%s\" class=\"LIST_LEFT\"" + " style=\"display:none;\"", // Initially hidden IdComments); for (NumCom = 0; NumCom < NumCommentsInitiallyHidden; diff --git a/swad_user.c b/swad_user.c index 6804cf5f7..8fbb6085b 100644 --- a/swad_user.c +++ b/swad_user.c @@ -209,7 +209,7 @@ static void Usr_PutParamsConfirmIWantToSeeBigList (void); static void Usr_BuildParamName (char **ParamName, const char *ParamRoot, - struct SelectedUsrs *SelectedUsrs); + const char *ParamSuffix); static void Usr_AllocateListSelectedEncryptedUsrCods (struct SelectedUsrs *SelectedUsrs, Rol_Role_t Role); @@ -5722,7 +5722,7 @@ void Usr_PutHiddenParSelectedUsrsCods (struct SelectedUsrs *SelectedUsrs) /* Build name of the parameter. Sometimes a unique action needs several distinct lists of users, so, it's necessary to use distinct names for the parameters. */ - Usr_BuildParamName (&ParamName,Usr_ParamUsrCod[Rol_UNK],SelectedUsrs); + Usr_BuildParamName (&ParamName,Usr_ParamUsrCod[Rol_UNK],SelectedUsrs->ParamSuffix); /* Put the parameter *****/ if (Gbl.Session.IsOpen) @@ -5750,7 +5750,7 @@ void Usr_GetListsSelectedEncryptedUsrsCods (struct SelectedUsrs *SelectedUsrs) /***** Build name of the parameter. Sometimes a unique action needs several distinct lists of users, so, it's necessary to use distinct names for the parameters. *****/ - Usr_BuildParamName (&ParamName,Usr_ParamUsrCod[Rol_UNK],SelectedUsrs); + Usr_BuildParamName (&ParamName,Usr_ParamUsrCod[Rol_UNK],SelectedUsrs->ParamSuffix); /***** Get possible list of all selected users *****/ Usr_AllocateListSelectedEncryptedUsrCods (SelectedUsrs,Rol_UNK); @@ -5765,17 +5765,26 @@ void Usr_GetListsSelectedEncryptedUsrsCods (struct SelectedUsrs *SelectedUsrs) Par_GetParMultiToText (ParamName,SelectedUsrs->List[Rol_UNK], Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); + /***** Free allocated memory for parameter name *****/ + free (ParamName); + /***** Get list of selected users for each possible role *****/ for (Role = Rol_TCH; // From the highest possible role of selected users... Role >= Rol_GST; // ...downto the lowest possible role of selected users Role--) if (Usr_ParamUsrCod[Role]) { + /* Build name of the parameter */ + Usr_BuildParamName (&ParamName,Usr_ParamUsrCod[Role],SelectedUsrs->ParamSuffix); + /* Get parameter with selected users with this role */ Usr_AllocateListSelectedEncryptedUsrCods (SelectedUsrs,Role); - Par_GetParMultiToText (Usr_ParamUsrCod[Role],SelectedUsrs->List[Role], + Par_GetParMultiToText (ParamName,SelectedUsrs->List[Role], Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); + /* Free allocated memory for parameter name */ + free (ParamName); + /* Add selected users with this role to the list with all selected users */ if (SelectedUsrs->List[Role][0]) @@ -5792,9 +5801,6 @@ void Usr_GetListsSelectedEncryptedUsrsCods (struct SelectedUsrs *SelectedUsrs) } } - /***** Free allocated memory for parameter name *****/ - free (ParamName); - /***** List is filled *****/ SelectedUsrs->Filled = true; } @@ -5802,14 +5808,14 @@ void Usr_GetListsSelectedEncryptedUsrsCods (struct SelectedUsrs *SelectedUsrs) static void Usr_BuildParamName (char **ParamName, const char *ParamRoot, - struct SelectedUsrs *SelectedUsrs) + const char *ParamSuffix) { /* Build name of the parameter. Sometimes a unique action needs several distinct lists of users, so, it's necessary to use distinct names for the parameters. */ - if (SelectedUsrs->ParamSuffix) + if (ParamSuffix) { - if (asprintf (ParamName,"%s%s",ParamRoot,SelectedUsrs->ParamSuffix) < 0) + if (asprintf (ParamName,"%s%s",ParamRoot,ParamSuffix) < 0) Lay_NotEnoughMemoryExit (); } else @@ -5952,7 +5958,7 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs) Usr_GetUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS); // Really only EncryptedUsrCod is needed /* Find if encrypted user's code is already in list */ - if (!Usr_FindEncryptedUsrCodsInListOfSelectedEncryptedUsrCods (UsrDat.EncryptedUsrCod)) // If not in list ==> add it + if (!Usr_FindEncryptedUsrCodsInListOfSelectedEncryptedUsrCods (UsrDat.EncryptedUsrCod,&Gbl.Usrs.Selected)) // If not in list ==> add it { LengthUsrCod = strlen (UsrDat.EncryptedUsrCod); @@ -6001,16 +6007,17 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs) /*****************************************************************************/ /************** Find if encrypted user's code is yet in list *****************/ /*****************************************************************************/ -// Returns true if EncryptedUsrCodToFind is in Gbl.Usrs.Selected.List[Rol_UNK] +// Returns true if EncryptedUsrCodToFind is in list -bool Usr_FindEncryptedUsrCodsInListOfSelectedEncryptedUsrCods (const char *EncryptedUsrCodToFind) +bool Usr_FindEncryptedUsrCodsInListOfSelectedEncryptedUsrCods (const char *EncryptedUsrCodToFind, + struct SelectedUsrs *SelectedUsrs) { const char *Ptr; char EncryptedUsrCod[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1]; - if (Gbl.Usrs.Selected.List[Rol_UNK]) + if (SelectedUsrs->List[Rol_UNK]) { - Ptr = Gbl.Usrs.Selected.List[Rol_UNK]; + Ptr = SelectedUsrs->List[Rol_UNK]; while (*Ptr) { Par_GetNextStrUntilSeparParamMult (&Ptr,EncryptedUsrCod, @@ -6085,7 +6092,7 @@ static void Usr_AllocateListSelectedEncryptedUsrCods (struct SelectedUsrs *Selec } /*****************************************************************************/ -/*********** Free memory used by lists of selected users' codes **************/ +/******* Free memory used by lists of selected encrypted users' codes ********/ /*****************************************************************************/ // Role = Rol_UNK here means all users @@ -6411,9 +6418,6 @@ void Usr_GetSelectedUsrsAndGoToAct (struct SelectedUsrs *SelectedUsrs, /***** Get lists of the selected users if not already got *****/ Usr_GetListsSelectedEncryptedUsrsCods (SelectedUsrs); - Ale_ShowAlert (Ale_INFO,"DEBUG: SelectedUsrs->List[Rol_UNK] = %s;", - SelectedUsrs->List[Rol_UNK]); - Lay_ShowErrorAndExit ("DEBUG: Usr_GetSelectedUsrsAndGoToAct ()"); /***** Check number of users *****/ if (Usr_CheckIfThereAreUsrsInListOfSelectedEncryptedUsrCods (SelectedUsrs)) // If some users are selected... @@ -6474,7 +6478,7 @@ static void Usr_PutCheckboxToSelectAllUsers (Rol_Role_t Role, HTM_LABEL_Begin (NULL); if (Usr_NameSelUnsel[Role] && Usr_ParamUsrCod[Role]) { - Usr_BuildParamName (&ParamName,Usr_ParamUsrCod[Role],SelectedUsrs); + Usr_BuildParamName (&ParamName,Usr_ParamUsrCod[Role],SelectedUsrs->ParamSuffix); HTM_INPUT_CHECKBOX (Usr_NameSelUnsel[Role],false, "value=\"\" onclick=\"togglecheckChildren(this,'%s')\"", ParamName); @@ -6548,10 +6552,10 @@ static void Usr_PutCheckboxToSelectUser (Rol_Role_t Role, CheckboxChecked = true; else /* Check if user is in lists of selected users */ - CheckboxChecked = Usr_FindEncryptedUsrCodsInListOfSelectedEncryptedUsrCods (EncryptedUsrCod); + CheckboxChecked = Usr_FindEncryptedUsrCodsInListOfSelectedEncryptedUsrCods (EncryptedUsrCod,SelectedUsrs); /***** Check box *****/ - Usr_BuildParamName (&ParamName,Usr_ParamUsrCod[Role],SelectedUsrs); + Usr_BuildParamName (&ParamName,Usr_ParamUsrCod[Role],SelectedUsrs->ParamSuffix); HTM_INPUT_CHECKBOX (ParamName,false, "value=\"%s\"%s onclick=\"checkParent(this,'%s')\"", EncryptedUsrCod, diff --git a/swad_user.h b/swad_user.h index 8f1051b04..165848d87 100644 --- a/swad_user.h +++ b/swad_user.h @@ -443,7 +443,8 @@ void Usr_GetListsSelectedEncryptedUsrsCods (struct SelectedUsrs *SelectedUsrs); bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs); -bool Usr_FindEncryptedUsrCodsInListOfSelectedEncryptedUsrCods (const char *EncryptedUsrCodToFind); +bool Usr_FindEncryptedUsrCodsInListOfSelectedEncryptedUsrCods (const char *EncryptedUsrCodToFind, + struct SelectedUsrs *SelectedUsrs); bool Usr_CheckIfThereAreUsrsInListOfSelectedEncryptedUsrCods (struct SelectedUsrs *SelectedUsrs); unsigned Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods (struct SelectedUsrs *SelectedUsrs); void Usr_FreeListsSelectedEncryptedUsrsCods (struct SelectedUsrs *SelectedUsrs);