Version19.66.4

This commit is contained in:
Antonio Cañas Vargas 2019-11-13 21:31:06 +01:00
parent 9cd0ebed7f
commit 6e2bdbf4aa
14 changed files with 210 additions and 128 deletions

View File

@ -525,7 +525,7 @@ static void Asg_WriteAssignmentFolder (struct Assignment *Asg,bool PrintView)
break;
case Rol_NET:
case Rol_TCH:
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
break;
default:
break;

View File

@ -119,7 +119,9 @@ static void Att_PutLinkAttEvent (struct AttendanceEvent *AttEvent,
const char *LinkStyle);
static void Att_PutParamsCodGrps (long AttCod);
static void Att_GetNumStdsTotalWhoAreInAttEvent (struct AttendanceEvent *Att);
static unsigned Att_GetNumStdsFromAListWhoAreInAttEvent (long AttCod,long LstSelectedUsrCods[],unsigned NumUsrsInList);
static unsigned Att_GetNumUsrsFromAListWhoAreInAttEvent (long AttCod,
long LstSelectedUsrCods[],
unsigned NumUsrsInList);
static bool Att_CheckIfUsrIsInTableAttUsr (long AttCod,long UsrCod,bool *Present);
static bool Att_CheckIfUsrIsPresentInAttEvent (long AttCod,long UsrCod);
static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long UsrCod,
@ -2362,7 +2364,7 @@ void Att_RegisterStudentsInAttEvent (void)
/***** Free memory *****/
/* Free memory used by list of selected students' codes */
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
// 5. Delete from att_usr all the students marked as Remove=true
// 6. Replace (insert without duplicated) into att_usr all the students marked as Remove=false
@ -2432,43 +2434,24 @@ static void Att_GetNumStdsTotalWhoAreInAttEvent (struct AttendanceEvent *Att)
}
/*****************************************************************************/
/******* Get number of students from a list who attended to an event *********/
/********* Get number of users from a list who attended to an event **********/
/*****************************************************************************/
static unsigned Att_GetNumStdsFromAListWhoAreInAttEvent (long AttCod,long LstSelectedUsrCods[],unsigned NumUsrsInList)
static unsigned Att_GetNumUsrsFromAListWhoAreInAttEvent (long AttCod,
long LstSelectedUsrCods[],
unsigned NumUsrsInList)
{
char *SubQueryAllUsrs = NULL;
char SubQueryOneUsr[1 + Cns_MAX_DECIMAL_DIGITS_LONG + 1];
unsigned NumUsr;
unsigned NumStdsInAttEvent = 0;
size_t MaxLength;
char *SubQueryAllUsrs;
unsigned NumUsrsInAttEvent;
if (NumUsrsInList)
{
/***** Allocate space for subquery *****/
MaxLength = 256 + NumUsrsInList * (1 + Cns_MAX_DECIMAL_DIGITS_LONG);
if ((SubQueryAllUsrs = (char *) malloc (MaxLength + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
SubQueryAllUsrs[0] = '\0';
/***** Create subquery string *****/
Usr_CreateSubqueryUsrCods (LstSelectedUsrCods,NumUsrsInList,
&SubQueryAllUsrs);
/***** Count number of students registered in an event in database *****/
for (NumUsr = 0;
NumUsr < NumUsrsInList;
NumUsr++)
if (NumUsr)
{
snprintf (SubQueryOneUsr,sizeof (SubQueryOneUsr),
",%ld",
LstSelectedUsrCods[NumUsr]);
Str_Concat (SubQueryAllUsrs,SubQueryOneUsr,
MaxLength);
}
else
snprintf (SubQueryAllUsrs,sizeof (SubQueryOneUsr),
"%ld",
LstSelectedUsrCods[NumUsr]);
NumStdsInAttEvent =
/***** Get number of users in attendance event from database ****/
NumUsrsInAttEvent =
(unsigned) DB_QueryCOUNT ("can not get number of students"
" from a list who are registered in an event",
"SELECT COUNT(*) FROM att_usr"
@ -2477,9 +2460,12 @@ static unsigned Att_GetNumStdsFromAListWhoAreInAttEvent (long AttCod,long LstSel
AttCod,SubQueryAllUsrs);
/***** Free memory for subquery string *****/
free (SubQueryAllUsrs);
Usr_FreeSubqueryUsrCods (SubQueryAllUsrs);
}
return NumStdsInAttEvent;
else
NumUsrsInAttEvent = 0;
return NumUsrsInAttEvent;
}
/*****************************************************************************/
@ -2712,7 +2698,8 @@ static void Usr_ListOrPrintMyAttendanceCrs (Att_TypeOfView_t TypeOfView)
NumAttEvent < Gbl.AttEvents.Num;
NumAttEvent++)
/* Get number of students in this event */
Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList = Att_GetNumStdsFromAListWhoAreInAttEvent (Gbl.AttEvents.Lst[NumAttEvent].AttCod,
Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList =
Att_GetNumUsrsFromAListWhoAreInAttEvent (Gbl.AttEvents.Lst[NumAttEvent].AttCod,
&Gbl.Usrs.Me.UsrDat.UsrCod,1);
/***** Get list of attendance events selected *****/
@ -2782,7 +2769,7 @@ static void Usr_ListOrPrintUsrsAttendanceCrs (Att_TypeOfView_t TypeOfView)
Usr_GetListsSelectedUsrsCods ();
/* Check the number of students to list */
if ((NumUsrsInList = Usr_CountNumUsrsInListOfSelectedUsrs ()))
if ((NumUsrsInList = Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods ()))
{
/***** Get boolean parameter that indicates if details must be shown *****/
Gbl.AttEvents.ShowDetails = Par_GetParToBool ("ShowDetails");
@ -2798,7 +2785,8 @@ static void Usr_ListOrPrintUsrsAttendanceCrs (Att_TypeOfView_t TypeOfView)
NumAttEvent < Gbl.AttEvents.Num;
NumAttEvent++)
/* Get number of students in this event */
Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList = Att_GetNumStdsFromAListWhoAreInAttEvent (Gbl.AttEvents.Lst[NumAttEvent].AttCod,
Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList =
Att_GetNumUsrsFromAListWhoAreInAttEvent (Gbl.AttEvents.Lst[NumAttEvent].AttCod,
LstSelectedUsrCods,NumUsrsInList);
/***** Get list of attendance events selected *****/
@ -2844,7 +2832,7 @@ static void Usr_ListOrPrintUsrsAttendanceCrs (Att_TypeOfView_t TypeOfView)
}
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
/***** Free list of attendance events *****/
Att_FreeListAttEvents ();

View File

@ -487,7 +487,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 19.66.3 (2019-11-13)"
#define Log_PLATFORM_VERSION "SWAD 19.66.4 (2019-11-13)"
#define CSS_FILE "swad19.47.css"
#define JS_FILE "swad19.65.js"
/*
@ -496,7 +496,8 @@ ps2pdf source.ps destination.pdf
// TODO: Importante: filtrar proyectos por usuarios (igual que en trabajos o en asistencia)
// TODO: Code refactoring in HTML h1, title, meta, video, p, iframe, input hidden, area
Version 19.66.4: Nov 13, 2019 Filter projects by selected users. (? lines)
Version 19.66.5: Nov 13, 2019 Filter projects by selected users. (? lines)
Version 19.66.4: Nov 13, 2019 Code refactoring in list of users in attendance event. (246729 lines)
Version 19.66.3: Nov 13, 2019 Filter projects by selected users. Not finished. (246656 lines)
Version 19.66.2: Nov 13, 2019 Fixed bug in edition of test question. (246628 lines)
Version 19.66.1: Nov 13, 2019 Filter projects by selected users. Not finished. (246627 lines)

View File

@ -1103,7 +1103,7 @@ static void Fol_RequestFollowUsrs (Act_Action_t NextAction)
}
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
}
void Fol_RequestUnfollowStds (void)
@ -1147,7 +1147,7 @@ static void Fol_RequestUnfollowUsrs (Act_Action_t NextAction)
}
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
}
/*****************************************************************************/
@ -1239,7 +1239,7 @@ void Fol_FollowUsrs ()
Usr_UsrDataDestructor (&UsrDat);
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
/***** Show alert *****/
if (NumFollowed == 1)
@ -1286,7 +1286,7 @@ void Fol_UnfollowUsrs (void)
Usr_UsrDataDestructor (&UsrDat);
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
/***** Show alert *****/
if (NumUnfollowed == 1)

View File

@ -466,7 +466,7 @@ void Gbl_Cleanup (void)
Usr_FreeUsrsList (Role);
Usr_FreeListOtherRecipients ();
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
Syl_FreeListItemsSyllabus ();
Tst_FreeTagsList ();
Exa_FreeMemExamAnnouncement ();

View File

@ -250,7 +250,7 @@ void McR_SelUsrsToViewUsrsMchResults (void)
Usr_FreeUsrsList (Rol_STD);
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
/***** Free memory for list of selected groups *****/
Grp_FreeListCodSelectedGrps ();
@ -274,7 +274,7 @@ void McR_ShowUsrsMchResults (void)
Dat_GetIniEndDatesFromForm ();
/***** Check the number of users whose matches results will be shown *****/
if (Usr_CountNumUsrsInListOfSelectedUsrs ()) // If some users are selected...
if (Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods ()) // If some users are selected...
{
/***** Begin box and table *****/
Box_StartBoxTable (NULL,Txt_Results,NULL,
@ -308,7 +308,7 @@ void McR_ShowUsrsMchResults (void)
}
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
}
/*****************************************************************************/

View File

@ -350,7 +350,7 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
}
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
/***** Free memory for list of selected groups *****/
Grp_FreeListCodSelectedGrps ();
@ -728,7 +728,7 @@ void Msg_RecMsgFromUsr (void)
Error = Usr_GetListMsgRecipientsWrittenExplicitelyBySender (true);
/***** Check number of recipients *****/
if ((NumRecipients = Usr_CountNumUsrsInListOfSelectedUsrs ()))
if ((NumRecipients = Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods ()))
{
if (Gbl.Usrs.Me.Role.Logged == Rol_STD &&
NumRecipients > Cfg_MAX_RECIPIENTS)
@ -847,7 +847,7 @@ void Msg_RecMsgFromUsr (void)
/***** Free memory *****/
/* Free memory used for list of users */
Usr_FreeListOtherRecipients ();
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
/***** Update received message setting Replied field to true *****/
if (Replied)

View File

@ -125,7 +125,6 @@ struct Prj_Faults
/*****************************************************************************/
static void Prj_ReqListUsrsToSelect (void);
static void Prj_GetListSelectedUsrCods (unsigned NumUsrsInList,long **LstSelectedUsrCods);
static void Prj_ShowProjectsInCurrentPage (void);
@ -278,38 +277,6 @@ static void Prj_ReqListUsrsToSelect (void)
Txt_View_projects);
}
/*****************************************************************************/
/************* Get list of users selected to show their projects *************/
/*****************************************************************************/
static void Prj_GetListSelectedUsrCods (unsigned NumUsrsInList,long **LstSelectedUsrCods)
{
unsigned NumUsr;
const char *Ptr;
struct UsrData UsrDat;
/***** Create list of user codes *****/
if ((*LstSelectedUsrCods = (long *) calloc ((size_t) NumUsrsInList,sizeof (long))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** Loop over the list Gbl.Usrs.Selected.List[Rol_UNK] getting users' codes *****/
for (NumUsr = 0, Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
NumUsr < NumUsrsInList && *Ptr;
NumUsr++)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
(*LstSelectedUsrCods)[NumUsr] = UsrDat.UsrCod;
}
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
/*****************************************************************************/
/********************** Show selected projects in a table ********************/
/*****************************************************************************/
@ -2691,13 +2658,11 @@ static void Prj_GetListProjects (void)
/***** Get list of selected users' codes if not already got *****/
Usr_GetListsSelectedUsrsCods ();
NumUsrsInList = Usr_CountNumUsrsInListOfSelectedUsrs ();
NumUsrsInList = Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods ();
/***** Get list of users selected to show their projects *****/
if (NumUsrsInList)
Prj_GetListSelectedUsrCods (NumUsrsInList,&LstSelectedUsrCods);
// TODO: Filter by selected users if any
Usr_GetListSelectedUsrCods (NumUsrsInList,&LstSelectedUsrCods);
/***** Get list of projects from database *****/
if (Gbl.Prjs.LstIsRead)
@ -2808,6 +2773,41 @@ static void Prj_GetListProjects (void)
}
break;
case Usr_WHO_SELECTED:
switch (Gbl.Prjs.SelectedOrder)
{
case Prj_ORDER_START_TIME:
case Prj_ORDER_END_TIME:
case Prj_ORDER_TITLE:
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
"SELECT projects.PrjCod"
" FROM projects,prj_usr"
" WHERE projects.CrsCod=%ld"
"%s%s%s"
" AND projects.PrjCod=prj_usr.PrjCod"
" AND prj_usr.UsrCod=%ld"
" ORDER BY %s",
Gbl.Hierarchy.Crs.CrsCod,
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
Gbl.Usrs.Me.UsrDat.UsrCod,
OrderBySubQuery[Gbl.Prjs.SelectedOrder]);
break;
case Prj_ORDER_DEPARTMENT:
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
"SELECT projects.PrjCod"
" FROM prj_usr,projects LEFT JOIN departments"
" ON projects.DptCod=departments.DptCod"
" WHERE projects.CrsCod=%ld"
"%s%s%s"
" AND projects.PrjCod=prj_usr.PrjCod"
" AND prj_usr.UsrCod=%ld"
" ORDER BY %s",
Gbl.Hierarchy.Crs.CrsCod,
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
Gbl.Usrs.Me.UsrDat.UsrCod,
OrderBySubQuery[Gbl.Prjs.SelectedOrder]);
break;
}
break;
case Usr_WHO_ALL:
switch (Gbl.Prjs.SelectedOrder)
{
@ -2894,10 +2894,10 @@ static void Prj_GetListProjects (void)
/***** Free list of user codes *****/
if (NumUsrsInList)
free (LstSelectedUsrCods);
Usr_FreeListSelectedUsrCods (LstSelectedUsrCods);
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
}
/*****************************************************************************/

View File

@ -1035,7 +1035,7 @@ static void Rec_ListRecordsGsts (Rec_SharedRecordViewType_t TypeOfView)
Usr_UsrDataDestructor (&UsrDat);
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
}
/*****************************************************************************/
@ -1080,7 +1080,7 @@ static void Rec_ShowRecordOneStdCrs (void)
Frm_StartForm (ActPrnRecSevStd);
Usr_CreateListSelectedUsrsCodsAndFillWithOtherUsr ();
Usr_PutHiddenParSelectedUsrsCods ();
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
Rec_ShowLinkToPrintPreviewOfRecords ();
Frm_EndForm ();
@ -1259,7 +1259,7 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
Rec_FreeListFields ();
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
}
/*****************************************************************************/
@ -1312,7 +1312,7 @@ static void Rec_ShowRecordOneTchCrs (void)
Frm_StartForm (ActPrnRecSevTch);
Usr_CreateListSelectedUsrsCodsAndFillWithOtherUsr ();
Usr_PutHiddenParSelectedUsrsCods ();
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
Par_PutHiddenParamChar ("ShowOfficeHours",ShowOfficeHours ? 'Y' :
'N');
@ -1474,7 +1474,7 @@ static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView)
Usr_UsrDataDestructor (&UsrDat);
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
}
/*****************************************************************************/

View File

@ -916,11 +916,11 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
HTM_SECTION_Begin (Sta_STAT_RESULTS_SECTION_ID);
/***** Check selection *****/
if (!Usr_CountNumUsrsInListOfSelectedUsrs ()) // Error: there are no users selected
if (!Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods ()) // Error: there are no users selected
{
/* Write warning message, clean and abort */
Ale_ShowAlert (Ale_WARNING,Txt_You_must_select_one_ore_more_users);
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
return;
}
break;
@ -1495,7 +1495,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
/***** Free memory used by list of selected users' codes *****/
if (Gbl.Action.Act == ActSeeAccCrs)
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
/***** Write time zone used in the calculation of these statistics *****/
switch (Gbl.Stat.ClicksGroupedBy)

View File

@ -7532,7 +7532,7 @@ void Tst_SelUsrsToViewUsrsTstResults (void)
Usr_FreeUsrsList (Rol_STD);
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
/***** Free memory for list of selected groups *****/
Grp_FreeListCodSelectedGrps ();
@ -7646,7 +7646,7 @@ void Tst_ShowUsrsTstResults (void)
Dat_GetIniEndDatesFromForm ();
/***** Check the number of users whose tests results will be shown *****/
if (Usr_CountNumUsrsInListOfSelectedUsrs ()) // If some users are selected...
if (Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods ()) // If some users are selected...
{
/***** Begin box and table *****/
Box_StartBoxTable (NULL,Txt_Results,NULL,
@ -7680,7 +7680,7 @@ void Tst_ShowUsrsTstResults (void)
}
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
}
/*****************************************************************************/

View File

@ -205,7 +205,7 @@ static void Usr_PutButtonToConfirmIWantToSeeBigList (unsigned NumUsrs,
const char *OnSubmit);
static void Usr_PutParamsConfirmIWantToSeeBigList (void);
static void Usr_AllocateListSelectedUsrCod (Rol_Role_t Role);
static void Usr_AllocateListSelectedEncryptedUsrCods (Rol_Role_t Role);
static void Usr_AllocateListOtherRecipients (void);
static void Usr_FormToSelectUsrListType (void (*FuncParams) (void),
@ -5723,7 +5723,7 @@ void Usr_GetListsSelectedUsrsCods (void)
if (!Gbl.Usrs.Selected.Filled) // Get list only if not already got
{
/***** Get possible list of all selected users *****/
Usr_AllocateListSelectedUsrCod (Rol_UNK);
Usr_AllocateListSelectedEncryptedUsrCods (Rol_UNK);
if (Gbl.Session.IsOpen) // If the session is open, get parameter from DB
{
Ses_GetHiddenParFromDB (Usr_ParamUsrCod[Rol_UNK],Gbl.Usrs.Selected.List[Rol_UNK],
@ -5742,7 +5742,7 @@ void Usr_GetListsSelectedUsrsCods (void)
if (Usr_ParamUsrCod[Role])
{
/* Get parameter with selected users with this role */
Usr_AllocateListSelectedUsrCod (Role);
Usr_AllocateListSelectedEncryptedUsrCods (Role);
Par_GetParMultiToText (Usr_ParamUsrCod[Role],Gbl.Usrs.Selected.List[Role],
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS);
@ -5900,7 +5900,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_FindUsrCodInListOfSelectedUsrs (UsrDat.EncryptedUsrCod)) // If not in list ==> add it
if (!Usr_FindEncryptedUsrCodsInListOfSelectedEncryptedUsrCods (UsrDat.EncryptedUsrCod)) // If not in list ==> add it
{
LengthUsrCod = strlen (UsrDat.EncryptedUsrCod);
@ -5951,7 +5951,7 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs)
/*****************************************************************************/
// Returns true if EncryptedUsrCodToFind is in Gbl.Usrs.Selected.List[Rol_UNK]
bool Usr_FindUsrCodInListOfSelectedUsrs (const char *EncryptedUsrCodToFind)
bool Usr_FindEncryptedUsrCodsInListOfSelectedEncryptedUsrCods (const char *EncryptedUsrCodToFind)
{
const char *Ptr;
char EncryptedUsrCod[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1];
@ -5974,7 +5974,7 @@ bool Usr_FindUsrCodInListOfSelectedUsrs (const char *EncryptedUsrCodToFind)
/************ Count number of valid users' IDs in encrypted list *************/
/*****************************************************************************/
unsigned Usr_CountNumUsrsInListOfSelectedUsrs (void)
unsigned Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods (void)
{
const char *Ptr;
unsigned NumUsrs = 0;
@ -5998,7 +5998,7 @@ unsigned Usr_CountNumUsrsInListOfSelectedUsrs (void)
/*****************************************************************************/
// Role = Rol_UNK here means all users
static void Usr_AllocateListSelectedUsrCod (Rol_Role_t Role)
static void Usr_AllocateListSelectedEncryptedUsrCods (Rol_Role_t Role)
{
if (!Gbl.Usrs.Selected.List[Role])
{
@ -6013,7 +6013,7 @@ static void Usr_AllocateListSelectedUsrCod (Rol_Role_t Role)
/*****************************************************************************/
// Role = Rol_UNK here means all users
void Usr_FreeListsSelectedUsrsCods (void)
void Usr_FreeListsSelectedEncryptedUsrsCods (void)
{
Rol_Role_t Role;
@ -6036,6 +6036,89 @@ void Usr_FreeListsSelectedUsrsCods (void)
}
}
/*****************************************************************************/
/************* Get list of users selected to show their projects *************/
/*****************************************************************************/
void Usr_GetListSelectedUsrCods (unsigned NumUsrsInList,long **LstSelectedUsrCods)
{
unsigned NumUsr;
const char *Ptr;
struct UsrData UsrDat;
/***** Create list of user codes *****/
if ((*LstSelectedUsrCods = (long *) calloc ((size_t) NumUsrsInList,sizeof (long))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** Loop over the list Gbl.Usrs.Selected.List[Rol_UNK] getting users' codes *****/
for (NumUsr = 0, Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
NumUsr < NumUsrsInList && *Ptr;
NumUsr++)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
(*LstSelectedUsrCods)[NumUsr] = UsrDat.UsrCod;
}
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
void Usr_FreeListSelectedUsrCods (long *LstSelectedUsrCods)
{
if (LstSelectedUsrCods)
free (LstSelectedUsrCods);
}
/*****************************************************************************/
/******** Create subquery string with users' codes separated by commas *******/
/******** from list of users' codes *******/
/*****************************************************************************/
void Usr_CreateSubqueryUsrCods (long LstSelectedUsrCods[],
unsigned NumUsrsInList,
char **SubQueryAllUsrs)
{
char SubQueryOneUsr[1 + Cns_MAX_DECIMAL_DIGITS_LONG + 1];
unsigned NumUsr;
size_t MaxLength;
if (NumUsrsInList)
{
/***** Allocate space for subquery *****/
MaxLength = NumUsrsInList * (1 + Cns_MAX_DECIMAL_DIGITS_LONG);
if ((*SubQueryAllUsrs = (char *) malloc (MaxLength + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
(*SubQueryAllUsrs)[0] = '\0';
/***** Count number of students registered in an event in database *****/
for (NumUsr = 0;
NumUsr < NumUsrsInList;
NumUsr++)
if (NumUsr)
{
snprintf (SubQueryOneUsr,sizeof (SubQueryOneUsr),
",%ld",
LstSelectedUsrCods[NumUsr]);
Str_Concat (*SubQueryAllUsrs,SubQueryOneUsr,
MaxLength);
}
else
snprintf (*SubQueryAllUsrs,sizeof (SubQueryOneUsr),
"%ld",
LstSelectedUsrCods[NumUsr]);
}
}
void Usr_FreeSubqueryUsrCods (char *SubQueryAllUsrs)
{
free (SubQueryAllUsrs);
}
/*****************************************************************************/
/********** Allocate memory for list of users's IDs or nicknames *************/
/*****************************************************************************/
@ -6254,7 +6337,7 @@ void Usr_GetSelectedUsrsAndGoToAct (void (*FuncWhenUsrsSelected) (),
Usr_GetListsSelectedUsrsCods ();
/***** Check number of users *****/
if (Usr_CountNumUsrsInListOfSelectedUsrs ()) // If some users are selected...
if (Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods ()) // If some users are selected...
FuncWhenUsrsSelected ();
else // If no users are selected...
{
@ -6265,7 +6348,7 @@ void Usr_GetSelectedUsrsAndGoToAct (void (*FuncWhenUsrsSelected) (),
}
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
Usr_FreeListsSelectedEncryptedUsrsCods ();
}
/*****************************************************************************/
@ -6378,7 +6461,7 @@ static void Usr_PutCheckboxToSelectUser (Rol_Role_t Role,
CheckboxChecked = true;
else
/* Check if user is in lists of selected users */
CheckboxChecked = Usr_FindUsrCodInListOfSelectedUsrs (EncryptedUsrCod);
CheckboxChecked = Usr_FindEncryptedUsrCodsInListOfSelectedEncryptedUsrCods (EncryptedUsrCod);
/***** Check box *****/
HTM_INPUT_CHECKBOX (Usr_ParamUsrCod[Role],false,
@ -8371,7 +8454,7 @@ void Usr_DoActionOnSeveralUsrs1 (void)
Usr_GetListsSelectedUsrsCods ();
/* Check the number of users */
if (!Usr_CountNumUsrsInListOfSelectedUsrs ())// If no users selected...
if (!Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods ())// If no users selected...
{ // ...write warning notice
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_must_select_one_ore_more_users);

View File

@ -432,9 +432,19 @@ void Usr_PutHiddenParSelectedUsrsCods (void);
void Usr_CreateListSelectedUsrsCodsAndFillWithOtherUsr (void);
void Usr_GetListsSelectedUsrsCods (void);
bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs);
bool Usr_FindUsrCodInListOfSelectedUsrs (const char *EncryptedUsrCodToFind);
unsigned Usr_CountNumUsrsInListOfSelectedUsrs (void);
void Usr_FreeListsSelectedUsrsCods (void);
bool Usr_FindEncryptedUsrCodsInListOfSelectedEncryptedUsrCods (const char *EncryptedUsrCodToFind);
unsigned Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods (void);
void Usr_FreeListsSelectedEncryptedUsrsCods (void);
void Usr_GetListSelectedUsrCods (unsigned NumUsrsInList,long **LstSelectedUsrCods);
void Usr_FreeListSelectedUsrCods (long *LstSelectedUsrCods);
void Usr_CreateSubqueryUsrCods (long LstSelectedUsrCods[],
unsigned NumUsrsInList,
char **SubQueryAllUsrs);
void Usr_FreeSubqueryUsrCods (char *SubQueryAllUsrs);
void Usr_FreeListOtherRecipients (void);
void Usr_ShowFormsToSelectUsrListType (void (*FuncParams) (void));