mirror of https://github.com/acanas/swad-core.git
Version 23.72.1: Apr 01, 2024 New type Usr_ICan_t.
This commit is contained in:
parent
665eb5e4ce
commit
7c794da888
12
swad_API.c
12
swad_API.c
|
@ -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,
|
||||
bool UsrIDIsVisible);
|
||||
Usr_ICan_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;
|
||||
bool ICanSeeUsrID;
|
||||
Usr_ICan_t ICanSeeUsrID;
|
||||
|
||||
/***** Initialize result *****/
|
||||
getUsersOut->numUsers = 0;
|
||||
|
@ -1772,7 +1772,7 @@ static void API_CopyListUsers (struct soap *soap,
|
|||
|
||||
/* Get list of user's IDs */
|
||||
ID_GetListIDsFromUsrCod (&UsrDat);
|
||||
ICanSeeUsrID = (ID_ICanSeeOtherUsrIDs (&UsrDat) == Usr_I_CAN);
|
||||
ICanSeeUsrID = ID_ICanSeeOtherUsrIDs (&UsrDat);
|
||||
|
||||
/* Get nickname */
|
||||
Nck_DB_GetNicknameFromUsrCod (UsrDat.UsrCod,UsrDat.Nickname);
|
||||
|
@ -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,
|
||||
bool UsrIDIsVisible)
|
||||
Usr_ICan_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 (UsrIDIsVisible && UsrDat->IDs.List)
|
||||
if (ICanSeeUsrID == Usr_I_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,
|
||||
false);
|
||||
Usr_I_CAN_NOT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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_CheckIfIHavePermissionToExecuteAction (Action))
|
||||
if (Act_CheckIfICanExecuteAction (Action) == Usr_I_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_CheckIfIHavePermissionToExecuteAction (Action))
|
||||
if (Act_CheckIfICanExecuteAction (Action) == Usr_I_CAN)
|
||||
{
|
||||
MoreRecentActionInCurrentTab = Action;
|
||||
break;
|
||||
|
|
|
@ -99,12 +99,12 @@ Act_Action_t Act_GetSuperAction (Act_Action_t Action)
|
|||
/************* Check if I have permission to execute an action ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Act_CheckIfIHavePermissionToExecuteAction (Act_Action_t Action)
|
||||
Usr_ICan_t Act_CheckIfICanExecuteAction (Act_Action_t Action)
|
||||
{
|
||||
unsigned Permission;
|
||||
|
||||
if ((unsigned) Action >= ActLst_NUM_ACTIONS)
|
||||
return false;
|
||||
return Usr_I_CAN_NOT;
|
||||
|
||||
switch (Gbl.Hierarchy.Level)
|
||||
{
|
||||
|
@ -128,10 +128,11 @@ bool Act_CheckIfIHavePermissionToExecuteAction (Act_Action_t Action)
|
|||
ActLst_Actions[Action].PermissionCrsIfIDontBelong;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
return Usr_I_CAN_NOT;
|
||||
}
|
||||
|
||||
return ((Permission & (1 << Gbl.Usrs.Me.Role.Logged)) != 0);
|
||||
return ((Permission & (1 << Gbl.Usrs.Me.Role.Logged)) != 0) ? Usr_I_CAN :
|
||||
Usr_I_CAN_NOT;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "swad_language.h"
|
||||
#include "swad_string.h"
|
||||
#include "swad_tab.h"
|
||||
#include "swad_user_type.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
|
@ -105,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);
|
||||
bool Act_CheckIfIHavePermissionToExecuteAction (Act_Action_t Action);
|
||||
Usr_ICan_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);
|
||||
|
|
21
swad_admin.c
21
swad_admin.c
|
@ -90,7 +90,7 @@ void Adm_ReqAddAdm (Hie_Level_t Level)
|
|||
[Hie_DEG] = ActNewAdmDeg,
|
||||
[Hie_CRS] = ActUnk,
|
||||
};
|
||||
bool ICanRegister;
|
||||
Usr_ICan_t ICanRegister;
|
||||
|
||||
if (Gbl.Hierarchy.Node[Level].HieCod > 0)
|
||||
{
|
||||
|
@ -100,8 +100,9 @@ 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));
|
||||
if (ICanRegister)
|
||||
(Level == Hie_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_I_CAN :
|
||||
Usr_I_CAN_NOT;
|
||||
if (ICanRegister == Usr_I_CAN)
|
||||
{
|
||||
if (Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Level)) // User is already an administrator of current institution/center/degree
|
||||
{
|
||||
|
@ -185,7 +186,7 @@ void Adm_GetAdmsLst (Hie_Level_t Level)
|
|||
|
||||
static void Adm_AddAdm (Hie_Level_t Level)
|
||||
{
|
||||
bool ICanRegister;
|
||||
Usr_ICan_t ICanRegister;
|
||||
|
||||
if (Gbl.Hierarchy.Node[Level].HieCod > 0)
|
||||
{
|
||||
|
@ -195,8 +196,9 @@ 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));
|
||||
if (ICanRegister)
|
||||
(Level == Hie_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_I_CAN :
|
||||
Usr_I_CAN_NOT;
|
||||
if (ICanRegister == Usr_I_CAN)
|
||||
{
|
||||
/***** Register administrator in current institution/center/degree in database *****/
|
||||
Adm_RegisterAdmin (&Gbl.Usrs.Other.UsrDat,Level);
|
||||
|
@ -298,7 +300,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;
|
||||
bool ICanRemove;
|
||||
Usr_ICan_t ICanRemove;
|
||||
|
||||
if (Gbl.Hierarchy.Node[Level].HieCod > 0)
|
||||
{
|
||||
|
@ -310,8 +312,9 @@ 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));
|
||||
if (ICanRemove)
|
||||
(Level == Hie_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) ? Usr_I_CAN :
|
||||
Usr_I_CAN_NOT;
|
||||
if (ICanRemove == Usr_I_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))
|
||||
|
|
|
@ -338,14 +338,15 @@ static void Att_ParsWhichGroupsToShow (void *Events)
|
|||
|
||||
static void Att_PutIconsInListOfEvents (void *Events)
|
||||
{
|
||||
bool ICanEdit;
|
||||
Usr_ICan_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);
|
||||
if (ICanEdit)
|
||||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Usr_I_CAN :
|
||||
Usr_I_CAN_NOT;
|
||||
if (ICanEdit == Usr_I_CAN)
|
||||
Att_PutIconToCreateNewEvent ((struct Att_Events *) Events);
|
||||
|
||||
/***** Put icon to show attendance list *****/
|
||||
|
@ -1655,9 +1656,9 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
|||
bool Present;
|
||||
char CommentStd[Cns_MAX_BYTES_TEXT + 1];
|
||||
char CommentTch[Cns_MAX_BYTES_TEXT + 1];
|
||||
bool ICanChangeStdAttendance;
|
||||
bool ICanEditStdComment;
|
||||
bool ICanEditTchComment;
|
||||
Usr_ICan_t ICanChangeStdAttendance;
|
||||
Usr_ICan_t ICanEditStdComment;
|
||||
Usr_ICan_t ICanEditTchComment;
|
||||
|
||||
/***** Set who can edit *****/
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
|
@ -1666,24 +1667,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 = false;
|
||||
ICanEditStdComment = Event->Open; // Attendance event is open
|
||||
ICanEditTchComment = false;
|
||||
ICanChangeStdAttendance = Usr_I_CAN_NOT;
|
||||
ICanEditStdComment = Event->Open ? Usr_I_CAN : // Attendance event is open
|
||||
Usr_I_CAN_NOT;
|
||||
ICanEditTchComment = Usr_I_CAN_NOT;
|
||||
break;
|
||||
case Rol_TCH:
|
||||
ICanChangeStdAttendance = true;
|
||||
ICanEditStdComment = false;
|
||||
ICanEditTchComment = true;
|
||||
ICanChangeStdAttendance = Usr_I_CAN;
|
||||
ICanEditStdComment = Usr_I_CAN_NOT;
|
||||
ICanEditTchComment = Usr_I_CAN;
|
||||
break;
|
||||
case Rol_SYS_ADM:
|
||||
ICanChangeStdAttendance = true;
|
||||
ICanEditStdComment = false;
|
||||
ICanEditTchComment = false;
|
||||
ICanChangeStdAttendance = Usr_I_CAN;
|
||||
ICanEditStdComment = Usr_I_CAN_NOT;
|
||||
ICanEditTchComment = Usr_I_CAN_NOT;
|
||||
break;
|
||||
default:
|
||||
ICanChangeStdAttendance = false;
|
||||
ICanEditStdComment = false;
|
||||
ICanEditTchComment = false;
|
||||
ICanChangeStdAttendance = Usr_I_CAN_NOT;
|
||||
ICanEditStdComment = Usr_I_CAN_NOT;
|
||||
ICanEditTchComment = Usr_I_CAN_NOT;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1706,8 +1708,8 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
|||
"id=\"Std%u\" value=\"%s\"%s%s",
|
||||
NumUsr,UsrDat->EnUsrCod,
|
||||
Present ? " checked=\"checked\"" : "",
|
||||
ICanChangeStdAttendance ? "" :
|
||||
" disabled=\"disabled\"");
|
||||
(ICanChangeStdAttendance == Usr_I_CAN) ? "" :
|
||||
" disabled=\"disabled\"");
|
||||
HTM_TD_End ();
|
||||
|
||||
/***** Write number of student in the list *****/
|
||||
|
@ -1755,7 +1757,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
|||
"DAT_SMALL",
|
||||
The_GetSuffix (),
|
||||
The_GetColorRows ());
|
||||
if (ICanEditStdComment) // Show with form
|
||||
if (ICanEditStdComment == Usr_I_CAN) // Show with form
|
||||
{
|
||||
HTM_TEXTAREA_Begin ("name=\"CommentStd%s\" cols=\"40\" rows=\"3\""
|
||||
" class=\"INPUT_%s\"",
|
||||
|
@ -1778,7 +1780,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
|||
"DAT_SMALL",
|
||||
The_GetSuffix (),
|
||||
The_GetColorRows ());
|
||||
if (ICanEditTchComment) // Show with form
|
||||
if (ICanEditTchComment == Usr_I_CAN) // Show with form
|
||||
{
|
||||
HTM_TEXTAREA_Begin ("name=\"CommentTch%s\" cols=\"40\" rows=\"3\""
|
||||
" class=\"INPUT_%s\"",
|
||||
|
@ -1787,7 +1789,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
|||
HTM_Txt (CommentTch);
|
||||
HTM_TEXTAREA_End ();
|
||||
}
|
||||
else if (Event->CommentTchVisible) // Show without form
|
||||
else if (Event->CommentTchVisible) // Show without form
|
||||
{
|
||||
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
||||
CommentTch,Cns_MAX_BYTES_TEXT,
|
||||
|
|
|
@ -1140,7 +1140,7 @@ static void Brw_ListDir (unsigned Level,const char *RowId,
|
|||
static bool Brw_WriteRowFileBrowser (unsigned Level,const char *RowId,
|
||||
bool TreeContracted,
|
||||
Brw_IconTree_t IconThisRow);
|
||||
static bool Brw_CheckIfCanPasteIn (unsigned Level);
|
||||
static Usr_ICan_t Brw_CheckIfCanPasteIn (unsigned Level);
|
||||
static void Brw_PutIconRemove (void);
|
||||
static void Brw_PutIconCopy (void);
|
||||
static void Brw_PutIconPaste (unsigned Level);
|
||||
|
@ -4137,26 +4137,26 @@ void Brw_SetFullPathInTree (void)
|
|||
/*****************************************************************************/
|
||||
// Return true if Gbl.FileBrowser.Clipboard.FilFolLnk.Full can be pasted into Gbl.FileBrowser.FilFolLnk.Full
|
||||
|
||||
static bool Brw_CheckIfCanPasteIn (unsigned Level)
|
||||
static Usr_ICan_t Brw_CheckIfCanPasteIn (unsigned Level)
|
||||
{
|
||||
char PathDstWithFile[PATH_MAX + 1 + NAME_MAX + 1];
|
||||
|
||||
/***** If not in a folder... *****/
|
||||
if (Gbl.FileBrowser.FilFolLnk.Type != Brw_IS_FOLDER)
|
||||
return false;
|
||||
return Usr_I_CAN_NOT;
|
||||
|
||||
/***** If there is nothing in clipboard... *****/
|
||||
if (Gbl.FileBrowser.Clipboard.FileBrowser == Brw_UNKNOWN)
|
||||
return false;
|
||||
return Usr_I_CAN_NOT;
|
||||
|
||||
/***** Do not paste a link in marks... *****/
|
||||
if (Gbl.FileBrowser.Clipboard.FilFolLnk.Type == Brw_IS_LINK &&
|
||||
Brw_TypeIsAdmMrk[Gbl.FileBrowser.Type])
|
||||
return false;
|
||||
return Usr_I_CAN_NOT;
|
||||
|
||||
/**** If I can not create elements into this folder... *****/
|
||||
if (Brw_CheckIfICanCreateIntoFolder (Level) == Usr_I_CAN_NOT)
|
||||
return false; // Pasting into top level of assignments is forbidden
|
||||
return Usr_I_CAN_NOT; // Pasting into top level of assignments is forbidden
|
||||
|
||||
/**** If we are in the same tree of the clipboard... *****/
|
||||
if (Gbl.FileBrowser.Clipboard.IsThisTree) // We are in the same tree of the clipboard ==>
|
||||
|
@ -4167,11 +4167,12 @@ static bool Brw_CheckIfCanPasteIn (unsigned Level)
|
|||
Gbl.FileBrowser.FilFolLnk.Full,
|
||||
Gbl.FileBrowser.Clipboard.FilFolLnk.Name);
|
||||
|
||||
return !Str_Path1BeginsByPath2 (PathDstWithFile,
|
||||
Gbl.FileBrowser.Clipboard.FilFolLnk.Full);
|
||||
return Str_Path1BeginsByPath2 (PathDstWithFile,
|
||||
Gbl.FileBrowser.Clipboard.FilFolLnk.Full) ? Usr_I_CAN_NOT :
|
||||
Usr_I_CAN;
|
||||
}
|
||||
|
||||
return true; // I can paste
|
||||
return Usr_I_CAN; // I can paste
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4233,7 +4234,7 @@ static void Brw_PutIconPaste (unsigned Level)
|
|||
if (Gbl.FileBrowser.FilFolLnk.Type == Brw_IS_FOLDER) // Can't paste in a file or link
|
||||
{
|
||||
/* Icon to paste */
|
||||
if (Brw_CheckIfCanPasteIn (Level))
|
||||
if (Brw_CheckIfCanPasteIn (Level) == Usr_I_CAN)
|
||||
{
|
||||
/***** Form to paste the content of the clipboard *****/
|
||||
Ico_PutContextualIconToPaste (Brw_ActPaste[Gbl.FileBrowser.Type],
|
||||
|
@ -5768,7 +5769,7 @@ static void Brw_PasteClipboard (struct BrwSiz_BrowserSize *Size)
|
|||
Pasted.NumFolds = 0;
|
||||
|
||||
Gbl.FileBrowser.Clipboard.IsThisTree = Brw_CheckIfClipboardIsInThisTree ();
|
||||
if (Brw_CheckIfCanPasteIn (Gbl.FileBrowser.Level))
|
||||
if (Brw_CheckIfCanPasteIn (Gbl.FileBrowser.Level) == Usr_I_CAN)
|
||||
{
|
||||
/***** Construct the relative path of the origin file or folder *****/
|
||||
switch (Gbl.FileBrowser.Clipboard.FileBrowser)
|
||||
|
@ -6212,7 +6213,7 @@ void Brw_ShowFormFileBrowser (void)
|
|||
{
|
||||
/***** Check if we can paste in this folder *****/
|
||||
Gbl.FileBrowser.Clipboard.IsThisTree = Brw_CheckIfClipboardIsInThisTree ();
|
||||
if (Brw_CheckIfCanPasteIn (Gbl.FileBrowser.Level))
|
||||
if (Brw_CheckIfCanPasteIn (Gbl.FileBrowser.Level) == Usr_I_CAN)
|
||||
Brw_PutFormToPasteAFileOrFolder (FileNameToShow);
|
||||
}
|
||||
|
||||
|
|
|
@ -633,10 +633,11 @@ Me sale este error, no s
|
|||
"can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod')
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 23.72 (2024-04-01)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 23.72.1 (2024-04-01)"
|
||||
#define CSS_FILE "swad23.67.2.css"
|
||||
#define JS_FILE "swad23.53.6.js"
|
||||
/*
|
||||
Version 23.72.1: Apr 01, 2024 New type Usr_ICan_t. (334912 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.3: Mar 22, 2024 Code refactoring. (334827 lines)
|
||||
|
|
|
@ -147,7 +147,7 @@ int main (void)
|
|||
Fir_CheckFirewallAndExitIfTooManyRequests ();
|
||||
|
||||
/***** Check if the user have permission to execute the action *****/
|
||||
if (!Act_CheckIfIHavePermissionToExecuteAction (Gbl.Action.Act))
|
||||
if (Act_CheckIfICanExecuteAction (Gbl.Action.Act) == Usr_I_CAN_NOT)
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Update most frequently used actions *****/
|
||||
|
|
|
@ -227,7 +227,7 @@ Act_Action_t Mnu_GetFirstActionAvailableInCurrentTab (void)
|
|||
{
|
||||
if ((Action = Mnu_Menu[Gbl.Action.Tab][NumOptInMenu].Action) == 0)
|
||||
return ActUnk;
|
||||
if (Act_CheckIfIHavePermissionToExecuteAction (Action))
|
||||
if (Act_CheckIfICanExecuteAction (Action) == Usr_I_CAN)
|
||||
return Action;
|
||||
}
|
||||
return ActUnk;
|
||||
|
@ -264,7 +264,7 @@ void Mnu_WriteMenuThisTab (void)
|
|||
Action = Mnu_Menu[Gbl.Action.Tab][NumOptInMenu].Action;
|
||||
if (Action == 0) // At the end of each tab, actions are initialized to 0, so 0 marks the end of the menu
|
||||
break;
|
||||
if (Act_CheckIfIHavePermissionToExecuteAction (Action))
|
||||
if (Act_CheckIfICanExecuteAction (Action) == Usr_I_CAN)
|
||||
{
|
||||
IsTheSelectedAction = (Action == Act_GetSuperAction (Gbl.Action.Act));
|
||||
|
||||
|
|
109
swad_user.h
109
swad_user.h
|
@ -49,119 +49,10 @@
|
|||
#include "swad_string.h"
|
||||
#include "swad_theme.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Usr_MIN_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 6
|
||||
#define Usr_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 12
|
||||
#define Usr_MAX_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 60
|
||||
|
||||
#define Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME (32 - 1) // 31
|
||||
#define Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME ((Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511
|
||||
|
||||
#define Usr_MAX_BYTES_SURNAMES (Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1 + Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME)
|
||||
// Surname1 +' '+ Surname2
|
||||
#define Usr_MAX_BYTES_FULL_NAME (Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1 + Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 6 + Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME)
|
||||
// Surname1 +' '+ Surname2 + ','+' ' + FirstName
|
||||
// Surname1 +' '+ Surname2 + '<br />' + FirstName
|
||||
|
||||
#define Usr_BIRTHDAY_STR_DB_LENGTH (1 + 4 + 1 + 2 + 1 + 2 + 1) // "'%04u-%02u-%02u'"
|
||||
|
||||
#define Usr_MAX_CHARS_ADDRESS (128 - 1) // 127
|
||||
#define Usr_MAX_BYTES_ADDRESS ((Usr_MAX_CHARS_ADDRESS + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
||||
|
||||
#define Usr_MAX_CHARS_PHONE 16
|
||||
#define Usr_MAX_BYTES_PHONE Usr_MAX_CHARS_PHONE
|
||||
|
||||
#define Usr_CLASS_PHOTO_COLS_DEF 10 // Default number of columns in a class photo
|
||||
#define Usr_CLASS_PHOTO_COLS_MAX 100 // Maximum number of columns in a class photo
|
||||
|
||||
#define Usr_LIST_WITH_PHOTOS_DEF true
|
||||
|
||||
#define Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS (Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 * Cfg_MAX_USRS_IN_LIST)
|
||||
|
||||
#define Usr_NUM_MAIN_FIELDS_DATA_USR 8
|
||||
|
||||
#define Usr_USER_LIST_SECTION_ID "user_list"
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************** Public types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// Get user's data with or without personal settings
|
||||
typedef enum
|
||||
{
|
||||
Usr_DONT_GET_PREFS = 0,
|
||||
Usr_GET_PREFS = 1,
|
||||
} Usr_GetPrefs_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Usr_DONT_GET_ROLE_IN_CRS = 0,
|
||||
Usr_GET_ROLE_IN_CRS = 1,
|
||||
} Usr_GetRoleInCurrentCrs_t;
|
||||
|
||||
|
||||
// Related with user's sexes
|
||||
#define Usr_NUM_SEXS 4 // Unknown, female, male, all
|
||||
typedef enum
|
||||
{
|
||||
Usr_SEX_UNKNOWN = 0,
|
||||
Usr_SEX_FEMALE = 1,
|
||||
Usr_SEX_MALE = 2,
|
||||
Usr_SEX_ALL = 3, // Usr_SEX_ALL is intended for "all sexs"
|
||||
} Usr_Sex_t;
|
||||
// Don't change these numbers! They are used for user's sex in database
|
||||
|
||||
// Related with class photograph
|
||||
#define Usr_NUM_CLASS_PHOTO_TYPE 3
|
||||
typedef enum
|
||||
{
|
||||
Usr_CLASS_PHOTO_SEL, // Only for selection of users
|
||||
Usr_CLASS_PHOTO_SEL_SEE, // Selecting and seeing users
|
||||
Usr_CLASS_PHOTO_PRN, // Only print users
|
||||
} Usr_ClassPhotoType_t;
|
||||
|
||||
#define Usr_LIST_USRS_NUM_OPTIONS 8
|
||||
typedef enum
|
||||
{
|
||||
Usr_OPTION_UNKNOWN = 0,
|
||||
Usr_OPTION_RECORDS = 1,
|
||||
Usr_OPTION_HOMEWORK = 2,
|
||||
Usr_OPTION_ATTENDANCE = 3,
|
||||
Usr_OPTION_MESSAGE = 4,
|
||||
Usr_OPTION_EMAIL = 5,
|
||||
Usr_OPTION_FOLLOW = 6,
|
||||
Usr_OPTION_UNFOLLOW = 7,
|
||||
} Usr_ListUsrsOption_t;
|
||||
#define Usr_LIST_USRS_DEFAULT_OPTION Usr_OPTION_RECORDS
|
||||
|
||||
#define Usr_NUM_I_CAN 2
|
||||
typedef enum
|
||||
{
|
||||
Usr_I_CAN_NOT,
|
||||
Usr_I_CAN,
|
||||
} Usr_ICan_t;
|
||||
|
||||
#define Usr_NUM_ME_OR_OTHER 2
|
||||
typedef enum
|
||||
{
|
||||
Usr_ME,
|
||||
Usr_OTHER,
|
||||
} Usr_MeOrOther_t;
|
||||
|
||||
#define Usr_NUM_WHO 5
|
||||
typedef enum
|
||||
{
|
||||
Usr_WHO_UNKNOWN,
|
||||
Usr_WHO_ME,
|
||||
Usr_WHO_SELECTED,
|
||||
Usr_WHO_FOLLOWED,
|
||||
Usr_WHO_ALL,
|
||||
} Usr_Who_t;
|
||||
#define Usr_WHO_DEFAULT Usr_WHO_ALL
|
||||
|
||||
// Related with user's data
|
||||
struct Usr_Data
|
||||
{
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
// swad_user_type.h: definition of types for users
|
||||
|
||||
#ifndef _SWAD_USR_TYP
|
||||
#define _SWAD_USR_TYP
|
||||
/*
|
||||
SWAD (Shared Workspace At a Distance in Spanish),
|
||||
is a web platform developed at the University of Granada (Spain),
|
||||
and used to support university teaching.
|
||||
|
||||
This file is part of SWAD core.
|
||||
Copyright (C) 1999-2024 Antonio Cañas Vargas
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Usr_MIN_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 6
|
||||
#define Usr_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 12
|
||||
#define Usr_MAX_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 60
|
||||
|
||||
#define Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME (32 - 1) // 31
|
||||
#define Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME ((Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511
|
||||
|
||||
#define Usr_MAX_BYTES_SURNAMES (Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1 + Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME)
|
||||
// Surname1 +' '+ Surname2
|
||||
#define Usr_MAX_BYTES_FULL_NAME (Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1 + Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 6 + Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME)
|
||||
// Surname1 +' '+ Surname2 + ','+' ' + FirstName
|
||||
// Surname1 +' '+ Surname2 + '<br />' + FirstName
|
||||
|
||||
#define Usr_BIRTHDAY_STR_DB_LENGTH (1 + 4 + 1 + 2 + 1 + 2 + 1) // "'%04u-%02u-%02u'"
|
||||
|
||||
#define Usr_MAX_CHARS_ADDRESS (128 - 1) // 127
|
||||
#define Usr_MAX_BYTES_ADDRESS ((Usr_MAX_CHARS_ADDRESS + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
||||
|
||||
#define Usr_MAX_CHARS_PHONE 16
|
||||
#define Usr_MAX_BYTES_PHONE Usr_MAX_CHARS_PHONE
|
||||
|
||||
#define Usr_CLASS_PHOTO_COLS_DEF 10 // Default number of columns in a class photo
|
||||
#define Usr_CLASS_PHOTO_COLS_MAX 100 // Maximum number of columns in a class photo
|
||||
|
||||
#define Usr_LIST_WITH_PHOTOS_DEF true
|
||||
|
||||
#define Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS (Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 * Cfg_MAX_USRS_IN_LIST)
|
||||
|
||||
#define Usr_NUM_MAIN_FIELDS_DATA_USR 8
|
||||
|
||||
#define Usr_USER_LIST_SECTION_ID "user_list"
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************** Public types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// Get user's data with or without personal settings
|
||||
typedef enum
|
||||
{
|
||||
Usr_DONT_GET_PREFS = 0,
|
||||
Usr_GET_PREFS = 1,
|
||||
} Usr_GetPrefs_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Usr_DONT_GET_ROLE_IN_CRS = 0,
|
||||
Usr_GET_ROLE_IN_CRS = 1,
|
||||
} Usr_GetRoleInCurrentCrs_t;
|
||||
|
||||
// Related with user's sexes
|
||||
#define Usr_NUM_SEXS 4 // Unknown, female, male, all
|
||||
typedef enum
|
||||
{
|
||||
Usr_SEX_UNKNOWN = 0,
|
||||
Usr_SEX_FEMALE = 1,
|
||||
Usr_SEX_MALE = 2,
|
||||
Usr_SEX_ALL = 3, // Usr_SEX_ALL is intended for "all sexs"
|
||||
} Usr_Sex_t;
|
||||
// Don't change these numbers! They are used for user's sex in database
|
||||
|
||||
// Related with class photograph
|
||||
#define Usr_NUM_CLASS_PHOTO_TYPE 3
|
||||
typedef enum
|
||||
{
|
||||
Usr_CLASS_PHOTO_SEL, // Only for selection of users
|
||||
Usr_CLASS_PHOTO_SEL_SEE, // Selecting and seeing users
|
||||
Usr_CLASS_PHOTO_PRN, // Only print users
|
||||
} Usr_ClassPhotoType_t;
|
||||
|
||||
#define Usr_LIST_USRS_NUM_OPTIONS 8
|
||||
typedef enum
|
||||
{
|
||||
Usr_OPTION_UNKNOWN = 0,
|
||||
Usr_OPTION_RECORDS = 1,
|
||||
Usr_OPTION_HOMEWORK = 2,
|
||||
Usr_OPTION_ATTENDANCE = 3,
|
||||
Usr_OPTION_MESSAGE = 4,
|
||||
Usr_OPTION_EMAIL = 5,
|
||||
Usr_OPTION_FOLLOW = 6,
|
||||
Usr_OPTION_UNFOLLOW = 7,
|
||||
} Usr_ListUsrsOption_t;
|
||||
#define Usr_LIST_USRS_DEFAULT_OPTION Usr_OPTION_RECORDS
|
||||
|
||||
#define Usr_NUM_I_CAN 2
|
||||
typedef enum
|
||||
{
|
||||
Usr_I_CAN_NOT,
|
||||
Usr_I_CAN,
|
||||
} Usr_ICan_t;
|
||||
|
||||
#define Usr_NUM_ME_OR_OTHER 2
|
||||
typedef enum
|
||||
{
|
||||
Usr_ME,
|
||||
Usr_OTHER,
|
||||
} Usr_MeOrOther_t;
|
||||
|
||||
#define Usr_NUM_WHO 5
|
||||
typedef enum
|
||||
{
|
||||
Usr_WHO_UNKNOWN,
|
||||
Usr_WHO_ME,
|
||||
Usr_WHO_SELECTED,
|
||||
Usr_WHO_FOLLOWED,
|
||||
Usr_WHO_ALL,
|
||||
} Usr_Who_t;
|
||||
#define Usr_WHO_DEFAULT Usr_WHO_ALL
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue