diff --git a/swad_account.c b/swad_account.c index 15749e4b8..8be8bf70f 100644 --- a/swad_account.c +++ b/swad_account.c @@ -53,7 +53,7 @@ typedef enum { Acc_REQUEST_REMOVE_USR, Acc_REMOVE_USR, - } Acc_ReqDelOrDelUsr_t; + } Acc_ReqOrRemUsr_t; /*****************************************************************************/ /************** External global variables from others modules ****************/ @@ -81,7 +81,9 @@ static void Acc_PutLinkToRemoveMyAccountParams (void); static void Acc_PrintAccountSeparator (void); -static void Acc_ReqDelOrDelUsrGbl (Acc_ReqDelOrDelUsr_t ReqDelOrDelUsr); +static void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove); +static void Acc_AskIfRemoveUsrAccount (bool ItsMe); +static void Acc_AskIfRemoveOtherUsrAccount (void); static void Acc_RemoveUsrBriefcase (struct UsrData *UsrDat); static void Acc_RemoveUsr (struct UsrData *UsrDat); @@ -240,8 +242,7 @@ static void Acc_PutLinkToRemoveMyAccount (void) { extern const char *Txt_Remove_account; - // TODO: Put this option in Profile > Account - Act_PutContextualLink (ActUpdOthGst,Acc_PutLinkToRemoveMyAccountParams, + Act_PutContextualLink (ActReqRemMyAcc,Acc_PutLinkToRemoveMyAccountParams, "delon",Txt_Remove_account); } @@ -549,7 +550,7 @@ void Acc_AfterCreationNewAccount (void) void Acc_ReqRemUsrGbl (void) { - Acc_ReqDelOrDelUsrGbl (Acc_REQUEST_REMOVE_USR); + Acc_ReqRemAccountOrRemAccount (Acc_REQUEST_REMOVE_USR); } /*****************************************************************************/ @@ -558,14 +559,14 @@ void Acc_ReqRemUsrGbl (void) void Acc_RemUsrGbl (void) { - Acc_ReqDelOrDelUsrGbl (Acc_REMOVE_USR); + Acc_ReqRemAccountOrRemAccount (Acc_REMOVE_USR); } /*****************************************************************************/ /**************************** Removing of a user *****************************/ /*****************************************************************************/ -static void Acc_ReqDelOrDelUsrGbl (Acc_ReqDelOrDelUsr_t ReqDelOrDelUsr) +static void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove) { extern const char *Txt_User_not_found_or_you_do_not_have_permission_; bool ItsMe; @@ -575,10 +576,10 @@ static void Acc_ReqDelOrDelUsrGbl (Acc_ReqDelOrDelUsr_t ReqDelOrDelUsr) { ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod); if (Acc_CheckIfICanEliminateAccount (ItsMe)) - switch (ReqDelOrDelUsr) + switch (RequestOrRemove) { case Acc_REQUEST_REMOVE_USR: // Ask if eliminate completely the user from the platform - Acc_AskIfCompletelyEliminateAccount (ItsMe); + Acc_AskIfRemoveUsrAccount (ItsMe); break; case Acc_REMOVE_USR: // Eliminate completely the user from the platform if (Pwd_GetConfirmationOnDangerousAction ()) @@ -616,18 +617,42 @@ bool Acc_CheckIfICanEliminateAccount (bool ItsMe) /*********** Ask if really wanted to eliminate completely a user *************/ /*****************************************************************************/ -void Acc_AskIfCompletelyEliminateAccount (bool ItsMe) +static void Acc_AskIfRemoveUsrAccount (bool ItsMe) + { + if (ItsMe) + Acc_AskIfRemoveMyAccount (); + else + Acc_AskIfRemoveOtherUsrAccount (); + } + +void Acc_AskIfRemoveMyAccount (void) { extern const char *Txt_Do_you_really_want_to_completely_eliminate_your_user_account; - extern const char *Txt_Do_you_really_want_to_completely_eliminate_the_following_user; extern const char *Txt_Eliminate_my_user_account; + + Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_completely_eliminate_your_user_account); + + Rec_ShowCommonRecordUnmodifiable (&Gbl.Usrs.Me.UsrDat); + + Act_FormStart (ActRemMyAcc); + + /* Ask for consent on dangerous actions */ + Pwd_AskForConfirmationOnDangerousAction (); + + Lay_PutRemoveButton (Txt_Eliminate_my_user_account); + + Act_FormEnd (); + } + +static void Acc_AskIfRemoveOtherUsrAccount (void) + { + extern const char *Txt_Do_you_really_want_to_completely_eliminate_the_following_user; extern const char *Txt_Eliminate_user_account; extern const char *Txt_User_not_found_or_you_do_not_have_permission_; if (Usr_ChkIfUsrCodExists (Gbl.Usrs.Other.UsrDat.UsrCod)) { - Lay_ShowAlert (Lay_WARNING,ItsMe ? Txt_Do_you_really_want_to_completely_eliminate_your_user_account : - Txt_Do_you_really_want_to_completely_eliminate_the_following_user); + Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_completely_eliminate_the_following_user); Rec_ShowCommonRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat); @@ -637,8 +662,7 @@ void Acc_AskIfCompletelyEliminateAccount (bool ItsMe) /* Ask for consent on dangerous actions */ Pwd_AskForConfirmationOnDangerousAction (); - Lay_PutRemoveButton (ItsMe ? Txt_Eliminate_my_user_account : - Txt_Eliminate_user_account); + Lay_PutRemoveButton (Txt_Eliminate_user_account); Act_FormEnd (); } @@ -650,6 +674,17 @@ void Acc_AskIfCompletelyEliminateAccount (bool ItsMe) /************* Remove completely a user from the whole platform **************/ /*****************************************************************************/ +void Acc_RemoveMyAccount (void) + { + if (Pwd_GetConfirmationOnDangerousAction ()) + { + Acc_CompletelyEliminateAccount (&Gbl.Usrs.Me.UsrDat,Cns_VERBOSE); + + /***** Move unused contents of messages to table of deleted contents of messages *****/ + Msg_MoveUnusedMsgsContentToDeleted (); + } + } + void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, Cns_QuietOrVerbose_t QuietOrVerbose) { diff --git a/swad_account.h b/swad_account.h index 62d994872..64ac1e39e 100644 --- a/swad_account.h +++ b/swad_account.h @@ -53,7 +53,8 @@ void Acc_ReqRemUsrGbl (void); void Acc_RemUsrGbl (void); bool Acc_CheckIfICanEliminateAccount (bool ItsMe); -void Acc_AskIfCompletelyEliminateAccount (bool ItsMe); +void Acc_AskIfRemoveMyAccount (void); +void Acc_RemoveMyAccount (void); void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, Cns_QuietOrVerbose_t QuietOrVerbose); diff --git a/swad_action.c b/swad_action.c index b0610d0af..e721b8df5 100644 --- a/swad_action.c +++ b/swad_action.c @@ -1201,6 +1201,9 @@ Profile: 1020. ActCnfMai Confirm e-mail address 1021. ActFrmChgMyPwd Show form to the change of the password 1022. ActChgPwd Change the password + 1022b. ActReqRemMyAcc Request the removal of my account + 1022c. ActRemMyAcc Remove my account + 1023. ActChgMyData Update my personal data 1024. ActReqMyPho Show form to send my photo @@ -2636,6 +2639,9 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActFrmChgMyPwd */{ 34,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Pwd_ShowFormChgPwd ,NULL}, /* ActChgPwd */{ 35,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Pwd_ActChgMyPwd1 ,Pwd_ActChgMyPwd2 ,NULL}, + /* ActReqRemMyAcc */{1430,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_AskIfRemoveMyAccount ,NULL}, + /* ActRemMyAcc */{1431,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_RemoveMyAccount ,NULL}, + /* ActChgMyData */{ 298,-1,TabPrf,ActReqEdiRecCom ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Rec_UpdateMyRecord ,Rec_ShowMyCommonRecordUpd ,NULL}, /* ActReqMyPho */{ 30,-1,TabPrf,ActReqEdiRecCom ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Pho_ReqMyPhoto ,NULL}, @@ -4132,6 +4138,8 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActReqEnrSevTch, // #1427 ActRcvFrmEnrSevStd, // #1428 ActRcvFrmEnrSevTch, // #1429 + ActReqRemMyAcc, // #1430 + ActRemMyAcc, // #1431 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index 19e32f6bd..f3a43bba3 100644 --- a/swad_action.h +++ b/swad_action.h @@ -69,9 +69,9 @@ typedef enum typedef int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action -#define Act_NUM_ACTIONS (7+52+15+90+73+68+204+182+121+168+28+77) +#define Act_NUM_ACTIONS (7+52+15+90+73+68+204+182+121+168+28+79) -#define Act_MAX_ACTION_COD 1429 +#define Act_MAX_ACTION_COD 1431 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 20 @@ -1244,65 +1244,67 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica #define ActCnfMai (ActSeeAllStaCrs+24) #define ActFrmChgMyPwd (ActSeeAllStaCrs+25) #define ActChgPwd (ActSeeAllStaCrs+26) +#define ActReqRemMyAcc (ActSeeAllStaCrs+27) +#define ActRemMyAcc (ActSeeAllStaCrs+28) -#define ActChgMyData (ActSeeAllStaCrs+27) +#define ActChgMyData (ActSeeAllStaCrs+29) -#define ActReqMyPho (ActSeeAllStaCrs+28) -#define ActDetMyPho (ActSeeAllStaCrs+29) -#define ActUpdMyPho (ActSeeAllStaCrs+30) -#define ActRemMyPho (ActSeeAllStaCrs+31) +#define ActReqMyPho (ActSeeAllStaCrs+30) +#define ActDetMyPho (ActSeeAllStaCrs+31) +#define ActUpdMyPho (ActSeeAllStaCrs+32) +#define ActRemMyPho (ActSeeAllStaCrs+33) -#define ActEdiPri (ActSeeAllStaCrs+32) -#define ActChgPriPho (ActSeeAllStaCrs+33) -#define ActChgPriPrf (ActSeeAllStaCrs+34) +#define ActEdiPri (ActSeeAllStaCrs+34) +#define ActChgPriPho (ActSeeAllStaCrs+35) +#define ActChgPriPrf (ActSeeAllStaCrs+36) -#define ActReqEdiMyIns (ActSeeAllStaCrs+35) -#define ActChgCtyMyIns (ActSeeAllStaCrs+36) -#define ActChgMyIns (ActSeeAllStaCrs+37) -#define ActChgMyCtr (ActSeeAllStaCrs+38) -#define ActChgMyDpt (ActSeeAllStaCrs+39) -#define ActChgMyOff (ActSeeAllStaCrs+40) -#define ActChgMyOffPho (ActSeeAllStaCrs+41) +#define ActReqEdiMyIns (ActSeeAllStaCrs+37) +#define ActChgCtyMyIns (ActSeeAllStaCrs+38) +#define ActChgMyIns (ActSeeAllStaCrs+39) +#define ActChgMyCtr (ActSeeAllStaCrs+40) +#define ActChgMyDpt (ActSeeAllStaCrs+41) +#define ActChgMyOff (ActSeeAllStaCrs+42) +#define ActChgMyOffPho (ActSeeAllStaCrs+43) -#define ActReqEdiMyNet (ActSeeAllStaCrs+42) -#define ActChgMyNet (ActSeeAllStaCrs+43) +#define ActReqEdiMyNet (ActSeeAllStaCrs+44) +#define ActChgMyNet (ActSeeAllStaCrs+45) -#define ActChgLay (ActSeeAllStaCrs+44) -#define ActChgThe (ActSeeAllStaCrs+45) -#define ActReqChgLan (ActSeeAllStaCrs+46) -#define ActChgLan (ActSeeAllStaCrs+47) -#define ActChgCol (ActSeeAllStaCrs+48) -#define ActHidLftCol (ActSeeAllStaCrs+49) -#define ActHidRgtCol (ActSeeAllStaCrs+50) -#define ActShoLftCol (ActSeeAllStaCrs+51) -#define ActShoRgtCol (ActSeeAllStaCrs+52) -#define ActChgIco (ActSeeAllStaCrs+53) -#define ActChgMnu (ActSeeAllStaCrs+54) -#define ActChgNtfPrf (ActSeeAllStaCrs+55) +#define ActChgLay (ActSeeAllStaCrs+46) +#define ActChgThe (ActSeeAllStaCrs+47) +#define ActReqChgLan (ActSeeAllStaCrs+48) +#define ActChgLan (ActSeeAllStaCrs+49) +#define ActChgCol (ActSeeAllStaCrs+50) +#define ActHidLftCol (ActSeeAllStaCrs+51) +#define ActHidRgtCol (ActSeeAllStaCrs+52) +#define ActShoLftCol (ActSeeAllStaCrs+53) +#define ActShoRgtCol (ActSeeAllStaCrs+54) +#define ActChgIco (ActSeeAllStaCrs+55) +#define ActChgMnu (ActSeeAllStaCrs+56) +#define ActChgNtfPrf (ActSeeAllStaCrs+57) -#define ActPrnUsrQR (ActSeeAllStaCrs+56) +#define ActPrnUsrQR (ActSeeAllStaCrs+58) -#define ActPrnMyTimTbl (ActSeeAllStaCrs+57) -#define ActEdiTut (ActSeeAllStaCrs+58) -#define ActChgTut (ActSeeAllStaCrs+59) -#define ActReqRemFilBrf (ActSeeAllStaCrs+60) -#define ActRemFilBrf (ActSeeAllStaCrs+61) -#define ActRemFolBrf (ActSeeAllStaCrs+62) -#define ActCopBrf (ActSeeAllStaCrs+63) -#define ActPasBrf (ActSeeAllStaCrs+64) -#define ActRemTreBrf (ActSeeAllStaCrs+65) -#define ActFrmCreBrf (ActSeeAllStaCrs+66) -#define ActCreFolBrf (ActSeeAllStaCrs+67) -#define ActCreLnkBrf (ActSeeAllStaCrs+68) -#define ActRenFolBrf (ActSeeAllStaCrs+69) -#define ActRcvFilBrfDZ (ActSeeAllStaCrs+70) -#define ActRcvFilBrfCla (ActSeeAllStaCrs+71) -#define ActExpBrf (ActSeeAllStaCrs+72) -#define ActConBrf (ActSeeAllStaCrs+73) -#define ActZIPBrf (ActSeeAllStaCrs+74) -#define ActReqDatBrf (ActSeeAllStaCrs+75) -#define ActChgDatBrf (ActSeeAllStaCrs+76) -#define ActDowBrf (ActSeeAllStaCrs+77) +#define ActPrnMyTimTbl (ActSeeAllStaCrs+59) +#define ActEdiTut (ActSeeAllStaCrs+60) +#define ActChgTut (ActSeeAllStaCrs+61) +#define ActReqRemFilBrf (ActSeeAllStaCrs+62) +#define ActRemFilBrf (ActSeeAllStaCrs+63) +#define ActRemFolBrf (ActSeeAllStaCrs+64) +#define ActCopBrf (ActSeeAllStaCrs+65) +#define ActPasBrf (ActSeeAllStaCrs+66) +#define ActRemTreBrf (ActSeeAllStaCrs+67) +#define ActFrmCreBrf (ActSeeAllStaCrs+68) +#define ActCreFolBrf (ActSeeAllStaCrs+69) +#define ActCreLnkBrf (ActSeeAllStaCrs+70) +#define ActRenFolBrf (ActSeeAllStaCrs+71) +#define ActRcvFilBrfDZ (ActSeeAllStaCrs+72) +#define ActRcvFilBrfCla (ActSeeAllStaCrs+73) +#define ActExpBrf (ActSeeAllStaCrs+74) +#define ActConBrf (ActSeeAllStaCrs+75) +#define ActZIPBrf (ActSeeAllStaCrs+76) +#define ActReqDatBrf (ActSeeAllStaCrs+77) +#define ActChgDatBrf (ActSeeAllStaCrs+78) +#define ActDowBrf (ActSeeAllStaCrs+79) /*****************************************************************************/ /******************************** Public types *******************************/ diff --git a/swad_changelog.h b/swad_changelog.h index 4513d50cb..0b28a77fe 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -98,11 +98,16 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 14.130.3 (2015/09/14)" +#define Log_PLATFORM_VERSION "SWAD 14.131 (2015/09/15)" // 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 14.131: Sep 15, 2015 Changes in user enrollment. (184408 lines) + 2 changes necessary in database: +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1430','es','N','Preguntar si eliminar mi cuenta'); +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1431','es','N','Eliminar mi cuenta'); + Version 14.130.3: Sep 14, 2015 Changes in user enrollment. (184358 lines) Version 14.130.2: Sep 14, 2015 Changes in user enrollment. (184359 lines) Version 14.130.1: Sep 14, 2015 Changes and bug fixing in user enrollment. (184416 lines) diff --git a/swad_enrollment.c b/swad_enrollment.c index 5301e82cf..a3641d28e 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -101,6 +101,7 @@ static void Enr_MarkOfficialStdsAsRemovable (long ImpGrpCod,bool RemoveSpecified static void Enr_RemoveEnrollmentRequest (long CrsCod,long UsrCod); static void Enr_ReqRegRemUsr (Rol_Role_t Role); +static bool Enr_CheckIfICanAdminOtherUsrs (void); static void Enr_ReqAnotherUsrIDToRegisterRemove (Rol_Role_t Role); static void Enr_AskIfRegRemMe (Rol_Role_t Role); static void Enr_AskIfRegRemAnotherUsr (Rol_Role_t Role); @@ -2553,10 +2554,12 @@ static void Enr_RemoveEnrollmentRequest (long CrsCod,long UsrCod) void Enr_PutLinkToAdminOneUsr (Act_Action_t NextAction) { + extern const char *Txt_Admin_me; extern const char *Txt_Admin_one_user; - Act_PutContextualLink (NextAction,NULL, - "configtest",Txt_Admin_one_user); + Act_PutContextualLink (NextAction,NULL,"configtest", + Enr_CheckIfICanAdminOtherUsrs () ? Txt_Admin_one_user : + Txt_Admin_me); } /*****************************************************************************/ @@ -2601,47 +2604,37 @@ void Enr_ReqRegRemAdm (void) static void Enr_ReqRegRemUsr (Rol_Role_t Role) { - extern const char *Txt_You_dont_have_permission_to_perform_this_action; + if (Enr_CheckIfICanAdminOtherUsrs ()) + Enr_ReqAnotherUsrIDToRegisterRemove (Role); + else + Enr_AskIfRegRemMe (Role); + } +/*****************************************************************************/ +/*********** Check If I can admin other users (distinct to me) ***************/ +/*****************************************************************************/ + +static bool Enr_CheckIfICanAdminOtherUsrs (void) + { switch (Gbl.Usrs.Me.LoggedRole) { + case Rol_UNKNOWN: case Rol__GUEST_: - Enr_AskIfRegRemMe (Rol__GUEST_); - break; + case Rol_VISITOR: case Rol_STUDENT: - Enr_AskIfRegRemMe (Rol_STUDENT); - break; + return false; case Rol_TEACHER: - if (Gbl.CurrentCrs.Crs.CrsCod > 0) - Enr_ReqAnotherUsrIDToRegisterRemove (Role); - else - Enr_AskIfRegRemMe (Rol_TEACHER); - break; + return (Gbl.CurrentCrs.Crs.CrsCod > 0); case Rol_DEG_ADM: - if (Gbl.CurrentDeg.Deg.DegCod > 0) - Enr_ReqAnotherUsrIDToRegisterRemove (Role); - else - Enr_AskIfRegRemMe (Rol_DEG_ADM); - break; + return (Gbl.CurrentDeg.Deg.DegCod > 0); case Rol_CTR_ADM: - if (Gbl.CurrentCtr.Ctr.CtrCod > 0) - Enr_ReqAnotherUsrIDToRegisterRemove (Role); - else - Enr_AskIfRegRemMe (Rol_DEG_ADM); - break; + return (Gbl.CurrentCtr.Ctr.CtrCod > 0); case Rol_INS_ADM: - if (Gbl.CurrentIns.Ins.InsCod > 0) - Enr_ReqAnotherUsrIDToRegisterRemove (Role); - else - Enr_AskIfRegRemMe (Rol_DEG_ADM); - break; + return (Gbl.CurrentIns.Ins.InsCod > 0); case Rol_SYS_ADM: - Enr_ReqAnotherUsrIDToRegisterRemove (Role); - break; - default: - Lay_ShowAlert (Lay_ERROR,Txt_You_dont_have_permission_to_perform_this_action); - break; + return true; } + return false; } /*****************************************************************************/ diff --git a/swad_text.c b/swad_text.c index a4bbaa950..80006891a 100644 --- a/swad_text.c +++ b/swad_text.c @@ -1885,6 +1885,27 @@ const char *Txt_Admin_one_user = "Gerenciar um utilizador"; #endif +const char *Txt_Admin_me = +#if L==0 + "Administrarme"; +#elif L==1 + "Verwalten Sie mich"; +#elif L==2 + "Admin me"; +#elif L==3 + "Administrarme"; +#elif L==4 + "Gérer moi"; +#elif L==5 + "Administrarme"; // Okoteve traducción +#elif L==6 + "Gestire mi"; +#elif L==7 + "Zarządzaj mnie"; +#elif L==8 + "Gerenciar me"; +#endif + const char *Txt_Admin_user = #if L==0 "Administrar usuari"; @@ -9886,7 +9907,7 @@ const char *Txt_Enroll_in_groups = #elif L==5 "Inscribirme en grupos"; // Okoteve traducción #elif L==6 - "Iscriver in gruppi"; + "Iscriver mi in gruppi"; #elif L==7 "Zarejestruj mnie w grupach"; #elif L==8