mirror of https://github.com/acanas/swad-core.git
Version 23.72.2: Apr 02, 2024 Code refactoring related to new type Usr_ICan_t.
This commit is contained in:
parent
7c794da888
commit
b44376b118
34
swad_ID.c
34
swad_ID.c
|
@ -308,11 +308,12 @@ static bool ID_CheckIfUsrIDIsValidUsingMinDigits (const char *UsrID,unsigned Min
|
||||||
void ID_WriteUsrIDs (struct Usr_Data *UsrDat,const char *Anchor)
|
void ID_WriteUsrIDs (struct Usr_Data *UsrDat,const char *Anchor)
|
||||||
{
|
{
|
||||||
unsigned NumID;
|
unsigned NumID;
|
||||||
bool ICanSeeUsrID = (ID_ICanSeeOtherUsrIDs (UsrDat) == Usr_I_CAN);
|
Usr_ICan_t ICanSeeUsrID = ID_ICanSeeOtherUsrIDs (UsrDat);
|
||||||
bool ICanConfirmUsrID = ICanSeeUsrID &&
|
Usr_ICan_t ICanConfirmUsrID = (ICanSeeUsrID == Usr_I_CAN &&
|
||||||
Usr_ItsMe (UsrDat->UsrCod) == Usr_OTHER && // Not me
|
Usr_ItsMe (UsrDat->UsrCod) == Usr_OTHER && // Not me
|
||||||
!Frm_CheckIfInside () && // Not inside another form
|
!Frm_CheckIfInside () && // Not inside another form
|
||||||
Act_GetBrowserTab (Gbl.Action.Act) == Act_1ST_TAB; // Only in main browser tab
|
Act_GetBrowserTab (Gbl.Action.Act) == Act_1ST_TAB) ? Usr_I_CAN : // Only in main browser tab
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
|
|
||||||
for (NumID = 0;
|
for (NumID = 0;
|
||||||
NumID < UsrDat->IDs.Num;
|
NumID < UsrDat->IDs.Num;
|
||||||
|
@ -327,14 +328,14 @@ void ID_WriteUsrIDs (struct Usr_Data *UsrDat,const char *Anchor)
|
||||||
UsrDat->IDs.List[NumID].Confirmed ? "USR_ID_C" :
|
UsrDat->IDs.List[NumID].Confirmed ? "USR_ID_C" :
|
||||||
"USR_ID_NC",
|
"USR_ID_NC",
|
||||||
The_GetSuffix ());
|
The_GetSuffix ());
|
||||||
if (ICanSeeUsrID)
|
if (ICanSeeUsrID == Usr_I_CAN)
|
||||||
HTM_Txt (UsrDat->IDs.List[NumID].ID);
|
HTM_Txt (UsrDat->IDs.List[NumID].ID);
|
||||||
else
|
else
|
||||||
HTM_Txt ("********");
|
HTM_Txt ("********");
|
||||||
HTM_SPAN_End ();
|
HTM_SPAN_End ();
|
||||||
|
|
||||||
/* Put link to confirm ID? */
|
/* Put link to confirm ID? */
|
||||||
if (ICanConfirmUsrID && !UsrDat->IDs.List[NumID].Confirmed)
|
if (ICanConfirmUsrID == Usr_I_CAN && !UsrDat->IDs.List[NumID].Confirmed)
|
||||||
ID_PutLinkToConfirmID (UsrDat,NumID,Anchor);
|
ID_PutLinkToConfirmID (UsrDat,NumID,Anchor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -719,7 +720,7 @@ static void ID_RemoveUsrID (const struct Usr_Data *UsrDat,Usr_MeOrOther_t MeOrOt
|
||||||
extern const char *Txt_ID_X_removed;
|
extern const char *Txt_ID_X_removed;
|
||||||
extern const char *Txt_You_can_not_delete_this_ID;
|
extern const char *Txt_You_can_not_delete_this_ID;
|
||||||
char UsrID[ID_MAX_BYTES_USR_ID + 1];
|
char UsrID[ID_MAX_BYTES_USR_ID + 1];
|
||||||
bool ICanRemove;
|
Usr_ICan_t ICanRemove;
|
||||||
|
|
||||||
if (Usr_CheckIfICanEditOtherUsr (UsrDat) == Usr_I_CAN)
|
if (Usr_CheckIfICanEditOtherUsr (UsrDat) == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
|
@ -730,21 +731,22 @@ static void ID_RemoveUsrID (const struct Usr_Data *UsrDat,Usr_MeOrOther_t MeOrOt
|
||||||
Str_ConvertToUpperText (UsrID);
|
Str_ConvertToUpperText (UsrID);
|
||||||
|
|
||||||
if (UsrDat->IDs.Num < 2) // One unique ID
|
if (UsrDat->IDs.Num < 2) // One unique ID
|
||||||
ICanRemove = false;
|
ICanRemove = Usr_I_CAN_NOT;
|
||||||
else
|
else
|
||||||
switch (MeOrOther)
|
switch (MeOrOther)
|
||||||
{
|
{
|
||||||
case Usr_ME:
|
case Usr_ME:
|
||||||
// I can remove my ID only if it is not confirmed
|
// I can remove my ID only if it is not confirmed
|
||||||
ICanRemove = !ID_DB_CheckIfConfirmed (UsrDat->UsrCod,UsrID);
|
ICanRemove = ID_DB_CheckIfConfirmed (UsrDat->UsrCod,UsrID) ? Usr_I_CAN_NOT :
|
||||||
|
Usr_I_CAN;
|
||||||
break;
|
break;
|
||||||
case Usr_OTHER:
|
case Usr_OTHER:
|
||||||
default:
|
default:
|
||||||
ICanRemove = true;
|
ICanRemove = Usr_I_CAN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ICanRemove)
|
if (ICanRemove == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
/***** Remove one of the user's IDs *****/
|
/***** Remove one of the user's IDs *****/
|
||||||
ID_DB_RemoveUsrID (UsrDat->UsrCod,UsrID);
|
ID_DB_RemoveUsrID (UsrDat->UsrCod,UsrID);
|
||||||
|
@ -892,7 +894,7 @@ void ID_ConfirmOtherUsrID (void)
|
||||||
extern const char *Txt_ID_X_had_already_been_confirmed;
|
extern const char *Txt_ID_X_had_already_been_confirmed;
|
||||||
extern const char *Txt_The_ID_X_has_been_confirmed;
|
extern const char *Txt_The_ID_X_has_been_confirmed;
|
||||||
char UsrID[ID_MAX_BYTES_USR_ID + 1];
|
char UsrID[ID_MAX_BYTES_USR_ID + 1];
|
||||||
bool ICanConfirm;
|
Usr_ICan_t ICanConfirm;
|
||||||
bool Found;
|
bool Found;
|
||||||
unsigned NumID;
|
unsigned NumID;
|
||||||
unsigned NumIDFound = 0; // Initialized to avoid warning
|
unsigned NumIDFound = 0; // Initialized to avoid warning
|
||||||
|
@ -901,7 +903,7 @@ void ID_ConfirmOtherUsrID (void)
|
||||||
Gbl.Action.Original = Act_GetActionFromActCod (ParCod_GetPar (ParCod_OrgAct));
|
Gbl.Action.Original = Act_GetActionFromActCod (ParCod_GetPar (ParCod_OrgAct));
|
||||||
|
|
||||||
/***** Get other user's code from form and get user's data *****/
|
/***** Get other user's code from form and get user's data *****/
|
||||||
ICanConfirm = false;
|
ICanConfirm = Usr_I_CAN_NOT;
|
||||||
if (Usr_GetParOtherUsrCodEncryptedAndGetUsrData ())
|
if (Usr_GetParOtherUsrCodEncryptedAndGetUsrData ())
|
||||||
if (Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod) == Usr_OTHER) // Not me
|
if (Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod) == Usr_OTHER) // Not me
|
||||||
{
|
{
|
||||||
|
@ -912,10 +914,10 @@ void ID_ConfirmOtherUsrID (void)
|
||||||
Gbl.Usrs.Other.UsrDat.Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
Gbl.Usrs.Other.UsrDat.Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
||||||
|
|
||||||
if (ID_ICanSeeOtherUsrIDs (&Gbl.Usrs.Other.UsrDat) == Usr_I_CAN)
|
if (ID_ICanSeeOtherUsrIDs (&Gbl.Usrs.Other.UsrDat) == Usr_I_CAN)
|
||||||
ICanConfirm = true;
|
ICanConfirm = Usr_I_CAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ICanConfirm)
|
if (ICanConfirm == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
/***** Get user's ID from form *****/
|
/***** Get user's ID from form *****/
|
||||||
Par_GetParText ("UsrID",UsrID,ID_MAX_BYTES_USR_ID);
|
Par_GetParText ("UsrID",UsrID,ID_MAX_BYTES_USR_ID);
|
||||||
|
|
|
@ -7261,7 +7261,7 @@ void Brw_ShowFileMetadata (void)
|
||||||
Usr_ICan_t ICanView = Usr_I_CAN_NOT;
|
Usr_ICan_t ICanView = Usr_I_CAN_NOT;
|
||||||
bool IAmTheOwner;
|
bool IAmTheOwner;
|
||||||
Usr_ICan_t ICanEdit;
|
Usr_ICan_t ICanEdit;
|
||||||
bool ICanChangePublic = false;
|
Usr_ICan_t ICanChangePublic = Usr_I_CAN_NOT;
|
||||||
bool FileHasPublisher;
|
bool FileHasPublisher;
|
||||||
Brw_License_t License;
|
Brw_License_t License;
|
||||||
unsigned LicenseUnsigned;
|
unsigned LicenseUnsigned;
|
||||||
|
@ -7379,10 +7379,10 @@ void Brw_ShowFileMetadata (void)
|
||||||
case Brw_ADMI_SHR_DEG:
|
case Brw_ADMI_SHR_DEG:
|
||||||
case Brw_ADMI_DOC_CRS:
|
case Brw_ADMI_DOC_CRS:
|
||||||
case Brw_ADMI_SHR_CRS:
|
case Brw_ADMI_SHR_CRS:
|
||||||
ICanChangePublic = true;
|
ICanChangePublic = Usr_I_CAN;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ICanChangePublic = false;
|
ICanChangePublic = Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7476,14 +7476,14 @@ void Brw_ShowFileMetadata (void)
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
|
||||||
/* Label */
|
/* Label */
|
||||||
Frm_LabelColumn ("RT",ICanChangePublic ? "PublicFile" :
|
Frm_LabelColumn ("RT",ICanChangePublic == Usr_I_CAN ? "PublicFile" :
|
||||||
NULL,
|
NULL,
|
||||||
Txt_Availability);
|
Txt_Availability);
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
HTM_TD_Begin ("class=\"LT DAT_STRONG_%s\"",
|
HTM_TD_Begin ("class=\"LT DAT_STRONG_%s\"",
|
||||||
The_GetSuffix ());
|
The_GetSuffix ());
|
||||||
if (ICanChangePublic) // I can change file to public
|
if (ICanChangePublic == Usr_I_CAN) // I can change file to public
|
||||||
{
|
{
|
||||||
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,NULL,
|
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,NULL,
|
||||||
"id=\"PublicFile\" name=\"PublicFile\" class=\"PUBLIC_FILE\"");
|
"id=\"PublicFile\" name=\"PublicFile\" class=\"PUBLIC_FILE\"");
|
||||||
|
|
|
@ -884,7 +884,8 @@ static void Ctr_ListCentersForEdition (const struct Plc_Places *Places)
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/* Center status */
|
/* Center status */
|
||||||
Hie_WriteStatusCellEditable (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM,
|
Hie_WriteStatusCellEditable (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT,
|
||||||
Ctr->Status,ActChgCtrSta,Ctr->HieCod,
|
Ctr->Status,ActChgCtrSta,Ctr->HieCod,
|
||||||
Txt_CENTER_STATUS);
|
Txt_CENTER_STATUS);
|
||||||
|
|
||||||
|
|
|
@ -633,11 +633,12 @@ Me sale este error, no s
|
||||||
"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.72.1 (2024-04-01)"
|
#define Log_PLATFORM_VERSION "SWAD 23.72.2 (2024-04-02)"
|
||||||
#define CSS_FILE "swad23.67.2.css"
|
#define CSS_FILE "swad23.67.2.css"
|
||||||
#define JS_FILE "swad23.53.6.js"
|
#define JS_FILE "swad23.53.6.js"
|
||||||
/*
|
/*
|
||||||
Version 23.72.1: Apr 01, 2024 New type Usr_ICan_t. (334912 lines)
|
Version 23.72.2: Apr 02, 2024 Code refactoring related to new type Usr_ICan_t. (334970 lines)
|
||||||
|
Version 23.72.1: Apr 01, 2024 Code refactoring related to new type Usr_ICan_t. (334912 lines)
|
||||||
Version 23.72: Apr 01, 2024 New type Usr_ICan_t. (334879 lines)
|
Version 23.72: Apr 01, 2024 New type Usr_ICan_t. (334879 lines)
|
||||||
Version 23.71.4: Mar 22, 2024 Code refactoring. (334860 lines)
|
Version 23.71.4: Mar 22, 2024 Code refactoring. (334860 lines)
|
||||||
Version 23.71.3: Mar 22, 2024 Code refactoring. (334827 lines)
|
Version 23.71.3: Mar 22, 2024 Code refactoring. (334827 lines)
|
||||||
|
|
|
@ -773,7 +773,8 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year)
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/* Course status */
|
/* Course status */
|
||||||
Hie_WriteStatusCellEditable (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM,
|
Hie_WriteStatusCellEditable (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT,
|
||||||
Crs->Status,ActChgCrsSta,Crs->HieCod,
|
Crs->Status,ActChgCrsSta,Crs->HieCod,
|
||||||
Txt_COURSE_STATUS);
|
Txt_COURSE_STATUS);
|
||||||
|
|
||||||
|
|
|
@ -466,7 +466,8 @@ static void Deg_ListDegreesForEdition (const struct DegTyp_DegTypes *DegTypes)
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/* Degree status */
|
/* Degree status */
|
||||||
Hie_WriteStatusCellEditable (Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM,
|
Hie_WriteStatusCellEditable (Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT,
|
||||||
Deg->Status,ActChgDegSta,Deg->HieCod,
|
Deg->Status,ActChgDegSta,Deg->HieCod,
|
||||||
Txt_DEGREE_STATUS);
|
Txt_DEGREE_STATUS);
|
||||||
|
|
||||||
|
|
|
@ -53,11 +53,11 @@
|
||||||
/****************************** Private constants ****************************/
|
/****************************** Private constants ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static bool Dpt_ICanEditDpts[Rol_NUM_ROLES] =
|
static Usr_ICan_t Dpt_ICanEditDpts[Rol_NUM_ROLES] =
|
||||||
{
|
{
|
||||||
/* Users who can edit */
|
/* Users who can edit */
|
||||||
[Rol_INS_ADM] = true,
|
[Rol_INS_ADM] = Usr_I_CAN,
|
||||||
[Rol_SYS_ADM] = true,
|
[Rol_SYS_ADM] = Usr_I_CAN,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -243,7 +243,7 @@ static Dpt_Order_t Dpt_GetParDptOrder (void)
|
||||||
|
|
||||||
static void Dpt_PutIconToEditDpts (__attribute__((unused)) void *Args)
|
static void Dpt_PutIconToEditDpts (__attribute__((unused)) void *Args)
|
||||||
{
|
{
|
||||||
if (Dpt_ICanEditDpts[Gbl.Usrs.Me.Role.Logged])
|
if (Dpt_ICanEditDpts[Gbl.Usrs.Me.Role.Logged] == Usr_I_CAN)
|
||||||
Ico_PutContextualIconToEdit (ActEdiDpt,NULL,NULL,NULL);
|
Ico_PutContextualIconToEdit (ActEdiDpt,NULL,NULL,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
175
swad_forum.c
175
swad_forum.c
|
@ -322,7 +322,7 @@ static void For_PutParsNewPost (void *Forums);
|
||||||
static void For_ShowAForumPost (struct For_Forums *Forums,
|
static void For_ShowAForumPost (struct For_Forums *Forums,
|
||||||
unsigned PstNum,
|
unsigned PstNum,
|
||||||
bool LastPst,char LastSubject[Cns_MAX_BYTES_SUBJECT + 1],
|
bool LastPst,char LastSubject[Cns_MAX_BYTES_SUBJECT + 1],
|
||||||
bool NewPst,bool ICanModerateForum);
|
bool NewPst,Usr_ICan_t ICanModerateForum);
|
||||||
static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
|
static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
|
||||||
char Subject[Cns_MAX_BYTES_SUBJECT + 1],
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1],
|
||||||
char Content[Cns_MAX_BYTES_LONG_TEXT + 1],
|
char Content[Cns_MAX_BYTES_LONG_TEXT + 1],
|
||||||
|
@ -711,7 +711,7 @@ void For_ShowPostsOfAThread (struct For_Forums *Forums,
|
||||||
time_t CreatTimeUTC; // Creation time of post
|
time_t CreatTimeUTC; // Creation time of post
|
||||||
struct Pag_Pagination PaginationPsts;
|
struct Pag_Pagination PaginationPsts;
|
||||||
bool NewPst = false;
|
bool NewPst = false;
|
||||||
bool ICanModerateForum = false;
|
Usr_ICan_t ICanModerateForum = Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/***** Get data of the thread *****/
|
/***** Get data of the thread *****/
|
||||||
Thread.ThrCod =
|
Thread.ThrCod =
|
||||||
|
@ -751,26 +751,31 @@ void For_ShowPostsOfAThread (struct For_Forums *Forums,
|
||||||
case For_FORUM_GLOBAL_TCHS:
|
case For_FORUM_GLOBAL_TCHS:
|
||||||
case For_FORUM__SWAD__USRS:
|
case For_FORUM__SWAD__USRS:
|
||||||
case For_FORUM__SWAD__TCHS:
|
case For_FORUM__SWAD__TCHS:
|
||||||
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_INSTIT_USRS:
|
case For_FORUM_INSTIT_USRS:
|
||||||
case For_FORUM_INSTIT_TCHS:
|
case For_FORUM_INSTIT_TCHS:
|
||||||
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM);
|
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_CENTER_USRS:
|
case For_FORUM_CENTER_USRS:
|
||||||
case For_FORUM_CENTER_TCHS:
|
case For_FORUM_CENTER_TCHS:
|
||||||
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM);
|
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_DEGREE_USRS:
|
case For_FORUM_DEGREE_USRS:
|
||||||
case For_FORUM_DEGREE_TCHS:
|
case For_FORUM_DEGREE_TCHS:
|
||||||
case For_FORUM_COURSE_TCHS:
|
case For_FORUM_COURSE_TCHS:
|
||||||
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM);
|
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_COURSE_USRS:
|
case For_FORUM_COURSE_USRS:
|
||||||
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_TCH);
|
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_TCH) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ICanModerateForum = false;
|
ICanModerateForum = Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -896,7 +901,7 @@ static void For_PutParsNewPost (void *Forums)
|
||||||
static void For_ShowAForumPost (struct For_Forums *Forums,
|
static void For_ShowAForumPost (struct For_Forums *Forums,
|
||||||
unsigned PstNum,
|
unsigned PstNum,
|
||||||
bool LastPst,char LastSubject[Cns_MAX_BYTES_SUBJECT + 1],
|
bool LastPst,char LastSubject[Cns_MAX_BYTES_SUBJECT + 1],
|
||||||
bool NewPst,bool ICanModerateForum)
|
bool NewPst,Usr_ICan_t ICanModerateForum)
|
||||||
{
|
{
|
||||||
extern const char *Txt_MSG_New;
|
extern const char *Txt_MSG_New;
|
||||||
extern const char *Txt_MSG_Open;
|
extern const char *Txt_MSG_Open;
|
||||||
|
@ -999,7 +1004,7 @@ static void For_ShowAForumPost (struct For_Forums *Forums,
|
||||||
/***** Form to ban/unban post *****/
|
/***** Form to ban/unban post *****/
|
||||||
HTM_TD_Begin ("class=\"CONTEXT_COL\"");
|
HTM_TD_Begin ("class=\"CONTEXT_COL\"");
|
||||||
|
|
||||||
if (ICanModerateForum)
|
if (ICanModerateForum == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
NextAction = DisabledOrEnabled == Cns_ENABLED ? For_ActionsDisPstFor[Forums->Forum.Type] :
|
NextAction = DisabledOrEnabled == Cns_ENABLED ? For_ActionsDisPstFor[Forums->Forum.Type] :
|
||||||
For_ActionsEnbPstFor[Forums->Forum.Type];
|
For_ActionsEnbPstFor[Forums->Forum.Type];
|
||||||
|
@ -1228,9 +1233,9 @@ void For_ShowForumList (struct For_Forums *Forums)
|
||||||
unsigned NumDegs;
|
unsigned NumDegs;
|
||||||
unsigned NumCrs;
|
unsigned NumCrs;
|
||||||
unsigned NumCrss;
|
unsigned NumCrss;
|
||||||
bool ICanSeeInsForum;
|
Usr_ICan_t ICanSeeInsForum;
|
||||||
bool ICanSeeCtrForum;
|
Usr_ICan_t ICanSeeCtrForum;
|
||||||
bool ICanSeeDegForum;
|
Usr_ICan_t ICanSeeDegForum;
|
||||||
|
|
||||||
/***** Get if there is a thread ready to be moved *****/
|
/***** Get if there is a thread ready to be moved *****/
|
||||||
if (For_CheckIfICanMoveThreads () == Usr_I_CAN)
|
if (For_CheckIfICanMoveThreads () == Usr_I_CAN)
|
||||||
|
@ -1257,40 +1262,43 @@ void For_ShowForumList (struct For_Forums *Forums)
|
||||||
if (Gbl.Hierarchy.Node[Hie_INS].HieCod > 0)
|
if (Gbl.Hierarchy.Node[Hie_INS].HieCod > 0)
|
||||||
{
|
{
|
||||||
if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM)
|
if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM)
|
||||||
ICanSeeInsForum = true;
|
ICanSeeInsForum = Usr_I_CAN;
|
||||||
else
|
else
|
||||||
ICanSeeInsForum = Hie_CheckIfIBelongTo (Hie_INS,Gbl.Hierarchy.Node[Hie_INS].HieCod);
|
ICanSeeInsForum = Hie_CheckIfIBelongTo (Hie_INS,Gbl.Hierarchy.Node[Hie_INS].HieCod) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ICanSeeInsForum = false;
|
ICanSeeInsForum = Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/***** Links to forums about the platform *****/
|
/***** Links to forums about the platform *****/
|
||||||
For_WriteLinksToPlatformForums (Forums,true,IsLastItemInLevel);
|
For_WriteLinksToPlatformForums (Forums,true,IsLastItemInLevel);
|
||||||
|
|
||||||
if (ICanSeeInsForum)
|
if (ICanSeeInsForum == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM)
|
if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM)
|
||||||
ICanSeeCtrForum = true;
|
ICanSeeCtrForum = Usr_I_CAN;
|
||||||
else
|
else
|
||||||
ICanSeeCtrForum = Hie_CheckIfIBelongTo (Hie_CTR,Gbl.Hierarchy.Node[Hie_CTR].HieCod);
|
ICanSeeCtrForum = Hie_CheckIfIBelongTo (Hie_CTR,Gbl.Hierarchy.Node[Hie_CTR].HieCod) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/***** Links to forums of current institution *****/
|
/***** Links to forums of current institution *****/
|
||||||
if (For_WriteLinksToInsForums (Forums,Gbl.Hierarchy.Node[Hie_INS].HieCod,
|
if (For_WriteLinksToInsForums (Forums,Gbl.Hierarchy.Node[Hie_INS].HieCod,
|
||||||
true,
|
true,
|
||||||
IsLastItemInLevel) > 0)
|
IsLastItemInLevel) > 0)
|
||||||
if (ICanSeeCtrForum)
|
if (ICanSeeCtrForum == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM)
|
if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM)
|
||||||
ICanSeeDegForum = true;
|
ICanSeeDegForum = Usr_I_CAN;
|
||||||
else
|
else
|
||||||
ICanSeeDegForum = Hie_CheckIfIBelongTo (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod);
|
ICanSeeDegForum = Hie_CheckIfIBelongTo (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/***** Links to forums of current center *****/
|
/***** Links to forums of current center *****/
|
||||||
if (For_WriteLinksToCtrForums (Forums,
|
if (For_WriteLinksToCtrForums (Forums,
|
||||||
Gbl.Hierarchy.Node[Hie_CTR].HieCod,
|
Gbl.Hierarchy.Node[Hie_CTR].HieCod,
|
||||||
true,
|
true,
|
||||||
IsLastItemInLevel) > 0)
|
IsLastItemInLevel) > 0)
|
||||||
if (ICanSeeDegForum)
|
if (ICanSeeDegForum == Usr_I_CAN)
|
||||||
/***** Links to forums of current degree *****/
|
/***** Links to forums of current degree *****/
|
||||||
if (For_WriteLinksToDegForums (Forums,
|
if (For_WriteLinksToDegForums (Forums,
|
||||||
Gbl.Hierarchy.Node[Hie_DEG].HieCod,
|
Gbl.Hierarchy.Node[Hie_DEG].HieCod,
|
||||||
|
@ -1455,14 +1463,15 @@ static void For_WriteLinksToGblForums (const struct For_Forums *Forums,
|
||||||
Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS])
|
Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS])
|
||||||
{
|
{
|
||||||
Lay_Highlight_t Highlight;
|
Lay_Highlight_t Highlight;
|
||||||
bool ICanSeeTeacherForum;
|
Usr_ICan_t ICanSeeTeacherForum;
|
||||||
struct For_Forum Forum;
|
struct For_Forum Forum;
|
||||||
|
|
||||||
/***** Can I see teachers's forums? *****/
|
/***** Can I see teachers's forums? *****/
|
||||||
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
||||||
ICanSeeTeacherForum = Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
(Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) |
|
(Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) |
|
||||||
(1 << Rol_TCH)));
|
(1 << Rol_TCH)))) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/***** Link to forum global *****/
|
/***** Link to forum global *****/
|
||||||
Forum.Type = For_FORUM_GLOBAL_USRS;
|
Forum.Type = For_FORUM_GLOBAL_USRS;
|
||||||
|
@ -1474,7 +1483,7 @@ static void For_WriteLinksToGblForums (const struct For_Forums *Forums,
|
||||||
|
|
||||||
/***** Link to forum of teachers global *****/
|
/***** Link to forum of teachers global *****/
|
||||||
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
||||||
if (ICanSeeTeacherForum)
|
if (ICanSeeTeacherForum == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
Forum.Type = For_FORUM_GLOBAL_TCHS;
|
Forum.Type = For_FORUM_GLOBAL_TCHS;
|
||||||
Forum.HieCod = -1L;
|
Forum.HieCod = -1L;
|
||||||
|
@ -1494,26 +1503,27 @@ static void For_WriteLinksToPlatformForums (const struct For_Forums *Forums,
|
||||||
Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS])
|
Lay_LastItem_t IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS])
|
||||||
{
|
{
|
||||||
Lay_Highlight_t Highlight;
|
Lay_Highlight_t Highlight;
|
||||||
bool ICanSeeTeacherForum;
|
Usr_ICan_t ICanSeeTeacherForum;
|
||||||
struct For_Forum Forum;
|
struct For_Forum Forum;
|
||||||
|
|
||||||
/***** Can I see teachers's forums? *****/
|
/***** Can I see teachers's forums? *****/
|
||||||
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
||||||
ICanSeeTeacherForum = Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
(Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) |
|
(Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) |
|
||||||
(1 << Rol_TCH)));
|
(1 << Rol_TCH)))) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/***** Link to forum of users about the platform *****/
|
/***** Link to forum of users about the platform *****/
|
||||||
Forum.Type = For_FORUM__SWAD__USRS;
|
Forum.Type = For_FORUM__SWAD__USRS;
|
||||||
Forum.HieCod = -1L;
|
Forum.HieCod = -1L;
|
||||||
Highlight = (Forums->Forum.Type == For_FORUM__SWAD__USRS) ? Lay_HIGHLIGHT :
|
Highlight = (Forums->Forum.Type == For_FORUM__SWAD__USRS) ? Lay_HIGHLIGHT :
|
||||||
Lay_NO_HIGHLIGHT;
|
Lay_NO_HIGHLIGHT;
|
||||||
IsLastItemInLevel[1] = (IsLastForum && !ICanSeeTeacherForum) ? Lay_LAST_ITEM :
|
IsLastItemInLevel[1] = (IsLastForum && ICanSeeTeacherForum == Usr_I_CAN_NOT) ? Lay_LAST_ITEM :
|
||||||
Lay_NO_LAST_ITEM;
|
Lay_NO_LAST_ITEM;
|
||||||
For_WriteLinkToForum (Forums,&Forum,Highlight,1,IsLastItemInLevel);
|
For_WriteLinkToForum (Forums,&Forum,Highlight,1,IsLastItemInLevel);
|
||||||
|
|
||||||
/***** Link to forum of teachers about the platform *****/
|
/***** Link to forum of teachers about the platform *****/
|
||||||
if (ICanSeeTeacherForum)
|
if (ICanSeeTeacherForum == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
Forum.Type = For_FORUM__SWAD__TCHS;
|
Forum.Type = For_FORUM__SWAD__TCHS;
|
||||||
Forum.HieCod = -1L;
|
Forum.HieCod = -1L;
|
||||||
|
@ -1536,15 +1546,16 @@ static long For_WriteLinksToInsForums (const struct For_Forums *Forums,
|
||||||
{
|
{
|
||||||
Lay_Highlight_t Highlight;
|
Lay_Highlight_t Highlight;
|
||||||
Rol_Role_t MaxRoleInIns;
|
Rol_Role_t MaxRoleInIns;
|
||||||
bool ICanSeeTeacherForum;
|
Usr_ICan_t ICanSeeTeacherForum;
|
||||||
struct For_Forum Forum;
|
struct For_Forum Forum;
|
||||||
|
|
||||||
if (InsCod > 0)
|
if (InsCod > 0)
|
||||||
{
|
{
|
||||||
MaxRoleInIns = Rol_GetMyMaxRoleIn (Hie_INS,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)) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/***** Link to the forum of users from this institution *****/
|
/***** Link to the forum of users from this institution *****/
|
||||||
Forum.Type = For_FORUM_INSTIT_USRS;
|
Forum.Type = For_FORUM_INSTIT_USRS;
|
||||||
|
@ -1552,12 +1563,12 @@ static long For_WriteLinksToInsForums (const struct For_Forums *Forums,
|
||||||
Highlight = (Forums->Forum.Type == For_FORUM_INSTIT_USRS &&
|
Highlight = (Forums->Forum.Type == For_FORUM_INSTIT_USRS &&
|
||||||
Forums->Forum.HieCod == InsCod) ? Lay_HIGHLIGHT :
|
Forums->Forum.HieCod == InsCod) ? Lay_HIGHLIGHT :
|
||||||
Lay_NO_HIGHLIGHT;
|
Lay_NO_HIGHLIGHT;
|
||||||
IsLastItemInLevel[2] = (IsLastIns && !ICanSeeTeacherForum) ? Lay_LAST_ITEM :
|
IsLastItemInLevel[2] = (IsLastIns && ICanSeeTeacherForum == Usr_I_CAN_NOT) ? Lay_LAST_ITEM :
|
||||||
Lay_NO_LAST_ITEM;
|
Lay_NO_LAST_ITEM;
|
||||||
For_WriteLinkToForum (Forums,&Forum,Highlight,2,IsLastItemInLevel);
|
For_WriteLinkToForum (Forums,&Forum,Highlight,2,IsLastItemInLevel);
|
||||||
|
|
||||||
/***** Link to forum of teachers from this institution *****/
|
/***** Link to forum of teachers from this institution *****/
|
||||||
if (ICanSeeTeacherForum)
|
if (ICanSeeTeacherForum == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
Forum.Type = For_FORUM_INSTIT_TCHS;
|
Forum.Type = For_FORUM_INSTIT_TCHS;
|
||||||
Forum.HieCod = InsCod;
|
Forum.HieCod = InsCod;
|
||||||
|
@ -1583,15 +1594,16 @@ static long For_WriteLinksToCtrForums (const struct For_Forums *Forums,
|
||||||
{
|
{
|
||||||
Lay_Highlight_t Highlight;
|
Lay_Highlight_t Highlight;
|
||||||
Rol_Role_t MaxRoleInCtr;
|
Rol_Role_t MaxRoleInCtr;
|
||||||
bool ICanSeeTeacherForum;
|
Usr_ICan_t ICanSeeTeacherForum;
|
||||||
struct For_Forum Forum;
|
struct For_Forum Forum;
|
||||||
|
|
||||||
if (CtrCod > 0)
|
if (CtrCod > 0)
|
||||||
{
|
{
|
||||||
MaxRoleInCtr = Rol_GetMyMaxRoleIn (Hie_CTR,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)) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/***** Link to the forum of users from this center *****/
|
/***** Link to the forum of users from this center *****/
|
||||||
Forum.Type = For_FORUM_CENTER_USRS;
|
Forum.Type = For_FORUM_CENTER_USRS;
|
||||||
|
@ -1599,12 +1611,12 @@ static long For_WriteLinksToCtrForums (const struct For_Forums *Forums,
|
||||||
Highlight = (Forums->Forum.Type == For_FORUM_CENTER_USRS &&
|
Highlight = (Forums->Forum.Type == For_FORUM_CENTER_USRS &&
|
||||||
Forums->Forum.HieCod == CtrCod) ? Lay_HIGHLIGHT :
|
Forums->Forum.HieCod == CtrCod) ? Lay_HIGHLIGHT :
|
||||||
Lay_NO_HIGHLIGHT;
|
Lay_NO_HIGHLIGHT;
|
||||||
IsLastItemInLevel[3] = (IsLastCtr && !ICanSeeTeacherForum) ? Lay_LAST_ITEM :
|
IsLastItemInLevel[3] = (IsLastCtr && ICanSeeTeacherForum == Usr_I_CAN_NOT) ? Lay_LAST_ITEM :
|
||||||
Lay_NO_LAST_ITEM;
|
Lay_NO_LAST_ITEM;
|
||||||
For_WriteLinkToForum (Forums,&Forum,Highlight,3,IsLastItemInLevel);
|
For_WriteLinkToForum (Forums,&Forum,Highlight,3,IsLastItemInLevel);
|
||||||
|
|
||||||
/***** Link to forum of teachers from this center *****/
|
/***** Link to forum of teachers from this center *****/
|
||||||
if (ICanSeeTeacherForum)
|
if (ICanSeeTeacherForum == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
Forum.Type = For_FORUM_CENTER_TCHS;
|
Forum.Type = For_FORUM_CENTER_TCHS;
|
||||||
Forum.HieCod = CtrCod;
|
Forum.HieCod = CtrCod;
|
||||||
|
@ -1630,15 +1642,16 @@ static long For_WriteLinksToDegForums (const struct For_Forums *Forums,
|
||||||
{
|
{
|
||||||
Lay_Highlight_t Highlight;
|
Lay_Highlight_t Highlight;
|
||||||
Rol_Role_t MaxRoleInDeg;
|
Rol_Role_t MaxRoleInDeg;
|
||||||
bool ICanSeeTeacherForum;
|
Usr_ICan_t ICanSeeTeacherForum;
|
||||||
struct For_Forum Forum;
|
struct For_Forum Forum;
|
||||||
|
|
||||||
if (DegCod > 0)
|
if (DegCod > 0)
|
||||||
{
|
{
|
||||||
MaxRoleInDeg = Rol_GetMyMaxRoleIn (Hie_DEG,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)) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/***** Link to the forum of users from this degree *****/
|
/***** Link to the forum of users from this degree *****/
|
||||||
Forum.Type = For_FORUM_DEGREE_USRS;
|
Forum.Type = For_FORUM_DEGREE_USRS;
|
||||||
|
@ -1646,12 +1659,12 @@ static long For_WriteLinksToDegForums (const struct For_Forums *Forums,
|
||||||
Highlight = (Forums->Forum.Type == For_FORUM_DEGREE_USRS &&
|
Highlight = (Forums->Forum.Type == For_FORUM_DEGREE_USRS &&
|
||||||
Forums->Forum.HieCod == DegCod) ? Lay_HIGHLIGHT :
|
Forums->Forum.HieCod == DegCod) ? Lay_HIGHLIGHT :
|
||||||
Lay_NO_HIGHLIGHT;
|
Lay_NO_HIGHLIGHT;
|
||||||
IsLastItemInLevel[4] = (IsLastDeg && !ICanSeeTeacherForum) ? Lay_LAST_ITEM :
|
IsLastItemInLevel[4] = (IsLastDeg && ICanSeeTeacherForum == Usr_I_CAN_NOT) ? Lay_LAST_ITEM :
|
||||||
Lay_NO_LAST_ITEM;
|
Lay_NO_LAST_ITEM;
|
||||||
For_WriteLinkToForum (Forums,&Forum,Highlight,4,IsLastItemInLevel);
|
For_WriteLinkToForum (Forums,&Forum,Highlight,4,IsLastItemInLevel);
|
||||||
|
|
||||||
/***** Link to forum of teachers from this degree *****/
|
/***** Link to forum of teachers from this degree *****/
|
||||||
if (ICanSeeTeacherForum)
|
if (ICanSeeTeacherForum == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
Forum.Type = For_FORUM_DEGREE_TCHS;
|
Forum.Type = For_FORUM_DEGREE_TCHS;
|
||||||
Forum.HieCod = DegCod;
|
Forum.HieCod = DegCod;
|
||||||
|
@ -1677,15 +1690,16 @@ static long For_WriteLinksToCrsForums (const struct For_Forums *Forums,
|
||||||
{
|
{
|
||||||
Lay_Highlight_t Highlight;
|
Lay_Highlight_t Highlight;
|
||||||
Rol_Role_t MyRoleInCrs;
|
Rol_Role_t MyRoleInCrs;
|
||||||
bool ICanSeeTeacherForum;
|
Usr_ICan_t ICanSeeTeacherForum;
|
||||||
struct For_Forum Forum;
|
struct For_Forum Forum;
|
||||||
|
|
||||||
if (CrsCod > 0)
|
if (CrsCod > 0)
|
||||||
{
|
{
|
||||||
MyRoleInCrs = Rol_GetMyRoleInCrs (CrsCod);
|
MyRoleInCrs = Rol_GetMyRoleInCrs (CrsCod);
|
||||||
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
ICanSeeTeacherForum = ((Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
||||||
MyRoleInCrs == Rol_NET ||
|
MyRoleInCrs == Rol_NET ||
|
||||||
MyRoleInCrs == Rol_TCH);
|
MyRoleInCrs == Rol_TCH)) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/***** Link to the forum of users from this course *****/
|
/***** Link to the forum of users from this course *****/
|
||||||
Forum.Type = For_FORUM_COURSE_USRS;
|
Forum.Type = For_FORUM_COURSE_USRS;
|
||||||
|
@ -1693,12 +1707,12 @@ static long For_WriteLinksToCrsForums (const struct For_Forums *Forums,
|
||||||
Highlight = (Forums->Forum.Type == For_FORUM_COURSE_USRS &&
|
Highlight = (Forums->Forum.Type == For_FORUM_COURSE_USRS &&
|
||||||
Forums->Forum.HieCod == CrsCod) ? Lay_HIGHLIGHT :
|
Forums->Forum.HieCod == CrsCod) ? Lay_HIGHLIGHT :
|
||||||
Lay_NO_HIGHLIGHT;
|
Lay_NO_HIGHLIGHT;
|
||||||
IsLastItemInLevel[5] = (IsLastCrs && !ICanSeeTeacherForum) ? Lay_LAST_ITEM :
|
IsLastItemInLevel[5] = (IsLastCrs && ICanSeeTeacherForum == Usr_I_CAN_NOT) ? Lay_LAST_ITEM :
|
||||||
Lay_NO_LAST_ITEM;
|
Lay_NO_LAST_ITEM;
|
||||||
For_WriteLinkToForum (Forums,&Forum,Highlight,5,IsLastItemInLevel);
|
For_WriteLinkToForum (Forums,&Forum,Highlight,5,IsLastItemInLevel);
|
||||||
|
|
||||||
/***** Link to forum of teachers from this course *****/
|
/***** Link to forum of teachers from this course *****/
|
||||||
if (ICanSeeTeacherForum)
|
if (ICanSeeTeacherForum == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
Forum.Type = For_FORUM_COURSE_TCHS;
|
Forum.Type = For_FORUM_COURSE_TCHS;
|
||||||
Forum.HieCod = CrsCod;
|
Forum.HieCod = CrsCod;
|
||||||
|
@ -2674,78 +2688,87 @@ static void For_SetForumType (struct For_Forums *Forums)
|
||||||
static void For_RestrictAccess (const struct For_Forums *Forums)
|
static void For_RestrictAccess (const struct For_Forums *Forums)
|
||||||
{
|
{
|
||||||
Rol_Role_t MaxRole;
|
Rol_Role_t MaxRole;
|
||||||
bool ICanSeeForum;
|
Usr_ICan_t ICanSeeForum;
|
||||||
|
|
||||||
/***** Restrict access *****/
|
/***** Restrict access *****/
|
||||||
switch (Forums->Forum.Type)
|
switch (Forums->Forum.Type)
|
||||||
{
|
{
|
||||||
case For_FORUM_GLOBAL_USRS:
|
case For_FORUM_GLOBAL_USRS:
|
||||||
case For_FORUM__SWAD__USRS:
|
case For_FORUM__SWAD__USRS:
|
||||||
ICanSeeForum = true;
|
ICanSeeForum = Usr_I_CAN;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_GLOBAL_TCHS:
|
case For_FORUM_GLOBAL_TCHS:
|
||||||
case For_FORUM__SWAD__TCHS:
|
case For_FORUM__SWAD__TCHS:
|
||||||
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
||||||
ICanSeeForum = (Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) |
|
ICanSeeForum = (Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) |
|
||||||
(1 << Rol_TCH)));
|
(1 << Rol_TCH))) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_INSTIT_USRS:
|
case For_FORUM_INSTIT_USRS:
|
||||||
MaxRole = Rol_GetMyMaxRoleIn (Hie_INS,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) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_INSTIT_TCHS:
|
case For_FORUM_INSTIT_TCHS:
|
||||||
MaxRole = Rol_GetMyMaxRoleIn (Hie_INS,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) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_CENTER_USRS:
|
case For_FORUM_CENTER_USRS:
|
||||||
MaxRole = Rol_GetMyMaxRoleIn (Hie_CTR,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) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_CENTER_TCHS:
|
case For_FORUM_CENTER_TCHS:
|
||||||
MaxRole = Rol_GetMyMaxRoleIn (Hie_CTR,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) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_DEGREE_USRS:
|
case For_FORUM_DEGREE_USRS:
|
||||||
MaxRole = Rol_GetMyMaxRoleIn (Hie_DEG,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) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_DEGREE_TCHS:
|
case For_FORUM_DEGREE_TCHS:
|
||||||
MaxRole = Rol_GetMyMaxRoleIn (Hie_DEG,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) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_COURSE_USRS:
|
case For_FORUM_COURSE_USRS:
|
||||||
MaxRole = Rol_GetMyRoleInCrs (Forums->Forum.HieCod);
|
MaxRole = Rol_GetMyRoleInCrs (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) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case For_FORUM_COURSE_TCHS:
|
case For_FORUM_COURSE_TCHS:
|
||||||
MaxRole = Rol_GetMyRoleInCrs (Forums->Forum.HieCod);
|
MaxRole = Rol_GetMyRoleInCrs (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) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ICanSeeForum = false;
|
ICanSeeForum = Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!ICanSeeForum)
|
if (ICanSeeForum == Usr_I_CAN_NOT)
|
||||||
Err_NoPermissionExit ();
|
Err_NoPermissionExit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -348,10 +348,10 @@ static void Gam_ListAllGamesHeading (const struct Gam_Games *Games)
|
||||||
|
|
||||||
static Usr_ICan_t Gam_CheckIfICanEditGames (void)
|
static Usr_ICan_t Gam_CheckIfICanEditGames (void)
|
||||||
{
|
{
|
||||||
static bool ICanEditGames[Rol_NUM_ROLES] =
|
static Usr_ICan_t ICanEditGames[Rol_NUM_ROLES] =
|
||||||
{
|
{
|
||||||
[Rol_TCH ] = true,
|
[Rol_TCH ] = Usr_I_CAN,
|
||||||
[Rol_SYS_ADM] = true,
|
[Rol_SYS_ADM] = Usr_I_CAN,
|
||||||
};
|
};
|
||||||
|
|
||||||
return ICanEditGames[Gbl.Usrs.Me.Role.Logged];
|
return ICanEditGames[Gbl.Usrs.Me.Role.Logged];
|
||||||
|
|
134
swad_group.c
134
swad_group.c
|
@ -107,8 +107,8 @@ static void Grp_WriteHeadingGroups (void);
|
||||||
static void Grp_PutIconToEditGroups (__attribute__((unused)) void *Args);
|
static void Grp_PutIconToEditGroups (__attribute__((unused)) void *Args);
|
||||||
|
|
||||||
static void Grp_ShowWarningToStdsToChangeGrps (void);
|
static void Grp_ShowWarningToStdsToChangeGrps (void);
|
||||||
static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
static Usr_ICan_t Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
||||||
unsigned *NumGrpsThisTypeIBelong);
|
unsigned *NumGrpsThisTypeIBelong);
|
||||||
static void Grp_ListGrpsToAddOrRemUsrs (struct GroupType *GrpTyp,long UsrCod);
|
static void Grp_ListGrpsToAddOrRemUsrs (struct GroupType *GrpTyp,long UsrCod);
|
||||||
static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp);
|
static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp);
|
||||||
static void Grp_WriteGrpHead (struct GroupType *GrpTyp);
|
static void Grp_WriteGrpHead (struct GroupType *GrpTyp);
|
||||||
|
@ -348,19 +348,21 @@ void Grp_ShowFormToSelectSeveralGroups (Act_Action_t NextAction,
|
||||||
extern const char *Txt_Groups;
|
extern const char *Txt_Groups;
|
||||||
extern const char *Txt_Update_users;
|
extern const char *Txt_Update_users;
|
||||||
unsigned NumGrpTyp;
|
unsigned NumGrpTyp;
|
||||||
bool ICanEdit;
|
Usr_ICan_t ICanEdit;
|
||||||
|
|
||||||
/***** Trivial check: if no groups ==> nothing to do *****/
|
/***** Trivial check: if no groups ==> nothing to do *****/
|
||||||
if (!Gbl.Crs.Grps.NumGrps)
|
if (!Gbl.Crs.Grps.NumGrps)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
ICanEdit = !Frm_CheckIfInside () &&
|
ICanEdit = (!Frm_CheckIfInside () &&
|
||||||
(Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
(Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
Box_BoxBegin (Txt_Groups,
|
Box_BoxBegin (Txt_Groups,
|
||||||
ICanEdit ? Grp_PutIconToEditGroups :
|
ICanEdit == Usr_I_CAN ? Grp_PutIconToEditGroups :
|
||||||
NULL,NULL,
|
NULL,
|
||||||
|
NULL,
|
||||||
Hlp_USERS_Groups,Box_CLOSABLE);
|
Hlp_USERS_Groups,Box_CLOSABLE);
|
||||||
|
|
||||||
/***** Begin form to update the students listed
|
/***** Begin form to update the students listed
|
||||||
|
@ -405,7 +407,7 @@ void Grp_ShowFormToSelectSeveralGroups (Act_Action_t NextAction,
|
||||||
static void Grp_PutCheckboxAllGrps (void)
|
static void Grp_PutCheckboxAllGrps (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_All_groups;
|
extern const char *Txt_All_groups;
|
||||||
bool ICanSelUnselGroup;
|
Usr_ICan_t ICanSelUnselGroup;
|
||||||
|
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
|
@ -414,10 +416,10 @@ static void Grp_PutCheckboxAllGrps (void)
|
||||||
case Rol_CTR_ADM:
|
case Rol_CTR_ADM:
|
||||||
case Rol_INS_ADM:
|
case Rol_INS_ADM:
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
ICanSelUnselGroup = true;
|
ICanSelUnselGroup = Usr_I_CAN;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ICanSelUnselGroup = false;
|
ICanSelUnselGroup = Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,10 +427,10 @@ static void Grp_PutCheckboxAllGrps (void)
|
||||||
HTM_LABEL_Begin ("class=\"FORM_IN_%s\"",The_GetSuffix ());
|
HTM_LABEL_Begin ("class=\"FORM_IN_%s\"",The_GetSuffix ());
|
||||||
HTM_INPUT_CHECKBOX ("AllGroups",HTM_DONT_SUBMIT_ON_CHANGE,
|
HTM_INPUT_CHECKBOX ("AllGroups",HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
"value=\"Y\"%s",
|
"value=\"Y\"%s",
|
||||||
ICanSelUnselGroup ? (Gbl.Crs.Grps.AllGrps ? " checked=\"checked\""
|
ICanSelUnselGroup == Usr_I_CAN ? (Gbl.Crs.Grps.AllGrps ? " checked=\"checked\""
|
||||||
" onclick=\"togglecheckChildren(this,'GrpCods')\"" :
|
" onclick=\"togglecheckChildren(this,'GrpCods')\"" :
|
||||||
" onclick=\"togglecheckChildren(this,'GrpCods')\"") :
|
" onclick=\"togglecheckChildren(this,'GrpCods')\"") :
|
||||||
" disabled=\"disabled\"");
|
" disabled=\"disabled\"");
|
||||||
HTM_NBSPTxt (Txt_All_groups);
|
HTM_NBSPTxt (Txt_All_groups);
|
||||||
HTM_LABEL_End ();
|
HTM_LABEL_End ();
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
@ -1707,10 +1709,11 @@ void Grp_ShowLstGrpsToChgMyGrps (void)
|
||||||
unsigned NumGrpsIBelong = 0;
|
unsigned NumGrpsIBelong = 0;
|
||||||
Frm_PutForm_t PutFormToChangeGrps = Frm_CheckIfInside () ? Frm_DONT_PUT_FORM : // Inside another form (record card)?
|
Frm_PutForm_t PutFormToChangeGrps = Frm_CheckIfInside () ? Frm_DONT_PUT_FORM : // Inside another form (record card)?
|
||||||
Frm_PUT_FORM;
|
Frm_PUT_FORM;
|
||||||
bool ICanEdit = !Frm_CheckIfInside () &&
|
Usr_ICan_t ICanEdit = (!Frm_CheckIfInside () &&
|
||||||
(Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
(Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_I_CAN :
|
||||||
bool ICanChangeMyGrps = false;
|
Usr_I_CAN_NOT;
|
||||||
|
Usr_ICan_t ICanChangeMyGrps = Usr_I_CAN_NOT;
|
||||||
|
|
||||||
if (Gbl.Crs.Grps.NumGrps) // This course has groups
|
if (Gbl.Crs.Grps.NumGrps) // This course has groups
|
||||||
{
|
{
|
||||||
|
@ -1725,8 +1728,8 @@ void Grp_ShowLstGrpsToChgMyGrps (void)
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
Box_BoxBegin (Txt_My_groups,
|
Box_BoxBegin (Txt_My_groups,
|
||||||
ICanEdit ? Grp_PutIconToEditGroups :
|
ICanEdit == Usr_I_CAN ? Grp_PutIconToEditGroups :
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
Hlp_USERS_Groups,Box_NOT_CLOSABLE);
|
Hlp_USERS_Groups,Box_NOT_CLOSABLE);
|
||||||
|
|
||||||
|
@ -1743,8 +1746,9 @@ void Grp_ShowLstGrpsToChgMyGrps (void)
|
||||||
NumGrpTyp++)
|
NumGrpTyp++)
|
||||||
if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) // If there are groups of this type
|
if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) // If there are groups of this type
|
||||||
{
|
{
|
||||||
ICanChangeMyGrps |= Grp_ListGrpsForChangeMySelection (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],
|
if (Grp_ListGrpsForChangeMySelection (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],
|
||||||
&NumGrpsThisTypeIBelong);
|
&NumGrpsThisTypeIBelong) == Usr_I_CAN)
|
||||||
|
ICanChangeMyGrps = Usr_I_CAN;
|
||||||
NumGrpsIBelong += NumGrpsThisTypeIBelong;
|
NumGrpsIBelong += NumGrpsThisTypeIBelong;
|
||||||
}
|
}
|
||||||
HTM_TABLE_End ();
|
HTM_TABLE_End ();
|
||||||
|
@ -1752,7 +1756,7 @@ void Grp_ShowLstGrpsToChgMyGrps (void)
|
||||||
/***** End form *****/
|
/***** End form *****/
|
||||||
if (PutFormToChangeGrps)
|
if (PutFormToChangeGrps)
|
||||||
{
|
{
|
||||||
if (ICanChangeMyGrps)
|
if (ICanChangeMyGrps == Usr_I_CAN)
|
||||||
Btn_PutConfirmButton (NumGrpsIBelong ? Txt_Change_my_groups :
|
Btn_PutConfirmButton (NumGrpsIBelong ? Txt_Change_my_groups :
|
||||||
Txt_Enrol_in_groups);
|
Txt_Enrol_in_groups);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
|
@ -1821,16 +1825,16 @@ static void Grp_ShowWarningToStdsToChangeGrps (void)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Returns true if I can change my selection
|
// Returns true if I can change my selection
|
||||||
|
|
||||||
static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
static Usr_ICan_t Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
||||||
unsigned *NumGrpsThisTypeIBelong)
|
unsigned *NumGrpsThisTypeIBelong)
|
||||||
{
|
{
|
||||||
struct ListCodGrps LstGrpsIBelong;
|
struct ListCodGrps LstGrpsIBelong;
|
||||||
unsigned NumGrpThisType;
|
unsigned NumGrpThisType;
|
||||||
struct Group *Grp;
|
struct Group *Grp;
|
||||||
bool IBelongToThisGroup;
|
bool IBelongToThisGroup;
|
||||||
bool IBelongToAClosedGroup;
|
bool IBelongToAClosedGroup;
|
||||||
bool ICanChangeMySelectionForThisGrpTyp;
|
Usr_ICan_t ICanChangeMySelectionForThisGrpTyp;
|
||||||
bool ICanChangeMySelectionForThisGrp;
|
Usr_ICan_t ICanChangeMySelectionForThisGrp;
|
||||||
char StrGrpCod[32];
|
char StrGrpCod[32];
|
||||||
|
|
||||||
/***** Write heading *****/
|
/***** Write heading *****/
|
||||||
|
@ -1847,8 +1851,8 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
if (GrpTyp->MultipleEnrolment) // Enrolment is multiple
|
if (GrpTyp->MultipleEnrolment) // Enrolment is multiple
|
||||||
{
|
{
|
||||||
for (NumGrpThisType = 0, ICanChangeMySelectionForThisGrpTyp = false;
|
for (NumGrpThisType = 0, ICanChangeMySelectionForThisGrpTyp = Usr_I_CAN_NOT;
|
||||||
NumGrpThisType < GrpTyp->NumGrps && !ICanChangeMySelectionForThisGrpTyp;
|
NumGrpThisType < GrpTyp->NumGrps && ICanChangeMySelectionForThisGrpTyp == Usr_I_CAN_NOT;
|
||||||
NumGrpThisType++)
|
NumGrpThisType++)
|
||||||
{
|
{
|
||||||
Grp = &(GrpTyp->LstGrps[NumGrpThisType]);
|
Grp = &(GrpTyp->LstGrps[NumGrpThisType]);
|
||||||
|
@ -1856,10 +1860,10 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
||||||
{
|
{
|
||||||
IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong);
|
IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong);
|
||||||
if (IBelongToThisGroup) // I belong to this group
|
if (IBelongToThisGroup) // I belong to this group
|
||||||
ICanChangeMySelectionForThisGrpTyp = true; // I can unregister from group
|
ICanChangeMySelectionForThisGrpTyp = Usr_I_CAN; // I can unregister from group
|
||||||
else // I don't belong
|
else // I don't belong
|
||||||
if (Grp->NumUsrs[Rol_STD] < Grp->MaxStudents) // Group is not full
|
if (Grp->NumUsrs[Rol_STD] < Grp->MaxStudents) // Group is not full
|
||||||
ICanChangeMySelectionForThisGrpTyp = true; // I can register into group
|
ICanChangeMySelectionForThisGrpTyp = Usr_I_CAN; // I can register into group
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1880,11 +1884,11 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IBelongToAClosedGroup) // I belong to a closed group
|
if (IBelongToAClosedGroup) // I belong to a closed group
|
||||||
ICanChangeMySelectionForThisGrpTyp = false; // I can not unregister
|
ICanChangeMySelectionForThisGrpTyp = Usr_I_CAN_NOT; // I can not unregister
|
||||||
else // I don't belong to a closed group
|
else // I don't belong to a closed group
|
||||||
/* Step 2: Check if I can register in at least one group to which I don't belong */
|
/* Step 2: Check if I can register in at least one group to which I don't belong */
|
||||||
for (NumGrpThisType = 0, ICanChangeMySelectionForThisGrpTyp = false;
|
for (NumGrpThisType = 0, ICanChangeMySelectionForThisGrpTyp = Usr_I_CAN_NOT;
|
||||||
NumGrpThisType < GrpTyp->NumGrps && !ICanChangeMySelectionForThisGrpTyp;
|
NumGrpThisType < GrpTyp->NumGrps && ICanChangeMySelectionForThisGrpTyp == Usr_I_CAN_NOT;
|
||||||
NumGrpThisType++)
|
NumGrpThisType++)
|
||||||
{
|
{
|
||||||
Grp = &(GrpTyp->LstGrps[NumGrpThisType]);
|
Grp = &(GrpTyp->LstGrps[NumGrpThisType]);
|
||||||
|
@ -1893,17 +1897,17 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
||||||
{
|
{
|
||||||
IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong);
|
IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong);
|
||||||
if (!IBelongToThisGroup) // I don't belong to this group
|
if (!IBelongToThisGroup) // I don't belong to this group
|
||||||
ICanChangeMySelectionForThisGrpTyp = true; // I can register into this group
|
ICanChangeMySelectionForThisGrpTyp = Usr_I_CAN; // I can register into this group
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
ICanChangeMySelectionForThisGrpTyp = true; // I can not register/unregister
|
ICanChangeMySelectionForThisGrpTyp = Usr_I_CAN; // I can not register/unregister
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ICanChangeMySelectionForThisGrpTyp = false; // I can not register/unregister
|
ICanChangeMySelectionForThisGrpTyp = Usr_I_CAN_NOT; // I can not register/unregister
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1916,23 +1920,23 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
||||||
IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong);
|
IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong);
|
||||||
|
|
||||||
/* Selection disabled? */
|
/* Selection disabled? */
|
||||||
if (ICanChangeMySelectionForThisGrpTyp) // I can change my selection for this group type
|
if (ICanChangeMySelectionForThisGrpTyp == Usr_I_CAN) // I can change my selection for this group type
|
||||||
{
|
{
|
||||||
ICanChangeMySelectionForThisGrp = true;
|
ICanChangeMySelectionForThisGrp = Usr_I_CAN;
|
||||||
if (Gbl.Usrs.Me.Role.Logged == Rol_STD)
|
if (Gbl.Usrs.Me.Role.Logged == Rol_STD)
|
||||||
{
|
{
|
||||||
if (Grp->Open) // If group is open
|
if (Grp->Open) // If group is open
|
||||||
{
|
{
|
||||||
if (!IBelongToThisGroup && // I don't belong to group
|
if (!IBelongToThisGroup && // I don't belong to group
|
||||||
Grp->NumUsrs[Rol_STD] >= Grp->MaxStudents) // Group is full
|
Grp->NumUsrs[Rol_STD] >= Grp->MaxStudents) // Group is full
|
||||||
ICanChangeMySelectionForThisGrp = false;
|
ICanChangeMySelectionForThisGrp = Usr_I_CAN_NOT;
|
||||||
}
|
}
|
||||||
else // If group is closed
|
else // If group is closed
|
||||||
ICanChangeMySelectionForThisGrp = false;
|
ICanChangeMySelectionForThisGrp = Usr_I_CAN_NOT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // I can not change my selection for this group type
|
else // I can not change my selection for this group type
|
||||||
ICanChangeMySelectionForThisGrp = false;
|
ICanChangeMySelectionForThisGrp = Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/* Put radio item or checkbox to select the group */
|
/* Put radio item or checkbox to select the group */
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
@ -1951,18 +1955,18 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
||||||
"id=\"Grp%ld\" value=\"%ld\"%s%s",
|
"id=\"Grp%ld\" value=\"%ld\"%s%s",
|
||||||
Grp->GrpCod,Grp->GrpCod,
|
Grp->GrpCod,Grp->GrpCod,
|
||||||
IBelongToThisGroup ? " checked=\"checked\"" : "", // Group selected?
|
IBelongToThisGroup ? " checked=\"checked\"" : "", // Group selected?
|
||||||
ICanChangeMySelectionForThisGrp ? "" :
|
ICanChangeMySelectionForThisGrp == Usr_I_CAN ? "" :
|
||||||
IBelongToThisGroup ? " readonly" : // I can not unregister (disabled does not work because the value is not submitted)
|
IBelongToThisGroup ? " readonly" : // I can not unregister (disabled does not work because the value is not submitted)
|
||||||
" disabled=\"disabled\""); // I can not register
|
" disabled=\"disabled\""); // I can not register
|
||||||
else // If the enrolment is not mandatory, I can select no groups
|
else // If the enrolment is not mandatory, I can select no groups
|
||||||
HTM_INPUT_RADIO (StrGrpCod,HTM_DONT_SUBMIT_ON_CLICK,
|
HTM_INPUT_RADIO (StrGrpCod,HTM_DONT_SUBMIT_ON_CLICK,
|
||||||
"id=\"Grp%ld\" value=\"%ld\"%s%s"
|
"id=\"Grp%ld\" value=\"%ld\"%s%s"
|
||||||
" onclick=\"selectUnselectRadio(this,this.form.GrpCod%ld,%u)\"",
|
" onclick=\"selectUnselectRadio(this,this.form.GrpCod%ld,%u)\"",
|
||||||
Grp->GrpCod,Grp->GrpCod,
|
Grp->GrpCod,Grp->GrpCod,
|
||||||
IBelongToThisGroup ? " checked=\"checked\"" : "", // Group selected?
|
IBelongToThisGroup ? " checked=\"checked\"" : "", // Group selected?
|
||||||
ICanChangeMySelectionForThisGrp ? "" :
|
ICanChangeMySelectionForThisGrp == Usr_I_CAN ? "" :
|
||||||
IBelongToThisGroup ? " readonly" : // I can not unregister (disabled does not work because the value is not submitted)
|
IBelongToThisGroup ? " readonly" : // I can not unregister (disabled does not work because the value is not submitted)
|
||||||
" disabled=\"disabled\"", // I can not register
|
" disabled=\"disabled\"", // I can not register
|
||||||
GrpTyp->GrpTypCod,GrpTyp->NumGrps);
|
GrpTyp->GrpTypCod,GrpTyp->NumGrps);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1971,9 +1975,9 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
||||||
"id=\"Grp%ld\" value=\"%ld\"%s%s",
|
"id=\"Grp%ld\" value=\"%ld\"%s%s",
|
||||||
Grp->GrpCod,Grp->GrpCod,
|
Grp->GrpCod,Grp->GrpCod,
|
||||||
IBelongToThisGroup ? " checked=\"checked\"" : "",
|
IBelongToThisGroup ? " checked=\"checked\"" : "",
|
||||||
ICanChangeMySelectionForThisGrp ? "" :
|
ICanChangeMySelectionForThisGrp == Usr_I_CAN ? "" :
|
||||||
IBelongToThisGroup ? " readonly" : // I can not unregister (disabled does not work because the value is not submitted)
|
IBelongToThisGroup ? " readonly" : // I can not unregister (disabled does not work because the value is not submitted)
|
||||||
" disabled=\"disabled\""); // I can not register
|
" disabled=\"disabled\""); // I can not register
|
||||||
|
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
|
@ -2097,7 +2101,7 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp)
|
||||||
unsigned NumGrpSel;
|
unsigned NumGrpSel;
|
||||||
struct ListCodGrps LstGrpsIBelong;
|
struct ListCodGrps LstGrpsIBelong;
|
||||||
bool IBelongToThisGroup;
|
bool IBelongToThisGroup;
|
||||||
bool ICanSelUnselGroup;
|
Usr_ICan_t ICanSelUnselGroup;
|
||||||
bool Checked;
|
bool Checked;
|
||||||
struct Group *Grp;
|
struct Group *Grp;
|
||||||
Rol_Role_t Role;
|
Rol_Role_t Role;
|
||||||
|
@ -2122,23 +2126,24 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp)
|
||||||
|
|
||||||
/* Check if I can select / unselect this group */
|
/* Check if I can select / unselect this group */
|
||||||
if (IBelongToThisGroup)
|
if (IBelongToThisGroup)
|
||||||
ICanSelUnselGroup = true;
|
ICanSelUnselGroup = Usr_I_CAN;
|
||||||
else
|
else
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
case Rol_NET:
|
case Rol_NET:
|
||||||
ICanSelUnselGroup = IBelongToThisGroup;
|
ICanSelUnselGroup = IBelongToThisGroup ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
case Rol_DEG_ADM:
|
case Rol_DEG_ADM:
|
||||||
case Rol_CTR_ADM:
|
case Rol_CTR_ADM:
|
||||||
case Rol_INS_ADM:
|
case Rol_INS_ADM:
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
ICanSelUnselGroup = true; // GroupsSelectable is ignored
|
ICanSelUnselGroup = Usr_I_CAN;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ICanSelUnselGroup = false; // GroupsSelectable is ignored
|
ICanSelUnselGroup = Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2165,8 +2170,8 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp)
|
||||||
Grp->GrpCod,Grp->GrpCod,
|
Grp->GrpCod,Grp->GrpCod,
|
||||||
Checked ? " checked=\"checked\"" :
|
Checked ? " checked=\"checked\"" :
|
||||||
"",
|
"",
|
||||||
ICanSelUnselGroup ? " onclick=\"checkParent(this,'AllGroups')\"" :
|
ICanSelUnselGroup == Usr_I_CAN ? " onclick=\"checkParent(this,'AllGroups')\"" :
|
||||||
" disabled=\"disabled\"");
|
" disabled=\"disabled\"");
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
Grp_WriteRowGrp (Grp,IBelongToThisGroup ? Lay_HIGHLIGHT :
|
Grp_WriteRowGrp (Grp,IBelongToThisGroup ? Lay_HIGHLIGHT :
|
||||||
|
@ -2181,8 +2186,9 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp)
|
||||||
/***** Write rows to select the students who don't belong to any group *****/
|
/***** Write rows to select the students who don't belong to any group *****/
|
||||||
/* To get the students who don't belong to a type of group, use group code -(GrpTyp->GrpTypCod) */
|
/* To get the students who don't belong to a type of group, use group code -(GrpTyp->GrpTypCod) */
|
||||||
/* Write checkbox to select the group */
|
/* Write checkbox to select the group */
|
||||||
ICanSelUnselGroup = (Gbl.Usrs.Me.Role.Logged >= Rol_STD);
|
ICanSelUnselGroup = (Gbl.Usrs.Me.Role.Logged >= Rol_STD) ? Usr_I_CAN :
|
||||||
if (ICanSelUnselGroup)
|
Usr_I_CAN_NOT;
|
||||||
|
if (ICanSelUnselGroup == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
if (Gbl.Crs.Grps.AllGrps)
|
if (Gbl.Crs.Grps.AllGrps)
|
||||||
Checked = true;
|
Checked = true;
|
||||||
|
@ -2206,9 +2212,9 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp)
|
||||||
"id=\"Grp%ld\" value=\"%ld\"%s"
|
"id=\"Grp%ld\" value=\"%ld\"%s"
|
||||||
" onclick=\"checkParent(this,'AllGroups')\"",
|
" onclick=\"checkParent(this,'AllGroups')\"",
|
||||||
-GrpTyp->GrpTypCod,-GrpTyp->GrpTypCod,
|
-GrpTyp->GrpTypCod,-GrpTyp->GrpTypCod,
|
||||||
ICanSelUnselGroup ? (Checked ? " checked=\"checked\"" :
|
ICanSelUnselGroup == Usr_I_CAN ? (Checked ? " checked=\"checked\"" :
|
||||||
"") :
|
"") :
|
||||||
" disabled=\"disabled\"");
|
" disabled=\"disabled\"");
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/* Column closed/open */
|
/* Column closed/open */
|
||||||
|
|
|
@ -746,7 +746,7 @@ void Hie_WriteStatusCell (Hie_Status_t Status,
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hie_WriteStatusCellEditable (bool ICanEdit,Hie_Status_t Status,
|
void Hie_WriteStatusCellEditable (Usr_ICan_t ICanEdit,Hie_Status_t Status,
|
||||||
Act_Action_t NextAction,long HieCod,
|
Act_Action_t NextAction,long HieCod,
|
||||||
const char *Txt[Hie_NUM_STATUS_TXT])
|
const char *Txt[Hie_NUM_STATUS_TXT])
|
||||||
{
|
{
|
||||||
|
@ -755,7 +755,7 @@ void Hie_WriteStatusCellEditable (bool ICanEdit,Hie_Status_t Status,
|
||||||
|
|
||||||
/***** Begin cell *****/
|
/***** Begin cell *****/
|
||||||
HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ());
|
HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ());
|
||||||
if (ICanEdit && StatusTxt == Hie_STATUS_PENDING)
|
if (ICanEdit == Usr_I_CAN && StatusTxt == Hie_STATUS_PENDING)
|
||||||
{
|
{
|
||||||
/* Begin form */
|
/* Begin form */
|
||||||
Frm_BeginForm (NextAction);
|
Frm_BeginForm (NextAction);
|
||||||
|
|
|
@ -54,7 +54,7 @@ Usr_ICan_t Hie_CheckIfICanEdit (void);
|
||||||
void Hie_WriteStatusCell (Hie_Status_t Status,
|
void Hie_WriteStatusCell (Hie_Status_t Status,
|
||||||
const char *Class,const char *BgColor,
|
const char *Class,const char *BgColor,
|
||||||
const char *Txt[Hie_NUM_STATUS_TXT]);
|
const char *Txt[Hie_NUM_STATUS_TXT]);
|
||||||
void Hie_WriteStatusCellEditable (bool ICanEdit,Hie_Status_t Status,
|
void Hie_WriteStatusCellEditable (Usr_ICan_t ICanEdit,Hie_Status_t Status,
|
||||||
Act_Action_t NextAction,long HieCod,
|
Act_Action_t NextAction,long HieCod,
|
||||||
const char *Txt[Hie_NUM_STATUS_TXT]);
|
const char *Txt[Hie_NUM_STATUS_TXT]);
|
||||||
Hie_Status_t Hie_GetParStatus (void);
|
Hie_Status_t Hie_GetParStatus (void);
|
||||||
|
|
13
swad_info.c
13
swad_info.c
|
@ -186,8 +186,9 @@ void Inf_ShowInfo (void)
|
||||||
struct Syl_Syllabus Syllabus;
|
struct Syl_Syllabus Syllabus;
|
||||||
struct Inf_FromDB FromDB;
|
struct Inf_FromDB FromDB;
|
||||||
bool Disabled;
|
bool Disabled;
|
||||||
bool ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
Usr_ICan_t ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
bool ShowWarningNoInfo = false;
|
bool ShowWarningNoInfo = false;
|
||||||
const char *Help[Inf_NUM_TYPES] =
|
const char *Help[Inf_NUM_TYPES] =
|
||||||
{
|
{
|
||||||
|
@ -244,10 +245,10 @@ void Inf_ShowInfo (void)
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
Box_BoxBegin (Txt_INFO_TITLE[Gbl.Crs.Info.Type],
|
Box_BoxBegin (Txt_INFO_TITLE[Gbl.Crs.Info.Type],
|
||||||
ICanEdit ? Inf_PutIconToEditInfo :
|
(ICanEdit == Usr_I_CAN) ? Inf_PutIconToEditInfo :
|
||||||
NULL,
|
NULL,
|
||||||
ICanEdit ? &Gbl.Crs.Info.Type :
|
(ICanEdit == Usr_I_CAN) ? &Gbl.Crs.Info.Type :
|
||||||
NULL,
|
NULL,
|
||||||
Help[Gbl.Crs.Info.Type],Box_NOT_CLOSABLE);
|
Help[Gbl.Crs.Info.Type],Box_NOT_CLOSABLE);
|
||||||
|
|
||||||
/****** Form to select syllabus *****/
|
/****** Form to select syllabus *****/
|
||||||
|
|
|
@ -995,7 +995,8 @@ static void Ins_ListInstitutionsForEdition (void)
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/* Institution status */
|
/* Institution status */
|
||||||
Hie_WriteStatusCellEditable (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM,
|
Hie_WriteStatusCellEditable (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT,
|
||||||
Ins->Status,ActChgInsSta,Ins->HieCod,
|
Ins->Status,ActChgInsSta,Ins->HieCod,
|
||||||
Txt_INSTITUTION_STATUS);
|
Txt_INSTITUTION_STATUS);
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ static void Lnk_EditingLinkDestructor (void);
|
||||||
|
|
||||||
static Usr_ICan_t Lnk_CheckIfICanEditLinks (void)
|
static Usr_ICan_t Lnk_CheckIfICanEditLinks (void)
|
||||||
{
|
{
|
||||||
static bool Lnk_ICanEditLinks[Rol_NUM_ROLES] =
|
static Usr_ICan_t Lnk_ICanEditLinks[Rol_NUM_ROLES] =
|
||||||
{
|
{
|
||||||
/* Users who can edit */
|
/* Users who can edit */
|
||||||
[Rol_SYS_ADM] = Usr_I_CAN,
|
[Rol_SYS_ADM] = Usr_I_CAN,
|
||||||
|
|
29
swad_mail.c
29
swad_mail.c
|
@ -1666,11 +1666,11 @@ void Mai_WriteFootNoteEMail (FILE *FileMail,Lan_Language_t Language)
|
||||||
/**************** Check if I can see another user's email ********************/
|
/**************** Check if I can see another user's email ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
bool Mai_ICanSeeOtherUsrEmail (const struct Usr_Data *UsrDat)
|
Usr_ICan_t Mai_ICanSeeOtherUsrEmail (const struct Usr_Data *UsrDat)
|
||||||
{
|
{
|
||||||
/***** I can see my email *****/
|
/***** I can see my email *****/
|
||||||
if (Usr_ItsMe (UsrDat->UsrCod) == Usr_ME)
|
if (Usr_ItsMe (UsrDat->UsrCod) == Usr_ME)
|
||||||
return true;
|
return Usr_I_CAN;
|
||||||
|
|
||||||
/***** Check if I have permission to see another user's email *****/
|
/***** Check if I have permission to see another user's email *****/
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
|
@ -1678,37 +1678,42 @@ bool Mai_ICanSeeOtherUsrEmail (const struct Usr_Data *UsrDat)
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
/* If I am a student in the current course,
|
/* If I am a student in the current course,
|
||||||
I can see the email of confirmed teachers */
|
I can see the email of confirmed teachers */
|
||||||
return (UsrDat->Roles.InCurrentCrs == Rol_NET || // A non-editing teacher
|
return ((UsrDat->Roles.InCurrentCrs == Rol_NET || // A non-editing teacher
|
||||||
UsrDat->Roles.InCurrentCrs == Rol_TCH) && // or a teacher
|
UsrDat->Roles.InCurrentCrs == Rol_TCH) && // or a teacher
|
||||||
UsrDat->Accepted; // who accepted registration
|
UsrDat->Accepted) ? Usr_I_CAN : // who accepted registration
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
case Rol_NET:
|
case Rol_NET:
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
/* If I am a teacher in the current course,
|
/* If I am a teacher in the current course,
|
||||||
I can see the email of confirmed students and teachers */
|
I can see the email of confirmed students and teachers */
|
||||||
return Enr_CheckIfUsrBelongsToCurrentCrs (UsrDat) && // A user belonging to the current course
|
return (Enr_CheckIfUsrBelongsToCurrentCrs (UsrDat) && // A user belonging to the current course
|
||||||
UsrDat->Accepted; // who accepted registration
|
UsrDat->Accepted) ? Usr_I_CAN : // who accepted registration
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
case Rol_DEG_ADM:
|
case Rol_DEG_ADM:
|
||||||
/* If I am an administrator of current degree,
|
/* If I am an administrator of current degree,
|
||||||
I only can see the user's email of users from current degree */
|
I only can see the user's email of users from current degree */
|
||||||
return Hie_CheckIfUsrBelongsTo (Hie_DEG,UsrDat->UsrCod,
|
return Hie_CheckIfUsrBelongsTo (Hie_DEG,UsrDat->UsrCod,
|
||||||
Gbl.Hierarchy.Node[Hie_DEG].HieCod,
|
Gbl.Hierarchy.Node[Hie_DEG].HieCod,
|
||||||
true); // count only accepted courses
|
true) ? Usr_I_CAN : // count only accepted courses
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
case Rol_CTR_ADM:
|
case Rol_CTR_ADM:
|
||||||
/* If I am an administrator of current center,
|
/* If I am an administrator of current center,
|
||||||
I only can see the user's email of users from current center */
|
I only can see the user's email of users from current center */
|
||||||
return Hie_CheckIfUsrBelongsTo (Hie_CTR,UsrDat->UsrCod,
|
return Hie_CheckIfUsrBelongsTo (Hie_CTR,UsrDat->UsrCod,
|
||||||
Gbl.Hierarchy.Node[Hie_CTR].HieCod,
|
Gbl.Hierarchy.Node[Hie_CTR].HieCod,
|
||||||
true); // count only accepted courses
|
true) ? Usr_I_CAN : // count only accepted courses
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
case Rol_INS_ADM:
|
case Rol_INS_ADM:
|
||||||
/* If I am an administrator of current institution,
|
/* If I am an administrator of current institution,
|
||||||
I only can see the user's email of users from current institution */
|
I only can see the user's email of users from current institution */
|
||||||
return Hie_CheckIfUsrBelongsTo (Hie_INS,UsrDat->UsrCod,
|
return Hie_CheckIfUsrBelongsTo (Hie_INS,UsrDat->UsrCod,
|
||||||
Gbl.Hierarchy.Node[Hie_INS].HieCod,
|
Gbl.Hierarchy.Node[Hie_INS].HieCod,
|
||||||
true); // count only accepted courses
|
true) ? Usr_I_CAN : // count only accepted courses
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
return true;
|
return Usr_I_CAN;
|
||||||
default:
|
default:
|
||||||
return false;
|
return Usr_I_CAN_NOT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ void Mai_WriteWelcomeNoteEMail (FILE *FileMail,const struct Usr_Data *UsrDat,
|
||||||
Lan_Language_t ToUsrLanguage);
|
Lan_Language_t ToUsrLanguage);
|
||||||
void Mai_WriteFootNoteEMail (FILE *FileMail,Lan_Language_t Language);
|
void Mai_WriteFootNoteEMail (FILE *FileMail,Lan_Language_t Language);
|
||||||
|
|
||||||
bool Mai_ICanSeeOtherUsrEmail (const struct Usr_Data *UsrDat);
|
Usr_ICan_t Mai_ICanSeeOtherUsrEmail (const struct Usr_Data *UsrDat);
|
||||||
|
|
||||||
int Mai_SendMailMsg (const char FileNameMail[PATH_MAX + 1],
|
int Mai_SendMailMsg (const char FileNameMail[PATH_MAX + 1],
|
||||||
const char *Subject,
|
const char *Subject,
|
||||||
|
|
12
swad_place.c
12
swad_place.c
|
@ -61,7 +61,7 @@ static struct Plc_Place *Plc_EditingPlc = NULL; // Static variable to keep the p
|
||||||
/***************************** Private prototypes ****************************/
|
/***************************** Private prototypes ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static bool Plc_CheckIfICanEditPlaces (void);
|
static Usr_ICan_t Plc_CheckIfICanEditPlaces (void);
|
||||||
|
|
||||||
static Plc_Order_t Plc_GetParPlcOrder (void);
|
static Plc_Order_t Plc_GetParPlcOrder (void);
|
||||||
static void Plc_PutIconsListingPlaces (__attribute__((unused)) void *Args);
|
static void Plc_PutIconsListingPlaces (__attribute__((unused)) void *Args);
|
||||||
|
@ -86,13 +86,13 @@ static void Plc_EditingPlaceDestructor (void);
|
||||||
/************************* Check if I can edit places ************************/
|
/************************* Check if I can edit places ************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static bool Plc_CheckIfICanEditPlaces (void)
|
static Usr_ICan_t Plc_CheckIfICanEditPlaces (void)
|
||||||
{
|
{
|
||||||
static bool Plc_ICanEditPlaces[Rol_NUM_ROLES] =
|
static Usr_ICan_t Plc_ICanEditPlaces[Rol_NUM_ROLES] =
|
||||||
{
|
{
|
||||||
/* Users who can edit */
|
/* Users who can edit */
|
||||||
[Rol_INS_ADM] = true,
|
[Rol_INS_ADM] = Usr_I_CAN,
|
||||||
[Rol_SYS_ADM] = true,
|
[Rol_SYS_ADM] = Usr_I_CAN,
|
||||||
};
|
};
|
||||||
|
|
||||||
return Plc_ICanEditPlaces[Gbl.Usrs.Me.Role.Logged];
|
return Plc_ICanEditPlaces[Gbl.Usrs.Me.Role.Logged];
|
||||||
|
@ -238,7 +238,7 @@ static Plc_Order_t Plc_GetParPlcOrder (void)
|
||||||
static void Plc_PutIconsListingPlaces (__attribute__((unused)) void *Args)
|
static void Plc_PutIconsListingPlaces (__attribute__((unused)) void *Args)
|
||||||
{
|
{
|
||||||
/***** Put icon to edit places *****/
|
/***** Put icon to edit places *****/
|
||||||
if (Plc_CheckIfICanEditPlaces ())
|
if (Plc_CheckIfICanEditPlaces () == Usr_I_CAN)
|
||||||
Plc_PutIconToEditPlaces ();
|
Plc_PutIconToEditPlaces ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1337,7 +1337,7 @@ static void Prf_ShowUsrInRanking (struct Usr_Data *UsrDat,unsigned Rank,
|
||||||
[PhoSha_SHAPE_OVAL ] = "PHOTOO30x40",
|
[PhoSha_SHAPE_OVAL ] = "PHOTOO30x40",
|
||||||
[PhoSha_SHAPE_RECTANGLE] = "PHOTOR30x40",
|
[PhoSha_SHAPE_RECTANGLE] = "PHOTOR30x40",
|
||||||
};
|
};
|
||||||
bool Visible = (Pri_CheckIfICanView (UsrDat->BaPrfVisibility,UsrDat) == Usr_I_CAN);
|
Usr_ICan_t ICanView = Pri_CheckIfICanView (UsrDat->BaPrfVisibility,UsrDat);
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"RM %s_%s %s\"",
|
HTM_TD_Begin ("class=\"RM %s_%s %s\"",
|
||||||
Class[MeOrOther],
|
Class[MeOrOther],
|
||||||
|
@ -1348,7 +1348,7 @@ static void Prf_ShowUsrInRanking (struct Usr_Data *UsrDat,unsigned Rank,
|
||||||
|
|
||||||
/***** Check if I can see the public profile *****/
|
/***** Check if I can see the public profile *****/
|
||||||
HTM_TD_Begin ("class=\"RANK_PHOTO %s\"",The_GetColorRows ());
|
HTM_TD_Begin ("class=\"RANK_PHOTO %s\"",The_GetColorRows ());
|
||||||
if (Visible)
|
if (ICanView == Usr_I_CAN)
|
||||||
/***** User's photo *****/
|
/***** User's photo *****/
|
||||||
Pho_ShowUsrPhotoIfAllowed (UsrDat,
|
Pho_ShowUsrPhotoIfAllowed (UsrDat,
|
||||||
ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM);
|
ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM);
|
||||||
|
@ -1359,7 +1359,7 @@ static void Prf_ShowUsrInRanking (struct Usr_Data *UsrDat,unsigned Rank,
|
||||||
Class[MeOrOther],
|
Class[MeOrOther],
|
||||||
The_GetSuffix (),
|
The_GetSuffix (),
|
||||||
The_GetColorRows ());
|
The_GetColorRows ());
|
||||||
if (Visible)
|
if (ICanView == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
Frm_BeginForm (ActSeeOthPubPrf);
|
Frm_BeginForm (ActSeeOthPubPrf);
|
||||||
Usr_PutParUsrCodEncrypted (UsrDat->EnUsrCod);
|
Usr_PutParUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
|
|
|
@ -1575,13 +1575,13 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
[Rec_CRS_PRINT_ONE_RECORD ] = NULL,
|
[Rec_CRS_PRINT_ONE_RECORD ] = NULL,
|
||||||
[Rec_CRS_PRINT_SEVERAL_RECORDS ] = NULL,
|
[Rec_CRS_PRINT_SEVERAL_RECORDS ] = NULL,
|
||||||
};
|
};
|
||||||
bool ICanEdit = false;
|
Usr_ICan_t ICanEdit = Usr_I_CAN_NOT;
|
||||||
unsigned NumField;
|
unsigned NumField;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row = NULL; // Initialized to avoid warning
|
MYSQL_ROW row = NULL; // Initialized to avoid warning
|
||||||
bool ShowField;
|
bool ShowField;
|
||||||
bool ThisFieldHasText;
|
bool ThisFieldHasText;
|
||||||
bool ICanEditThisField;
|
Usr_ICan_t ICanEditThisField;
|
||||||
char Text[Cns_MAX_BYTES_TEXT + 1];
|
char Text[Cns_MAX_BYTES_TEXT + 1];
|
||||||
|
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
|
@ -1614,7 +1614,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
NumField++)
|
NumField++)
|
||||||
if (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
|
if (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
|
||||||
{
|
{
|
||||||
ICanEdit = true;
|
ICanEdit = Usr_I_CAN;
|
||||||
Frm_BeginForm (ActRcvRecCrs);
|
Frm_BeginForm (ActRcvRecCrs);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1626,7 +1626,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
if (TypeOfView == Rec_CRS_LIST_ONE_RECORD ||
|
if (TypeOfView == Rec_CRS_LIST_ONE_RECORD ||
|
||||||
TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS)
|
TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS)
|
||||||
{
|
{
|
||||||
ICanEdit = true;
|
ICanEdit = Usr_I_CAN;
|
||||||
Frm_BeginFormAnchor (ActRcvRecOthUsr,Anchor);
|
Frm_BeginFormAnchor (ActRcvRecOthUsr,Anchor);
|
||||||
ParCod_PutPar (ParCod_OrgAct,Act_GetActCod (ActSeeRecSevStd)); // Original action, used to know where we came from
|
ParCod_PutPar (ParCod_OrgAct,Act_GetActCod (ActSeeRecSevStd)); // Original action, used to know where we came from
|
||||||
Usr_PutParUsrCodEncrypted (UsrDat->EnUsrCod);
|
Usr_PutParUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||||
|
@ -1682,15 +1682,17 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
{
|
{
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
ICanEditThisField = (TypeOfView == Rec_CRS_MY_RECORD_AS_STUDENT_FORM &&
|
ICanEditThisField = (TypeOfView == Rec_CRS_MY_RECORD_AS_STUDENT_FORM &&
|
||||||
Gbl.Crs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD);
|
Gbl.Crs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
ICanEditThisField = (TypeOfView == Rec_CRS_LIST_ONE_RECORD ||
|
ICanEditThisField = (TypeOfView == Rec_CRS_LIST_ONE_RECORD ||
|
||||||
TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS);
|
TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ICanEditThisField = false;
|
ICanEditThisField = Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1698,8 +1700,8 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"REC_C1_BOT %s_%s RT %s\"",
|
HTM_TD_Begin ("class=\"REC_C1_BOT %s_%s RT %s\"",
|
||||||
ICanEditThisField ? "FORM_IN" :
|
ICanEditThisField == Usr_I_CAN ? "FORM_IN" :
|
||||||
"REC_DAT_SMALL", // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
"REC_DAT_SMALL", // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
The_GetSuffix (),
|
The_GetSuffix (),
|
||||||
The_GetColorRows ());
|
The_GetColorRows ());
|
||||||
HTM_TxtColon (Gbl.Crs.Records.LstFields.Lst[NumField].Name);
|
HTM_TxtColon (Gbl.Crs.Records.LstFields.Lst[NumField].Name);
|
||||||
|
@ -1731,7 +1733,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
HTM_TD_Begin ("class=\"REC_C2_BOT LT DAT_STRONG_%s %s\"",
|
HTM_TD_Begin ("class=\"REC_C2_BOT LT DAT_STRONG_%s %s\"",
|
||||||
The_GetSuffix (),
|
The_GetSuffix (),
|
||||||
The_GetColorRows ());
|
The_GetColorRows ());
|
||||||
if (ICanEditThisField) // Show with form
|
if (ICanEditThisField == Usr_I_CAN) // Show with form
|
||||||
{
|
{
|
||||||
HTM_TEXTAREA_Begin ("name=\"Field%ld\" rows=\"%u\""
|
HTM_TEXTAREA_Begin ("name=\"Field%ld\" rows=\"%u\""
|
||||||
" class=\"REC_C2_BOT_INPUT INPUT_%s\"",
|
" class=\"REC_C2_BOT_INPUT INPUT_%s\"",
|
||||||
|
@ -1765,7 +1767,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** End box *****/
|
/***** End box *****/
|
||||||
if (ICanEdit)
|
if (ICanEdit == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
/* End table, send button and end box */
|
/* End table, send button and end box */
|
||||||
Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_changes);
|
Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_changes);
|
||||||
|
@ -2681,7 +2683,7 @@ static void Rec_ShowEmail (struct Usr_Data *UsrDat)
|
||||||
The_GetSuffix ());
|
The_GetSuffix ());
|
||||||
if (UsrDat->Email[0])
|
if (UsrDat->Email[0])
|
||||||
{
|
{
|
||||||
if (Mai_ICanSeeOtherUsrEmail (UsrDat))
|
if (Mai_ICanSeeOtherUsrEmail (UsrDat) == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
HTM_A_Begin ("href=\"mailto:%s\" class=\"DAT_STRONG_%s\"",
|
HTM_A_Begin ("href=\"mailto:%s\" class=\"DAT_STRONG_%s\"",
|
||||||
UsrDat->Email,The_GetSuffix ());
|
UsrDat->Email,The_GetSuffix ());
|
||||||
|
|
23
swad_role.c
23
swad_role.c
|
@ -70,11 +70,11 @@ extern struct Globals Gbl;
|
||||||
|
|
||||||
void Rol_SetMyRoles (void)
|
void Rol_SetMyRoles (void)
|
||||||
{
|
{
|
||||||
bool ICanBeAdm[Hie_NUM_LEVELS] =
|
Usr_ICan_t ICanBeAdm[Hie_NUM_LEVELS] =
|
||||||
{
|
{
|
||||||
[Hie_INS] = false,
|
[Hie_INS] = Usr_I_CAN_NOT,
|
||||||
[Hie_CTR] = false,
|
[Hie_CTR] = Usr_I_CAN_NOT,
|
||||||
[Hie_DEG] = false,
|
[Hie_DEG] = Usr_I_CAN_NOT,
|
||||||
};
|
};
|
||||||
|
|
||||||
/***** Get my role in current course if not yet filled *****/
|
/***** Get my role in current course if not yet filled *****/
|
||||||
|
@ -109,16 +109,19 @@ void Rol_SetMyRoles (void)
|
||||||
{
|
{
|
||||||
/* Check if I am and administrator of current institution */
|
/* Check if I am and administrator of current institution */
|
||||||
ICanBeAdm[Hie_INS] = Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
ICanBeAdm[Hie_INS] = Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Hie_INS);
|
Hie_INS) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
if (Gbl.Hierarchy.Node[Hie_CTR].HieCod > 0)
|
if (Gbl.Hierarchy.Node[Hie_CTR].HieCod > 0)
|
||||||
{
|
{
|
||||||
/* Check if I am and administrator of current center */
|
/* Check if I am and administrator of current center */
|
||||||
ICanBeAdm[Hie_CTR] = Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
ICanBeAdm[Hie_CTR] = Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Hie_CTR);
|
Hie_CTR) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
if (Gbl.Hierarchy.Node[Hie_DEG].HieCod > 0)
|
if (Gbl.Hierarchy.Node[Hie_DEG].HieCod > 0)
|
||||||
/* Check if I am and administrator of current degree */
|
/* Check if I am and administrator of current degree */
|
||||||
ICanBeAdm[Hie_DEG] = Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
ICanBeAdm[Hie_DEG] = Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Hie_DEG);
|
Hie_DEG) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,11 +188,11 @@ void Rol_SetMyRoles (void)
|
||||||
else
|
else
|
||||||
Gbl.Usrs.Me.Role.Available = (1 << Rol_GST);
|
Gbl.Usrs.Me.Role.Available = (1 << Rol_GST);
|
||||||
|
|
||||||
if (ICanBeAdm[Hie_INS])
|
if (ICanBeAdm[Hie_INS] == Usr_I_CAN)
|
||||||
Gbl.Usrs.Me.Role.Available |= (1 << Rol_INS_ADM);
|
Gbl.Usrs.Me.Role.Available |= (1 << Rol_INS_ADM);
|
||||||
if (ICanBeAdm[Hie_CTR])
|
if (ICanBeAdm[Hie_CTR] == Usr_I_CAN)
|
||||||
Gbl.Usrs.Me.Role.Available |= (1 << Rol_CTR_ADM);
|
Gbl.Usrs.Me.Role.Available |= (1 << Rol_CTR_ADM);
|
||||||
if (ICanBeAdm[Hie_DEG])
|
if (ICanBeAdm[Hie_DEG] == Usr_I_CAN)
|
||||||
Gbl.Usrs.Me.Role.Available |= (1 << Rol_DEG_ADM);
|
Gbl.Usrs.Me.Role.Available |= (1 << Rol_DEG_ADM);
|
||||||
if (Usr_CheckIfUsrIsSuperuser (Gbl.Usrs.Me.UsrDat.UsrCod))
|
if (Usr_CheckIfUsrIsSuperuser (Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||||
Gbl.Usrs.Me.Role.Available |= (1 << Rol_SYS_ADM);
|
Gbl.Usrs.Me.Role.Available |= (1 << Rol_SYS_ADM);
|
||||||
|
|
|
@ -527,7 +527,8 @@ void RubCri_ListCriteriaForEdition (struct Rub_Rubrics *Rubrics)
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned MaxCriInd;
|
unsigned MaxCriInd;
|
||||||
unsigned NumCriteria;
|
unsigned NumCriteria;
|
||||||
bool ICanEditCriteria = Rub_CheckIfEditable ();
|
Usr_ICan_t ICanEditCriteria = Rub_CheckIfEditable () ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/***** Get maximum criterion index *****/
|
/***** Get maximum criterion index *****/
|
||||||
MaxCriInd = Rub_DB_GetMaxCriterionIndexInRubric (Rubrics->Rubric.RubCod);
|
MaxCriInd = Rub_DB_GetMaxCriterionIndexInRubric (Rubrics->Rubric.RubCod);
|
||||||
|
@ -546,7 +547,7 @@ void RubCri_ListCriteriaForEdition (struct Rub_Rubrics *Rubrics)
|
||||||
NumCriteria,mysql_res);
|
NumCriteria,mysql_res);
|
||||||
|
|
||||||
/***** Put forms to create/edit a criterion *****/
|
/***** Put forms to create/edit a criterion *****/
|
||||||
if (ICanEditCriteria)
|
if (ICanEditCriteria == Usr_I_CAN)
|
||||||
RubCri_PutFormNewCriterion (Rubrics,MaxCriInd);
|
RubCri_PutFormNewCriterion (Rubrics,MaxCriInd);
|
||||||
|
|
||||||
/***** End box *****/
|
/***** End box *****/
|
||||||
|
|
|
@ -74,7 +74,7 @@ static struct Sch_Search Sch_Search =
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Sch_PutFormToSearchWithWhatToSearchAndScope (Hie_Level_t DefaultScope);
|
static void Sch_PutFormToSearchWithWhatToSearchAndScope (Hie_Level_t DefaultScope);
|
||||||
static bool Sch_CheckIfIHavePermissionToSearch (Sch_WhatToSearch_t WhatToSearch);
|
static Usr_ICan_t Sch_CheckIfICanSearch (Sch_WhatToSearch_t WhatToSearch);
|
||||||
static void Sch_GetParSearchStr (void);
|
static void Sch_GetParSearchStr (void);
|
||||||
static void Sch_SearchInDB (void);
|
static void Sch_SearchInDB (void);
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ static void Sch_PutFormToSearchWithWhatToSearchAndScope (Hie_Level_t DefaultScop
|
||||||
for (WhatToSearch = (Sch_WhatToSearch_t) 0;
|
for (WhatToSearch = (Sch_WhatToSearch_t) 0;
|
||||||
WhatToSearch <= (Sch_WhatToSearch_t) (Sch_NUM_WHAT_TO_SEARCH - 1);
|
WhatToSearch <= (Sch_WhatToSearch_t) (Sch_NUM_WHAT_TO_SEARCH - 1);
|
||||||
WhatToSearch++)
|
WhatToSearch++)
|
||||||
if (Sch_CheckIfIHavePermissionToSearch (WhatToSearch))
|
if (Sch_CheckIfICanSearch (WhatToSearch) == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
WTS = (unsigned) WhatToSearch;
|
WTS = (unsigned) WhatToSearch;
|
||||||
HTM_OPTION (HTM_Type_UNSIGNED,&WTS,
|
HTM_OPTION (HTM_Type_UNSIGNED,&WTS,
|
||||||
|
@ -222,7 +222,7 @@ static void Sch_PutFormToSearchWithWhatToSearchAndScope (Hie_Level_t DefaultScop
|
||||||
/************* Check if I have permission to execute an action ***************/
|
/************* Check if I have permission to execute an action ***************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static bool Sch_CheckIfIHavePermissionToSearch (Sch_WhatToSearch_t WhatToSearch)
|
static Usr_ICan_t Sch_CheckIfICanSearch (Sch_WhatToSearch_t WhatToSearch)
|
||||||
{
|
{
|
||||||
static unsigned Permissions[Sch_NUM_WHAT_TO_SEARCH] =
|
static unsigned Permissions[Sch_NUM_WHAT_TO_SEARCH] =
|
||||||
{
|
{
|
||||||
|
@ -242,7 +242,8 @@ static bool Sch_CheckIfIHavePermissionToSearch (Sch_WhatToSearch_t WhatToSearch)
|
||||||
[Sch_SEARCH_MY_DOCUMENTS ] = 0x3FE, // Only if I am logged
|
[Sch_SEARCH_MY_DOCUMENTS ] = 0x3FE, // Only if I am logged
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Permissions[WhatToSearch] & (1 << Gbl.Usrs.Me.Role.Logged));
|
return (Permissions[WhatToSearch] & (1 << Gbl.Usrs.Me.Role.Logged)) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -488,7 +489,7 @@ static unsigned Sch_SearchCountrsInDB (const char *RangeQuery)
|
||||||
Gbl.Scope.Current != Hie_DEG &&
|
Gbl.Scope.Current != Hie_DEG &&
|
||||||
Gbl.Scope.Current != Hie_CRS)
|
Gbl.Scope.Current != Hie_CRS)
|
||||||
/***** Check user's permission *****/
|
/***** Check user's permission *****/
|
||||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_COUNTRIES))
|
if (Sch_CheckIfICanSearch (Sch_SEARCH_COUNTRIES) == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
/***** Split countries string into words *****/
|
/***** Split countries string into words *****/
|
||||||
snprintf (FldName,sizeof (FldName),"Name_%s",
|
snprintf (FldName,sizeof (FldName),"Name_%s",
|
||||||
|
@ -523,7 +524,7 @@ static unsigned Sch_SearchInstitsInDB (const char *RangeQuery)
|
||||||
Gbl.Scope.Current != Hie_DEG &&
|
Gbl.Scope.Current != Hie_DEG &&
|
||||||
Gbl.Scope.Current != Hie_CRS)
|
Gbl.Scope.Current != Hie_CRS)
|
||||||
/***** Check user's permission *****/
|
/***** Check user's permission *****/
|
||||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_INSTITS))
|
if (Sch_CheckIfICanSearch (Sch_SEARCH_INSTITS) == Usr_I_CAN)
|
||||||
/***** Split institutions string into words *****/
|
/***** Split institutions string into words *****/
|
||||||
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
||||||
"ins_instits.FullName",NULL,NULL))
|
"ins_instits.FullName",NULL,NULL))
|
||||||
|
@ -552,7 +553,7 @@ static unsigned Sch_SearchCentersInDB (const char *RangeQuery)
|
||||||
if (Gbl.Scope.Current != Hie_DEG &&
|
if (Gbl.Scope.Current != Hie_DEG &&
|
||||||
Gbl.Scope.Current != Hie_CRS)
|
Gbl.Scope.Current != Hie_CRS)
|
||||||
/***** Check user's permission *****/
|
/***** Check user's permission *****/
|
||||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_CENTERS))
|
if (Sch_CheckIfICanSearch (Sch_SEARCH_CENTERS) == Usr_I_CAN)
|
||||||
/***** Split center string into words *****/
|
/***** Split center string into words *****/
|
||||||
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
||||||
"ctr_centers.FullName",NULL,NULL))
|
"ctr_centers.FullName",NULL,NULL))
|
||||||
|
@ -580,7 +581,7 @@ static unsigned Sch_SearchDegreesInDB (const char *RangeQuery)
|
||||||
/***** Check scope *****/
|
/***** Check scope *****/
|
||||||
if (Gbl.Scope.Current != Hie_CRS)
|
if (Gbl.Scope.Current != Hie_CRS)
|
||||||
/***** Check user's permission *****/
|
/***** Check user's permission *****/
|
||||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_DEGREES))
|
if (Sch_CheckIfICanSearch (Sch_SEARCH_DEGREES) == Usr_I_CAN)
|
||||||
/***** Split degree string into words *****/
|
/***** Split degree string into words *****/
|
||||||
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
||||||
"deg_degrees.FullName",NULL,NULL))
|
"deg_degrees.FullName",NULL,NULL))
|
||||||
|
@ -606,7 +607,7 @@ static unsigned Sch_SearchCoursesInDB (const char *RangeQuery)
|
||||||
unsigned NumCrss;
|
unsigned NumCrss;
|
||||||
|
|
||||||
/***** Check user's permission *****/
|
/***** Check user's permission *****/
|
||||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_COURSES))
|
if (Sch_CheckIfICanSearch (Sch_SEARCH_COURSES) == Usr_I_CAN)
|
||||||
/***** Split course string into words *****/
|
/***** Split course string into words *****/
|
||||||
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
||||||
"crs_courses.FullName",NULL,NULL))
|
"crs_courses.FullName",NULL,NULL))
|
||||||
|
@ -662,7 +663,7 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery)
|
||||||
unsigned NumDocs;
|
unsigned NumDocs;
|
||||||
|
|
||||||
/***** Check user's permission *****/
|
/***** Check user's permission *****/
|
||||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_OPEN_DOCUMENTS))
|
if (Sch_CheckIfICanSearch (Sch_SEARCH_OPEN_DOCUMENTS) == Usr_I_CAN)
|
||||||
/***** Split document string into words *****/
|
/***** Split document string into words *****/
|
||||||
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
||||||
"SUBSTRING_INDEX(brw_files.Path,'/',-1)",
|
"SUBSTRING_INDEX(brw_files.Path,'/',-1)",
|
||||||
|
@ -695,7 +696,7 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
unsigned NumDocs;
|
unsigned NumDocs;
|
||||||
|
|
||||||
/***** Check user's permission *****/
|
/***** Check user's permission *****/
|
||||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_DOCUM_IN_MY_COURSES))
|
if (Sch_CheckIfICanSearch (Sch_SEARCH_DOCUM_IN_MY_COURSES) == Usr_I_CAN)
|
||||||
/***** Split document string into words *****/
|
/***** Split document string into words *****/
|
||||||
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
||||||
"SUBSTRING_INDEX(brw_files.Path,'/',-1)",
|
"SUBSTRING_INDEX(brw_files.Path,'/',-1)",
|
||||||
|
@ -728,7 +729,7 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
|
||||||
unsigned NumDocs;
|
unsigned NumDocs;
|
||||||
|
|
||||||
/***** Check user's permission *****/
|
/***** Check user's permission *****/
|
||||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_MY_DOCUMENTS))
|
if (Sch_CheckIfICanSearch (Sch_SEARCH_MY_DOCUMENTS) == Usr_I_CAN)
|
||||||
/***** Split document string into words *****/
|
/***** Split document string into words *****/
|
||||||
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
if (Sch_BuildSearchQuery (SearchQuery,Sch_GetSearch (),
|
||||||
"SUBSTRING_INDEX(brw_files.Path,'/',-1)",
|
"SUBSTRING_INDEX(brw_files.Path,'/',-1)",
|
||||||
|
|
|
@ -791,7 +791,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
Sta_ClicksDetailedOrGrouped_t DetailedOrGrouped = Sta_CLICKS_GROUPED;
|
Sta_ClicksDetailedOrGrouped_t DetailedOrGrouped = Sta_CLICKS_GROUPED;
|
||||||
char BrowserTimeZone[Dat_MAX_BYTES_TIME_ZONE + 1];
|
char BrowserTimeZone[Dat_MAX_BYTES_TIME_ZONE + 1];
|
||||||
unsigned NumDays;
|
unsigned NumDays;
|
||||||
bool ICanQueryWholeRange;
|
Usr_ICan_t ICanQueryWholeRange;
|
||||||
unsigned NumUsrsInList = 0;
|
unsigned NumUsrsInList = 0;
|
||||||
long *LstSelectedUsrCods = NULL;
|
long *LstSelectedUsrCods = NULL;
|
||||||
|
|
||||||
|
@ -932,19 +932,21 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
||||||
/***** Check if range of dates is forbidden for me *****/
|
/***** Check if range of dates is forbidden for me *****/
|
||||||
NumDays = Dat_GetNumDaysBetweenDates (Dat_GetRangeDate (Dat_STR_TIME),
|
NumDays = Dat_GetNumDaysBetweenDates (Dat_GetRangeDate (Dat_STR_TIME),
|
||||||
Dat_GetRangeDate (Dat_END_TIME));
|
Dat_GetRangeDate (Dat_END_TIME));
|
||||||
ICanQueryWholeRange = (Gbl.Usrs.Me.Role.Logged >= Rol_TCH && Stats.GlobalOrCourse == Sta_SHOW_COURSE_ACCESSES) ||
|
ICanQueryWholeRange = ((Gbl.Usrs.Me.Role.Logged >= Rol_TCH && Stats.GlobalOrCourse == Sta_SHOW_COURSE_ACCESSES) ||
|
||||||
(Gbl.Usrs.Me.Role.Logged == Rol_TCH && Gbl.Scope.Current == Hie_CRS) ||
|
(Gbl.Usrs.Me.Role.Logged == Rol_TCH && Gbl.Scope.Current == Hie_CRS) ||
|
||||||
(Gbl.Usrs.Me.Role.Logged == Rol_DEG_ADM && (Gbl.Scope.Current == Hie_DEG ||
|
(Gbl.Usrs.Me.Role.Logged == Rol_DEG_ADM && (Gbl.Scope.Current == Hie_DEG ||
|
||||||
Gbl.Scope.Current == Hie_CRS)) ||
|
Gbl.Scope.Current == Hie_CRS)) ||
|
||||||
(Gbl.Usrs.Me.Role.Logged == Rol_CTR_ADM && (Gbl.Scope.Current == Hie_CTR ||
|
(Gbl.Usrs.Me.Role.Logged == Rol_CTR_ADM && (Gbl.Scope.Current == Hie_CTR ||
|
||||||
Gbl.Scope.Current == Hie_DEG ||
|
Gbl.Scope.Current == Hie_DEG ||
|
||||||
Gbl.Scope.Current == Hie_CRS)) ||
|
Gbl.Scope.Current == Hie_CRS)) ||
|
||||||
(Gbl.Usrs.Me.Role.Logged == Rol_INS_ADM && (Gbl.Scope.Current == Hie_INS ||
|
(Gbl.Usrs.Me.Role.Logged == Rol_INS_ADM && (Gbl.Scope.Current == Hie_INS ||
|
||||||
Gbl.Scope.Current == Hie_CTR ||
|
Gbl.Scope.Current == Hie_CTR ||
|
||||||
Gbl.Scope.Current == Hie_DEG ||
|
Gbl.Scope.Current == Hie_DEG ||
|
||||||
Gbl.Scope.Current == Hie_CRS)) ||
|
Gbl.Scope.Current == Hie_CRS)) ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM;
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Usr_I_CAN :
|
||||||
if (!ICanQueryWholeRange && NumDays > Cfg_DAYS_IN_RECENT_LOG)
|
Usr_I_CAN_NOT;
|
||||||
|
if (ICanQueryWholeRange == Usr_I_CAN_NOT &&
|
||||||
|
NumDays > Cfg_DAYS_IN_RECENT_LOG)
|
||||||
{
|
{
|
||||||
/* ...write warning message and show the form again */
|
/* ...write warning message and show the form again */
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_The_date_range_must_be_less_than_or_equal_to_X_days,
|
Ale_ShowAlert (Ale_WARNING,Txt_The_date_range_must_be_less_than_or_equal_to_X_days,
|
||||||
|
|
|
@ -1738,7 +1738,7 @@ void Svy_ReqCreatOrEditSvy (void)
|
||||||
|
|
||||||
static void Svy_SetAllowedScopes (struct Svy_Survey *Svy)
|
static void Svy_SetAllowedScopes (struct Svy_Survey *Svy)
|
||||||
{
|
{
|
||||||
bool ICanEdit = false;
|
Usr_ICan_t ICanEdit = Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/***** Set allowed scopes *****/
|
/***** Set allowed scopes *****/
|
||||||
Gbl.Scope.Allowed = 0;
|
Gbl.Scope.Allowed = 0;
|
||||||
|
@ -1753,7 +1753,7 @@ static void Svy_SetAllowedScopes (struct Svy_Survey *Svy)
|
||||||
if (Svy->Level == Hie_CRS)
|
if (Svy->Level == Hie_CRS)
|
||||||
{
|
{
|
||||||
Gbl.Scope.Allowed = 1 << Hie_CRS;
|
Gbl.Scope.Allowed = 1 << Hie_CRS;
|
||||||
ICanEdit = true;
|
ICanEdit = Usr_I_CAN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1763,7 +1763,7 @@ static void Svy_SetAllowedScopes (struct Svy_Survey *Svy)
|
||||||
if (Svy->Level == Hie_DEG)
|
if (Svy->Level == Hie_DEG)
|
||||||
{
|
{
|
||||||
Gbl.Scope.Allowed = 1 << Hie_DEG;
|
Gbl.Scope.Allowed = 1 << Hie_DEG;
|
||||||
ICanEdit = true;
|
ICanEdit = Usr_I_CAN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Rol_CTR_ADM: // Center admins only can edit center surveys
|
case Rol_CTR_ADM: // Center admins only can edit center surveys
|
||||||
|
@ -1772,7 +1772,7 @@ static void Svy_SetAllowedScopes (struct Svy_Survey *Svy)
|
||||||
if (Svy->Level == Hie_CTR)
|
if (Svy->Level == Hie_CTR)
|
||||||
{
|
{
|
||||||
Gbl.Scope.Allowed = 1 << Hie_CTR;
|
Gbl.Scope.Allowed = 1 << Hie_CTR;
|
||||||
ICanEdit = true;
|
ICanEdit = Usr_I_CAN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Rol_INS_ADM: // Institution admins only can edit institution surveys
|
case Rol_INS_ADM: // Institution admins only can edit institution surveys
|
||||||
|
@ -1781,7 +1781,7 @@ static void Svy_SetAllowedScopes (struct Svy_Survey *Svy)
|
||||||
if (Svy->Level == Hie_INS)
|
if (Svy->Level == Hie_INS)
|
||||||
{
|
{
|
||||||
Gbl.Scope.Allowed = 1 << Hie_INS;
|
Gbl.Scope.Allowed = 1 << Hie_INS;
|
||||||
ICanEdit = true;
|
ICanEdit = Usr_I_CAN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Rol_SYS_ADM:// System admins can edit any survey
|
case Rol_SYS_ADM:// System admins can edit any survey
|
||||||
|
@ -1795,13 +1795,13 @@ static void Svy_SetAllowedScopes (struct Svy_Survey *Svy)
|
||||||
1 << Hie_CTR |
|
1 << Hie_CTR |
|
||||||
1 << Hie_DEG |
|
1 << Hie_DEG |
|
||||||
1 << Hie_CRS;
|
1 << Hie_CRS;
|
||||||
ICanEdit = true;
|
ICanEdit = Usr_I_CAN;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ICanEdit)
|
if (ICanEdit == Usr_I_CAN_NOT)
|
||||||
Err_NoPermissionExit ();
|
Err_NoPermissionExit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2087,27 +2087,29 @@ static void TstPrn_ShowPrintsSummaryRow (Usr_MeOrOther_t MeOrOther,
|
||||||
double TotalScore)
|
double TotalScore)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Visible_tests;
|
extern const char *Txt_Visible_tests;
|
||||||
bool ICanViewTotalScore;
|
Usr_ICan_t ICanViewTotalScore;
|
||||||
|
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
ICanViewTotalScore = MeOrOther == Usr_ME &&
|
ICanViewTotalScore = (MeOrOther == Usr_ME &&
|
||||||
TstVis_IsVisibleTotalScore (TstCfg_GetConfigVisibility ());
|
TstVis_IsVisibleTotalScore (TstCfg_GetConfigVisibility ())) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case Rol_NET:
|
case Rol_NET:
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
case Rol_DEG_ADM:
|
case Rol_DEG_ADM:
|
||||||
case Rol_CTR_ADM:
|
case Rol_CTR_ADM:
|
||||||
case Rol_INS_ADM:
|
case Rol_INS_ADM:
|
||||||
ICanViewTotalScore = MeOrOther == Usr_ME ||
|
ICanViewTotalScore = (MeOrOther == Usr_ME ||
|
||||||
NumPrints;
|
NumPrints) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
ICanViewTotalScore = true;
|
ICanViewTotalScore = Usr_I_CAN;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ICanViewTotalScore = false;
|
ICanViewTotalScore = Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2151,7 +2153,7 @@ static void TstPrn_ShowPrintsSummaryRow (Usr_MeOrOther_t MeOrOther,
|
||||||
HTM_TD_Begin ("class=\"RM DAT_STRONG_%s LINE_TOP LINE_BOTTOM LINE_LEFT %s\"",
|
HTM_TD_Begin ("class=\"RM DAT_STRONG_%s LINE_TOP LINE_BOTTOM LINE_LEFT %s\"",
|
||||||
The_GetSuffix (),
|
The_GetSuffix (),
|
||||||
The_GetColorRows ());
|
The_GetColorRows ());
|
||||||
if (ICanViewTotalScore)
|
if (ICanViewTotalScore == Usr_I_CAN)
|
||||||
{
|
{
|
||||||
HTM_Double2Decimals (TotalScore);
|
HTM_Double2Decimals (TotalScore);
|
||||||
HTM_Txt ("/");
|
HTM_Txt ("/");
|
||||||
|
@ -2163,7 +2165,7 @@ static void TstPrn_ShowPrintsSummaryRow (Usr_MeOrOther_t MeOrOther,
|
||||||
HTM_TD_Begin ("class=\"RM DAT_STRONG_%s LINE_TOP LINE_BOTTOM %s\"",
|
HTM_TD_Begin ("class=\"RM DAT_STRONG_%s LINE_TOP LINE_BOTTOM %s\"",
|
||||||
The_GetSuffix (),
|
The_GetSuffix (),
|
||||||
The_GetColorRows ());
|
The_GetColorRows ());
|
||||||
if (ICanViewTotalScore)
|
if (ICanViewTotalScore == Usr_I_CAN)
|
||||||
HTM_Double2Decimals (NumTotalQsts->All ? TotalScore / (double) NumTotalQsts->All :
|
HTM_Double2Decimals (NumTotalQsts->All ? TotalScore / (double) NumTotalQsts->All :
|
||||||
0.0);
|
0.0);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
@ -2172,7 +2174,7 @@ static void TstPrn_ShowPrintsSummaryRow (Usr_MeOrOther_t MeOrOther,
|
||||||
HTM_TD_Begin ("class=\"RM DAT_STRONG_%s LINE_TOP LINE_BOTTOM LINE_LEFT %s\"",
|
HTM_TD_Begin ("class=\"RM DAT_STRONG_%s LINE_TOP LINE_BOTTOM LINE_LEFT %s\"",
|
||||||
The_GetSuffix (),
|
The_GetSuffix (),
|
||||||
The_GetColorRows ());
|
The_GetColorRows ());
|
||||||
if (ICanViewTotalScore)
|
if (ICanViewTotalScore == Usr_I_CAN)
|
||||||
TstPrn_ComputeAndShowGrade (NumTotalQsts->All,TotalScore,Tst_SCORE_MAX);
|
TstPrn_ComputeAndShowGrade (NumTotalQsts->All,TotalScore,Tst_SCORE_MAX);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
|
|
49
swad_user.c
49
swad_user.c
|
@ -234,8 +234,8 @@ static void Usr_PutLinkToSeeAdmins (void);
|
||||||
static void Usr_PutLinkToSeeGuests (void);
|
static void Usr_PutLinkToSeeGuests (void);
|
||||||
|
|
||||||
static Frm_PutForm_t Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole,
|
static Frm_PutForm_t Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole,
|
||||||
bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]);
|
Usr_ICan_t ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]);
|
||||||
static void Usr_PutOptionsListUsrs (const bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]);
|
static void Usr_PutOptionsListUsrs (const Usr_ICan_t ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]);
|
||||||
static void Usr_ShowOneListUsrsOption (Usr_ListUsrsOption_t ListUsrsAction,
|
static void Usr_ShowOneListUsrsOption (Usr_ListUsrsOption_t ListUsrsAction,
|
||||||
const char *Label);
|
const char *Label);
|
||||||
static Usr_ListUsrsOption_t Usr_GetListUsrsOption (Usr_ListUsrsOption_t DefaultAction);
|
static Usr_ListUsrsOption_t Usr_GetListUsrsOption (Usr_ListUsrsOption_t DefaultAction);
|
||||||
|
@ -2622,23 +2622,23 @@ static void Usr_WriteMainUsrDataExceptUsrID (struct Usr_Data *UsrDat,
|
||||||
|
|
||||||
static void Usr_WriteEmail (struct Usr_Data *UsrDat,const char *BgColor)
|
static void Usr_WriteEmail (struct Usr_Data *UsrDat,const char *BgColor)
|
||||||
{
|
{
|
||||||
bool ShowEmail;
|
Usr_ICan_t ShowEmail;
|
||||||
char MailLink[7 + Cns_MAX_BYTES_EMAIL_ADDRESS + 1]; // mailto:mail_address
|
char MailLink[7 + Cns_MAX_BYTES_EMAIL_ADDRESS + 1]; // mailto:mail_address
|
||||||
|
|
||||||
if (UsrDat->Email[0])
|
if (UsrDat->Email[0])
|
||||||
{
|
{
|
||||||
ShowEmail = Mai_ICanSeeOtherUsrEmail (UsrDat);
|
ShowEmail = Mai_ICanSeeOtherUsrEmail (UsrDat);
|
||||||
if (ShowEmail)
|
if (ShowEmail == Usr_I_CAN)
|
||||||
snprintf (MailLink,sizeof (MailLink),"mailto:%s",UsrDat->Email);
|
snprintf (MailLink,sizeof (MailLink),"mailto:%s",UsrDat->Email);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ShowEmail = false;
|
ShowEmail = Usr_I_CAN_NOT;
|
||||||
Usr_WriteUsrData (BgColor,
|
Usr_WriteUsrData (BgColor,
|
||||||
UsrDat->Email[0] ? (ShowEmail ? UsrDat->Email :
|
UsrDat->Email[0] ? (ShowEmail == Usr_I_CAN ? UsrDat->Email :
|
||||||
"********") :
|
"********") :
|
||||||
" ",
|
" ",
|
||||||
ShowEmail ? MailLink :
|
ShowEmail == Usr_I_CAN ? MailLink :
|
||||||
NULL,
|
NULL,
|
||||||
true,UsrDat->Accepted);
|
true,UsrDat->Accepted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5022,7 +5022,7 @@ void Usr_SeeGuests (void)
|
||||||
extern const char *Hlp_USERS_Guests;
|
extern const char *Hlp_USERS_Guests;
|
||||||
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||||
extern const char *Txt_Scope;
|
extern const char *Txt_Scope;
|
||||||
bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS];
|
Usr_ICan_t ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS];
|
||||||
Frm_PutForm_t PutForm;
|
Frm_PutForm_t PutForm;
|
||||||
|
|
||||||
/***** Contextual menu *****/
|
/***** Contextual menu *****/
|
||||||
|
@ -5142,7 +5142,7 @@ void Usr_SeeStudents (void)
|
||||||
extern const char *Hlp_USERS_Students;
|
extern const char *Hlp_USERS_Students;
|
||||||
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||||
extern const char *Txt_Scope;
|
extern const char *Txt_Scope;
|
||||||
bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS];
|
Usr_ICan_t ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS];
|
||||||
Frm_PutForm_t PutForm;
|
Frm_PutForm_t PutForm;
|
||||||
|
|
||||||
/***** Put contextual links *****/
|
/***** Put contextual links *****/
|
||||||
|
@ -5301,7 +5301,7 @@ void Usr_SeeTeachers (void)
|
||||||
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||||
extern const char *Txt_Scope;
|
extern const char *Txt_Scope;
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS];
|
Usr_ICan_t ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS];
|
||||||
Frm_PutForm_t PutForm;
|
Frm_PutForm_t PutForm;
|
||||||
|
|
||||||
/***** Put contextual links *****/
|
/***** Put contextual links *****/
|
||||||
|
@ -5477,7 +5477,7 @@ void Usr_SeeTeachers (void)
|
||||||
// Returns true if any option is allowed
|
// Returns true if any option is allowed
|
||||||
|
|
||||||
static Frm_PutForm_t Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole,
|
static Frm_PutForm_t Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole,
|
||||||
bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS])
|
Usr_ICan_t ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS])
|
||||||
{
|
{
|
||||||
Usr_ListUsrsOption_t Opt;
|
Usr_ListUsrsOption_t Opt;
|
||||||
|
|
||||||
|
@ -5486,13 +5486,14 @@ static Frm_PutForm_t Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole,
|
||||||
for (Opt = (Usr_ListUsrsOption_t) 1; // Skip unknown option
|
for (Opt = (Usr_ListUsrsOption_t) 1; // Skip unknown option
|
||||||
Opt <= (Usr_ListUsrsOption_t) (Usr_LIST_USRS_NUM_OPTIONS - 1);
|
Opt <= (Usr_ListUsrsOption_t) (Usr_LIST_USRS_NUM_OPTIONS - 1);
|
||||||
Opt++)
|
Opt++)
|
||||||
ICanChooseOption[Opt] = false;
|
ICanChooseOption[Opt] = Usr_I_CAN_NOT;
|
||||||
|
|
||||||
/* Activate some options depending on users' role, on my role, etc. */
|
/* Activate some options depending on users' role, on my role, etc. */
|
||||||
switch (UsrsRole)
|
switch (UsrsRole)
|
||||||
{
|
{
|
||||||
case Rol_GST:
|
case Rol_GST:
|
||||||
ICanChooseOption[Usr_OPTION_RECORDS] = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
ICanChooseOption[Usr_OPTION_RECORDS] = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
ICanChooseOption[Usr_OPTION_RECORDS] =
|
ICanChooseOption[Usr_OPTION_RECORDS] =
|
||||||
|
@ -5502,14 +5503,16 @@ static Frm_PutForm_t Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole,
|
||||||
(Gbl.Usrs.Me.Role.Logged == Rol_STD ||
|
(Gbl.Usrs.Me.Role.Logged == Rol_STD ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM));
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
|
|
||||||
ICanChooseOption[Usr_OPTION_HOMEWORK] =
|
ICanChooseOption[Usr_OPTION_HOMEWORK] =
|
||||||
ICanChooseOption[Usr_OPTION_ATTENDANCE] =
|
ICanChooseOption[Usr_OPTION_ATTENDANCE] =
|
||||||
ICanChooseOption[Usr_OPTION_EMAIL] = (Gbl.Scope.Current == Hie_CRS &&
|
ICanChooseOption[Usr_OPTION_EMAIL] = (Gbl.Scope.Current == Hie_CRS &&
|
||||||
(Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
(Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM));
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
ICanChooseOption[Usr_OPTION_RECORDS] =
|
ICanChooseOption[Usr_OPTION_RECORDS] =
|
||||||
|
@ -5520,11 +5523,13 @@ static Frm_PutForm_t Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole,
|
||||||
(Gbl.Usrs.Me.Role.Logged == Rol_STD ||
|
(Gbl.Usrs.Me.Role.Logged == Rol_STD ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM));
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
ICanChooseOption[Usr_OPTION_HOMEWORK] = (Gbl.Scope.Current == Hie_CRS &&
|
ICanChooseOption[Usr_OPTION_HOMEWORK] = (Gbl.Scope.Current == Hie_CRS &&
|
||||||
(Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
(Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
||||||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM));
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_I_CAN :
|
||||||
|
Usr_I_CAN_NOT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return Frm_DONT_PUT_FORM;
|
return Frm_DONT_PUT_FORM;
|
||||||
|
@ -5534,7 +5539,7 @@ static Frm_PutForm_t Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole,
|
||||||
for (Opt = (Usr_ListUsrsOption_t) 1; // Skip unknown option
|
for (Opt = (Usr_ListUsrsOption_t) 1; // Skip unknown option
|
||||||
Opt <= (Usr_ListUsrsOption_t) (Usr_LIST_USRS_NUM_OPTIONS - 1);
|
Opt <= (Usr_ListUsrsOption_t) (Usr_LIST_USRS_NUM_OPTIONS - 1);
|
||||||
Opt++)
|
Opt++)
|
||||||
if (ICanChooseOption[Opt])
|
if (ICanChooseOption[Opt] == Usr_I_CAN)
|
||||||
return Frm_PUT_FORM;
|
return Frm_PUT_FORM;
|
||||||
|
|
||||||
return Frm_DONT_PUT_FORM;
|
return Frm_DONT_PUT_FORM;
|
||||||
|
@ -5545,7 +5550,7 @@ static Frm_PutForm_t Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole,
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Returns true if at least one action can be shown
|
// Returns true if at least one action can be shown
|
||||||
|
|
||||||
static void Usr_PutOptionsListUsrs (const bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS])
|
static void Usr_PutOptionsListUsrs (const Usr_ICan_t ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS])
|
||||||
{
|
{
|
||||||
extern const char *Txt_View_records;
|
extern const char *Txt_View_records;
|
||||||
extern const char *Txt_View_homework;
|
extern const char *Txt_View_homework;
|
||||||
|
@ -5579,7 +5584,7 @@ static void Usr_PutOptionsListUsrs (const bool ICanChooseOption[Usr_LIST_USRS_NU
|
||||||
for (Opt = (Usr_ListUsrsOption_t) 1; // Skip unknown option
|
for (Opt = (Usr_ListUsrsOption_t) 1; // Skip unknown option
|
||||||
Opt <= (Usr_ListUsrsOption_t) (Usr_LIST_USRS_NUM_OPTIONS - 1);
|
Opt <= (Usr_ListUsrsOption_t) (Usr_LIST_USRS_NUM_OPTIONS - 1);
|
||||||
Opt++)
|
Opt++)
|
||||||
if (ICanChooseOption[Opt])
|
if (ICanChooseOption[Opt] == Usr_I_CAN)
|
||||||
Usr_ShowOneListUsrsOption (Opt,*Label[Opt]);
|
Usr_ShowOneListUsrsOption (Opt,*Label[Opt]);
|
||||||
|
|
||||||
/* End list of options */
|
/* End list of options */
|
||||||
|
|
Loading…
Reference in New Issue