mirror of https://github.com/acanas/swad-core.git
Version 23.25: Oct 03, 2023 Code refactoring in user's roles.
This commit is contained in:
parent
2f5fd84097
commit
e286fdde15
|
@ -632,10 +632,11 @@ TODO: Francisco Javier Fern
|
||||||
Me sale este error, no sé si por no recordar yo la sintaxis apropiada para mandar a varios destinatarios. ¿No era así?
|
Me sale este error, no sé si por no recordar yo la sintaxis apropiada para mandar a varios destinatarios. ¿No era así?
|
||||||
"can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod')
|
"can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod')
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 23.24 (2023-10-03)"
|
#define Log_PLATFORM_VERSION "SWAD 23.25 (2023-10-03)"
|
||||||
#define CSS_FILE "swad23.16.1.css"
|
#define CSS_FILE "swad23.16.1.css"
|
||||||
#define JS_FILE "swad22.49.js"
|
#define JS_FILE "swad22.49.js"
|
||||||
/*
|
/*
|
||||||
|
Version 23.25: Oct 03, 2023 Code refactoring in user's roles. (336276 lines)
|
||||||
Version 23.24: Oct 03, 2023 Code refactoring in user's hierarchy. (336276 lines)
|
Version 23.24: Oct 03, 2023 Code refactoring in user's hierarchy. (336276 lines)
|
||||||
Version 23.23.1: Oct 03, 2023 Removed unused code in user's hierarchy. (336349 lines)
|
Version 23.23.1: Oct 03, 2023 Removed unused code in user's hierarchy. (336349 lines)
|
||||||
Version 23.23: Oct 03, 2023 Code refactoring in user's hierarchy. (336620 lines)
|
Version 23.23: Oct 03, 2023 Code refactoring in user's hierarchy. (336620 lines)
|
||||||
|
|
|
@ -574,7 +574,7 @@ void Crs_WriteSelectorMyCoursesInBreadcrumb (void)
|
||||||
|
|
||||||
/***** Begin form *****/
|
/***** Begin form *****/
|
||||||
Frm_BeginFormGoTo (Gbl.Usrs.Me.Hierarchy[Hie_CRS].Num ? ActSeePrg :
|
Frm_BeginFormGoTo (Gbl.Usrs.Me.Hierarchy[Hie_CRS].Num ? ActSeePrg :
|
||||||
ActReqSch);
|
ActReqSch);
|
||||||
|
|
||||||
/***** Begin selector of courses *****/
|
/***** Begin selector of courses *****/
|
||||||
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL,
|
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL,
|
||||||
|
|
18
swad_forum.c
18
swad_forum.c
|
@ -1537,7 +1537,7 @@ static long For_WriteLinksToInsForums (const struct For_Forums *Forums,
|
||||||
|
|
||||||
if (InsCod > 0)
|
if (InsCod > 0)
|
||||||
{
|
{
|
||||||
MaxRoleInIns = Rol_GetMyMaxRoleInIns (InsCod);
|
MaxRoleInIns = Rol_GetMyMaxRoleIn (Hie_INS,InsCod);
|
||||||
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
MaxRoleInIns == Rol_NET ||
|
MaxRoleInIns == Rol_NET ||
|
||||||
MaxRoleInIns == Rol_TCH);
|
MaxRoleInIns == Rol_TCH);
|
||||||
|
@ -1580,7 +1580,7 @@ static long For_WriteLinksToCtrForums (const struct For_Forums *Forums,
|
||||||
|
|
||||||
if (CtrCod > 0)
|
if (CtrCod > 0)
|
||||||
{
|
{
|
||||||
MaxRoleInCtr = Rol_GetMyMaxRoleInCtr (CtrCod);
|
MaxRoleInCtr = Rol_GetMyMaxRoleIn (Hie_CTR,CtrCod);
|
||||||
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
MaxRoleInCtr == Rol_NET ||
|
MaxRoleInCtr == Rol_NET ||
|
||||||
MaxRoleInCtr == Rol_TCH);
|
MaxRoleInCtr == Rol_TCH);
|
||||||
|
@ -1623,7 +1623,7 @@ static long For_WriteLinksToDegForums (const struct For_Forums *Forums,
|
||||||
|
|
||||||
if (DegCod > 0)
|
if (DegCod > 0)
|
||||||
{
|
{
|
||||||
MaxRoleInDeg = Rol_GetMyMaxRoleInDeg (DegCod);
|
MaxRoleInDeg = Rol_GetMyMaxRoleIn (Hie_DEG,DegCod);
|
||||||
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
MaxRoleInDeg == Rol_NET ||
|
MaxRoleInDeg == Rol_NET ||
|
||||||
MaxRoleInDeg == Rol_TCH);
|
MaxRoleInDeg == Rol_TCH);
|
||||||
|
@ -2662,40 +2662,40 @@ static void For_RestrictAccess (const struct For_Forums *Forums)
|
||||||
(1 << Rol_TCH)));
|
(1 << Rol_TCH)));
|
||||||
break;
|
break;
|
||||||
case For_FORUM_INSTIT_USRS:
|
case For_FORUM_INSTIT_USRS:
|
||||||
MaxRole = Rol_GetMyMaxRoleInIns (Forums->Forum.HieCod);
|
MaxRole = Rol_GetMyMaxRoleIn (Hie_INS,Forums->Forum.HieCod);
|
||||||
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
MaxRole == Rol_STD ||
|
MaxRole == Rol_STD ||
|
||||||
MaxRole == Rol_NET ||
|
MaxRole == Rol_NET ||
|
||||||
MaxRole == Rol_TCH);
|
MaxRole == Rol_TCH);
|
||||||
break;
|
break;
|
||||||
case For_FORUM_INSTIT_TCHS:
|
case For_FORUM_INSTIT_TCHS:
|
||||||
MaxRole = Rol_GetMyMaxRoleInIns (Forums->Forum.HieCod);
|
MaxRole = Rol_GetMyMaxRoleIn (Hie_INS,Forums->Forum.HieCod);
|
||||||
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
MaxRole == Rol_NET ||
|
MaxRole == Rol_NET ||
|
||||||
MaxRole == Rol_TCH);
|
MaxRole == Rol_TCH);
|
||||||
break;
|
break;
|
||||||
case For_FORUM_CENTER_USRS:
|
case For_FORUM_CENTER_USRS:
|
||||||
MaxRole = Rol_GetMyMaxRoleInCtr (Forums->Forum.HieCod);
|
MaxRole = Rol_GetMyMaxRoleIn (Hie_CTR,Forums->Forum.HieCod);
|
||||||
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
MaxRole >= Rol_STD ||
|
MaxRole >= Rol_STD ||
|
||||||
MaxRole == Rol_NET ||
|
MaxRole == Rol_NET ||
|
||||||
MaxRole == Rol_TCH);
|
MaxRole == Rol_TCH);
|
||||||
break;
|
break;
|
||||||
case For_FORUM_CENTER_TCHS:
|
case For_FORUM_CENTER_TCHS:
|
||||||
MaxRole = Rol_GetMyMaxRoleInCtr (Forums->Forum.HieCod);
|
MaxRole = Rol_GetMyMaxRoleIn (Hie_CTR,Forums->Forum.HieCod);
|
||||||
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
MaxRole == Rol_NET ||
|
MaxRole == Rol_NET ||
|
||||||
MaxRole == Rol_TCH);
|
MaxRole == Rol_TCH);
|
||||||
break;
|
break;
|
||||||
case For_FORUM_DEGREE_USRS:
|
case For_FORUM_DEGREE_USRS:
|
||||||
MaxRole = Rol_GetMyMaxRoleInDeg (Forums->Forum.HieCod);
|
MaxRole = Rol_GetMyMaxRoleIn (Hie_DEG,Forums->Forum.HieCod);
|
||||||
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
MaxRole >= Rol_STD ||
|
MaxRole >= Rol_STD ||
|
||||||
MaxRole == Rol_NET ||
|
MaxRole == Rol_NET ||
|
||||||
MaxRole == Rol_TCH);
|
MaxRole == Rol_TCH);
|
||||||
break;
|
break;
|
||||||
case For_FORUM_DEGREE_TCHS:
|
case For_FORUM_DEGREE_TCHS:
|
||||||
MaxRole = Rol_GetMyMaxRoleInDeg (Forums->Forum.HieCod);
|
MaxRole = Rol_GetMyMaxRoleIn (Hie_DEG,Forums->Forum.HieCod);
|
||||||
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
MaxRole == Rol_NET ||
|
MaxRole == Rol_NET ||
|
||||||
MaxRole == Rol_TCH);
|
MaxRole == Rol_TCH);
|
||||||
|
|
|
@ -1048,7 +1048,7 @@ bool Hie_CheckIfIBelongTo (Hie_Level_t Level,long HieCod)
|
||||||
{
|
{
|
||||||
unsigned NumMyNode;
|
unsigned NumMyNode;
|
||||||
|
|
||||||
/***** Fill the list with the centers I belong to *****/
|
/***** Fill the list with the nodes I belong to *****/
|
||||||
Hie_GetMyHierarchy (Level);
|
Hie_GetMyHierarchy (Level);
|
||||||
|
|
||||||
/***** Check if the node passed as parameter is any of my nodes *****/
|
/***** Check if the node passed as parameter is any of my nodes *****/
|
||||||
|
|
87
swad_role.c
87
swad_role.c
|
@ -247,74 +247,27 @@ Rol_Role_t Rol_GetMaxRoleInCrss (unsigned Roles)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************* Get my maximum role in a institution ********************/
|
/***** Get my maximum role in a course/degree/center/institution/country *****/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
Rol_Role_t Rol_GetMyMaxRoleInIns (long InsCod)
|
Rol_Role_t Rol_GetMyMaxRoleIn (Hie_Level_t Level,long HieCod)
|
||||||
{
|
{
|
||||||
unsigned NumMyIns;
|
unsigned NumMyNode;
|
||||||
|
|
||||||
if (InsCod > 0)
|
|
||||||
{
|
|
||||||
/***** Fill the list with the institutions I belong to (if not already filled) *****/
|
|
||||||
Hie_GetMyHierarchy (Hie_INS);
|
|
||||||
|
|
||||||
/***** Check if the institution passed as parameter is any of my institutions *****/
|
|
||||||
for (NumMyIns = 0;
|
|
||||||
NumMyIns < Gbl.Usrs.Me.Hierarchy[Hie_INS].Num;
|
|
||||||
NumMyIns++)
|
|
||||||
if (Gbl.Usrs.Me.Hierarchy[Hie_INS].Nodes[NumMyIns].HieCod == InsCod)
|
|
||||||
return Gbl.Usrs.Me.Hierarchy[Hie_INS].Nodes[NumMyIns].MaxRole;
|
|
||||||
return Rol_GST;
|
|
||||||
}
|
|
||||||
return Rol_UNK; // No degree
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/********************** Get my maximum role in a center **********************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
Rol_Role_t Rol_GetMyMaxRoleInCtr (long CtrCod)
|
|
||||||
{
|
|
||||||
unsigned NumMyCtr;
|
|
||||||
|
|
||||||
if (CtrCod > 0)
|
|
||||||
{
|
|
||||||
/***** Fill the list with the centers I belong to (if not already filled) *****/
|
|
||||||
Hie_GetMyHierarchy (Hie_CTR);
|
|
||||||
|
|
||||||
/***** Check if the center passed as parameter is any of my centers *****/
|
|
||||||
for (NumMyCtr = 0;
|
|
||||||
NumMyCtr < Gbl.Usrs.Me.Hierarchy[Hie_CTR].Num;
|
|
||||||
NumMyCtr++)
|
|
||||||
if (Gbl.Usrs.Me.Hierarchy[Hie_CTR].Nodes[NumMyCtr].HieCod == CtrCod)
|
|
||||||
return Gbl.Usrs.Me.Hierarchy[Hie_CTR].Nodes[NumMyCtr].MaxRole;
|
|
||||||
return Rol_GST;
|
|
||||||
}
|
|
||||||
return Rol_UNK; // No center
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/********************** Get my maximum role in a degree **********************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
Rol_Role_t Rol_GetMyMaxRoleInDeg (long DegCod)
|
|
||||||
{
|
|
||||||
unsigned NumMyDeg;
|
|
||||||
|
|
||||||
/***** 1. Fast check: trivial cases *****/
|
/***** 1. Fast check: trivial cases *****/
|
||||||
if (DegCod <= 0)
|
if (HieCod <= 0)
|
||||||
return Rol_UNK;
|
return Rol_UNK;
|
||||||
|
|
||||||
/***** Fill the list with the degrees I belong to (if not already filled) *****/
|
/***** Fill the list with the nodes I belong to (if not already filled) *****/
|
||||||
Hie_GetMyHierarchy (Hie_DEG);
|
Hie_GetMyHierarchy (HieCod);
|
||||||
|
|
||||||
|
/***** Check if the node passed as parameter is any of my nodes *****/
|
||||||
|
for (NumMyNode = 0;
|
||||||
|
NumMyNode < Gbl.Usrs.Me.Hierarchy[Level].Num;
|
||||||
|
NumMyNode++)
|
||||||
|
if (Gbl.Usrs.Me.Hierarchy[Level].Nodes[NumMyNode].HieCod == HieCod)
|
||||||
|
return Gbl.Usrs.Me.Hierarchy[Level].Nodes[NumMyNode].MaxRole;
|
||||||
|
|
||||||
/***** Check if the degree passed as parameter is any of my degrees *****/
|
|
||||||
for (NumMyDeg = 0;
|
|
||||||
NumMyDeg < Gbl.Usrs.Me.Hierarchy[Hie_DEG].Num;
|
|
||||||
NumMyDeg++)
|
|
||||||
if (Gbl.Usrs.Me.Hierarchy[Hie_DEG].Nodes[NumMyDeg].HieCod == DegCod)
|
|
||||||
return Gbl.Usrs.Me.Hierarchy[Hie_DEG].Nodes[NumMyDeg].MaxRole;
|
|
||||||
return Rol_GST;
|
return Rol_GST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +282,6 @@ void Rol_FlushCacheMyRoleInCurrentCrs (void)
|
||||||
|
|
||||||
Rol_Role_t Rol_GetMyRoleInCrs (long CrsCod)
|
Rol_Role_t Rol_GetMyRoleInCrs (long CrsCod)
|
||||||
{
|
{
|
||||||
unsigned NumMyCrs;
|
|
||||||
Rol_Role_t Role;
|
Rol_Role_t Role;
|
||||||
|
|
||||||
/***** 1. Fast check: trivial cases *****/
|
/***** 1. Fast check: trivial cases *****/
|
||||||
|
@ -342,18 +294,7 @@ Rol_Role_t Rol_GetMyRoleInCrs (long CrsCod)
|
||||||
return Gbl.Cache.MyRoleInCurrentCrs.Role;
|
return Gbl.Cache.MyRoleInCurrentCrs.Role;
|
||||||
|
|
||||||
/***** 3. Slow check: get my role from list of my courses *****/
|
/***** 3. Slow check: get my role from list of my courses *****/
|
||||||
/* Fill the list with the courses I belong to (if not already filled) */
|
Role = Rol_GetMyMaxRoleIn (Hie_CRS,CrsCod);
|
||||||
Hie_GetMyHierarchy (Hie_CRS);
|
|
||||||
|
|
||||||
/* Check if the current course is any of my courses */
|
|
||||||
for (NumMyCrs = 0, Role = Rol_UNK;
|
|
||||||
NumMyCrs < Gbl.Usrs.Me.Hierarchy[Hie_CRS].Num;
|
|
||||||
NumMyCrs++)
|
|
||||||
if (Gbl.Usrs.Me.Hierarchy[Hie_CRS].Nodes[NumMyCrs].HieCod == CrsCod)
|
|
||||||
{
|
|
||||||
Role = Gbl.Usrs.Me.Hierarchy[Hie_CRS].Nodes[NumMyCrs].MaxRole;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Update my role in current course */
|
/* Update my role in current course */
|
||||||
if (CrsCod == Gbl.Hierarchy.Node[Hie_CRS].HieCod)
|
if (CrsCod == Gbl.Hierarchy.Node[Hie_CRS].HieCod)
|
||||||
|
|
|
@ -38,9 +38,8 @@ void Rol_SetMyRoles (void);
|
||||||
|
|
||||||
unsigned Rol_GetNumAvailableRoles (void);
|
unsigned Rol_GetNumAvailableRoles (void);
|
||||||
Rol_Role_t Rol_GetMaxRoleInCrss (unsigned Roles);
|
Rol_Role_t Rol_GetMaxRoleInCrss (unsigned Roles);
|
||||||
Rol_Role_t Rol_GetMyMaxRoleInIns (long InsCod);
|
Rol_Role_t Rol_GetMyMaxRoleIn (Hie_Level_t Level,long HieCod);
|
||||||
Rol_Role_t Rol_GetMyMaxRoleInCtr (long CtrCod);
|
|
||||||
Rol_Role_t Rol_GetMyMaxRoleInDeg (long DegCod);
|
|
||||||
void Rol_FlushCacheMyRoleInCurrentCrs (void);
|
void Rol_FlushCacheMyRoleInCurrentCrs (void);
|
||||||
Rol_Role_t Rol_GetMyRoleInCrs (long CrsCod);
|
Rol_Role_t Rol_GetMyRoleInCrs (long CrsCod);
|
||||||
void Rol_FlushCacheRoleUsrInCrs (void);
|
void Rol_FlushCacheRoleUsrInCrs (void);
|
||||||
|
|
Loading…
Reference in New Issue