diff --git a/swad_ID.c b/swad_ID.c index aa65630a..8a898239 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -54,12 +54,6 @@ extern struct Globals Gbl; /******************************* Private types *******************************/ /*****************************************************************************/ -typedef enum - { - ID_REQUEST_CONFIRM_ID, - ID_CONFIRM_ID, - } ID_ReqConfOrConfID_t; - /*****************************************************************************/ /***************************** Private variables *****************************/ /*****************************************************************************/ @@ -70,9 +64,8 @@ typedef enum static bool ID_CheckIfUsrIDIsValidUsingMinDigits (const char *UsrID,unsigned MinDigits); -static void ID_PutLinkToReqConfirmID (struct UsrData *UsrDat,unsigned NumID); -static void ID_PutButtonToConfirmID (unsigned NumID); -static void ID_PutParamsConfirmID (void); +static void ID_PutLinkToConfirmID (struct UsrData *UsrDat,unsigned NumID, + const char *Anchor); static void ID_RemoveUsrID (const struct UsrData *UsrDat,bool ItsMe); static bool ID_CheckIfConfirmed (long UsrCod,const char *UsrID); @@ -80,8 +73,6 @@ static void ID_RemoveUsrIDFromDB (long UsrCod,const char *UsrID); static void ID_NewUsrID (const struct UsrData *UsrDat,bool ItsMe); static void ID_InsertANewUsrIDInDB (long UsrCod,const char *NewID,bool Confirmed); -static void ID_ReqConfOrConfOtherUsrID (ID_ReqConfOrConfID_t ReqConfOrConfID); - /*****************************************************************************/ /********************** Get list of IDs of a user ****************************/ /*****************************************************************************/ @@ -368,7 +359,7 @@ static bool ID_CheckIfUsrIDIsValidUsingMinDigits (const char *UsrID,unsigned Min /*************************** Write list of user's ID *************************/ /*****************************************************************************/ -void ID_WriteUsrIDs (struct UsrData *UsrDat) +void ID_WriteUsrIDs (struct UsrData *UsrDat,const char *Anchor) { extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; unsigned NumID; @@ -399,7 +390,7 @@ void ID_WriteUsrIDs (struct UsrData *UsrDat) if (ICanConfirmUsrID && !UsrDat->IDs.List[NumID].Confirmed) - ID_PutLinkToReqConfirmID (UsrDat,NumID); + ID_PutLinkToConfirmID (UsrDat,NumID,Anchor); } } @@ -448,55 +439,49 @@ bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat) } /*****************************************************************************/ -/******** Put a link to request the confirmation of another user's ID ********/ +/****************** Put a link to confirm of another user's ID ***************/ /*****************************************************************************/ -static void ID_PutLinkToReqConfirmID (struct UsrData *UsrDat,unsigned NumID) +static void ID_PutLinkToConfirmID (struct UsrData *UsrDat,unsigned NumID, + const char *Anchor) { + extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; extern const char *The_ClassFormBold[The_NUM_THEMES]; extern const char *Txt_Confirm_ID; - Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ? ActReqCnfID_Std : - (UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ActReqCnfID_Tch : - ActReqCnfID_Oth)); // Guest, visitor or admin + /***** Start form *****/ + Act_FormStartAnchor ( UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ? ActCnfID_Std : + (UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ActCnfID_Tch : + ActCnfID_Oth), + Anchor); + if (Gbl.Action.Original != ActUnk) + { + Par_PutHiddenParamLong ("OriginalActCod",Act_Actions[Gbl.Action.Original].ActCod); // Original action, used to know where we came from + switch (Gbl.Action.Original) + { + case ActSeeRecSevGst: + Usr_PutHiddenParUsrCodAll (ActCnfID_Oth,Gbl.Usrs.Select.All); + break; + case ActSeeRecSevStd: + Usr_PutHiddenParUsrCodAll (ActCnfID_Std,Gbl.Usrs.Select.All); + break; + case ActSeeRecSevTch: + Usr_PutHiddenParUsrCodAll (ActCnfID_Tch,Gbl.Usrs.Select.All); + break; + } + } Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); fprintf (Gbl.F.Out,"", UsrDat->IDs.List[NumID].ID); + + /***** Put link *****/ Lay_PutIconLink ("ok_on16x16.gif",Txt_Confirm_ID,Txt_Confirm_ID, The_ClassFormBold[Gbl.Prefs.Theme],NULL); + + /***** End form *****/ Act_FormEnd (); } -/*****************************************************************************/ -/**************** Put a button to confirm another user's ID ******************/ -/*****************************************************************************/ - -static void ID_PutButtonToConfirmID (unsigned NumID) - { - extern const char *Txt_Do_you_want_to_confirm_the_ID_X; - extern const char *Txt_Confirm_ID; - - Gbl.Usrs.Other.NumIDToConfirm = NumID; - - /***** Ask for confirmation *****/ - sprintf (Gbl.Title,Txt_Do_you_want_to_confirm_the_ID_X, - Gbl.Usrs.Other.UsrDat.IDs.List[NumID].ID); - Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Title); - Lay_ShowAlertAndButton2 ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT ? ActCnfID_Std : - (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TEACHER ? ActCnfID_Tch : - ActCnfID_Oth), // Guest, visitor or admin - NULL, - ID_PutParamsConfirmID, - Lay_CREATE_BUTTON,Txt_Confirm_ID); - } - -static void ID_PutParamsConfirmID (void) - { - Usr_PutParamOtherUsrCodEncrypted (); - fprintf (Gbl.F.Out,"", - Gbl.Usrs.Other.UsrDat.IDs.List[Gbl.Usrs.Other.NumIDToConfirm].ID); - } - /*****************************************************************************/ /*********** Put a link to the action used to request user's IDs *************/ /*****************************************************************************/ @@ -539,7 +524,8 @@ void ID_ShowFormOthIDs (void) Lay_StartRoundFrame (NULL,Txt_ID,NULL,NULL); /***** Show user's record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST, + &Gbl.Usrs.Other.UsrDat,NULL); /***** Form with the user's ID *****/ Lay_StartTableWide (2); @@ -719,7 +705,8 @@ void ID_RemoveOtherUsrID (void) ID_GetListIDsFromUsrCod (&Gbl.Usrs.Other.UsrDat); /***** Show user's record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST, + &Gbl.Usrs.Other.UsrDat,NULL); } else // User not found Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); @@ -834,7 +821,8 @@ void ID_NewOtherUsrID (void) ID_GetListIDsFromUsrCod (&Gbl.Usrs.Other.UsrDat); /***** Show user's record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST, + &Gbl.Usrs.Other.UsrDat,NULL); } else // User not found Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); @@ -945,39 +933,29 @@ static void ID_InsertANewUsrIDInDB (long UsrCod,const char *NewID,bool Confirmed DB_QueryINSERT (Query,"can not insert a new ID"); } -/*****************************************************************************/ -/*************** Request the confirmation of another user's ID ***************/ -/*****************************************************************************/ - -void ID_RequestConfirmOtherUsrID (void) - { - ID_ReqConfOrConfOtherUsrID (ID_REQUEST_CONFIRM_ID); - } - /*****************************************************************************/ /************************ Confirm another user's ID **************************/ /*****************************************************************************/ void ID_ConfirmOtherUsrID (void) - { - ID_ReqConfOrConfOtherUsrID (ID_CONFIRM_ID); - } - -/*****************************************************************************/ -/********** Request the confirmation or confirm another user's ID ************/ -/*****************************************************************************/ - -static void ID_ReqConfOrConfOtherUsrID (ID_ReqConfOrConfID_t ReqConfOrConfID) { extern const char *Txt_ID_X_had_already_been_confirmed; extern const char *Txt_The_ID_X_has_been_confirmed; extern const char *Txt_User_not_found_or_you_do_not_have_permission_; + long OriginalActCod; char UsrID[ID_MAX_BYTES_USR_ID + 1]; bool ICanConfirm; bool Found; unsigned NumID; unsigned NumIDFound = 0; // Initialized to avoid warning + /***** Initialize alert type and message *****/ + Gbl.AlertType = Lay_NONE; // Do not show alert + + /***** Get where we came from *****/ + OriginalActCod = Par_GetParToLong ("OriginalActCod"); + Gbl.Action.Original = Act_GetActionFromActCod (OriginalActCod); + /***** Get other user's code from form and get user's data *****/ ICanConfirm = false; if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) @@ -1007,40 +985,59 @@ static void ID_ReqConfOrConfOtherUsrID (ID_ReqConfOrConfID_t ReqConfOrConfID) if (Gbl.Usrs.Other.UsrDat.IDs.List[NumIDFound].Confirmed) { /***** ID found and already confirmed *****/ + Gbl.AlertType = Lay_INFO; sprintf (Gbl.Message,Txt_ID_X_had_already_been_confirmed, Gbl.Usrs.Other.UsrDat.IDs.List[NumIDFound].ID); - Lay_ShowAlert (Lay_INFO,Gbl.Message); } else { - switch (ReqConfOrConfID) - { - case ID_REQUEST_CONFIRM_ID: // Ask if confirm ID - /***** Put button to confirm ID *****/ - ID_PutButtonToConfirmID (NumIDFound); - break; - case ID_CONFIRM_ID: // Confirm ID - /***** Mark this ID as confirmed *****/ - ID_ConfirmUsrID (&Gbl.Usrs.Other.UsrDat, - Gbl.Usrs.Other.UsrDat.IDs.List[NumIDFound].ID); - Gbl.Usrs.Other.UsrDat.IDs.List[NumIDFound].Confirmed = true; + /***** Mark this ID as confirmed *****/ + ID_ConfirmUsrID (&Gbl.Usrs.Other.UsrDat, + Gbl.Usrs.Other.UsrDat.IDs.List[NumIDFound].ID); + Gbl.Usrs.Other.UsrDat.IDs.List[NumIDFound].Confirmed = true; - /***** Write success message *****/ - sprintf (Gbl.Message,Txt_The_ID_X_has_been_confirmed, - Gbl.Usrs.Other.UsrDat.IDs.List[NumIDFound].ID); - Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); - break; - } + /***** Write success message *****/ + Gbl.AlertType = Lay_SUCCESS; + sprintf (Gbl.Message,Txt_The_ID_X_has_been_confirmed, + Gbl.Usrs.Other.UsrDat.IDs.List[NumIDFound].ID); } } else // User's ID not found - Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); - - /***** Show user's record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat); + { + Gbl.AlertType = Lay_WARNING; + sprintf (Gbl.Message,"%s",Txt_User_not_found_or_you_do_not_have_permission_); + } + } + else // I can not confirm + { + Gbl.AlertType = Lay_WARNING; + sprintf (Gbl.Message,"%s",Txt_User_not_found_or_you_do_not_have_permission_); + } + + /***** Show one or multiple records *****/ + switch (Gbl.Action.Original) + { + case ActSeeRecSevGst: + /* Show multiple records of guests again (including the updated one) */ + Rec_ListRecordsGstsShow (); + break; + case ActSeeRecSevStd: + /* Show multiple records of students again (including the updated one) */ + Rec_ListRecordsStdsShow (); + break; + case ActSeeRecSevTch: + /* Show multiple records of teachers again (including the updated one) */ + Rec_ListRecordsTchsShow (); + break; + default: + /* Show optional alert */ + Lay_ShowPendingAlert (); + + /* Show only the updated record of this user */ + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST, + &Gbl.Usrs.Other.UsrDat,NULL); + break; } - else // User not found - Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } /*****************************************************************************/ diff --git a/swad_ID.h b/swad_ID.h index 986a2d93..f0e0b389 100644 --- a/swad_ID.h +++ b/swad_ID.h @@ -69,7 +69,7 @@ void ID_GetParamOtherUsrIDPlain (void); bool ID_CheckIfUsrIDIsValid (const char *UsrID); bool ID_CheckIfUsrIDSeemsAValidID (const char *UsrID); -void ID_WriteUsrIDs (struct UsrData *UsrDat); +void ID_WriteUsrIDs (struct UsrData *UsrDat,const char *Anchor); bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat); void ID_PutLinkToChangeUsrIDs (void); @@ -80,7 +80,6 @@ void ID_RemoveOtherUsrID (void); void ID_NewMyUsrID (void); void ID_NewOtherUsrID (void); -void ID_RequestConfirmOtherUsrID (void); void ID_ConfirmOtherUsrID (void); void ID_ConfirmUsrID (const struct UsrData *UsrDat,const char *UsrID); diff --git a/swad_action.c b/swad_action.c index 701030b2..25c1c165 100644 --- a/swad_action.c +++ b/swad_action.c @@ -1079,9 +1079,6 @@ Users: 884. ActRcvFrmEnrSevStd Receive a form with IDs of users to be registeres/removed to/from current course 885. ActRcvFrmEnrSevTch Receive a form with IDs of users to be registeres/removed to/from current course - 886. ActReqCnfID_Oth Request the confirmation of another user's ID - 887. ActReqCnfID_Std Request the confirmation of another user's ID - 888. ActReqCnfID_Tch Request the confirmation of another user's ID 889. ActCnfID_Oth Confirm another user's ID 890. ActCnfID_Std Confirm another user's ID 891. ActCnfID_Tch Confirm another user's ID @@ -2453,12 +2450,12 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActSeeRecOneStd */{1174,-1,TabUnk,ActLstStd ,0x118,0x100, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_GetUsrAndShowRecordOneStdCrs,NULL}, /* ActSeeRecOneTch */{1175,-1,TabUnk,ActLstTch ,0x1FC,0x1FC,0x1FC,0x1FC,0x1FC,0x1FC,0x1FC,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_GetUsrAndShowRecordOneTchCrs,NULL}, - /* ActSeeRecSevGst */{1187,-1,TabUnk,ActLstOth ,0x100,0x100,0x100,0x100,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_ListRecordsGsts ,NULL}, - /* ActSeeRecSevStd */{ 89,-1,TabUnk,ActLstStd ,0x118,0x100, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_ListRecordsStdsForEdit ,NULL}, - /* ActSeeRecSevTch */{ 22,-1,TabUnk,ActLstTch ,0x1FF,0x1FF, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_ListRecordsTchs ,NULL}, - /* ActPrnRecSevGst */{1188,-1,TabUnk,ActLstOth ,0x100,0x100,0x100,0x100,0x100,0x100,0x100,Act_CONT_NORM,Act_BLNK_WINDOW,NULL ,Rec_ListRecordsGsts ,NULL}, - /* ActPrnRecSevStd */{ 111,-1,TabUnk,ActLstStd ,0x118,0x100, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BLNK_WINDOW,NULL ,Rec_ListRecordsStdsForPrint ,NULL}, - /* ActPrnRecSevTch */{ 127,-1,TabUnk,ActLstTch ,0x1FF,0x1FF, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BLNK_WINDOW,NULL ,Rec_ListRecordsTchs ,NULL}, + /* ActSeeRecSevGst */{1187,-1,TabUnk,ActLstOth ,0x100,0x100,0x100,0x100,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_ListRecordsGstsShow ,NULL}, + /* ActSeeRecSevStd */{ 89,-1,TabUnk,ActLstStd ,0x118,0x100, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_ListRecordsStdsShow ,NULL}, + /* ActSeeRecSevTch */{ 22,-1,TabUnk,ActLstTch ,0x1FF,0x1FF, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_ListRecordsTchsShow ,NULL}, + /* ActPrnRecSevGst */{1188,-1,TabUnk,ActLstOth ,0x100,0x100,0x100,0x100,0x100,0x100,0x100,Act_CONT_NORM,Act_BLNK_WINDOW,NULL ,Rec_ListRecordsGstsPrint ,NULL}, + /* ActPrnRecSevStd */{ 111,-1,TabUnk,ActLstStd ,0x118,0x100, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BLNK_WINDOW,NULL ,Rec_ListRecordsStdsPrint ,NULL}, + /* ActPrnRecSevTch */{ 127,-1,TabUnk,ActLstTch ,0x1FF,0x1FF, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BLNK_WINDOW,NULL ,Rec_ListRecordsTchsPrint ,NULL}, /* ActRcvRecOthUsr */{ 300,-1,TabUnk,ActLstStd ,0x110,0x100, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_UpdateAndShowOtherCrsRecord,NULL}, /* ActEdiRecFie */{ 292,-1,TabUnk,ActLstStd ,0x110,0x100, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_ReqEditRecordFields ,NULL}, @@ -2554,9 +2551,6 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActRcvFrmEnrSevStd*/{1428,-1,TabUnk,ActLstStd ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Enr_ReceiveFormAdminStds ,NULL}, /* ActRcvFrmEnrSevTch*/{1429,-1,TabUnk,ActLstTch ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Enr_ReceiveFormAdminTchs ,NULL}, - /* ActReqCnfID_Oth */{1565,-1,TabUnk,ActLstOth ,0x1F0,0x1E0,0x1E0,0x1E0,0x1E0,0x1E0,0x1E0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,ID_RequestConfirmOtherUsrID ,NULL}, - /* ActReqCnfID_Std */{1566,-1,TabUnk,ActLstStd ,0x1F0,0x1E0,0x1E0,0x1E0,0x1E0,0x1E0,0x1E0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,ID_RequestConfirmOtherUsrID ,NULL}, - /* ActReqCnfID_Tch */{1567,-1,TabUnk,ActLstTch ,0x1F0,0x1E0,0x1E0,0x1E0,0x1E0,0x1E0,0x1E0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,ID_RequestConfirmOtherUsrID ,NULL}, /* ActCnfID_Oth */{1568,-1,TabUnk,ActLstOth ,0x1F0,0x1E0,0x1E0,0x1E0,0x1E0,0x1E0,0x1E0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,ID_ConfirmOtherUsrID ,NULL}, /* ActCnfID_Std */{1569,-1,TabUnk,ActLstStd ,0x1F0,0x1E0,0x1E0,0x1E0,0x1E0,0x1E0,0x1E0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,ID_ConfirmOtherUsrID ,NULL}, /* ActCnfID_Tch */{1570,-1,TabUnk,ActLstTch ,0x1F0,0x1E0,0x1E0,0x1E0,0x1E0,0x1E0,0x1E0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,ID_ConfirmOtherUsrID ,NULL}, @@ -4555,9 +4549,9 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un ActReqDatTchGrp, // #1562 ActChgDatTchGrp, // #1563 ActDowTchGrp, // #1564 - ActReqCnfID_Oth, // #1565 - ActReqCnfID_Std, // #1566 - ActReqCnfID_Tch, // #1567 + -1, // #1565 (obsolete action) + -1, // #1566 (obsolete action) + -1, // #1567 (obsolete action) ActCnfID_Oth, // #1568 ActCnfID_Std, // #1569 ActCnfID_Tch, // #1570 @@ -4638,6 +4632,18 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un static void Act_FormStartInternal (Act_Action_t NextAction,bool PutParameterLocationIfNoSesion, const char *Id,const char *Anchor,const char *OnSubmit); +/*****************************************************************************/ +/****************** Get action from permanent action code ********************/ +/*****************************************************************************/ + +Act_Action_t Act_GetActionFromActCod (long ActCod) + { + if (ActCod >= 0 && ActCod <= Act_MAX_ACTION_COD) + return Act_FromActCodToAction[ActCod]; + + return ActUnk; + } + /*****************************************************************************/ /************* Check if I have permission to execute an action ***************/ /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index 53d4ffee..d74b0513 100644 --- a/swad_action.h +++ b/swad_action.h @@ -57,7 +57,7 @@ typedef enum typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action -#define Act_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 32 + 24 + 115 + 72 + 416 + 159 + 172 + 42 + 14 + 97) +#define Act_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 32 + 24 + 115 + 72 + 416 + 156 + 172 + 42 + 14 + 97) #define Act_MAX_ACTION_COD 1638 @@ -1096,53 +1096,50 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to #define ActRcvFrmEnrSevStd (ActChgNumRowFooGrp + 117) #define ActRcvFrmEnrSevTch (ActChgNumRowFooGrp + 118) -#define ActReqCnfID_Oth (ActChgNumRowFooGrp + 119) -#define ActReqCnfID_Std (ActChgNumRowFooGrp + 120) -#define ActReqCnfID_Tch (ActChgNumRowFooGrp + 121) -#define ActCnfID_Oth (ActChgNumRowFooGrp + 122) -#define ActCnfID_Std (ActChgNumRowFooGrp + 123) -#define ActCnfID_Tch (ActChgNumRowFooGrp + 124) +#define ActCnfID_Oth (ActChgNumRowFooGrp + 119) +#define ActCnfID_Std (ActChgNumRowFooGrp + 120) +#define ActCnfID_Tch (ActChgNumRowFooGrp + 121) -#define ActFrmIDsOth (ActChgNumRowFooGrp + 125) -#define ActFrmIDsStd (ActChgNumRowFooGrp + 126) -#define ActFrmIDsTch (ActChgNumRowFooGrp + 127) -#define ActRemID_Oth (ActChgNumRowFooGrp + 128) -#define ActRemID_Std (ActChgNumRowFooGrp + 129) -#define ActRemID_Tch (ActChgNumRowFooGrp + 130) -#define ActNewID_Oth (ActChgNumRowFooGrp + 131) -#define ActNewID_Std (ActChgNumRowFooGrp + 132) -#define ActNewID_Tch (ActChgNumRowFooGrp + 133) -#define ActFrmPwdOth (ActChgNumRowFooGrp + 134) -#define ActFrmPwdStd (ActChgNumRowFooGrp + 135) -#define ActFrmPwdTch (ActChgNumRowFooGrp + 136) -#define ActChgPwdOth (ActChgNumRowFooGrp + 137) -#define ActChgPwdStd (ActChgNumRowFooGrp + 138) -#define ActChgPwdTch (ActChgNumRowFooGrp + 139) -#define ActFrmMaiOth (ActChgNumRowFooGrp + 140) -#define ActFrmMaiStd (ActChgNumRowFooGrp + 141) -#define ActFrmMaiTch (ActChgNumRowFooGrp + 142) -#define ActRemMaiOth (ActChgNumRowFooGrp + 143) -#define ActRemMaiStd (ActChgNumRowFooGrp + 144) -#define ActRemMaiTch (ActChgNumRowFooGrp + 145) -#define ActNewMaiOth (ActChgNumRowFooGrp + 146) -#define ActNewMaiStd (ActChgNumRowFooGrp + 147) -#define ActNewMaiTch (ActChgNumRowFooGrp + 148) +#define ActFrmIDsOth (ActChgNumRowFooGrp + 122) +#define ActFrmIDsStd (ActChgNumRowFooGrp + 123) +#define ActFrmIDsTch (ActChgNumRowFooGrp + 124) +#define ActRemID_Oth (ActChgNumRowFooGrp + 125) +#define ActRemID_Std (ActChgNumRowFooGrp + 126) +#define ActRemID_Tch (ActChgNumRowFooGrp + 127) +#define ActNewID_Oth (ActChgNumRowFooGrp + 128) +#define ActNewID_Std (ActChgNumRowFooGrp + 129) +#define ActNewID_Tch (ActChgNumRowFooGrp + 130) +#define ActFrmPwdOth (ActChgNumRowFooGrp + 131) +#define ActFrmPwdStd (ActChgNumRowFooGrp + 132) +#define ActFrmPwdTch (ActChgNumRowFooGrp + 133) +#define ActChgPwdOth (ActChgNumRowFooGrp + 134) +#define ActChgPwdStd (ActChgNumRowFooGrp + 135) +#define ActChgPwdTch (ActChgNumRowFooGrp + 136) +#define ActFrmMaiOth (ActChgNumRowFooGrp + 137) +#define ActFrmMaiStd (ActChgNumRowFooGrp + 138) +#define ActFrmMaiTch (ActChgNumRowFooGrp + 139) +#define ActRemMaiOth (ActChgNumRowFooGrp + 140) +#define ActRemMaiStd (ActChgNumRowFooGrp + 141) +#define ActRemMaiTch (ActChgNumRowFooGrp + 142) +#define ActNewMaiOth (ActChgNumRowFooGrp + 143) +#define ActNewMaiStd (ActChgNumRowFooGrp + 144) +#define ActNewMaiTch (ActChgNumRowFooGrp + 145) -#define ActRemStdCrs (ActChgNumRowFooGrp + 149) -#define ActRemTchCrs (ActChgNumRowFooGrp + 150) -#define ActRemUsrGbl (ActChgNumRowFooGrp + 151) +#define ActRemStdCrs (ActChgNumRowFooGrp + 146) +#define ActRemTchCrs (ActChgNumRowFooGrp + 147) +#define ActRemUsrGbl (ActChgNumRowFooGrp + 148) -#define ActReqRemAllStdCrs (ActChgNumRowFooGrp + 152) -#define ActRemAllStdCrs (ActChgNumRowFooGrp + 153) +#define ActReqRemAllStdCrs (ActChgNumRowFooGrp + 149) +#define ActRemAllStdCrs (ActChgNumRowFooGrp + 150) -#define ActReqRemOldUsr (ActChgNumRowFooGrp + 154) -#define ActRemOldUsr (ActChgNumRowFooGrp + 155) +#define ActReqRemOldUsr (ActChgNumRowFooGrp + 151) +#define ActRemOldUsr (ActChgNumRowFooGrp + 152) -#define ActLstDupUsr (ActChgNumRowFooGrp + 156) -#define ActLstSimUsr (ActChgNumRowFooGrp + 157) -#define ActRemDupUsr (ActChgNumRowFooGrp + 158) +#define ActLstDupUsr (ActChgNumRowFooGrp + 153) +#define ActLstSimUsr (ActChgNumRowFooGrp + 154) +#define ActRemDupUsr (ActChgNumRowFooGrp + 155) -#define ActLstClk (ActChgNumRowFooGrp + 159) +#define ActLstClk (ActChgNumRowFooGrp + 156) /*****************************************************************************/ /******************************** Social tab *********************************/ @@ -1547,6 +1544,8 @@ struct Act_Actions /***************************** Public prototypes *****************************/ /*****************************************************************************/ +Act_Action_t Act_GetActionFromActCod (long ActCod); + bool Act_CheckIfIHavePermissionToExecuteAction (Act_Action_t Action); const char *Act_GetTitleAction (Act_Action_t Action); const char *Act_GetSubtitleAction (Act_Action_t Action); diff --git a/swad_attendance.c b/swad_attendance.c index e7347004..6422ea98 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -2067,7 +2067,7 @@ static void Att_WriteRowStdToCallTheRoll (unsigned NumStd,struct UsrData *UsrDat UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat); + ID_WriteUsrIDs (UsrDat,NULL); fprintf (Gbl.F.Out,""); /***** Write student's name *****/ @@ -3298,7 +3298,7 @@ static void Att_WriteRowStdSeveralAttEvents (unsigned NumStd,struct UsrData *Usr UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat); + ID_WriteUsrIDs (UsrDat,NULL); fprintf (Gbl.F.Out,""); /***** Write student's name *****/ @@ -3444,7 +3444,7 @@ static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat) Gbl.RowEvenOdd, UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL"); - ID_WriteUsrIDs (UsrDat); + ID_WriteUsrIDs (UsrDat,NULL); fprintf (Gbl.F.Out,""); /***** Write student's name *****/ diff --git a/swad_centre.c b/swad_centre.c index e9553c48..c622dbdb 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -1813,7 +1813,7 @@ void Ctr_ChangeCtrInsInConfig (void) void Ctr_ContEditAfterChgCtrInConfig (void) { /***** Write error/success message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Show the form again *****/ Ctr_ShowConfiguration (); @@ -2160,7 +2160,7 @@ void Ctr_ChangeCtrStatus (void) void Ctr_ContEditAfterChgCtr (void) { /***** Write success / warning message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); if (Gbl.AlertType == Lay_SUCCESS) /***** Put button to go to centre changed *****/ diff --git a/swad_changelog.h b/swad_changelog.h index 7457c5d5..15ea0943 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -234,13 +234,17 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.208.7 (2017-05-08)" +#define Log_PLATFORM_VERSION "SWAD 16.209 (2017-05-08)" #define CSS_FILE "swad16.208.7.css" #define JS_FILE "swad16.206.3.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 /* + Version 16.209: May 09, 2017 Confirmation of user's ID is made directly, without confirmation. (218836 lines) + 1 change necessary in database: +UPDATE actions SET Obsolete='Y' WHERE ActCod IN ('1565','1566','1567'); + Version 16.208.7: May 09, 2017 Changes in layout of student records. (218771 lines) Version 16.208.6: May 09, 2017 Changes in alerts. Changes in layout of student records. (218744 lines) diff --git a/swad_connected.c b/swad_connected.c index 43cca439..8c6659e5 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -179,7 +179,6 @@ void Con_ShowLastClicks (void) void Con_GetAndShowLastClicks (void) { extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; - extern Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD]; extern const char *Txt_Click; extern const char *Txt_ELAPSED_TIME; extern const char *Txt_Role; @@ -269,12 +268,12 @@ void Con_GetAndShowLastClicks (void) ActCod = Str_ConvertStrCodToLongCod (row[1]); /* Use a special color for this row depending on the action */ - ClassRow = (Act_Actions[Act_FromActCodToAction[ActCod]].BrowserWindow == Act_DOWNLD_FILE) ? "DAT_SMALL_YELLOW LEFT_MIDDLE" : - (ActCod == Act_Actions[ActLogIn].ActCod || + ClassRow = (Act_Actions[Act_GetActionFromActCod (ActCod)].BrowserWindow == Act_DOWNLD_FILE) ? "DAT_SMALL_YELLOW LEFT_MIDDLE" : + (ActCod == Act_Actions[ActLogIn ].ActCod || ActCod == Act_Actions[ActLogInNew].ActCod) ? "DAT_SMALL_GREEN" : - (ActCod == Act_Actions[ActLogOut].ActCod ) ? "DAT_SMALL_RED" : - (ActCod == Act_Actions[ActWebSvc].ActCod ) ? "DAT_SMALL_BLUE" : - "DAT_SMALL_GREY"; + (ActCod == Act_Actions[ActLogOut ].ActCod) ? "DAT_SMALL_RED" : + (ActCod == Act_Actions[ActWebSvc ].ActCod) ? "DAT_SMALL_BLUE" : + "DAT_SMALL_GREY"; /* Compute elapsed time from last access */ if (sscanf (row[2],"%ld",&TimeDiff) != 1) diff --git a/swad_course.c b/swad_course.c index d267f713..8ead30d7 100644 --- a/swad_course.c +++ b/swad_course.c @@ -2385,7 +2385,7 @@ void Crs_ChangeCrsDegInConfig (void) void Crs_ContEditAfterChgCrsInConfig (void) { /***** Write error/success message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Show the form again *****/ Crs_ShowIntroduction (); @@ -2772,7 +2772,7 @@ void Crs_ContEditAfterChgCrs (void) bool PutButtonToRequestRegistration; /***** Write warning / success message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); if (Gbl.AlertType == Lay_SUCCESS) { diff --git a/swad_degree.c b/swad_degree.c index 4d8d084d..f546f5ee 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -2086,7 +2086,7 @@ void Deg_ChangeDegCtrInConfig (void) void Deg_ContEditAfterChgDegInConfig (void) { /***** Write success / warning message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Show the form again *****/ Deg_ShowConfiguration (); @@ -2252,7 +2252,7 @@ void Deg_ChangeDegStatus (void) void Deg_ContEditAfterChgDeg (void) { /***** Write success / warning message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); if (Gbl.AlertType == Lay_SUCCESS) /***** Put button to go to degree changed *****/ diff --git a/swad_enrolment.c b/swad_enrolment.c index 261080ee..3062d909 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -3183,7 +3183,8 @@ static void Enr_ShowFormToEditOtherUsr (void) fprintf (Gbl.F.Out,""); /***** User's record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_EXISTING_USR_FORM,&Gbl.Usrs.Other.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_EXISTING_USR_FORM, + &Gbl.Usrs.Other.UsrDat,NULL); } /*****************************************************************************/ @@ -3633,13 +3634,13 @@ void Enr_CreateNewUsr1 (void) void Enr_CreateNewUsr2 (void) { if (Gbl.AlertType == Lay_ERROR) // User's ID not valid - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); else // User's ID valid { if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected { /***** Show optional alert *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Change user's groups *****/ if (Gbl.CurrentCrs.Grps.NumGrps) // This course has groups? @@ -3786,7 +3787,7 @@ void Enr_ModifyUsr2 (void) extern const char *Txt_User_not_found_or_you_do_not_have_permission_; if (Gbl.AlertType == Lay_WARNING) - Lay_ShowAlert (Gbl.AlertType,Txt_User_not_found_or_you_do_not_have_permission_); + Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); else // No error switch (Gbl.Usrs.RegRemAction) { @@ -3794,7 +3795,7 @@ void Enr_ModifyUsr2 (void) if (Gbl.CurrentCrs.Crs.CrsCod > 0) { /***** Show optional alert *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Change user's groups *****/ if (Gbl.CurrentCrs.Grps.NumGrps) // This course has groups? diff --git a/swad_file_browser.c b/swad_file_browser.c index 34d07338..3cf6ce69 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -3407,7 +3407,7 @@ static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat) Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); /***** Show user's ID *****/ - ID_WriteUsrIDs (UsrDat); + ID_WriteUsrIDs (UsrDat,NULL); /***** Show user's name *****/ fprintf (Gbl.F.Out,"
"); diff --git a/swad_follow.c b/swad_follow.c index 825bea7a..0f6c1564 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -996,6 +996,7 @@ static void Fol_PutIconToUnfollow (struct UsrData *UsrDat) void Fol_FollowUsr1 (void) { + extern const char *Txt_User_not_found_or_you_do_not_have_permission_; char Query[256]; bool CreateNotif; bool NotifyByEmail; @@ -1033,7 +1034,10 @@ void Fol_FollowUsr1 (void) Gbl.AlertType = Lay_SUCCESS; } else + { Gbl.AlertType = Lay_WARNING; + sprintf (Gbl.Message,"%s",Txt_User_not_found_or_you_do_not_have_permission_); + } } void Fol_FollowUsr2 (void) @@ -1042,11 +1046,14 @@ void Fol_FollowUsr2 (void) if (Gbl.AlertType == Lay_SUCCESS) /***** Show user's profile again *****/ - Gbl.AlertType = Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat) ? Lay_SUCCESS : - Lay_WARNING; + if (!Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat)) + { + Gbl.AlertType = Lay_WARNING; + sprintf (Gbl.Message,"%s",Txt_User_not_found_or_you_do_not_have_permission_); + } - if (Gbl.AlertType == Lay_WARNING) - Lay_ShowAlert (Gbl.AlertType,Txt_User_not_found_or_you_do_not_have_permission_); + if (Gbl.AlertType != Lay_SUCCESS) + Lay_ShowPendingAlert (); } /*****************************************************************************/ @@ -1055,6 +1062,7 @@ void Fol_FollowUsr2 (void) void Fol_UnfollowUsr1 (void) { + extern const char *Txt_User_not_found_or_you_do_not_have_permission_; char Query[256]; /***** Get user to be unfollowed *****/ @@ -1074,13 +1082,14 @@ void Fol_UnfollowUsr1 (void) Gbl.AlertType = Lay_SUCCESS; } else + { Gbl.AlertType = Lay_WARNING; + sprintf (Gbl.Message,"%s",Txt_User_not_found_or_you_do_not_have_permission_); + } } void Fol_UnfollowUsr2 (void) { - extern const char *Txt_User_not_found_or_you_do_not_have_permission_; - /***** Get user to be unfollowed *****/ if (Gbl.AlertType == Lay_SUCCESS) { @@ -1092,7 +1101,7 @@ void Fol_UnfollowUsr2 (void) Fol_ListFollowingUsr (&Gbl.Usrs.Me.UsrDat); // List users I follow } else - Lay_ShowAlert (Gbl.AlertType,Txt_User_not_found_or_you_do_not_have_permission_); + Lay_ShowPendingAlert (); } /*****************************************************************************/ diff --git a/swad_global.c b/swad_global.c index e79af0eb..7af387b4 100644 --- a/swad_global.c +++ b/swad_global.c @@ -179,7 +179,8 @@ void Gbl_InitializeGlobals (void) Gbl.Usrs.Other.UsrDat.UsrIDNickOrEmail[0] = '\0'; Usr_UsrDataConstructor (&Gbl.Usrs.Other.UsrDat); - Gbl.Action.Act = ActUnk; + Gbl.Action.Act = ActUnk; + Gbl.Action.Original = ActUnk; // Used in some actions to know what action gave rise to the current action Gbl.Action.UsesAJAX = false; Gbl.Action.IsAJAXAutoRefresh = false; Gbl.Action.Tab = TabUnk; diff --git a/swad_global.h b/swad_global.h index 662cfc18..407320ac 100644 --- a/swad_global.h +++ b/swad_global.h @@ -175,6 +175,7 @@ struct Globals { Tab_Tab_t Tab; Act_Action_t Act; + Act_Action_t Original; // Used in some actions to know what action gave rise to the current action bool UsesAJAX; // Do not generate full HTML page, only the content of a div bool IsAJAXAutoRefresh; // It's an automatic refresh drom time to time } Action; @@ -372,7 +373,6 @@ struct Globals struct ListUsrs LstUsrs[Rol_NUM_ROLES]; struct { - // bool MultipleUsrs; // Listing multiple users? char *All; char *Std; char *Tch; diff --git a/swad_holiday.c b/swad_holiday.c index e0d0ff57..964dbd99 100644 --- a/swad_holiday.c +++ b/swad_holiday.c @@ -659,7 +659,7 @@ void Hld_RemoveHoliday1 (void) void Hld_RemoveHoliday2 (void) { /***** Show success message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Show the form again *****/ Hld_EditHolidays (); @@ -709,7 +709,7 @@ void Hld_ChangeHolidayPlace1 (void) void Hld_ChangeHolidayPlace2 (void) { /***** Show success message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Show the form again *****/ Hld_EditHolidays (); @@ -753,7 +753,7 @@ void Hld_ChangeHolidayType1 (void) void Hld_ChangeHolidayType2 (void) { /***** Show success message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Show the form again *****/ Hld_EditHolidays (); @@ -857,7 +857,7 @@ static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate) void Hld_ChangeDate2 (void) { /***** Show success message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Show the form again *****/ Hld_EditHolidays (); @@ -926,7 +926,7 @@ void Hld_RenameHoliday1 (void) void Hld_RenameHoliday2 (void) { /***** Write error/success message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Show the form again *****/ Hld_EditHolidays (); @@ -1161,7 +1161,7 @@ void Hld_RecFormNewHoliday1 (void) void Hld_RecFormNewHoliday2 (void) { /***** Write error/success message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Show the form again *****/ Hld_EditHolidays (); diff --git a/swad_institution.c b/swad_institution.c index 76738979..794ecff4 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -1922,7 +1922,7 @@ void Ins_ChangeInsCtyInConfig (void) void Ins_ContEditAfterChgInsInConfig (void) { /***** Write success / warning message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Show the form again *****/ Ins_ShowConfiguration (); @@ -2088,7 +2088,7 @@ void Ins_ChangeInsStatus (void) void Ins_ContEditAfterChgIns (void) { /***** Write success / warning message *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); if (Gbl.AlertType == Lay_SUCCESS) /***** Put button to go to institution changed *****/ diff --git a/swad_layout.c b/swad_layout.c index 936e399e..a13944c9 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1660,6 +1660,18 @@ void Lay_ShowErrorAndExit (const char *Message) exit (0); } +/*****************************************************************************/ +/*********************** Show a write-pending alert **************************/ +/*****************************************************************************/ +// Gbl.AlertType must be Lay_NONE or any type of alert +// If Gbl.AlertType != Lay_NONE ==> Gbl.Message must hold the message + +void Lay_ShowPendingAlert (void) + { + if (Gbl.AlertType != Lay_NONE) + Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + } + /*****************************************************************************/ /******************** Show an alert message to the user **********************/ /*****************************************************************************/ diff --git a/swad_layout.h b/swad_layout.h index 3dc13079..65259e14 100644 --- a/swad_layout.h +++ b/swad_layout.h @@ -131,6 +131,7 @@ void Lay_StartTableWideMargin (unsigned CellPadding); void Lay_EndTable (void); void Lay_ShowErrorAndExit (const char *Message); +void Lay_ShowPendingAlert (void); void Lay_ShowAlert (Lay_AlertType_t AlertType,const char *Message); void Lay_ShowAlertAndButton1 (Lay_AlertType_t AlertType,const char *Message); void Lay_ShowAlertAndButton2 (Act_Action_t NextAction,const char *Anchor, diff --git a/swad_mail.c b/swad_mail.c index 9433986b..a942f13a 100644 --- a/swad_mail.c +++ b/swad_mail.c @@ -1162,7 +1162,8 @@ void Mai_ShowFormOthEmail (void) Lay_StartRoundFrame (NULL,Txt_Email,NULL,NULL); /***** Show user's record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST, + &Gbl.Usrs.Other.UsrDat,NULL); /***** Form with the user's email *****/ Lay_StartTableCenter (2); @@ -1359,7 +1360,8 @@ void Mai_RemoveOtherUsrEmail (void) Mai_RemoveEmail (&Gbl.Usrs.Other.UsrDat); /***** Show user's record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST, + &Gbl.Usrs.Other.UsrDat,NULL); } else // User not found Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); @@ -1438,7 +1440,8 @@ void Mai_NewOtherUsrEmail (void) (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)); // It's me? /***** Show user's record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST, + &Gbl.Usrs.Other.UsrDat,NULL); } else // User not found Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); diff --git a/swad_message.c b/swad_message.c index 8a253f62..d2e938e3 100644 --- a/swad_message.c +++ b/swad_message.c @@ -402,7 +402,7 @@ static void Msg_ShowOneUniqueRecipient (void) fprintf (Gbl.F.Out,"
", Gbl.Usrs.Other.UsrDat.Accepted ? "DAT_SMALL_NOBR_N" : "DAT_SMALL_NOBR"); - ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat); + ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat,NULL); fprintf (Gbl.F.Out,"
"); /***** Write user's name *****/ diff --git a/swad_password.c b/swad_password.c index d6b2de7f..f63f77ce 100644 --- a/swad_password.c +++ b/swad_password.c @@ -823,7 +823,8 @@ void Pwd_ShowFormOthPwd (void) Lay_StartRoundFrame (NULL,Txt_Password,NULL,NULL); /***** Show user's record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST, + &Gbl.Usrs.Other.UsrDat,NULL); /***** Form to change password *****/ /* Start form */ diff --git a/swad_photo.c b/swad_photo.c index 47ca9d0b..df96bf9b 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -437,8 +437,7 @@ void Pho_ReqRemoveMyPhoto (void) void Pho_RemoveMyPhoto1 (void) { /***** Remove photo *****/ - Gbl.AlertType = Pho_RemovePhoto (&Gbl.Usrs.Me.UsrDat) ? Lay_SUCCESS : - Lay_WARNING; + Pho_RemovePhoto (&Gbl.Usrs.Me.UsrDat); /***** The link to my photo is not valid now, so build it again before writing the web page *****/ Gbl.Usrs.Me.MyPhotoExists = Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,Gbl.Usrs.Me.PhotoURL); @@ -446,10 +445,8 @@ void Pho_RemoveMyPhoto1 (void) void Pho_RemoveMyPhoto2 (void) { - extern const char *Txt_Photo_removed; - - if (Gbl.AlertType == Lay_SUCCESS) - Lay_ShowAlert (Gbl.AlertType,Txt_Photo_removed); + /***** Write success / warning message *****/ + Lay_ShowPendingAlert (); } /*****************************************************************************/ @@ -511,7 +508,6 @@ void Pho_ReqRemoveUsrPhoto (void) void Pho_RemoveUsrPhoto (void) { - extern const char *Txt_Photo_removed; extern const char *Txt_User_not_found_or_you_do_not_have_permission_; /***** Get user's code from form *****/ @@ -522,7 +518,7 @@ void Pho_RemoveUsrPhoto (void) { /***** Remove photo *****/ if (Pho_RemovePhoto (&Gbl.Usrs.Other.UsrDat)) - Lay_ShowAlert (Lay_SUCCESS,Txt_Photo_removed); + Lay_ShowPendingAlert (); } else Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); @@ -801,6 +797,7 @@ void Pho_UpdateUsrPhoto2 (void) static void Pho_UpdatePhoto1 (struct UsrData *UsrDat) { + extern const char *Txt_Photo_has_been_updated; char PathPhotoTmp[PATH_MAX + 1]; // Full name (including path and .jpg) of the temporary file with the selected face char PathRelPhoto[PATH_MAX + 1]; @@ -825,15 +822,18 @@ static void Pho_UpdatePhoto1 (struct UsrData *UsrDat) Pho_RemoveUsrFromTableClicksWithoutPhoto (UsrDat->UsrCod); Gbl.AlertType = Lay_SUCCESS; + sprintf (Gbl.Message,"%s",Txt_Photo_has_been_updated); } else + { Gbl.AlertType = Lay_ERROR; + sprintf (Gbl.Message,"%s","Error updating photo."); + } } static void Pho_UpdatePhoto2 (void) { extern const char *Txt_PHOTO_PROCESSING_CAPTIONS[3]; - extern const char *Txt_Photo_has_been_updated; unsigned NumPhoto; /***** Show the three images resulting of the processing *****/ @@ -858,10 +858,7 @@ static void Pho_UpdatePhoto2 (void) Lay_EndTable (); /***** Show message *****/ - if (Gbl.AlertType == Lay_ERROR) // The file with the selected photo does not exist! - Lay_ShowErrorAndExit ("Selected photo does not exist."); - - Lay_ShowAlert (Gbl.AlertType,Txt_Photo_has_been_updated); + Lay_ShowPendingAlert (); } /*****************************************************************************/ @@ -1011,6 +1008,7 @@ bool Pho_CheckIfPrivPhotoExists (long UsrCod,char *PathPrivRelPhoto) bool Pho_RemovePhoto (struct UsrData *UsrDat) { + extern const char *Txt_Photo_removed; char PathPrivRelPhoto[PATH_MAX + 1]; char PathPublPhoto[PATH_MAX + 1]; unsigned NumErrors = 0; @@ -1025,10 +1023,7 @@ bool Pho_RemovePhoto (struct UsrData *UsrDat) Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,UsrDat->Photo); if (Fil_CheckIfPathExists (PathPublPhoto)) // Public link exists if (unlink (PathPublPhoto)) // Remove public link - { - Lay_ShowAlert (Lay_ERROR,"Error removing public link to photo."); NumErrors++; - } /***** Remove photo *****/ sprintf (PathPrivRelPhoto,"%s/%s/%02u/%ld.jpg", @@ -1037,10 +1032,7 @@ bool Pho_RemovePhoto (struct UsrData *UsrDat) if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Photo exists { if (unlink (PathPrivRelPhoto)) // Remove photo - { - Lay_ShowAlert (Lay_ERROR,"Error removing photo."); NumErrors++; - } } /***** Remove original photo *****/ @@ -1049,16 +1041,24 @@ bool Pho_RemovePhoto (struct UsrData *UsrDat) (unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod); if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Original photo exists if (unlink (PathPrivRelPhoto)) // Remove original photo - { - Lay_ShowAlert (Lay_ERROR,"Error removing the original photo."); NumErrors++; - } /***** Clear photo name in user's data *****/ UsrDat->Photo[0] = '\0'; } - return (NumErrors == 0); + if (NumErrors) + { + Gbl.AlertType = Lay_ERROR; + sprintf (Gbl.Message,"%s","Error removing photo."); + return false; + } + else + { + Gbl.AlertType = Lay_SUCCESS; + sprintf (Gbl.Message,"%s",Txt_Photo_removed); + return true; + } } /*****************************************************************************/ diff --git a/swad_profile.c b/swad_profile.c index 878a8664..5d82250d 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -290,7 +290,7 @@ bool Prf_ShowUserProfile (struct UsrData *UsrDat) Gbl.CurrentCrs.Crs.CrsCod, true); } - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_PUBLIC,UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_PUBLIC,UsrDat,NULL); /***** Show details of user's profile *****/ Prf_ShowDetailsUserProfile (UsrDat); diff --git a/swad_record.c b/swad_record.c index 385718c6..8ebb296c 100644 --- a/swad_record.c +++ b/swad_record.c @@ -76,10 +76,14 @@ static void Rec_PutParamFielCod (void); static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD + 1], unsigned *NumLines,Rec_VisibilityRecordFields_t *Visibility); +static void Rec_ListRecordsGsts (Rec_SharedRecordViewType_t TypeOfView); + static void Rec_ShowRecordOneStdCrs (void); static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView, Rec_CourseRecordViewType_t CrsTypeOfView); + static void Rec_ShowRecordOneTchCrs (void); +static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView); static void Rec_ShowLinkToPrintPreviewOfRecords (void); static void Rec_GetParamRecordsPerPage (void); @@ -105,7 +109,8 @@ static void Rec_ShowCountryInHead (struct UsrData *UsrDat,bool ShowData); static void Rec_ShowWebsAndSocialNets (struct UsrData *UsrDat, Rec_SharedRecordViewType_t TypeOfView); static void Rec_ShowEmail (struct UsrData *UsrDat,const char *ClassForm); -static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm); +static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *Anchor, + const char *ClassForm); static void Rec_ShowRole (struct UsrData *UsrDat, Rec_SharedRecordViewType_t TypeOfView, const char *ClassForm); @@ -977,20 +982,29 @@ void Rec_PutLinkToEditRecordFields (void) /*********************** Draw records of several guests **********************/ /*****************************************************************************/ -void Rec_ListRecordsGsts (void) +void Rec_ListRecordsGstsShow (void) + { + Gbl.Action.Original = ActSeeRecSevGst; + Rec_ListRecordsGsts (Rec_SHA_RECORD_LIST); + } + +void Rec_ListRecordsGstsPrint (void) + { + Rec_ListRecordsGsts (Rec_SHA_RECORD_PRINT); + } + +static void Rec_ListRecordsGsts (Rec_SharedRecordViewType_t TypeOfView) { extern const char *Txt_You_must_select_one_ore_more_users; unsigned NumUsrs = 0; const char *Ptr; - Rec_SharedRecordViewType_t TypeOfView = (Gbl.Action.Act == ActSeeRecSevGst) ? Rec_SHA_RECORD_LIST : - Rec_SHA_RECORD_PRINT; struct UsrData UsrDat; /***** Assign users listing type depending on current action *****/ Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_GUESTS; /***** Get parameter with number of user records per page (only for printing) *****/ - if (Gbl.Action.Act == ActPrnRecSevGst) + if (TypeOfView == Rec_SHA_RECORD_PRINT) Rec_GetParamRecordsPerPage (); /***** Get list of selected users *****/ @@ -1004,7 +1018,7 @@ void Rec_ListRecordsGsts (void) return; } - if (Gbl.Action.Act == ActSeeRecSevGst) + if (TypeOfView == Rec_SHA_RECORD_LIST) // Listing several records { fprintf (Gbl.F.Out,"
"); @@ -1040,7 +1054,7 @@ void Rec_ListRecordsGsts (void) fprintf (Gbl.F.Out,"\">"); /* Shared record */ - Rec_ShowSharedUsrRecord (TypeOfView,&UsrDat); + Rec_ShowSharedUsrRecord (TypeOfView,&UsrDat,NULL); fprintf (Gbl.F.Out,"
"); @@ -1050,10 +1064,6 @@ void Rec_ListRecordsGsts (void) /***** Free memory used for user's data *****/ Usr_UsrDataDestructor (&UsrDat); - /***** Free list of fields of records *****/ - if (Gbl.Usrs.Listing.RecsUsrs == Rec_RECORD_USERS_STUDENTS) - Rec_FreeListFields (); - /***** Free memory used by list of selected users' codes *****/ Usr_FreeListsSelectedUsrsCods (); } @@ -1102,10 +1112,10 @@ static void Rec_ShowRecordOneStdCrs (void) fprintf (Gbl.F.Out,""); /***** Show optional alert *****/ - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /***** Shared record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat,NULL); /***** Record of the student in the course *****/ /* Get list of fields of records in current course */ @@ -1129,13 +1139,14 @@ static void Rec_ShowRecordOneStdCrs (void) /******************** Draw records of several students ***********************/ /*****************************************************************************/ -void Rec_ListRecordsStdsForEdit (void) +void Rec_ListRecordsStdsShow (void) { + Gbl.Action.Original = ActSeeRecSevStd; Rec_ListRecordsStds (Rec_SHA_RECORD_LIST, Rec_CRS_LIST_SEVERAL_RECORDS); } -void Rec_ListRecordsStdsForPrint (void) +void Rec_ListRecordsStdsPrint (void) { Rec_ListRecordsStds (Rec_SHA_RECORD_PRINT, Rec_CRS_PRINT_SEVERAL_RECORDS); @@ -1220,11 +1231,11 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView, /* Show optional alert */ if (UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod) // Selected user - Lay_ShowAlert (Gbl.AlertType,Gbl.Message); + Lay_ShowPendingAlert (); /* Shared record */ fprintf (Gbl.F.Out,"
"); - Rec_ShowSharedUsrRecord (ShaTypeOfView,&UsrDat); + Rec_ShowSharedUsrRecord (ShaTypeOfView,&UsrDat,Anchor); fprintf (Gbl.F.Out,"
"); /* Record of the student in the course */ @@ -1320,7 +1331,7 @@ static void Rec_ShowRecordOneTchCrs (void) " style=\"margin-bottom:12px;\">"); /* Shared record */ - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat,NULL); /* Office hours */ if (ShowOfficeHours) @@ -1339,15 +1350,24 @@ static void Rec_ShowRecordOneTchCrs (void) /******************** Draw records of several teachers ***********************/ /*****************************************************************************/ -void Rec_ListRecordsTchs (void) +void Rec_ListRecordsTchsShow (void) + { + Gbl.Action.Original = ActSeeRecSevTch; + Rec_ListRecordsTchs (Rec_SHA_RECORD_LIST); + } + +void Rec_ListRecordsTchsPrint (void) + { + Rec_ListRecordsTchs (Rec_SHA_RECORD_PRINT); + } + +static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView) { extern const char *Hlp_USERS_Teachers_timetable; extern const char *Txt_You_must_select_one_ore_more_teachers; extern const char *Txt_TIMETABLE_TYPES[TT_NUM_TIMETABLE_TYPES]; unsigned NumUsrs = 0; const char *Ptr; - Rec_SharedRecordViewType_t TypeOfView = (Gbl.Action.Act == ActSeeRecSevTch) ? Rec_SHA_RECORD_LIST : - Rec_SHA_RECORD_PRINT; struct UsrData UsrDat; bool ShowOfficeHours; char Width[10 + 2 + 1]; @@ -1425,7 +1445,7 @@ void Rec_ListRecordsTchs (void) fprintf (Gbl.F.Out,"\">"); /* Shared record */ - Rec_ShowSharedUsrRecord (TypeOfView,&UsrDat); + Rec_ShowSharedUsrRecord (TypeOfView,&UsrDat,NULL); /* Office hours */ if (ShowOfficeHours) @@ -1575,13 +1595,14 @@ void Rec_UpdateAndShowMyCrsRecord (void) void Rec_UpdateAndShowOtherCrsRecord (void) { extern const char *Txt_Student_record_card_in_this_course_has_been_updated; - bool MultipleUsrs; + long OriginalActCod; /***** Initialize alert type and message *****/ Gbl.AlertType = Lay_NONE; // Do not show alert - /***** Get parameter indicating if listing multiple users *****/ - MultipleUsrs = Par_GetParToBool ("MultiUsrs"); + /***** Get where we came from *****/ + OriginalActCod = Par_GetParToLong ("OriginalActCod"); + Gbl.Action.Original = Act_GetActionFromActCod (OriginalActCod); /***** Get the user whose record we want to modify *****/ Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); @@ -1603,12 +1624,17 @@ void Rec_UpdateAndShowOtherCrsRecord (void) Txt_Student_record_card_in_this_course_has_been_updated); /***** Show one or multiple records *****/ - if (MultipleUsrs) - /* Show multiple records again (including the updated one) */ - Rec_ListRecordsStdsForEdit (); - else - /* Show only the updated record of this student */ - Rec_ShowRecordOneStdCrs (); + switch (Gbl.Action.Original) + { + case ActSeeRecSevStd: + /* Show multiple records again (including the updated one) */ + Rec_ListRecordsStdsShow (); + break; + default: + /* Show only the updated record of one student */ + Rec_ShowRecordOneStdCrs (); + break; + } /***** Free memory used for some fields *****/ Rec_FreeMemFieldsRecordsCrs (); @@ -1622,6 +1648,7 @@ void Rec_UpdateAndShowOtherCrsRecord (void) static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView, struct UsrData *UsrDat,const char *Anchor) { + extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; extern const char *Hlp_USERS_Students_course_record_card; extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *Txt_You_dont_have_permission_to_perform_this_action; @@ -1690,12 +1717,15 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView, case Rec_CRS_LIST_ONE_RECORD: ICanEdit = true; Act_FormStartAnchor (ActRcvRecOthUsr,Anchor); - // Usr_PutHiddenParUsrCodAll (ActRcvRecOthUsr,Gbl.Usrs.Select.All); // TODO: Remove this line + Par_PutHiddenParamLong ("OriginalActCod", + Act_Actions[ActSeeRecOneStd].ActCod); // Original action, used to know where we came from Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); break; case Rec_CRS_LIST_SEVERAL_RECORDS: ICanEdit = true; Act_FormStartAnchor (ActRcvRecOthUsr,Anchor); + Par_PutHiddenParamLong ("OriginalActCod", + Act_Actions[ActSeeRecSevStd].ActCod); // Original action, used to know where we came from Usr_PutHiddenParUsrCodAll (ActRcvRecOthUsr,Gbl.Usrs.Select.All); Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); break; @@ -1961,7 +1991,7 @@ static void Rec_ShowMyCrsRecordUpdated (void) Lay_ShowAlert (Lay_SUCCESS,Txt_Your_record_card_in_this_course_has_been_updated); /***** Shared record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Me.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Me.UsrDat,NULL); /***** Show updated user's record *****/ Rec_ShowCrsRecord (Rec_CRS_MY_RECORD_AS_STUDENT_CHECK,&Gbl.Usrs.Me.UsrDat,NULL); @@ -2016,7 +2046,7 @@ void Rec_ShowFormSignUpWithMySharedRecord (void) /***** Show the form *****/ Act_FormStart (ActSignUp); - Rec_ShowSharedUsrRecord (Rec_SHA_SIGN_UP_FORM,&Gbl.Usrs.Me.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_SIGN_UP_FORM,&Gbl.Usrs.Me.UsrDat,NULL); Lay_PutConfirmButton (Txt_Sign_up); Act_FormEnd (); } @@ -2049,7 +2079,7 @@ void Rec_ShowFormMySharedRecord (void) fprintf (Gbl.F.Out,""); /***** My record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_MY_RECORD_FORM,&Gbl.Usrs.Me.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_MY_RECORD_FORM,&Gbl.Usrs.Me.UsrDat,NULL); Rec_WriteLinkToDataProtectionClause (); } @@ -2065,7 +2095,7 @@ void Rec_ShowFormOtherNewSharedRecord (struct UsrData *UsrDat,Rol_Role_t Default Instead it is initialized with the preferred role. */ UsrDat->RoleInCurrentCrsDB = (Gbl.CurrentCrs.Crs.CrsCod > 0) ? DefaultRole : // Course selected Rol__GUEST_; // No course selected - Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_NEW_USR_FORM,UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_NEW_USR_FORM,UsrDat,NULL); } /*****************************************************************************/ @@ -2080,7 +2110,7 @@ void Rec_ShowMySharedRecordUpd (void) Lay_ShowAlert (Lay_SUCCESS,Txt_Your_personal_data_have_been_updated); /***** Show my record for checking *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_MY_RECORD_CHECK,&Gbl.Usrs.Me.UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_MY_RECORD_CHECK,&Gbl.Usrs.Me.UsrDat,NULL); } /*****************************************************************************/ @@ -2097,7 +2127,7 @@ void Rec_ShowSharedRecordUnmodifiable (struct UsrData *UsrDat) /***** Show user's record *****/ fprintf (Gbl.F.Out,"
"); - Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_USR_CHECK,UsrDat); + Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_USR_CHECK,UsrDat,NULL); fprintf (Gbl.F.Out,"
"); } @@ -2107,7 +2137,7 @@ void Rec_ShowSharedRecordUnmodifiable (struct UsrData *UsrDat) // Show form or only data depending on TypeOfView void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, - struct UsrData *UsrDat) + struct UsrData *UsrDat,const char *Anchor) { extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; extern const char *Hlp_USERS_SignUp; @@ -2265,12 +2295,26 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, fprintf (Gbl.F.Out,"" ""); - /***** Show email and user's ID *****/ + /***** Show email and user's IDs *****/ if (ShowIDRows) { Lay_StartTableWide (2); + + /* Show email */ Rec_ShowEmail (UsrDat,ClassForm); - Rec_ShowUsrIDs (UsrDat,ClassForm); + + /* Show user's IDs */ + if (TypeOfView == Rec_SHA_RECORD_LIST) // Listing several records + switch (Gbl.Action.Act) + { + case ActSeeRecSevGst: + case ActSeeRecSevStd: + case ActSeeRecSevTch: + Gbl.Action.Original = Gbl.Action.Act; // Used to know what action gave rise to other actions + break; + } + Rec_ShowUsrIDs (UsrDat,Anchor,ClassForm); + Lay_EndTable (); } @@ -2786,7 +2830,8 @@ static void Rec_ShowEmail (struct UsrData *UsrDat,const char *ClassForm) /******************************* Show user's IDs *****************************/ /*****************************************************************************/ -static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm) +static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *Anchor, + const char *ClassForm) { extern const char *Txt_ID; @@ -2796,7 +2841,7 @@ static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm) "" "", ClassForm,Txt_ID); - ID_WriteUsrIDs (UsrDat); + ID_WriteUsrIDs (UsrDat,Anchor); fprintf (Gbl.F.Out,"" ""); } diff --git a/swad_record.h b/swad_record.h index 1c4729c8..777d23a0 100644 --- a/swad_record.h +++ b/swad_record.h @@ -138,12 +138,18 @@ void Rec_ChangeVisibilityField (void); void Rec_FreeListFields (void); void Rec_PutLinkToEditRecordFields (void); -void Rec_ListRecordsGsts (void); + +void Rec_ListRecordsGstsShow (void); +void Rec_ListRecordsGstsPrint (void); + void Rec_GetUsrAndShowRecordOneStdCrs (void); -void Rec_ListRecordsStdsForEdit (void); -void Rec_ListRecordsStdsForPrint (void); +void Rec_ListRecordsStdsShow (void); +void Rec_ListRecordsStdsPrint (void); + void Rec_GetUsrAndShowRecordOneTchCrs (void); -void Rec_ListRecordsTchs (void); +void Rec_ListRecordsTchsShow (void); +void Rec_ListRecordsTchsPrint (void); + void Rec_UpdateAndShowMyCrsRecord (void); void Rec_UpdateAndShowOtherCrsRecord (void); unsigned long Rec_GetFieldFromCrsRecord (long UsrCod,long FieldCod,MYSQL_RES **mysql_res); @@ -160,7 +166,7 @@ void Rec_ShowFormOtherNewSharedRecord (struct UsrData *UsrDat,Rol_Role_t Default void Rec_ShowMySharedRecordUpd (void); void Rec_ShowSharedRecordUnmodifiable (struct UsrData *UsrDat); void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, - struct UsrData *UsrDat); + struct UsrData *UsrDat,const char *Anchor); void Rec_UpdateMyRecord (void); Rol_Role_t Rec_GetRoleFromRecordForm (void); diff --git a/swad_session.c b/swad_session.c index d2aff00f..0ed05d1c 100644 --- a/swad_session.c +++ b/swad_session.c @@ -53,7 +53,8 @@ extern struct Globals Gbl; static void Ses_RemoveSessionFromDB (void); -static bool Ses_CheckIfHiddenParIsAlreadyInDB (Act_Action_t Action,const char *ParamName); +static bool Ses_CheckIfHiddenParIsAlreadyInDB (Act_Action_t NextAction, + const char *ParamName); /*****************************************************************************/ /************************** Get number of open sessions **********************/ @@ -344,8 +345,10 @@ bool Ses_GetSessionData (void) /******************* Insert hidden parameter in the database *****************/ /*****************************************************************************/ -void Ses_InsertHiddenParInDB (Act_Action_t Action,const char *ParamName,const char *ParamValue) +void Ses_InsertHiddenParInDB (Act_Action_t NextAction, + const char *ParamName,const char *ParamValue) { + extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; char *Query; size_t LengthParamName; size_t LengthParamValue; @@ -358,7 +361,7 @@ void Ses_InsertHiddenParInDB (Act_Action_t Action,const char *ParamName,const ch /***** For a unique session-action-parameter, don't insert a parameter more than one time *****/ if (ParamName) if ((LengthParamName = strlen (ParamName))) - if (!Ses_CheckIfHiddenParIsAlreadyInDB (Action,ParamName)) + if (!Ses_CheckIfHiddenParIsAlreadyInDB (NextAction,ParamName)) { /***** Allocate space for query *****/ if (ParamValue) @@ -376,8 +379,9 @@ void Ses_InsertHiddenParInDB (Act_Action_t Action,const char *ParamName,const ch sprintf (Query,"INSERT INTO hidden_params" " (SessionId,Action,ParamName,ParamValue)" " VALUES" - " ('%s',%d,'%s','%s')", - Gbl.Session.Id,(int) Action, + " ('%s',%ld,'%s','%s')", + Gbl.Session.Id, + Act_Actions[NextAction].ActCod, ParamName, LengthParamValue ? ParamValue : ""); @@ -426,14 +430,16 @@ void Ses_RemoveHiddenParFromExpiredSessions (void) /*****************************************************************************/ // Return true if the parameter already existed in database -static bool Ses_CheckIfHiddenParIsAlreadyInDB (Act_Action_t Action,const char *ParamName) +static bool Ses_CheckIfHiddenParIsAlreadyInDB (Act_Action_t NextAction, + const char *ParamName) { - char Query[512]; + extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; + char Query[512 + Ses_BYTES_SESSION_ID]; /***** Get a hidden parameter from database *****/ sprintf (Query,"SELECT COUNT(*) FROM hidden_params" - " WHERE SessionId='%s' AND Action=%d AND ParamName='%s'", - Gbl.Session.Id,(int) Action,ParamName); + " WHERE SessionId='%s' AND Action=%ld AND ParamName='%s'", + Gbl.Session.Id,Act_Actions[NextAction].ActCod,ParamName); return (DB_QueryCOUNT (Query,"can not check if a hidden parameter is already in database") != 0); } @@ -442,9 +448,12 @@ static bool Ses_CheckIfHiddenParIsAlreadyInDB (Act_Action_t Action,const char *P /*****************************************************************************/ // Return true if the parameter is too big -unsigned Ses_GetHiddenParFromDB (Act_Action_t Action,const char *ParamName,char *ParamValue,size_t MaxBytes) +unsigned Ses_GetHiddenParFromDB (Act_Action_t NextAction, + const char *ParamName,char *ParamValue, + size_t MaxBytes) { - char Query[512]; + extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; + char Query[512 + Ses_BYTES_SESSION_ID]; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned long NumRows; @@ -457,8 +466,8 @@ unsigned Ses_GetHiddenParFromDB (Act_Action_t Action,const char *ParamName,char { /***** Get a hidden parameter from database *****/ sprintf (Query,"SELECT ParamValue FROM hidden_params" - " WHERE SessionId='%s' AND Action=%d AND ParamName='%s'", - Gbl.Session.Id,(int) Action,ParamName); + " WHERE SessionId='%s' AND Action=%ld AND ParamName='%s'", + Gbl.Session.Id,Act_Actions[NextAction].ActCod,ParamName); NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get a hidden parameter"); /***** Check if the parameter is found in database *****/ diff --git a/swad_session.h b/swad_session.h index efe0407a..7175f2a1 100644 --- a/swad_session.h +++ b/swad_session.h @@ -51,9 +51,12 @@ void Ses_UpdateSessionDataInDB (void); void Ses_UpdateSessionLastRefreshInDB (void); void Ses_RemoveExpiredSessions (void); bool Ses_GetSessionData (void); -void Ses_InsertHiddenParInDB (Act_Action_t Action,const char *ParamName,const char *ParamValue); +void Ses_InsertHiddenParInDB (Act_Action_t NextAction, + const char *ParamName,const char *ParamValue); void Ses_RemoveHiddenParFromThisSession (void); void Ses_RemoveHiddenParFromExpiredSessions (void); -unsigned Ses_GetHiddenParFromDB (Act_Action_t Action,const char *ParamName,char *ParamValue,size_t MaxBytes); +unsigned Ses_GetHiddenParFromDB (Act_Action_t NextAction, + const char *ParamName,char *ParamValue, + size_t MaxBytes); #endif diff --git a/swad_statistic.c b/swad_statistic.c index 7f998497..0d919d18 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -1751,7 +1751,7 @@ static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql /* Write the user's ID if user is a student */ fprintf (Gbl.F.Out,"", Gbl.RowEvenOdd); - ID_WriteUsrIDs (&UsrDat); + ID_WriteUsrIDs (&UsrDat,NULL); fprintf (Gbl.F.Out," "); /* Write the first name and the surnames */ @@ -1912,7 +1912,7 @@ static void Sta_ShowNumHitsPerUsr (unsigned long NumRows, /* Write the user's ID if user is a student in current course */ fprintf (Gbl.F.Out,"", Gbl.RowEvenOdd); - ID_WriteUsrIDs (&UsrDat); + ID_WriteUsrIDs (&UsrDat,NULL); fprintf (Gbl.F.Out," "); /* Write the name and the surnames */ diff --git a/swad_test.c b/swad_test.c index 23c37006..404ddf8b 100644 --- a/swad_test.c +++ b/swad_test.c @@ -7551,7 +7551,7 @@ static void Tst_ShowDataUsr (struct UsrData *UsrDat,unsigned NumTestResults) Act_LinkFormSubmit (UsrDat->FullName,"AUTHOR_TXT",NULL); /***** Show user's ID *****/ - ID_WriteUsrIDs (UsrDat); + ID_WriteUsrIDs (UsrDat,NULL); /***** Show user's name *****/ fprintf (Gbl.F.Out,"
%s",UsrDat->Surname1); @@ -7691,7 +7691,7 @@ void Tst_ShowOneTestResult (void) "" "", Txt_ROLES_SINGUL_Abc[Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB][Gbl.Usrs.Other.UsrDat.Sex]); - ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat); + ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat,NULL); fprintf (Gbl.F.Out," %s", Gbl.Usrs.Other.UsrDat.Surname1); if (Gbl.Usrs.Other.UsrDat.Surname2[0]) diff --git a/swad_text.c b/swad_text.c index 294aa726..516a3c5c 100644 --- a/swad_text.c +++ b/swad_text.c @@ -9591,27 +9591,6 @@ const char *Txt_Do_you_think_you_are_this_user = "Você acha que você é deste usuário?"; #endif -const char *Txt_Do_you_want_to_confirm_the_ID_X = // Warning: it is very important to include %s in the following sentences -#if L==1 - "Voleu confirmar l'ID (DNI/cèdula) %s?"; -#elif L==2 - "Wollen Sie die ID %s zu bestätigen?"; -#elif L==3 - "Do you want to confirm the ID (identity number/passport) %s?"; -#elif L==4 - "¿Desea confirmar el ID (DNI/cédula) %s?"; -#elif L==5 - "Voulez-vous confirmer l'ID %s?"; -#elif L==6 - "¿Desea confirmar el ID (DNI/cédula) %s?"; // Okoteve traducción -#elif L==7 - "Vuoi confermare l'ID %s?"; -#elif L==8 - "Czy chcesz potwierdzić I %s?"; -#elif L==9 - "Você quer confirmar o ID %s?"; -#endif - const char *Txt_Document = #if L==1 "Document"; diff --git a/swad_user.c b/swad_user.c index 34753c36..18b30ba6 100644 --- a/swad_user.c +++ b/swad_user.c @@ -3194,7 +3194,7 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat, UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", BgColor); - ID_WriteUsrIDs (UsrDat); + ID_WriteUsrIDs (UsrDat,NULL); fprintf (Gbl.F.Out,""); /***** Write rest of main user's data *****/ @@ -3239,7 +3239,7 @@ static void Usr_WriteRowGstAllData (struct UsrData *UsrDat) /****** Write user's ID ******/ fprintf (Gbl.F.Out,"", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat); + ID_WriteUsrIDs (UsrDat,NULL); fprintf (Gbl.F.Out," "); /***** Write rest of guest's main data *****/ @@ -3343,7 +3343,7 @@ static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat); + ID_WriteUsrIDs (UsrDat,NULL); fprintf (Gbl.F.Out," "); /***** Write rest of main student's data *****/ @@ -3462,7 +3462,7 @@ static void Usr_WriteRowTchAllData (struct UsrData *UsrDat) UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat); + ID_WriteUsrIDs (UsrDat,NULL); fprintf (Gbl.F.Out," "); /***** Write rest of main teacher's data *****/ @@ -3541,7 +3541,7 @@ static void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat) UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat); + ID_WriteUsrIDs (UsrDat,NULL); fprintf (Gbl.F.Out," "); /***** Write rest of main administrator's data *****/