mirror of https://github.com/acanas/swad-core.git
Version 14.72.2
This commit is contained in:
parent
29d6c229fa
commit
9b133468ca
|
@ -39,11 +39,12 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 14.72.1 (2015/02/01)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 14.72.2 (2015/02/01)"
|
||||
|
||||
// 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 | tail -1
|
||||
/*
|
||||
Version 14.72.2: Feb 01, 2015 Refactoring of registering and removing admins. (177496 lines)
|
||||
Version 14.72.1: Feb 01, 2015 New options to register and remove institution and centre admins. (177477 lines)
|
||||
6 changes necessary in database:
|
||||
UPDATE actions SET Txt='Añadir administrador de titulación' WHERE ActCod='586' AND Language='es';
|
||||
|
|
|
@ -2523,7 +2523,9 @@ void Crs_ChangeCrsDegree (void)
|
|||
if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)
|
||||
ICanChangeCrsToNewDeg = true;
|
||||
else if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_DEG_ADMIN)
|
||||
ICanChangeCrsToNewDeg = Usr_CheckIfUsrIsAdmOfDeg (Gbl.Usrs.Me.UsrDat.UsrCod,NewDeg.DegCod);
|
||||
ICanChangeCrsToNewDeg = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Sco_SCOPE_DEGREE,
|
||||
NewDeg.DegCod);
|
||||
else
|
||||
ICanChangeCrsToNewDeg = false;
|
||||
|
||||
|
|
|
@ -828,23 +828,26 @@ static bool Enr_PutActionsRegRemOneUsr (bool ItsMe)
|
|||
/***** Check if the other user is administrator of the current institution *****/
|
||||
if ((Gbl.Usrs.Me.LoggedRole == Rol_ROLE_INS_ADMIN && ItsMe) ||
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)
|
||||
UsrIsInsAdmin = Usr_CheckIfUsrIsAdmOfIns (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
UsrIsInsAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Sco_SCOPE_INSTITUTION,
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
|
||||
if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
|
||||
{
|
||||
/***** Check if the other user is administrator of the current centre *****/
|
||||
if ((Gbl.Usrs.Me.LoggedRole == Rol_ROLE_CTR_ADMIN && ItsMe) ||
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)
|
||||
UsrIsCtrAdmin = Usr_CheckIfUsrIsAdmOfCtr (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
UsrIsCtrAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Sco_SCOPE_CENTRE,
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
|
||||
if (Gbl.CurrentDeg.Deg.DegCod > 0)
|
||||
/***** Check if the other user is administrator of the current degree *****/
|
||||
if ((Gbl.Usrs.Me.LoggedRole == Rol_ROLE_DEG_ADMIN && ItsMe) ||
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)
|
||||
UsrIsDegAdmin = Usr_CheckIfUsrIsAdmOfDeg (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
UsrIsDegAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Sco_SCOPE_DEGREE,
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2946,7 +2949,9 @@ static void Enr_RegisterAdminInCurrentIns (struct UsrData *UsrDat)
|
|||
char Query[512];
|
||||
|
||||
/***** Check if user was and administrator of current institution *****/
|
||||
if (Usr_CheckIfUsrIsAdmOfIns (UsrDat->UsrCod,Gbl.CurrentIns.Ins.InsCod))
|
||||
if (Usr_CheckIfUsrIsAdm (UsrDat->UsrCod,
|
||||
Sco_SCOPE_INSTITUTION,
|
||||
Gbl.CurrentIns.Ins.InsCod))
|
||||
sprintf (Gbl.Message,Txt_THE_USER_X_is_already_an_administrator_of_the_institution_Y,
|
||||
UsrDat->FullName,Gbl.CurrentIns.Ins.FullName);
|
||||
else // User was not administrator of current institution
|
||||
|
@ -2974,7 +2979,9 @@ static void Enr_RegisterAdminInCurrentCtr (struct UsrData *UsrDat)
|
|||
char Query[512];
|
||||
|
||||
/***** Check if user was and administrator of current centre *****/
|
||||
if (Usr_CheckIfUsrIsAdmOfCtr (UsrDat->UsrCod,Gbl.CurrentCtr.Ctr.CtrCod))
|
||||
if (Usr_CheckIfUsrIsAdm (UsrDat->UsrCod,
|
||||
Sco_SCOPE_CENTRE,
|
||||
Gbl.CurrentCtr.Ctr.CtrCod))
|
||||
sprintf (Gbl.Message,Txt_THE_USER_X_is_already_an_administrator_of_the_centre_Y,
|
||||
UsrDat->FullName,Gbl.CurrentCtr.Ctr.FullName);
|
||||
else // User was not administrator of current centre
|
||||
|
@ -3002,7 +3009,9 @@ static void Enr_RegisterAdminInCurrentDeg (struct UsrData *UsrDat)
|
|||
char Query[512];
|
||||
|
||||
/***** Check if user was and administrator of current degree *****/
|
||||
if (Usr_CheckIfUsrIsAdmOfDeg (UsrDat->UsrCod,Gbl.CurrentDeg.Deg.DegCod))
|
||||
if (Usr_CheckIfUsrIsAdm (UsrDat->UsrCod,
|
||||
Sco_SCOPE_DEGREE,
|
||||
Gbl.CurrentDeg.Deg.DegCod))
|
||||
sprintf (Gbl.Message,Txt_THE_USER_X_is_already_an_administrator_of_the_degree_Y,
|
||||
UsrDat->FullName,Gbl.CurrentDeg.Deg.FullName);
|
||||
else // User was not administrator of current degree
|
||||
|
@ -3162,7 +3171,9 @@ static void Enr_ReqRemOrRemAdmIns (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr)
|
|||
if (ICanRemove)
|
||||
{
|
||||
/* Check if the other user is and admin of the current institution */
|
||||
if (Usr_CheckIfUsrIsAdmOfIns (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentIns.Ins.InsCod))
|
||||
if (Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Sco_SCOPE_INSTITUTION,
|
||||
Gbl.CurrentIns.Ins.InsCod))
|
||||
{ // The other user is an administrator of current degree ==> ask for removing or remove him
|
||||
switch (ReqDelOrDelUsr)
|
||||
{
|
||||
|
@ -3213,7 +3224,9 @@ static void Enr_ReqRemOrRemAdmCtr (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr)
|
|||
if (ICanRemove)
|
||||
{
|
||||
/* Check if the other user is and admin of the current centre */
|
||||
if (Usr_CheckIfUsrIsAdmOfCtr (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentCtr.Ctr.CtrCod))
|
||||
if (Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Sco_SCOPE_CENTRE,
|
||||
Gbl.CurrentCtr.Ctr.CtrCod))
|
||||
{ // The other user is an administrator of current centre ==> ask for removing or remove him
|
||||
switch (ReqDelOrDelUsr)
|
||||
{
|
||||
|
@ -3264,7 +3277,9 @@ static void Enr_ReqRemOrRemAdmDeg (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr)
|
|||
if (ICanRemove)
|
||||
{
|
||||
/* Check if the other user is and admin of the current degree */
|
||||
if (Usr_CheckIfUsrIsAdmOfDeg (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentDeg.Deg.DegCod))
|
||||
if (Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Sco_SCOPE_DEGREE,
|
||||
Gbl.CurrentDeg.Deg.DegCod))
|
||||
{ // The other user is an administrator of current degree ==> ask for removing or remove him
|
||||
switch (ReqDelOrDelUsr)
|
||||
{
|
||||
|
@ -3310,7 +3325,9 @@ static void Enr_ReqAddAdmOfIns (void)
|
|||
/* Check if it's allowed to register this administrator in institution */
|
||||
if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)
|
||||
{
|
||||
if (Usr_CheckIfUsrIsAdmOfIns (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentIns.Ins.InsCod)) // User is yet an administrator of current institution
|
||||
if (Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Sco_SCOPE_INSTITUTION,
|
||||
Gbl.CurrentIns.Ins.InsCod)) // User is yet an administrator of current institution
|
||||
{
|
||||
sprintf (Gbl.Message,Txt_THE_USER_X_is_already_an_administrator_of_the_institution_Y,
|
||||
Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentIns.Ins.FullName);
|
||||
|
@ -3360,7 +3377,9 @@ static void Enr_ReqAddAdmOfCtr (void)
|
|||
/* Check if it's allowed to register this administrator in centre */
|
||||
if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)
|
||||
{
|
||||
if (Usr_CheckIfUsrIsAdmOfCtr (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentCtr.Ctr.CtrCod)) // User is yet an administrator of current centre
|
||||
if (Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Sco_SCOPE_CENTRE,
|
||||
Gbl.CurrentCtr.Ctr.CtrCod)) // User is yet an administrator of current centre
|
||||
{
|
||||
sprintf (Gbl.Message,Txt_THE_USER_X_is_already_an_administrator_of_the_centre_Y,
|
||||
Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCtr.Ctr.FullName);
|
||||
|
@ -3410,7 +3429,9 @@ static void Enr_ReqAddAdmOfDeg (void)
|
|||
/* Check if it's allowed to register this administrator in degree */
|
||||
if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)
|
||||
{
|
||||
if (Usr_CheckIfUsrIsAdmOfDeg (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentDeg.Deg.DegCod)) // User is yet an administrator of current degree
|
||||
if (Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Sco_SCOPE_DEGREE,
|
||||
Gbl.CurrentDeg.Deg.DegCod)) // User is yet an administrator of current degree
|
||||
{
|
||||
sprintf (Gbl.Message,Txt_THE_USER_X_is_already_an_administrator_of_the_degree_Y,
|
||||
Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentDeg.Deg.FullName);
|
||||
|
@ -3871,7 +3892,9 @@ static void Enr_EffectivelyRemAdmFromIns (struct UsrData *UsrDat)
|
|||
extern const char *Txt_THE_USER_X_is_not_an_administrator_of_the_institution_Y;
|
||||
char Query[1024];
|
||||
|
||||
if (Usr_CheckIfUsrIsAdmOfIns (UsrDat->UsrCod,Gbl.CurrentIns.Ins.InsCod)) // User is administrator of current institution
|
||||
if (Usr_CheckIfUsrIsAdm (UsrDat->UsrCod,
|
||||
Sco_SCOPE_INSTITUTION,
|
||||
Gbl.CurrentIns.Ins.InsCod)) // User is administrator of current institution
|
||||
{
|
||||
/***** Remove user from the table of admins *****/
|
||||
sprintf (Query,"DELETE FROM admin"
|
||||
|
@ -3901,7 +3924,9 @@ static void Enr_EffectivelyRemAdmFromCtr (struct UsrData *UsrDat)
|
|||
extern const char *Txt_THE_USER_X_is_not_an_administrator_of_the_centre_Y;
|
||||
char Query[1024];
|
||||
|
||||
if (Usr_CheckIfUsrIsAdmOfCtr (UsrDat->UsrCod,Gbl.CurrentCtr.Ctr.CtrCod)) // User is administrator of current centre
|
||||
if (Usr_CheckIfUsrIsAdm (UsrDat->UsrCod,
|
||||
Sco_SCOPE_CENTRE,
|
||||
Gbl.CurrentCtr.Ctr.CtrCod)) // User is administrator of current centre
|
||||
{
|
||||
/***** Remove user from the table of admins *****/
|
||||
sprintf (Query,"DELETE FROM admin"
|
||||
|
@ -3931,7 +3956,9 @@ static void Enr_EffectivelyRemAdmFromDeg (struct UsrData *UsrDat)
|
|||
extern const char *Txt_THE_USER_X_is_not_an_administrator_of_the_degree_Y;
|
||||
char Query[1024];
|
||||
|
||||
if (Usr_CheckIfUsrIsAdmOfDeg (UsrDat->UsrCod,Gbl.CurrentDeg.Deg.DegCod)) // User is administrator of current degree
|
||||
if (Usr_CheckIfUsrIsAdm (UsrDat->UsrCod,
|
||||
Sco_SCOPE_DEGREE,
|
||||
Gbl.CurrentDeg.Deg.DegCod)) // User is administrator of current degree
|
||||
{
|
||||
/***** Remove user from the table of admins *****/
|
||||
sprintf (Query,"DELETE FROM admin"
|
||||
|
|
11
swad_scope.c
11
swad_scope.c
|
@ -34,6 +34,17 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
const char *Sco_ScopeAdminDB[Sco_NUM_SCOPES] =
|
||||
{
|
||||
NULL, // Sco_SCOPE_NONE
|
||||
NULL, // Sco_SCOPE_PLATFORM,
|
||||
NULL, // Sco_SCOPE_COUNTRY,
|
||||
"Ins", // Sco_SCOPE_INSTITUTION,
|
||||
"Ctr", // Sco_SCOPE_CENTRE,
|
||||
"Deg", // Sco_SCOPE_DEGREE,
|
||||
NULL, // Sco_SCOPE_COURSE,
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Internal constants ****************************/
|
||||
/*****************************************************************************/
|
||||
|
|
53
swad_user.c
53
swad_user.c
|
@ -110,8 +110,6 @@ static void Usr_GetMyLastData (void);
|
|||
static void Usr_GetUsrCommentsFromString (char *Str,struct UsrData *UsrDat);
|
||||
static Usr_Sex_t Usr_GetSexFromStr (const char *Str);
|
||||
|
||||
static bool Usr_CheckIfUsrIsAdmOf (long UsrCod,const char *Scope,long Cod);
|
||||
|
||||
static bool Usr_CheckIfMyBirthdayHasNotBeenCongratulated (void);
|
||||
static void Usr_InsertMyBirthday (void);
|
||||
|
||||
|
@ -696,45 +694,19 @@ void Usr_RestrictLengthAndWriteName (struct UsrData *UsrDat,unsigned MaxChars)
|
|||
/*********** Check if a user is an administrator of an institution ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Usr_CheckIfUsrIsAdmOfIns (long UsrCod,long InsCod)
|
||||
{
|
||||
/***** Get if a user is administrator of an institution from database *****/
|
||||
return Usr_CheckIfUsrIsAdmOf (UsrCod,"Ins",InsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Check if a user is an administrator of a centre ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Usr_CheckIfUsrIsAdmOfCtr (long UsrCod,long CtrCod)
|
||||
{
|
||||
/***** Get if a user is administrator of a centre from database *****/
|
||||
return Usr_CheckIfUsrIsAdmOf (UsrCod,"Ctr",CtrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Check if a user is an administrator of a degree ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Usr_CheckIfUsrIsAdmOfDeg (long UsrCod,long DegCod)
|
||||
{
|
||||
/***** Get if a user is administrator of a degree from database *****/
|
||||
return Usr_CheckIfUsrIsAdmOf (UsrCod,"Deg",DegCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Check if a user is an administrator of an institution ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
static bool Usr_CheckIfUsrIsAdmOf (long UsrCod,const char *Scope,long Cod)
|
||||
bool Usr_CheckIfUsrIsAdm (long UsrCod,Sco_Scope_t Scope,long Cod)
|
||||
{
|
||||
extern const char *Sco_ScopeAdminDB[Sco_NUM_SCOPES];
|
||||
char Query[128];
|
||||
|
||||
/***** Get if a user is administrator of a degree from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM admin"
|
||||
" WHERE UsrCod='%ld' AND Scope='%s' AND Cod='%ld'",
|
||||
UsrCod,Scope,Cod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a user is administrator") != 0);
|
||||
if (Sco_ScopeAdminDB[Scope])
|
||||
{
|
||||
/***** Get if a user is administrator of a degree from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM admin"
|
||||
" WHERE UsrCod='%ld' AND Scope='%s' AND Cod='%ld'",
|
||||
UsrCod,Sco_ScopeAdminDB[Scope],Cod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a user is administrator") != 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2253,7 +2225,10 @@ static void Usr_SetUsrRoleAndPrefs (void)
|
|||
/***** Check if I belong to current degree and if I am administrator of current degree *****/
|
||||
if (Gbl.CurrentDeg.Deg.DegCod > 0)
|
||||
/* Check if I am and administrator of current degree */
|
||||
ICanBeAdmin = Usr_CheckIfUsrIsAdmOfDeg (Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.CurrentDeg.Deg.DegCod);
|
||||
ICanBeAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Sco_SCOPE_DEGREE,
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
|
||||
|
||||
/***** Check if I belong to current course *****/
|
||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
|
||||
|
|
|
@ -206,9 +206,7 @@ void Usr_BuildFullName (struct UsrData *UsrDat);
|
|||
|
||||
void Usr_RestrictLengthAndWriteName (struct UsrData *UsrDat,unsigned MaxChars);
|
||||
|
||||
bool Usr_CheckIfUsrIsAdmOfIns (long UsrCod,long InsCod);
|
||||
bool Usr_CheckIfUsrIsAdmOfCtr (long UsrCod,long CtrCod);
|
||||
bool Usr_CheckIfUsrIsAdmOfDeg (long UsrCod,long DegCod);
|
||||
bool Usr_CheckIfUsrIsAdm (long UsrCod,Sco_Scope_t Scope,long Cod);
|
||||
bool Usr_CheckIfUsrIsSuperuser (long UsrCod);
|
||||
bool Usr_CheckIfUsrSharesAnyOfMyCrs (long UsrCod);
|
||||
void Usr_GetMyInstitutions (void);
|
||||
|
|
Loading…
Reference in New Issue