From c38e98b4618db98e2cb6cf80b38673860ad333d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Fri, 17 Jun 2016 23:38:32 +0200 Subject: [PATCH] Version 15.226.3 --- swad_account.c | 80 +++++++++++++++++++---------------------------- swad_account.h | 12 +++++-- swad_action.c | 2 +- swad_changelog.h | 3 +- swad_duplicate.c | 18 ++++++----- swad_enrollment.c | 7 ++--- 6 files changed, 56 insertions(+), 66 deletions(-) diff --git a/swad_account.c b/swad_account.c index b652b16c2..a7b579aa8 100644 --- a/swad_account.c +++ b/swad_account.c @@ -54,12 +54,6 @@ /****************************** Internal types *******************************/ /*****************************************************************************/ -typedef enum - { - Acc_REQUEST_REMOVE_USR, - Acc_REMOVE_USR, - } Acc_ReqOrRemUsr_t; - /*****************************************************************************/ /************** External global variables from others modules ****************/ /*****************************************************************************/ @@ -86,7 +80,6 @@ static void Acc_PutLinkToRemoveMyAccountParams (void); static void Acc_PrintAccountSeparator (void); -static void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove); static void Acc_AskIfRemoveUsrAccount (bool ItsMe); static void Acc_AskIfRemoveOtherUsrAccount (void); @@ -242,7 +235,7 @@ void Acc_ShowFormChangeMyAccount (void) /***** Put links to change my password and to remove my account*****/ fprintf (Gbl.F.Out,"
"); Pwd_PutLinkToChangeMyPassword (); - if (Acc_CheckIfICanEliminateAccount (true)) // ItsMe = true + if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Me.UsrDat.UsrCod)) Acc_PutLinkToRemoveMyAccount (); fprintf (Gbl.F.Out,"
"); @@ -575,56 +568,44 @@ void Acc_AfterCreationNewAccount (void) } } -/*****************************************************************************/ -/********* Request definite removing of a user from the platform *************/ -/*****************************************************************************/ - -void Acc_ReqRemUsrGbl (void) - { - Acc_ReqRemAccountOrRemAccount (Acc_REQUEST_REMOVE_USR); - } - /*****************************************************************************/ /************** Definite removing of a user from the platform ****************/ /*****************************************************************************/ -void Acc_RemUsrGbl (void) +void Acc_GetUsrCodAndRemUsrGbl (void) { - Acc_ReqRemAccountOrRemAccount (Acc_REMOVE_USR); + extern const char *Txt_User_not_found_or_you_do_not_have_permission_; + + if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) + Acc_ReqRemAccountOrRemAccount (Acc_REMOVE_USR); + else + Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } /*****************************************************************************/ /**************************** Removing of a user *****************************/ /*****************************************************************************/ -static void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove) +void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove) { extern const char *Txt_User_not_found_or_you_do_not_have_permission_; - bool ItsMe; - /***** Get user to be removed *****/ - if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) - { - ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod); - if (Acc_CheckIfICanEliminateAccount (ItsMe)) - switch (RequestOrRemove) - { - case Acc_REQUEST_REMOVE_USR: // Ask if eliminate completely the user from the platform - Acc_AskIfRemoveUsrAccount (ItsMe); - break; - case Acc_REMOVE_USR: // Eliminate completely the user from the platform - if (Pwd_GetConfirmationOnDangerousAction ()) - { - Acc_CompletelyEliminateAccount (&Gbl.Usrs.Other.UsrDat,Cns_VERBOSE); + if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Other.UsrDat.UsrCod)) + switch (RequestOrRemove) + { + case Acc_REQUEST_REMOVE_USR: // Ask if eliminate completely the user from the platform + Acc_AskIfRemoveUsrAccount (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod); + break; + case Acc_REMOVE_USR: // Eliminate completely the user from the platform + if (Pwd_GetConfirmationOnDangerousAction ()) + { + Acc_CompletelyEliminateAccount (&Gbl.Usrs.Other.UsrDat,Cns_VERBOSE); - /***** Move unused contents of messages to table of deleted contents of messages *****/ - Msg_MoveUnusedMsgsContentToDeleted (); - } - break; - } - else - Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); - } + /***** Move unused contents of messages to table of deleted contents of messages *****/ + Msg_MoveUnusedMsgsContentToDeleted (); + } + break; + } else Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } @@ -633,15 +614,18 @@ static void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove) /******** Check if I can eliminate completely another user's account *********/ /*****************************************************************************/ -bool Acc_CheckIfICanEliminateAccount (bool ItsMe) +bool Acc_CheckIfICanEliminateAccount (long UsrCod) { + bool ItsMe = (Gbl.Usrs.Me.Logged && + UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod); + // A user logged as superuser can eliminate any user except her/him // Other users only can eliminate themselves - return (( ItsMe && // It's me - (Gbl.Usrs.Me.AvailableRoles & (1 << Rol_SYS_ADM)) == 0) // I can not be superuser + return (( ItsMe && // It's me + (Gbl.Usrs.Me.AvailableRoles & (1 << Rol_SYS_ADM)) == 0) // I can not be system admin || - (!ItsMe && // It's not me - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)); // I am logged as superuser + (!ItsMe && // It's not me + Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)); // I am logged as system admin } /*****************************************************************************/ diff --git a/swad_account.h b/swad_account.h index 5a54acb37..6287372cf 100644 --- a/swad_account.h +++ b/swad_account.h @@ -40,6 +40,12 @@ /******************************** Public types *******************************/ /*****************************************************************************/ +typedef enum + { + Acc_REQUEST_REMOVE_USR, + Acc_REMOVE_USR, + } Acc_ReqOrRemUsr_t; + /*****************************************************************************/ /****************************** Public prototypes ****************************/ /*****************************************************************************/ @@ -52,10 +58,10 @@ bool Acc_CreateNewAccountAndLogIn (void); void Acc_CreateNewUsr (struct UsrData *UsrDat); void Acc_AfterCreationNewAccount (void); -void Acc_ReqRemUsrGbl (void); -void Acc_RemUsrGbl (void); +void Acc_GetUsrCodAndRemUsrGbl (void); +void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove); -bool Acc_CheckIfICanEliminateAccount (bool ItsMe); +bool Acc_CheckIfICanEliminateAccount (long UsrCod); void Acc_AskIfRemoveMyAccount (void); void Acc_RemoveMyAccount (void); void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, diff --git a/swad_action.c b/swad_action.c index cefdf7f3f..95fe583da 100644 --- a/swad_action.c +++ b/swad_action.c @@ -2446,7 +2446,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActRemStdCrs */{1462,-1,TabUsr,ActLstStd ,0x1F8,0x1E0,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_RemUsrFromCrs ,NULL}, /* ActRemTchCrs */{1463,-1,TabUsr,ActLstTch ,0x1F0,0x1E0,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_RemUsrFromCrs ,NULL}, - /* ActRemUsrGbl */{ 62,-1,TabUsr,ActLstOth ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_RemUsrGbl ,NULL}, + /* ActRemUsrGbl */{ 62,-1,TabUsr,ActLstOth ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_GetUsrCodAndRemUsrGbl ,NULL}, /* ActReqRemAllStdCrs*/{ 88,-1,TabUsr,ActLstStd ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_AskRemAllStdsThisCrs ,NULL}, /* ActRemAllStdCrs */{ 87,-1,TabUsr,ActLstStd ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_RemAllStdsThisCrs ,NULL}, diff --git a/swad_changelog.h b/swad_changelog.h index 6fa0610aa..e5bbfebfc 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -129,13 +129,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.226.2 (2016-06-17)" +#define Log_PLATFORM_VERSION "SWAD 15.226.3 (2016-06-17)" #define CSS_FILE "swad15.226.css" #define JS_FILE "swad15.226.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 15.226.3: Jun 17, 2016 Request the removal of a user account from list of similar users. (202912 lines) Version 15.226.2: Jun 17, 2016 New action to remove a user from list of possible duplicate users. (202921 lines) 1 change necessary in database: INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1580','es','N','Quitar de usuarios duplicados'); diff --git a/swad_duplicate.c b/swad_duplicate.c index 70f518e9d..eb5895ccd 100644 --- a/swad_duplicate.c +++ b/swad_duplicate.c @@ -25,12 +25,10 @@ /*********************************** Headers *********************************/ /*****************************************************************************/ -// #include // For NULL -// #include // For exit, system, malloc, free, rand, etc. -// #include // For string functions - +#include "swad_account.h" #include "swad_database.h" #include "swad_duplicate.h" +#include "swad_enrollment.h" #include "swad_global.h" #include "swad_layout.h" #include "swad_profile.h" @@ -332,10 +330,14 @@ static void Dup_ListSimilarUsrsInternal (void) Gbl.RowEvenOdd); /* Button to remove this user */ - Act_FormStart (ActLstSimUsr); // TODO: Change to action to request confirmation to remove - Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod); - Lay_PutRemoveButtonInline ("Eliminar usuario"); // TODO: Need translation!!! - Act_FormEnd (); + if (Acc_CheckIfICanEliminateAccount (UsrDat.UsrCod)) + { + Act_FormStart (ActUpdOth); + Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod); + Par_PutHiddenParamUnsigned ("RegRemAction",(unsigned) Enr_ELIMINATE_ONE_USR_FROM_PLATFORM); + Lay_PutRemoveButtonInline ("Eliminar usuario"); // TODO: Need translation!!! + Act_FormEnd (); + } /* Button to remove from list of possible duplicate users */ if (Dup_CheckIfUsrIsDup (UsrDat.UsrCod)) diff --git a/swad_enrollment.c b/swad_enrollment.c index 64c70a564..d8de63573 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -1114,7 +1114,7 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) } /***** Eliminate user completely from platform *****/ - if (Acc_CheckIfICanEliminateAccount (ItsMe)) + if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Other.UsrDat.UsrCod)) { fprintf (Gbl.F.Out,"
  • " "