Version 23.76: Apr 19, 2024 Code refactoring related to don't belong/belong.

This commit is contained in:
acanas 2024-04-19 12:00:30 +02:00
parent b785e884ba
commit 9309bf9580
122 changed files with 2066 additions and 1999 deletions

View File

@ -264,7 +264,7 @@ static void API_CopyListUsers (struct soap *soap,
struct swad__getUsersOutput *getUsersOut);
static void API_CopyUsrData (struct soap *soap,
struct swad__user *Usr,struct Usr_Data *UsrDat,
Usr_ICan_t ICanSeeUsrID);
Usr_Can_t ICanSeeUsrID);
static void API_GetListGrpsInAttendanceEventFromDB (struct soap *soap,
long AttCod,char **ListGroups);
@ -1743,7 +1743,7 @@ static void API_CopyListUsers (struct soap *soap,
unsigned NumUsrs;
unsigned NumUsr;
struct Usr_Data UsrDat;
Usr_ICan_t ICanSeeUsrID;
Usr_Can_t ICanSeeUsrID;
/***** Initialize result *****/
getUsersOut->numUsers = 0;
@ -2191,7 +2191,7 @@ int swad__sendMyGroups (struct soap *soap,
static void API_CopyUsrData (struct soap *soap,
struct swad__user *Usr,struct Usr_Data *UsrDat,
Usr_ICan_t ICanSeeUsrID)
Usr_Can_t ICanSeeUsrID)
{
char PhotoURL[Cns_MAX_BYTES_WWW + 1];
const char *FirstID;
@ -2206,7 +2206,7 @@ static void API_CopyUsrData (struct soap *soap,
Str_Copy (Usr->userNickname,UsrDat->Nickname,Length);
/* Copy user's first ID */
if (ICanSeeUsrID == Usr_I_CAN && UsrDat->IDs.List)
if (ICanSeeUsrID == Usr_CAN && UsrDat->IDs.List)
FirstID = UsrDat->IDs.List[0].ID;
else // Hide user's ID
FirstID = "********";
@ -3262,7 +3262,7 @@ int swad__sendMessage (struct soap *soap,
API_CopyUsrData (soap,
&(sendMessageOut->usersArray.__ptr[NumUsr]),
&Gbl.Usrs.Other.UsrDat,
Usr_I_CAN_NOT);
Usr_CAN_NOT);
}
}
}
@ -4394,7 +4394,7 @@ int swad__getMatchStatus (struct soap *soap,
"Requester must be a student in the course");
/***** Can I play this match? *****/
if (Mch_CheckIfICanPlayThisMatchBasedOnGrps (&Match) == Usr_I_CAN_NOT)
if (Mch_CheckIfICanPlayThisMatchBasedOnGrps (&Match) == Usr_CAN_NOT)
return soap_receiver_fault (soap,
"Request forbidden",
"Requester can not join this match");
@ -4697,7 +4697,7 @@ int swad__getDirectoryTree (struct soap *soap,
/* Get directory tree into XML file */
XML_WriteStartFile (XML,"tree",false);
if (Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (Brw_IS_FOLDER,
if (Brw_CheckIfFileOrFolderIsHiddenOrVisible (Brw_IS_FOLDER,
Gbl.FileBrowser.FilFolLnk.Full) == HidVis_VISIBLE)
API_ListDir (XML,1,
Gbl.FileBrowser.Path.RootFolder,
@ -4811,7 +4811,7 @@ static bool API_WriteRowFileBrowser (FILE *XML,unsigned Level,
/***** Is this row hidden or visible? *****/
if (Gbl.FileBrowser.Type == Brw_SHOW_DOC_CRS ||
Gbl.FileBrowser.Type == Brw_SHOW_DOC_GRP)
if (Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (FileType,
if (Brw_CheckIfFileOrFolderIsHiddenOrVisible (FileType,
Gbl.FileBrowser.FilFolLnk.Full) == HidVis_HIDDEN)
return false;
@ -5263,7 +5263,7 @@ int swad__getLastLocation (struct soap *soap,
*/
switch (Roo_DB_CheckIfICanSeeUsrLocation ((long) userCode))
{
case Usr_I_CAN:
case Usr_CAN:
/***** Get list of locations *****/
NumLocs = Roo_DB_GetUsrLastLocation (&mysql_res,(long) userCode);
API_GetLocationData (soap,
@ -5271,7 +5271,7 @@ int swad__getLastLocation (struct soap *soap,
&(getLastLocationOut->checkinTime), // Get check in time
&mysql_res,NumLocs);
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
/* I can not see user's location ==> reset output */
API_ResetLocation (soap, &(getLastLocationOut->location));

View File

@ -308,12 +308,12 @@ static bool ID_CheckIfUsrIDIsValidUsingMinDigits (const char *UsrID,unsigned Min
void ID_WriteUsrIDs (struct Usr_Data *UsrDat,const char *Anchor)
{
unsigned NumID;
Usr_ICan_t ICanSeeUsrID = ID_ICanSeeOtherUsrIDs (UsrDat);
Usr_ICan_t ICanConfirmUsrID = (ICanSeeUsrID == Usr_I_CAN &&
Usr_Can_t ICanSeeUsrID = ID_ICanSeeOtherUsrIDs (UsrDat);
Usr_Can_t ICanConfirmUsrID = (ICanSeeUsrID == Usr_CAN &&
Usr_ItsMe (UsrDat->UsrCod) == Usr_OTHER && // Not me
!Frm_CheckIfInside () && // Not inside another form
Act_GetBrowserTab (Gbl.Action.Act) == Act_1ST_TAB) ? Usr_I_CAN : // Only in main browser tab
Usr_I_CAN_NOT;
Act_GetBrowserTab (Gbl.Action.Act) == Act_1ST_TAB) ? Usr_CAN : // Only in main browser tab
Usr_CAN_NOT;
for (NumID = 0;
NumID < UsrDat->IDs.Num;
@ -330,10 +330,10 @@ void ID_WriteUsrIDs (struct Usr_Data *UsrDat,const char *Anchor)
The_GetSuffix ());
switch (ICanSeeUsrID)
{
case Usr_I_CAN:
case Usr_CAN:
HTM_Txt (UsrDat->IDs.List[NumID].ID);
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
HTM_Txt ("********");
break;
@ -341,7 +341,7 @@ void ID_WriteUsrIDs (struct Usr_Data *UsrDat,const char *Anchor)
HTM_SPAN_End ();
/* Put link to confirm ID? */
if (ICanConfirmUsrID == Usr_I_CAN &&
if (ICanConfirmUsrID == Usr_CAN &&
!UsrDat->IDs.List[NumID].Confirmed)
ID_PutLinkToConfirmID (UsrDat,NumID,Anchor);
}
@ -351,11 +351,11 @@ void ID_WriteUsrIDs (struct Usr_Data *UsrDat,const char *Anchor)
/***************** Check if I can see another user's IDs *********************/
/*****************************************************************************/
Usr_ICan_t ID_ICanSeeOtherUsrIDs (const struct Usr_Data *UsrDat)
Usr_Can_t ID_ICanSeeOtherUsrIDs (const struct Usr_Data *UsrDat)
{
/***** Fast check: It's me? *****/
if (Usr_ItsMe (UsrDat->UsrCod) == Usr_ME)
return Usr_I_CAN;
return Usr_CAN;
/***** Check if I have permission to see another user's IDs *****/
switch (Gbl.Usrs.Me.Role.Logged)
@ -364,12 +364,12 @@ Usr_ICan_t ID_ICanSeeOtherUsrIDs (const struct Usr_Data *UsrDat)
case Rol_TCH:
/* Check 1: I can see the IDs of users who do not exist in database */
if (UsrDat->UsrCod <= 0) // User does not exist (when creating a new user)
return Usr_I_CAN;
return Usr_CAN;
/* Check 2: I can see the IDs of confirmed students */
if (UsrDat->Roles.InCurrentCrs == Rol_STD && // A student
UsrDat->Accepted) // who accepted registration
return Usr_I_CAN;
return Usr_CAN;
/* Check 3: I can see the IDs of users with user's data empty */
// This check is made to not view simultaneously:
@ -380,16 +380,16 @@ Usr_ICan_t ID_ICanSeeOtherUsrIDs (const struct Usr_Data *UsrDat)
!UsrDat->Surname2[0] && // and who has no surname 2 (nobody filled user's surname 2)
!UsrDat->FrstName[0] && // and who has no first name (nobody filled user's first name)
!UsrDat->Email[0]) // and who has no email (nobody filled user's email)
return Usr_I_CAN;
return Usr_CAN;
return Usr_I_CAN_NOT;
return Usr_CAN_NOT;
case Rol_DEG_ADM:
case Rol_CTR_ADM:
case Rol_INS_ADM:
case Rol_SYS_ADM:
return Usr_CheckIfICanEditOtherUsr (UsrDat);
default:
return Usr_I_CAN_NOT;
return Usr_CAN_NOT;
}
}
@ -700,7 +700,7 @@ void ID_RemoveOtherUsrID (void)
if (Usr_GetParOtherUsrCodEncryptedAndGetUsrData ())
switch (Usr_CheckIfICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
{
case Usr_I_CAN:
case Usr_CAN:
/***** Remove user's ID *****/
ID_RemoveUsrID (&Gbl.Usrs.Other.UsrDat,
Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod));
@ -711,7 +711,7 @@ void ID_RemoveOtherUsrID (void)
/***** Show form again *****/
Acc_ShowFormChgOtherUsrAccount ();
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission ();
break;
@ -729,11 +729,11 @@ static void ID_RemoveUsrID (const struct Usr_Data *UsrDat,Usr_MeOrOther_t MeOrOt
extern const char *Txt_ID_X_removed;
extern const char *Txt_You_can_not_delete_this_ID;
char UsrID[ID_MAX_BYTES_USR_ID + 1];
Usr_ICan_t ICanRemove = Usr_I_CAN_NOT;
Usr_Can_t ICanRemove = Usr_CAN_NOT;
switch (Usr_CheckIfICanEditOtherUsr (UsrDat))
{
case Usr_I_CAN:
case Usr_CAN:
/***** Get user's ID from form *****/
Par_GetParText ("UsrID",UsrID,ID_MAX_BYTES_USR_ID);
// Users' IDs are always stored internally in capitals and without leading zeros
@ -745,17 +745,17 @@ static void ID_RemoveUsrID (const struct Usr_Data *UsrDat,Usr_MeOrOther_t MeOrOt
{
case Usr_ME:
// I can remove my ID only if it is not confirmed
ICanRemove = ID_DB_CheckIfConfirmed (UsrDat->UsrCod,UsrID) ? Usr_I_CAN_NOT :
Usr_I_CAN;
ICanRemove = ID_DB_CheckIfConfirmed (UsrDat->UsrCod,UsrID) ? Usr_CAN_NOT :
Usr_CAN;
break;
case Usr_OTHER:
ICanRemove = Usr_I_CAN;
ICanRemove = Usr_CAN;
break;
}
switch (ICanRemove)
{
case Usr_I_CAN:
case Usr_CAN:
/***** Remove one of the user's IDs *****/
ID_DB_RemoveUsrID (UsrDat->UsrCod,UsrID);
@ -763,14 +763,14 @@ static void ID_RemoveUsrID (const struct Usr_Data *UsrDat,Usr_MeOrOther_t MeOrOt
Ale_CreateAlert (Ale_SUCCESS,ID_ID_SECTION_ID,
Txt_ID_X_removed,UsrID);
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
Ale_CreateAlert (Ale_WARNING,ID_ID_SECTION_ID,
Txt_You_can_not_delete_this_ID);
break;
}
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
Ale_CreateAlertUserNotFoundOrYouDoNotHavePermission ();
break;
@ -803,7 +803,7 @@ void ID_ChangeOtherUsrID (void)
if (Usr_GetParOtherUsrCodEncryptedAndGetUsrData ())
switch (Usr_CheckIfICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
{
case Usr_I_CAN:
case Usr_CAN:
/***** Change user's ID *****/
ID_ChangeUsrID (&Gbl.Usrs.Other.UsrDat,
Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod));
@ -814,7 +814,7 @@ void ID_ChangeOtherUsrID (void)
/***** Show form again *****/
Acc_ShowFormChgOtherUsrAccount ();
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission ();
break;
@ -841,7 +841,7 @@ static void ID_ChangeUsrID (const struct Usr_Data *UsrDat,Usr_MeOrOther_t MeOrOt
switch (Usr_CheckIfICanEditOtherUsr (UsrDat))
{
case Usr_I_CAN:
case Usr_CAN:
/***** Get new user's ID from form *****/
Par_GetParText ("NewID",NewID,ID_MAX_BYTES_USR_ID);
// Users' IDs are always stored internally in capitals and without leading zeros
@ -897,7 +897,7 @@ static void ID_ChangeUsrID (const struct Usr_Data *UsrDat,Usr_MeOrOther_t MeOrOt
Txt_The_ID_X_is_not_valid,
NewID);
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
Ale_CreateAlertUserNotFoundOrYouDoNotHavePermission ();
break;
@ -913,7 +913,7 @@ void ID_ConfirmOtherUsrID (void)
extern const char *Txt_ID_X_had_already_been_confirmed;
extern const char *Txt_The_ID_X_has_been_confirmed;
char UsrID[ID_MAX_BYTES_USR_ID + 1];
Usr_ICan_t ICanConfirm;
Usr_Can_t ICanConfirm;
bool Found;
unsigned NumID;
unsigned NumIDFound = 0; // Initialized to avoid warning
@ -922,7 +922,7 @@ void ID_ConfirmOtherUsrID (void)
Gbl.Action.Original = Act_GetActionFromActCod (ParCod_GetPar (ParCod_OrgAct));
/***** Get other user's code from form and get user's data *****/
ICanConfirm = Usr_I_CAN_NOT;
ICanConfirm = Usr_CAN_NOT;
if (Usr_GetParOtherUsrCodEncryptedAndGetUsrData ())
if (Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod) == Usr_OTHER) // Not me
{
@ -932,13 +932,13 @@ void ID_ConfirmOtherUsrID (void)
if (Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs == Rol_STD)
Gbl.Usrs.Other.UsrDat.Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
if (ID_ICanSeeOtherUsrIDs (&Gbl.Usrs.Other.UsrDat) == Usr_I_CAN)
ICanConfirm = Usr_I_CAN;
if (ID_ICanSeeOtherUsrIDs (&Gbl.Usrs.Other.UsrDat) == Usr_CAN)
ICanConfirm = Usr_CAN;
}
switch (ICanConfirm)
{
case Usr_I_CAN:
case Usr_CAN:
/***** Get user's ID from form *****/
Par_GetParText ("UsrID",UsrID,ID_MAX_BYTES_USR_ID);
// Users' IDs are always stored internally in capitals and without leading zeros
@ -977,7 +977,7 @@ void ID_ConfirmOtherUsrID (void)
else // User's ID not found
Ale_CreateAlertUserNotFoundOrYouDoNotHavePermission ();
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
Ale_CreateAlertUserNotFoundOrYouDoNotHavePermission ();
break;

View File

@ -70,7 +70,7 @@ bool ID_CheckIfUsrIDIsValid (const char *UsrID);
bool ID_CheckIfUsrIDSeemsAValidID (const char *UsrID);
void ID_WriteUsrIDs (struct Usr_Data *UsrDat,const char *Anchor);
Usr_ICan_t ID_ICanSeeOtherUsrIDs (const struct Usr_Data *UsrDat);
Usr_Can_t ID_ICanSeeOtherUsrIDs (const struct Usr_Data *UsrDat);
void ID_ShowFormChangeMyID (bool IShouldFillInID);
void ID_ShowFormChangeOtherUsrID (void);

View File

@ -112,7 +112,7 @@ void MFU_GetMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned MaxAc
ActCod = DB_GetNextCode (mysql_res);
if ((Action = Act_GetActionFromActCod (ActCod)) != ActUnk)
if (Act_GetIndexInMenu (Action) >= 0) // MFU actions must be only actions shown on menu (database could contain wrong action numbers)
if (Act_CheckIfICanExecuteAction (Action) == Usr_I_CAN)
if (Act_CheckIfICanExecuteAction (Action) == Usr_CAN)
ListMFUActions->Actions[ListMFUActions->NumActions++] = Action;
}
@ -148,7 +148,7 @@ Act_Action_t MFU_GetMyLastActionInCurrentTab (void)
if (ActCod >= 0 && ActCod <= ActLst_MAX_ACTION_COD)
if ((Action = Act_GetActionFromActCod (ActCod)) >= 0)
if (Act_GetTab (Action) == Gbl.Action.Tab)
if (Act_CheckIfICanExecuteAction (Action) == Usr_I_CAN)
if (Act_CheckIfICanExecuteAction (Action) == Usr_CAN)
{
MoreRecentActionInCurrentTab = Action;
break;

View File

@ -489,7 +489,7 @@ void Acc_ShowFormChgOtherUsrAccount (void)
if (Usr_GetParOtherUsrCodEncryptedAndGetUsrData ())
switch (Usr_CheckIfICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
{
case Usr_I_CAN:
case Usr_CAN:
/***** Get user's nickname and email address
It's necessary because nickname or email could be just updated *****/
Nck_DB_GetNicknameFromUsrCod (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.Nickname);
@ -517,7 +517,7 @@ void Acc_ShowFormChgOtherUsrAccount (void)
/***** End container for this user *****/
HTM_DIV_End ();
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission ();
break;
@ -532,7 +532,7 @@ void Acc_ShowFormChgOtherUsrAccount (void)
void Acc_PutLinkToRemoveMyAccount (__attribute__((unused)) void *Args)
{
if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Me.UsrDat.UsrCod) == Usr_I_CAN)
if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Me.UsrDat.UsrCod) == Usr_CAN)
Lay_PutContextualLinkOnlyIcon (ActReqRemMyAcc,NULL,
Acc_PutParsToRemoveMyAccount,Gbl.Usrs.Me.UsrDat.EnUsrCod,
"trash.svg",Ico_RED);
@ -774,10 +774,10 @@ void Acc_GetUsrCodAndRemUsrGbl (void)
if (Usr_GetParOtherUsrCodEncryptedAndGetUsrData ())
switch (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Other.UsrDat.UsrCod))
{
case Usr_I_CAN:
case Usr_CAN:
Acc_ReqRemAccountOrRemAccount (Acc_REMOVE_USR);
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
Error = true;
break;
@ -820,7 +820,7 @@ void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove)
/******** Check if I can eliminate completely another user's account *********/
/*****************************************************************************/
Usr_ICan_t Acc_CheckIfICanEliminateAccount (long UsrCod)
Usr_Can_t Acc_CheckIfICanEliminateAccount (long UsrCod)
{
Usr_MeOrOther_t MeOrOther = Usr_ItsMe (UsrCod);
@ -830,15 +830,15 @@ Usr_ICan_t Acc_CheckIfICanEliminateAccount (long UsrCod)
{
case Usr_ME:
// A system admin can not eliminate him/herself
return (Gbl.Usrs.Me.Role.Available & (1 << Rol_SYS_ADM)) == 0 ? Usr_I_CAN :
Usr_I_CAN_NOT;
return ((Gbl.Usrs.Me.Role.Available & (1 << Rol_SYS_ADM)) == 0) ? Usr_CAN :
Usr_CAN_NOT;
case Usr_OTHER:
// Only a system admin can eliminate other's account
return Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ? Usr_I_CAN :
Usr_I_CAN_NOT;
return Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ? Usr_CAN :
Usr_CAN_NOT;
}
return Usr_I_CAN_NOT;
return Usr_CAN_NOT;
}
/*****************************************************************************/
@ -1110,7 +1110,7 @@ void Acc_PutIconToChangeUsrAccount (struct Usr_Data *UsrDat)
"at.svg",Ico_BLACK);
break;
case Usr_OTHER:
if (Usr_CheckIfICanEditOtherUsr (UsrDat) == Usr_I_CAN)
if (Usr_CheckIfICanEditOtherUsr (UsrDat) == Usr_CAN)
Lay_PutContextualLinkOnlyIcon (NextAction[UsrDat->Roles.InCurrentCrs],NULL,
Rec_PutParUsrCodEncrypted,NULL,
"at.svg",Ico_BLACK);

View File

@ -62,7 +62,7 @@ void Acc_AfterCreationNewAccount (void);
void Acc_GetUsrCodAndRemUsrGbl (void);
void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove);
Usr_ICan_t Acc_CheckIfICanEliminateAccount (long UsrCod);
Usr_Can_t Acc_CheckIfICanEliminateAccount (long UsrCod);
void Acc_AskIfRemoveMyAccount (void);
void Acc_RemoveMyAccount (void);
void Acc_CompletelyEliminateAccount (struct Usr_Data *UsrDat,

View File

@ -99,12 +99,12 @@ Act_Action_t Act_GetSuperAction (Act_Action_t Action)
/************* Check if I have permission to execute an action ***************/
/*****************************************************************************/
Usr_ICan_t Act_CheckIfICanExecuteAction (Act_Action_t Action)
Usr_Can_t Act_CheckIfICanExecuteAction (Act_Action_t Action)
{
unsigned Permission;
if ((unsigned) Action >= ActLst_NUM_ACTIONS)
return Usr_I_CAN_NOT;
return Usr_CAN_NOT;
switch (Gbl.Hierarchy.Level)
{
@ -124,15 +124,15 @@ Usr_ICan_t Act_CheckIfICanExecuteAction (Act_Action_t Action)
Permission = ActLst_Actions[Action].PermissionDeg;
break;
case Hie_CRS: // Course selected
Permission = Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] ? ActLst_Actions[Action].PermissionCrsIfIBelong :
ActLst_Actions[Action].PermissionCrsIfIDontBelong;
Permission = (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] == Usr_BELONG) ? ActLst_Actions[Action].PermissionCrsIfIBelong :
ActLst_Actions[Action].PermissionCrsIfIDontBelong;
break;
default:
return Usr_I_CAN_NOT;
return Usr_CAN_NOT;
}
return ((Permission & (1 << Gbl.Usrs.Me.Role.Logged)) != 0) ? Usr_I_CAN :
Usr_I_CAN_NOT;
return ((Permission & (1 << Gbl.Usrs.Me.Role.Logged)) != 0) ? Usr_CAN :
Usr_CAN_NOT;
}
/*****************************************************************************/
@ -369,7 +369,7 @@ void Act_AdjustCurrentAction (void)
}
/***** If I belong to current course *****/
if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] == Usr_BELONG)
{
/***** Adjustment 6:
-------------

View File

@ -106,7 +106,7 @@ long Act_GetActCod (Act_Action_t Action);
signed int Act_GetIndexInMenu (Act_Action_t Action);
Tab_Tab_t Act_GetTab (Act_Action_t Action);
Act_Action_t Act_GetSuperAction (Act_Action_t Action);
Usr_ICan_t Act_CheckIfICanExecuteAction (Act_Action_t Action);
Usr_Can_t Act_CheckIfICanExecuteAction (Act_Action_t Action);
Act_Content_t Act_GetContentType (Act_Action_t Action);
Act_BrowserTab_t Act_GetBrowserTab (Act_Action_t Action);
void (*Act_GetFunctionPriori (Act_Action_t Action)) (void);

View File

@ -56,16 +56,16 @@ static void Adm_EffectivelyRemAdm (struct Usr_Data *UsrDat,Hie_Level_t Level);
/**************** Check if I can admin another user's account ****************/
/*****************************************************************************/
Usr_ICan_t Adm_CheckIfICanAdminOtherUsrs (void)
Usr_Can_t Adm_CheckIfICanAdminOtherUsrs (void)
{
static Usr_ICan_t Adm_ICanAdminOtherUsrs[Rol_NUM_ROLES] =
static Usr_Can_t Adm_ICanAdminOtherUsrs[Rol_NUM_ROLES] =
{
/* Users who can admin */
[Rol_TCH ] = Usr_I_CAN,
[Rol_DEG_ADM] = Usr_I_CAN,
[Rol_CTR_ADM] = Usr_I_CAN,
[Rol_INS_ADM] = Usr_I_CAN,
[Rol_SYS_ADM] = Usr_I_CAN,
[Rol_TCH ] = Usr_CAN,
[Rol_DEG_ADM] = Usr_CAN,
[Rol_CTR_ADM] = Usr_CAN,
[Rol_INS_ADM] = Usr_CAN,
[Rol_SYS_ADM] = Usr_CAN,
};
return Adm_ICanAdminOtherUsrs[Gbl.Usrs.Me.Role.Logged];
@ -90,7 +90,7 @@ void Adm_ReqAddAdm (Hie_Level_t Level)
[Hie_DEG] = ActNewAdmDeg,
[Hie_CRS] = ActUnk,
};
Usr_ICan_t ICanRegister;
Usr_Can_t ICanRegister;
if (Gbl.Hierarchy.Node[Level].HieCod > 0)
{
@ -100,11 +100,11 @@ void Adm_ReqAddAdm (Hie_Level_t Level)
/* Check if I am allowed to register user as administrator in institution/center/degree */
ICanRegister = ((Level == Hie_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) ||
(Level == Hie_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) ||
(Level == Hie_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_I_CAN :
Usr_I_CAN_NOT;
(Level == Hie_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_CAN :
Usr_CAN_NOT;
switch (ICanRegister)
{
case Usr_I_CAN:
case Usr_CAN:
if (Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Level)) // User is already an administrator of current institution/center/degree
{
Ale_ShowAlert (Ale_INFO,Txt_THE_USER_X_is_already_an_administrator_of_Y,
@ -128,7 +128,7 @@ void Adm_ReqAddAdm (Hie_Level_t Level)
Btn_CREATE_BUTTON,Txt_Register_user_IN_A_COURSE_OR_DEGREE);
}
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission ();
break;
@ -190,7 +190,7 @@ void Adm_GetAdmsLst (Hie_Level_t Level)
static void Adm_AddAdm (Hie_Level_t Level)
{
Usr_ICan_t ICanRegister;
Usr_Can_t ICanRegister;
if (Gbl.Hierarchy.Node[Level].HieCod > 0)
{
@ -200,18 +200,18 @@ static void Adm_AddAdm (Hie_Level_t Level)
/* Check if I am allowed to register user as administrator in institution/center/degree */
ICanRegister = ((Level == Hie_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) ||
(Level == Hie_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) ||
(Level == Hie_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_I_CAN :
Usr_I_CAN_NOT;
(Level == Hie_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_CAN :
Usr_CAN_NOT;
switch (ICanRegister)
{
case Usr_I_CAN:
case Usr_CAN:
/***** Register administrator in current institution/center/degree in database *****/
Adm_RegisterAdmin (&Gbl.Usrs.Other.UsrDat,Level);
/***** Show user's record *****/
Rec_ShowSharedRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat);
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission ();
break;
@ -308,7 +308,7 @@ static void Adm_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,
{
extern const char *Txt_THE_USER_X_is_not_an_administrator_of_Y;
Usr_MeOrOther_t MeOrOther;
Usr_ICan_t ICanRemove;
Usr_Can_t ICanRemove;
if (Gbl.Hierarchy.Node[Level].HieCod > 0)
{
@ -320,11 +320,11 @@ static void Adm_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,
ICanRemove = (MeOrOther == Usr_ME ||
(Level == Hie_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) ||
(Level == Hie_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) ||
(Level == Hie_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_I_CAN :
Usr_I_CAN_NOT;
(Level == Hie_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_CAN :
Usr_CAN_NOT;
switch (ICanRemove)
{
case Usr_I_CAN:
case Usr_CAN:
/* Check if the other user is an admin of the current institution/center/degree */
if (Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Level))
{ // The other user is an administrator of current institution/center/degree ==> ask for removing or remove her/him
@ -343,7 +343,7 @@ static void Adm_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,
Gbl.Usrs.Other.UsrDat.FullName,
Gbl.Hierarchy.Node[Level].FullName);
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission ();
break;

View File

@ -35,7 +35,7 @@
/****************************** Public prototypes ****************************/
/*****************************************************************************/
Usr_ICan_t Adm_CheckIfICanAdminOtherUsrs (void);
Usr_Can_t Adm_CheckIfICanAdminOtherUsrs (void);
void Adm_ReqAddAdm (Hie_Level_t Level);

View File

@ -125,23 +125,23 @@ static void Agd_HideUnhideEvent (HidVis_HiddenOrVisible_t HiddenOrVisible);
/******************* Check if I can view a user's agenda *********************/
/*****************************************************************************/
Usr_ICan_t Agd_CheckIfICanViewUsrAgenda (struct Usr_Data *UsrDat)
Usr_Can_t Agd_CheckIfICanViewUsrAgenda (struct Usr_Data *UsrDat)
{
/***** 1. Fast check: Am I logged? *****/
if (!Gbl.Usrs.Me.Logged)
return Usr_I_CAN_NOT;
return Usr_CAN_NOT;
/***** 2. Fast check: It's me? *****/
if (Usr_ItsMe (UsrDat->UsrCod) == Usr_ME)
return Usr_I_CAN;
return Usr_CAN;
/***** 3. Fast check: Am I logged as system admin? *****/
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
return Usr_I_CAN;
return Usr_CAN;
/***** 4. Slow check: Get if user shares any course with me from database *****/
return Enr_CheckIfUsrSharesAnyOfMyCrs (UsrDat) ? Usr_I_CAN :
Usr_I_CAN_NOT;
return Enr_CheckIfUsrSharesAnyOfMyCrs (UsrDat) ? Usr_CAN :
Usr_CAN_NOT;
}
/*****************************************************************************/
@ -410,7 +410,7 @@ void Agd_ShowUsrAgenda (void)
if (Usr_GetParOtherUsrCodEncryptedAndGetUsrData ())
switch (Agd_CheckIfICanViewUsrAgenda (&Gbl.Usrs.Other.UsrDat))
{
case Usr_I_CAN:
case Usr_CAN:
/***** Reset agenda context *****/
Agd_ResetAgenda (&Agenda);
@ -432,7 +432,7 @@ void Agd_ShowUsrAgenda (void)
/***** End box *****/
Box_BoxEnd ();
break;
case Usr_I_CAN_NOT:
case Usr_CAN_NOT:
default:
Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission ();
break;
@ -739,18 +739,18 @@ static void Agd_PutIconsOtherPublicAgenda (void *EncryptedUsrCod)
{
/***** Button to view user's public profile *****/
if (Pri_CheckIfICanView (Gbl.Usrs.Other.UsrDat.BaPrfVisibility,
&Gbl.Usrs.Other.UsrDat) == Usr_I_CAN)
&Gbl.Usrs.Other.UsrDat) == Usr_CAN)
Lay_PutContextualLinkOnlyIcon (ActSeeOthPubPrf,NULL,
Usr_PutParOtherUsrCodEncrypted,EncryptedUsrCod,
"user.svg",Ico_BLACK);
/***** Button to view user's record card *****/
if (Usr_CheckIfICanViewRecordStd (&Gbl.Usrs.Other.UsrDat) == Usr_I_CAN)
if (Usr_CheckIfICanViewRecordStd (&Gbl.Usrs.Other.UsrDat) == Usr_CAN)
/* View student's records: common record card and course record card */
Lay_PutContextualLinkOnlyIcon (ActSeeRecOneStd,NULL,
Usr_PutParOtherUsrCodEncrypted,EncryptedUsrCod,
"address-card.svg",Ico_BLACK);
else if (Usr_CheckIfICanViewRecordTch (&Gbl.Usrs.Other.UsrDat) == Usr_I_CAN)
else if (Usr_CheckIfICanViewRecordTch (&Gbl.Usrs.Other.UsrDat) == Usr_CAN)
Lay_PutContextualLinkOnlyIcon (ActSeeRecOneTch,NULL,
Usr_PutParOtherUsrCodEncrypted,EncryptedUsrCod,
"address-card.svg",Ico_BLACK);

View File

@ -101,7 +101,7 @@ typedef enum
/***************************** Public prototypes *****************************/
/*****************************************************************************/
Usr_ICan_t Agd_CheckIfICanViewUsrAgenda (struct Usr_Data *UsrDat);
Usr_Can_t Agd_CheckIfICanViewUsrAgenda (struct Usr_Data *UsrDat);
void Agd_PutFormLogInToShowUsrAgenda (void);
void Agd_PutParAgd (void);

View File

@ -79,7 +79,7 @@ extern struct Globals Gbl;
static void Asg_PutHead (struct Asg_Assignments *Assignments,
Asg_OneOrMultiple_t OneOrMultiple,
Vie_ViewType_t ViewType);
static Usr_ICan_t Asg_CheckIfICanCreateAssignments (void);
static Usr_Can_t Asg_CheckIfICanCreateAssignments (void);
static void Asg_PutIconsListAssignments (void *Assignments);
static void Asg_PutIconToCreateNewAsg (void *Assignments);
static void Asg_ParsWhichGroupsToShow (void *Assignments);
@ -106,7 +106,7 @@ static void Asg_CreateAssignment (struct Asg_Assignment *Asg,const char *Txt);
static void Asg_UpdateAssignment (struct Asg_Assignment *Asg,const char *Txt);
static void Asg_CreateGroups (long AsgCod);
static void Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (struct Asg_Assignment *Asg);
static bool Asg_CheckIfIBelongToCrsOrGrpsThisAssignment (long AsgCod);
static Usr_Can_t Asg_CheckIfICanDoAsgBasedOnGroups (long AsgCod);
/*****************************************************************************/
/*************************** Reset assignments *******************************/
@ -118,8 +118,8 @@ void Asg_ResetAssignments (struct Asg_Assignments *Assignments)
Assignments->Num = 0;
Assignments->LstAsgCods = NULL;
Assignments->SelectedOrder = Asg_ORDER_DEFAULT;
// Assignments->AsgCod = -1L; // Used as parameter in contextual links
Assignments->CurrentPage = 0;
Assignments->Asg.AsgCod = -1L; // Used as parameter in contextual links
Asg_ResetAssignment (&Assignments->Asg);
}
@ -287,11 +287,11 @@ static void Asg_PutHead (struct Asg_Assignments *Assignments,
/******************** Check if I can create assignments **********************/
/*****************************************************************************/
static Usr_ICan_t Asg_CheckIfICanCreateAssignments (void)
static Usr_Can_t Asg_CheckIfICanCreateAssignments (void)
{
return (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Usr_I_CAN :
Usr_I_CAN_NOT;
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Usr_CAN :
Usr_CAN_NOT;
}
/*****************************************************************************/
@ -303,11 +303,11 @@ static void Asg_PutIconsListAssignments (void *Assignments)
/***** Put icon to create a new assignment *****/
if (Assignments)
{
if (Asg_CheckIfICanCreateAssignments () == Usr_I_CAN)
if (Asg_CheckIfICanCreateAssignments () == Usr_CAN)
Asg_PutIconToCreateNewAsg (Assignments);
/***** Link to get resource link *****/
if (Rsc_CheckIfICanGetLink () == Usr_I_CAN)
if (Rsc_CheckIfICanGetLink () == Usr_CAN)
{
((struct Asg_Assignments *) Assignments)->Asg.AsgCod = -1L;
Ico_PutContextualIconToGetLink (ActReqLnkAsg,NULL,
@ -657,7 +657,7 @@ static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,
Act_Action_t NextAction;
bool ICanSendFiles = Asg->HiddenOrVisible == HidVis_VISIBLE && // It's visible (not hidden)
Asg->ClosedOrOpen == CloOpe_OPEN && // It's open (inside dates)
Asg->IBelongToCrsOrGrps; // I belong to course or groups
Asg->ICanDo == Usr_CAN; // I can do (I belong to course/group)
/***** Folder icon *****/
if (ViewType == Vie_VIEW && // Not print view
@ -766,7 +766,7 @@ static void Asg_PutIconsToRemEditOneAsg (struct Asg_Assignments *Assignments,
Asg_PutPars,Assignments);
/***** Link to get resource link *****/
if (Rsc_CheckIfICanGetLink () == Usr_I_CAN)
if (Rsc_CheckIfICanGetLink () == Usr_CAN)
Ico_PutContextualIconToGetLink (ActReqLnkAsg,NULL,
Asg_PutPars,Assignments);
/* falls through */
@ -938,7 +938,7 @@ static void Asg_GetAssignmentDataFromRow (MYSQL_RES **mysql_res,
Asg->SendWork = (Asg->Folder[0] != '\0');
/* Can I do this assignment? */
Asg->IBelongToCrsOrGrps = Asg_CheckIfIBelongToCrsOrGrpsThisAssignment (Asg->AsgCod);
Asg->ICanDo = Asg_CheckIfICanDoAsgBasedOnGroups (Asg->AsgCod);
}
/***** Free structure that stores the query result *****/
@ -953,16 +953,15 @@ static void Asg_ResetAssignment (struct Asg_Assignment *Asg)
{
if (Asg->AsgCod <= 0) // If > 0 ==> keep value
Asg->AsgCod = -1L;
Asg->AsgCod = -1L;
Asg->HiddenOrVisible = HidVis_VISIBLE;
Asg->UsrCod = -1L;
Asg->HiddenOrVisible = HidVis_VISIBLE;
Asg->UsrCod = -1L;
Asg->TimeUTC[Dat_STR_TIME] =
Asg->TimeUTC[Dat_END_TIME] = (time_t) 0;
Asg->ClosedOrOpen = CloOpe_CLOSED;
Asg->Title[0] = '\0';
Asg->SendWork = Asg_DO_NOT_SEND_WORK;
Asg->Folder[0] = '\0';
Asg->IBelongToCrsOrGrps = false;
Asg->ClosedOrOpen = CloOpe_CLOSED;
Asg->Title[0] = '\0';
Asg->SendWork = Asg_DONT_SEND_WORK;
Asg->Folder[0] = '\0';
Asg->ICanDo = Usr_CAN_NOT;
}
/*****************************************************************************/
@ -1178,14 +1177,14 @@ void Asg_ReqCreatOrEditAsg (void)
if (ItsANewAssignment)
{
/* Initialize to empty assignment */
Assignments.Asg.AsgCod = -1L;
Assignments.Asg.AsgCod = -1L;
Assignments.Asg.TimeUTC[Dat_STR_TIME] = Dat_GetStartExecutionTimeUTC ();
Assignments.Asg.TimeUTC[Dat_END_TIME] = Assignments.Asg.TimeUTC[Dat_STR_TIME] + (2 * 60 * 60); // +2 hours
Assignments.Asg.ClosedOrOpen = CloOpe_OPEN;
Assignments.Asg.Title[0] = '\0';
Assignments.Asg.SendWork = Asg_DO_NOT_SEND_WORK;
Assignments.Asg.Folder[0] = '\0';
Assignments.Asg.IBelongToCrsOrGrps = false;
Assignments.Asg.ClosedOrOpen = CloOpe_OPEN;
Assignments.Asg.Title[0] = '\0';
Assignments.Asg.SendWork = Asg_DONT_SEND_WORK;
Assignments.Asg.Folder[0] = '\0';
Assignments.Asg.ICanDo = Usr_CAN_NOT;
}
else
{
@ -1403,7 +1402,7 @@ void Asg_ReceiveAssignment (void)
/***** Get folder name where to send works of the assignment *****/
Par_GetParText ("Folder",Assignments.Asg.Folder,Brw_MAX_BYTES_FOLDER);
Assignments.Asg.SendWork = (Assignments.Asg.Folder[0]) ? Asg_SEND_WORK :
Asg_DO_NOT_SEND_WORK;
Asg_DONT_SEND_WORK;
/***** Get assignment text *****/
Par_GetParHTML ("Txt",Description,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
@ -1626,10 +1625,10 @@ void Asg_RemoveCrsAssignments (long CrsCod)
}
/*****************************************************************************/
/********* Check if I belong to any of the groups of an assignment ***********/
/*********************** Check if I can do an assignment *********************/
/*****************************************************************************/
static bool Asg_CheckIfIBelongToCrsOrGrpsThisAssignment (long AsgCod)
static Usr_Can_t Asg_CheckIfICanDoAsgBasedOnGroups (long AsgCod)
{
switch (Gbl.Usrs.Me.Role.Logged)
{
@ -1638,11 +1637,11 @@ static bool Asg_CheckIfIBelongToCrsOrGrpsThisAssignment (long AsgCod)
case Rol_TCH:
// Students and teachers can do assignments depending on groups
/***** Get if I can do an assignment from database *****/
return (Asg_DB_CheckIfICanDoAssignment (AsgCod) == Usr_I_CAN);
return Asg_DB_CheckIfICanDoAsgBasedOnGroups (AsgCod);
case Rol_SYS_ADM:
return true;
return Usr_CAN;
default:
return false;
return Usr_CAN_NOT;
}
}
@ -1704,26 +1703,26 @@ void Asg_WriteDatesAssignment (const struct Asg_Assignment *Asg)
/* Check if I have permission to create a file or folder into an assignment **/
/*****************************************************************************/
Usr_ICan_t Asg_CheckIfICanCreateIntoAssigment (const struct Asg_Assignment *Asg)
Usr_Can_t Asg_CheckIfICanCreateIntoAssigment (const struct Asg_Assignment *Asg)
{
static Usr_ICan_t CloOpe_ICanCreate[CloOpe_NUM_CLOSED_OPEN] =
static Usr_Can_t CloOpe_ICanCreate[CloOpe_NUM_CLOSED_OPEN] =
{
[CloOpe_CLOSED] = Usr_I_CAN_NOT,
[CloOpe_OPEN ] = Usr_I_CAN,
[CloOpe_CLOSED] = Usr_CAN_NOT,
[CloOpe_OPEN ] = Usr_CAN,
};
/***** Trivial check 1: assignment is valid *****/
if (Asg->AsgCod <= 0)
return Usr_I_CAN_NOT;
return Usr_CAN_NOT;
/***** Check 2: Do not create anything in hidden assigments *****/
if (Asg->HiddenOrVisible == HidVis_HIDDEN)
return Usr_I_CAN_NOT;
return Usr_CAN_NOT;
/***** Check 3: If I do not belong to course / groups of this assignment,
I can not create anything inside this assignment *****/
if (!Asg->IBelongToCrsOrGrps)
return Usr_I_CAN_NOT;
if (Asg->ICanDo == Usr_CAN_NOT)
return Usr_CAN_NOT;
/***** Check 4: Depending on my role in this course... *****/
switch (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs)
@ -1733,9 +1732,9 @@ Usr_ICan_t Asg_CheckIfICanCreateIntoAssigment (const struct Asg_Assignment *Asg)
// ...can create only inside open assignments
return CloOpe_ICanCreate[Asg->ClosedOrOpen];
case Rol_TCH: // Teachers...
return Usr_I_CAN; // ...can create inside any assignment
return Usr_CAN; // ...can create inside any assignment
default:
return Usr_I_CAN_NOT;
return Usr_CAN_NOT;
}
}

View File

@ -42,8 +42,8 @@
#define Asg_NUM_TYPES_SEND_WORK 2
typedef enum
{
Asg_DO_NOT_SEND_WORK = 0,
Asg_SEND_WORK = 1,
Asg_DONT_SEND_WORK = 0,
Asg_SEND_WORK = 1,
} Asg_SendWork_t;
struct Asg_Assignment
@ -56,10 +56,10 @@ struct Asg_Assignment
char Title[Asg_MAX_BYTES_ASSIGNMENT_TITLE + 1];
Asg_SendWork_t SendWork;
char Folder[Brw_MAX_BYTES_FOLDER + 1];
bool IBelongToCrsOrGrps; // I can do this assignment
// (it is associated to no groups
// or, if associated to groups,
// I belong to any of the groups)
Usr_Can_t ICanDo; // I can do this assignment
// (it is associated to no groups
// or, if associated to groups,
// I belong to any of the groups)
};
struct Asg_Assignments
@ -106,7 +106,7 @@ void Asg_ReceiveAssignment (void);
void Asg_RemoveCrsAssignments (long CrsCod);
void Asg_WriteDatesAssignment (const struct Asg_Assignment *Asg);
Usr_ICan_t Asg_CheckIfICanCreateIntoAssigment (const struct Asg_Assignment *Asg);
Usr_Can_t Asg_CheckIfICanCreateIntoAssigment (const struct Asg_Assignment *Asg);
void Asg_SetFolder (struct Asg_Assignment *Asg,unsigned Level);
unsigned Asg_GetNumAssignments (Hie_Level_t Level,unsigned *NumNotif);

View File

@ -331,7 +331,7 @@ void Asg_DB_RemoveAssignment (long AsgCod)
/********************* Check if I can do an assignment ***********************/
/*****************************************************************************/
Usr_ICan_t Asg_DB_CheckIfICanDoAssignment (long AsgCod)
Usr_Can_t Asg_DB_CheckIfICanDoAsgBasedOnGroups (long AsgCod)
{
// Students and teachers can do assignments depending on groups
return
@ -355,8 +355,8 @@ Usr_ICan_t Asg_DB_CheckIfICanDoAssignment (long AsgCod)
" AND asg_groups.GrpCod=grp_users.GrpCod)"
"))",
AsgCod,
Gbl.Usrs.Me.UsrDat.UsrCod) ? Usr_I_CAN :
Usr_I_CAN_NOT;
Gbl.Usrs.Me.UsrDat.UsrCod) ? Usr_CAN :
Usr_CAN_NOT;
}
/*****************************************************************************/

View File

@ -59,7 +59,7 @@ void Asg_DB_HideOrUnhideAssignment (long AsgCod,
void Asg_DB_RemoveAssignment (long AsgCod);
Usr_ICan_t Asg_DB_CheckIfICanDoAssignment (long AsgCod);
Usr_Can_t Asg_DB_CheckIfICanDoAsgBasedOnGroups (long AsgCod);
unsigned Asg_DB_GetGrps (MYSQL_RES **mysql_res,long AsgCod);
void Asg_DB_CreateGroup (long AsgCod,long GrpCod);

View File

@ -338,15 +338,15 @@ static void Att_ParsWhichGroupsToShow (void *Events)
static void Att_PutIconsInListOfEvents (void *Events)
{
Usr_ICan_t ICanEdit;
Usr_Can_t ICanEdit;
if (Events)
{
/***** Put icon to create a new attendance event *****/
ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Usr_I_CAN :
Usr_I_CAN_NOT;
if (ICanEdit == Usr_I_CAN)
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Usr_CAN :
Usr_CAN_NOT;
if (ICanEdit == Usr_CAN)
Att_PutIconToCreateNewEvent ((struct Att_Events *) Events);
/***** Put icon to show attendance list *****/
@ -372,7 +372,7 @@ static void Att_PutIconsInListOfEvents (void *Events)
Usr_PutParMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod);
/***** Put icon to get resource link *****/
if (Rsc_CheckIfICanGetLink () == Usr_I_CAN)
if (Rsc_CheckIfICanGetLink () == Usr_CAN)
Ico_PutContextualIconToGetLink (ActReqLnkAtt,NULL,
Att_PutPars,Events);
}
@ -576,7 +576,7 @@ static void Att_PutFormsToRemEditOneEvent (struct Att_Events *Events,
[HidVis_VISIBLE] = ActHidAtt, // Visible ==> action to hide
};
if (Att_CheckIfICanEditEvents () == Usr_I_CAN)
if (Att_CheckIfICanEditEvents () == Usr_CAN)
{
/***** Icon to remove attendance event *****/
Ico_PutContextualIconToRemove (ActReqRemAtt,NULL,
@ -592,7 +592,7 @@ static void Att_PutFormsToRemEditOneEvent (struct Att_Events *Events,
}
/***** Icon to get resource link *****/
if (Rsc_CheckIfICanGetLink () == Usr_I_CAN)
if (Rsc_CheckIfICanGetLink () == Usr_CAN)
Ico_PutContextualIconToGetLink (ActReqLnkAtt,NULL,Att_PutPars,Events);
}
@ -600,12 +600,12 @@ static void Att_PutFormsToRemEditOneEvent (struct Att_Events *Events,
/******************* Check if I can edit calls for exams *********************/
/*****************************************************************************/
Usr_ICan_t Att_CheckIfICanEditEvents (void)
Usr_Can_t Att_CheckIfICanEditEvents (void)
{
static Usr_ICan_t ICanEditAttEvents[Rol_NUM_ROLES] =
static Usr_Can_t ICanEditAttEvents[Rol_NUM_ROLES] =
{
[Rol_TCH ] = Usr_I_CAN,
[Rol_SYS_ADM] = Usr_I_CAN,
[Rol_TCH ] = Usr_CAN,
[Rol_SYS_ADM] = Usr_CAN,
};
return ICanEditAttEvents[Gbl.Usrs.Me.Role.Logged];
@ -1652,9 +1652,9 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
bool Present;
char CommentStd[Cns_MAX_BYTES_TEXT + 1];
char CommentTch[Cns_MAX_BYTES_TEXT + 1];
Usr_ICan_t ICanChangeStdAttendance;
Usr_ICan_t ICanEditStdComment;
Usr_ICan_t ICanEditTchComment;
Usr_Can_t ICanChangeStdAttendance;
Usr_Can_t ICanEditStdComment;
Usr_Can_t ICanEditTchComment;
/***** Set who can edit *****/
switch (Gbl.Usrs.Me.Role.Logged)
@ -1663,25 +1663,25 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
// A student can see only her/his attendance
if (Usr_ItsMe (UsrDat->UsrCod) == Usr_OTHER)
Err_ShowErrorAndExit ("Wrong call.");
ICanChangeStdAttendance = Usr_I_CAN_NOT;
ICanEditStdComment = (Event->ClosedOrOpen == CloOpe_OPEN) ? Usr_I_CAN : // Attendance event is open
Usr_I_CAN_NOT;
ICanEditTchComment = Usr_I_CAN_NOT;
ICanChangeStdAttendance = Usr_CAN_NOT;
ICanEditStdComment = (Event->ClosedOrOpen == CloOpe_OPEN) ? Usr_CAN : // Attendance event is open
Usr_CAN_NOT;
ICanEditTchComment = Usr_CAN_NOT;
break;
case Rol_TCH:
ICanChangeStdAttendance = Usr_I_CAN;
ICanEditStdComment = Usr_I_CAN_NOT;
ICanEditTchComment = Usr_I_CAN;
ICanChangeStdAttendance = Usr_CAN;
ICanEditStdComment = Usr_CAN_NOT;
ICanEditTchComment = Usr_CAN;
break;
case Rol_SYS_ADM:
ICanChangeStdAttendance = Usr_I_CAN;
ICanEditStdComment = Usr_I_CAN_NOT;
ICanEditTchComment = Usr_I_CAN_NOT;
ICanChangeStdAttendance = Usr_CAN;
ICanEditStdComment = Usr_CAN_NOT;
ICanEditTchComment = Usr_CAN_NOT;
break;
default:
ICanChangeStdAttendance = Usr_I_CAN_NOT;
ICanEditStdComment = Usr_I_CAN_NOT;
ICanEditTchComment = Usr_I_CAN_NOT;
ICanChangeStdAttendance = Usr_CAN_NOT;
ICanEditStdComment = Usr_CAN_NOT;
ICanEditTchComment = Usr_CAN_NOT;
break;
}
@ -1704,7 +1704,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
"id=\"Std%u\" value=\"%s\"%s%s",
NumUsr,UsrDat->EnUsrCod,
Present ? " checked=\"checked\"" : "",
(ICanChangeStdAttendance == Usr_I_CAN) ? "" :
(ICanChangeStdAttendance == Usr_CAN) ? "" :
" disabled=\"disabled\"");
HTM_TD_End ();
@ -1755,7 +1755,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
The_GetColorRows ());
switch (ICanEditStdComment)
{
case Usr_I_CAN: // Show with form
case Usr_CAN: // Show with form
HTM_TEXTAREA_Begin ("name=\"CommentStd%s\" cols=\"40\" rows=\"3\""
" class=\"INPUT_%s\"",
UsrDat->EnUsrCod,
@ -1763,7 +1763,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
HTM_Txt (CommentStd);
HTM_TEXTAREA_End ();
break;
case Usr_I_CAN_NOT: // Show without form
case Usr_CAN_NOT: // Show without form
default:
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
CommentStd,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES);
@ -1780,7 +1780,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
The_GetColorRows ());
switch (ICanEditTchComment)
{
case Usr_I_CAN: // Show with form
case Usr_CAN: // Show with form
HTM_TEXTAREA_Begin ("name=\"CommentTch%s\" cols=\"40\" rows=\"3\""
" class=\"INPUT_%s\"",
UsrDat->EnUsrCod,
@ -1788,7 +1788,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
HTM_Txt (CommentTch);
HTM_TEXTAREA_End ();
break;
case Usr_I_CAN_NOT: // Show without form
case Usr_CAN_NOT: // Show without form
default:
if (Event->CommentTchVisible)
{
@ -2775,7 +2775,7 @@ static void Att_ListUsrsAttendanceTable (struct Att_Events *Events,
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat, // Get from the database the data of the student
Usr_DONT_GET_PREFS,
Usr_DONT_GET_ROLE_IN_CRS))
if (Usr_CheckIfICanViewAtt (&UsrDat) == Usr_I_CAN)
if (Usr_CheckIfICanViewAtt (&UsrDat) == Usr_CAN)
{
UsrDat.Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
Att_WriteRowUsrSeveralAttEvents (Events,NumUsr,&UsrDat);
@ -3010,7 +3010,7 @@ static void Att_ListStdsWithAttEventsDetails (struct Att_Events *Events,
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat, // Get from the database the data of the student
<