Version 15.226.3

This commit is contained in:
Antonio Cañas Vargas 2016-06-17 23:38:32 +02:00
parent 50fe72d03e
commit c38e98b461
6 changed files with 56 additions and 66 deletions

View File

@ -54,12 +54,6 @@
/****************************** Internal types *******************************/ /****************************** Internal types *******************************/
/*****************************************************************************/ /*****************************************************************************/
typedef enum
{
Acc_REQUEST_REMOVE_USR,
Acc_REMOVE_USR,
} Acc_ReqOrRemUsr_t;
/*****************************************************************************/ /*****************************************************************************/
/************** External global variables from others modules ****************/ /************** External global variables from others modules ****************/
/*****************************************************************************/ /*****************************************************************************/
@ -86,7 +80,6 @@ static void Acc_PutLinkToRemoveMyAccountParams (void);
static void Acc_PrintAccountSeparator (void); static void Acc_PrintAccountSeparator (void);
static void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove);
static void Acc_AskIfRemoveUsrAccount (bool ItsMe); static void Acc_AskIfRemoveUsrAccount (bool ItsMe);
static void Acc_AskIfRemoveOtherUsrAccount (void); static void Acc_AskIfRemoveOtherUsrAccount (void);
@ -242,7 +235,7 @@ void Acc_ShowFormChangeMyAccount (void)
/***** Put links to change my password and to remove my account*****/ /***** Put links to change my password and to remove my account*****/
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">"); fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
Pwd_PutLinkToChangeMyPassword (); Pwd_PutLinkToChangeMyPassword ();
if (Acc_CheckIfICanEliminateAccount (true)) // ItsMe = true if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Me.UsrDat.UsrCod))
Acc_PutLinkToRemoveMyAccount (); Acc_PutLinkToRemoveMyAccount ();
fprintf (Gbl.F.Out,"</div>"); fprintf (Gbl.F.Out,"</div>");
@ -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 ****************/ /************** 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 *****************************/ /**************************** 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_; extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
bool ItsMe;
/***** Get user to be removed *****/ if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Other.UsrDat.UsrCod))
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) switch (RequestOrRemove)
{ {
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod); case Acc_REQUEST_REMOVE_USR: // Ask if eliminate completely the user from the platform
if (Acc_CheckIfICanEliminateAccount (ItsMe)) Acc_AskIfRemoveUsrAccount (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
switch (RequestOrRemove) break;
{ case Acc_REMOVE_USR: // Eliminate completely the user from the platform
case Acc_REQUEST_REMOVE_USR: // Ask if eliminate completely the user from the platform if (Pwd_GetConfirmationOnDangerousAction ())
Acc_AskIfRemoveUsrAccount (ItsMe); {
break; Acc_CompletelyEliminateAccount (&Gbl.Usrs.Other.UsrDat,Cns_VERBOSE);
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 *****/ /***** Move unused contents of messages to table of deleted contents of messages *****/
Msg_MoveUnusedMsgsContentToDeleted (); Msg_MoveUnusedMsgsContentToDeleted ();
} }
break; break;
} }
else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
}
else else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); 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 *********/ /******** 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 // A user logged as superuser can eliminate any user except her/him
// Other users only can eliminate themselves // Other users only can eliminate themselves
return (( ItsMe && // It's me return (( ItsMe && // It's me
(Gbl.Usrs.Me.AvailableRoles & (1 << Rol_SYS_ADM)) == 0) // I can not be superuser (Gbl.Usrs.Me.AvailableRoles & (1 << Rol_SYS_ADM)) == 0) // I can not be system admin
|| ||
(!ItsMe && // It's not me (!ItsMe && // It's not me
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)); // I am logged as superuser Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)); // I am logged as system admin
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -40,6 +40,12 @@
/******************************** Public types *******************************/ /******************************** Public types *******************************/
/*****************************************************************************/ /*****************************************************************************/
typedef enum
{
Acc_REQUEST_REMOVE_USR,
Acc_REMOVE_USR,
} Acc_ReqOrRemUsr_t;
/*****************************************************************************/ /*****************************************************************************/
/****************************** Public prototypes ****************************/ /****************************** Public prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
@ -52,10 +58,10 @@ bool Acc_CreateNewAccountAndLogIn (void);
void Acc_CreateNewUsr (struct UsrData *UsrDat); void Acc_CreateNewUsr (struct UsrData *UsrDat);
void Acc_AfterCreationNewAccount (void); void Acc_AfterCreationNewAccount (void);
void Acc_ReqRemUsrGbl (void); void Acc_GetUsrCodAndRemUsrGbl (void);
void Acc_RemUsrGbl (void); void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove);
bool Acc_CheckIfICanEliminateAccount (bool ItsMe); bool Acc_CheckIfICanEliminateAccount (long UsrCod);
void Acc_AskIfRemoveMyAccount (void); void Acc_AskIfRemoveMyAccount (void);
void Acc_RemoveMyAccount (void); void Acc_RemoveMyAccount (void);
void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,

View File

@ -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}, /* 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}, /* 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}, /* 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}, /* ActRemAllStdCrs */{ 87,-1,TabUsr,ActLstStd ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_RemAllStdsThisCrs ,NULL},

View File

@ -129,13 +129,14 @@
/****************************** Public constants *****************************/ /****************************** 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 CSS_FILE "swad15.226.css"
#define JS_FILE "swad15.226.js" #define JS_FILE "swad15.226.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // 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 // 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) 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: 1 change necessary in database:
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1580','es','N','Quitar de usuarios duplicados'); INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1580','es','N','Quitar de usuarios duplicados');

View File

@ -25,12 +25,10 @@
/*********************************** Headers *********************************/ /*********************************** Headers *********************************/
/*****************************************************************************/ /*****************************************************************************/
// #include <linux/stddef.h> // For NULL #include "swad_account.h"
// #include <stdlib.h> // For exit, system, malloc, free, rand, etc.
// #include <string.h> // For string functions
#include "swad_database.h" #include "swad_database.h"
#include "swad_duplicate.h" #include "swad_duplicate.h"
#include "swad_enrollment.h"
#include "swad_global.h" #include "swad_global.h"
#include "swad_layout.h" #include "swad_layout.h"
#include "swad_profile.h" #include "swad_profile.h"
@ -332,10 +330,14 @@ static void Dup_ListSimilarUsrsInternal (void)
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
/* Button to remove this user */ /* Button to remove this user */
Act_FormStart (ActLstSimUsr); // TODO: Change to action to request confirmation to remove if (Acc_CheckIfICanEliminateAccount (UsrDat.UsrCod))
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod); {
Lay_PutRemoveButtonInline ("Eliminar usuario"); // TODO: Need translation!!! Act_FormStart (ActUpdOth);
Act_FormEnd (); 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 */ /* Button to remove from list of possible duplicate users */
if (Dup_CheckIfUsrIsDup (UsrDat.UsrCod)) if (Dup_CheckIfUsrIsDup (UsrDat.UsrCod))

View File

@ -1114,7 +1114,7 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe)
} }
/***** Eliminate user completely from platform *****/ /***** Eliminate user completely from platform *****/
if (Acc_CheckIfICanEliminateAccount (ItsMe)) if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Other.UsrDat.UsrCod))
{ {
fprintf (Gbl.F.Out,"<li>" fprintf (Gbl.F.Out,"<li>"
"<input type=\"radio\" name=\"RegRemAction\" value=\"%u\"", "<input type=\"radio\" name=\"RegRemAction\" value=\"%u\"",
@ -3780,10 +3780,7 @@ void Enr_ModifyUsr (void)
Error = true; Error = true;
break; break;
case Enr_ELIMINATE_ONE_USR_FROM_PLATFORM: case Enr_ELIMINATE_ONE_USR_FROM_PLATFORM:
if (Acc_CheckIfICanEliminateAccount (ItsMe)) Acc_ReqRemAccountOrRemAccount (Acc_REQUEST_REMOVE_USR);
Acc_ReqRemUsrGbl ();
else
Error = true;
break; break;
default: default:
Error = true; Error = true;