2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_action.c: actions
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
This file is part of SWAD core.
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Copyright (C) 1999-2023 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01:00
|
|
|
|
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/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************************** Headers *********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
|
|
|
|
#include "swad_action.h"
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
2021-06-25 20:05:58 +02:00
|
|
|
|
#include "swad_group_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_photo.h"
|
2016-12-13 13:32:19 +01:00
|
|
|
|
#include "swad_role.h"
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_test_config.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
2022-11-06 18:11:10 +01:00
|
|
|
|
extern const struct Act_Actions ActLst_Actions[ActLst_NUM_ACTIONS];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-09 20:56:02 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Get action from permanent action code ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
Act_Action_t Act_GetActionFromActCod (long ActCod)
|
|
|
|
|
{
|
2022-11-06 18:11:10 +01:00
|
|
|
|
extern Act_Action_t ActLst_FromActCodToAction[1 + ActLst_MAX_ACTION_COD];
|
|
|
|
|
|
|
|
|
|
if (ActCod >= 0 && ActCod <= ActLst_MAX_ACTION_COD)
|
|
|
|
|
return ActLst_FromActCodToAction[ActCod];
|
2017-05-09 20:56:02 +02:00
|
|
|
|
|
|
|
|
|
return ActUnk;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-24 13:21:53 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Get permanent action code from action ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
long Act_GetActCod (Act_Action_t Action)
|
|
|
|
|
{
|
2022-11-06 18:11:10 +01:00
|
|
|
|
if (Action < 0 || Action >= ActLst_NUM_ACTIONS)
|
2018-04-24 13:21:53 +02:00
|
|
|
|
return -1L;
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
return ActLst_Actions[Action].ActCod;
|
2018-04-24 13:21:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Get index in menu associated to an action ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
signed int Act_GetIndexInMenu (Act_Action_t Action)
|
|
|
|
|
{
|
2022-11-06 18:11:10 +01:00
|
|
|
|
return ActLst_Actions[Act_GetSuperAction (Action)].IndexInMenu;
|
2018-04-24 13:21:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get tab associated to an action ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
Tab_Tab_t Act_GetTab (Act_Action_t Action)
|
|
|
|
|
{
|
2022-11-06 18:11:10 +01:00
|
|
|
|
return ActLst_Actions[Act_GetSuperAction (Action)].Tab;
|
2018-04-24 13:21:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Get superaction associated to an action *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
Act_Action_t Act_GetSuperAction (Act_Action_t Action)
|
|
|
|
|
{
|
2022-11-06 18:11:10 +01:00
|
|
|
|
if (Action < 0 || Action >= ActLst_NUM_ACTIONS)
|
2018-04-24 13:21:53 +02:00
|
|
|
|
return ActUnk;
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
return ActLst_Actions[Action].SuperAction;
|
2018-04-24 13:21:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Check if I have permission to execute an action ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
bool Act_CheckIfIHavePermissionToExecuteAction (Act_Action_t Action)
|
|
|
|
|
{
|
2017-02-08 23:25:29 +01:00
|
|
|
|
unsigned Permission;
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
if (Action < 0 || Action >= ActLst_NUM_ACTIONS)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
return false;
|
|
|
|
|
|
2019-04-03 20:57:04 +02:00
|
|
|
|
switch (Gbl.Hierarchy.Level)
|
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_SYS: // System
|
2022-11-06 18:11:10 +01:00
|
|
|
|
Permission = ActLst_Actions[Action].PermissionSys;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_CTY: // Country selected
|
2022-11-06 18:11:10 +01:00
|
|
|
|
Permission = ActLst_Actions[Action].PermissionCty;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_INS: // Institution selected
|
2022-11-06 18:11:10 +01:00
|
|
|
|
Permission = ActLst_Actions[Action].PermissionIns;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_CTR: // Center selected
|
2022-11-06 18:11:10 +01:00
|
|
|
|
Permission = ActLst_Actions[Action].PermissionCtr;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_DEG: // Degree selected
|
2022-11-06 18:11:10 +01:00
|
|
|
|
Permission = ActLst_Actions[Action].PermissionDeg;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_CRS: // Course selected
|
2022-11-06 18:11:10 +01:00
|
|
|
|
Permission = Gbl.Usrs.Me.IBelongToCurrentCrs ? ActLst_Actions[Action].PermissionCrsIfIBelong :
|
|
|
|
|
ActLst_Actions[Action].PermissionCrsIfIDontBelong;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-12 01:12:15 +01:00
|
|
|
|
return ((Permission & (1 << Gbl.Usrs.Me.Role.Logged)) != 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-24 13:21:53 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Get content type associated to an action ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
Act_Content_t Act_GetContentType (Act_Action_t Action)
|
|
|
|
|
{
|
2022-11-06 18:11:10 +01:00
|
|
|
|
if (Action < 0 || Action >= ActLst_NUM_ACTIONS)
|
2018-04-24 13:21:53 +02:00
|
|
|
|
return Act_CONT_NORM;
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
return ActLst_Actions[Action].ContentType;
|
2018-04-24 13:21:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Get browser tab associated to an action ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
Act_BrowserTab_t Act_GetBrowserTab (Act_Action_t Action)
|
|
|
|
|
{
|
2022-11-06 18:11:10 +01:00
|
|
|
|
if (Action < 0 || Action >= ActLst_NUM_ACTIONS)
|
2018-04-24 13:21:53 +02:00
|
|
|
|
return Act_BRW_UNK_TAB;
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
return ActLst_Actions[Action].BrowserTab;
|
2018-04-24 13:21:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Get pointer to function a priori associated to an action **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void (*Act_GetFunctionPriori (Act_Action_t Action)) (void)
|
|
|
|
|
{
|
2022-11-06 18:11:10 +01:00
|
|
|
|
if (Action < 0 || Action >= ActLst_NUM_ACTIONS)
|
2018-04-24 13:21:53 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
return ActLst_Actions[Action].FunctionPriori;
|
2018-04-24 13:21:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******* Get pointer to function a posteriori associated to an action ********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void (*Act_GetFunctionPosteriori (Act_Action_t Action)) (void)
|
|
|
|
|
{
|
2022-11-06 18:11:10 +01:00
|
|
|
|
if (Action < 0 || Action >= ActLst_NUM_ACTIONS)
|
2018-04-24 13:21:53 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
return ActLst_Actions[Action].FunctionPosteriori;
|
2018-04-24 13:21:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Get icon associated to an action *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
const char *Act_GetIcon (Act_Action_t Action)
|
|
|
|
|
{
|
2022-11-06 18:11:10 +01:00
|
|
|
|
if (Action < 0 || Action >= ActLst_NUM_ACTIONS)
|
2018-04-24 13:21:53 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
return Ico_GetIcon (ActLst_Actions[Action].Icon);
|
2018-04-24 13:21:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get the title associated to an action *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
const char *Act_GetTitleAction (Act_Action_t Action)
|
|
|
|
|
{
|
2015-01-04 15:48:24 +01:00
|
|
|
|
extern const char *Txt_MENU_TITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
if (Action < 0 || Action >= ActLst_NUM_ACTIONS)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
return NULL;
|
2016-10-20 22:58:11 +02:00
|
|
|
|
|
2018-04-24 13:21:53 +02:00
|
|
|
|
return Txt_MENU_TITLE[Act_GetTab (Action)][Act_GetIndexInMenu (Action)];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get text for action from database *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-01-02 13:58:13 +01:00
|
|
|
|
const char *Act_GetActionText (Act_Action_t Action)
|
|
|
|
|
{
|
2022-11-06 18:11:10 +01:00
|
|
|
|
extern const char *Txt_Actions[ActLst_NUM_ACTIONS];
|
2020-01-02 13:58:13 +01:00
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
if (Action >= 0 && Action < ActLst_NUM_ACTIONS)
|
2020-01-02 13:58:13 +01:00
|
|
|
|
if (Txt_Actions[Action])
|
|
|
|
|
if (Txt_Actions[Action][0])
|
|
|
|
|
return Txt_Actions[Action];
|
|
|
|
|
|
|
|
|
|
return "?";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2015-12-30 18:36:10 +01:00
|
|
|
|
/***************** Adjust current action when no user's logged ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Act_AdjustActionWhenNoUsrLogged (void)
|
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
static const Act_Action_t Actions[HieLvl_NUM_LEVELS] =
|
2019-04-03 20:57:04 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
[HieLvl_UNK] = ActUnk, // Unknown
|
|
|
|
|
[HieLvl_SYS] = ActFrmLogIn, // System
|
|
|
|
|
[HieLvl_CTY] = ActSeeCtyInf, // Country
|
|
|
|
|
[HieLvl_INS] = ActSeeInsInf, // Institution
|
|
|
|
|
[HieLvl_CTR] = ActSeeCtrInf, // Center
|
|
|
|
|
[HieLvl_DEG] = ActSeeDegInf, // Degree
|
|
|
|
|
[HieLvl_CRS] = ActSeeCrsInf, // Course
|
2019-04-03 20:57:04 +02:00
|
|
|
|
};
|
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Gbl.Hierarchy.Level >= HieLvl_NUM_LEVELS)
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Level = ActUnk;
|
|
|
|
|
|
|
|
|
|
Gbl.Action.Act = Actions[Gbl.Hierarchy.Level];
|
2015-01-04 15:48:24 +01:00
|
|
|
|
Tab_SetCurrentTab ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Adjust current action if it's mandatory to fill any empty data *******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Act_AdjustCurrentAction (void)
|
|
|
|
|
{
|
2019-02-18 14:41:46 +01:00
|
|
|
|
bool IAmATeacherInAnyCrs;
|
|
|
|
|
bool JustAfterLogin = Gbl.Action.Act == ActLogIn ||
|
|
|
|
|
Gbl.Action.Act == ActLogInLan ||
|
2019-04-01 23:15:17 +02:00
|
|
|
|
Gbl.Action.Act == ActLogInNew ||
|
2019-02-18 14:41:46 +01:00
|
|
|
|
Gbl.Action.Act == ActAnnSee;
|
|
|
|
|
|
|
|
|
|
/***** Don't adjust anything when:
|
2019-02-18 18:27:45 +01:00
|
|
|
|
- refreshing
|
2019-02-18 14:41:46 +01:00
|
|
|
|
- web service *****/
|
2016-01-17 15:10:54 +01:00
|
|
|
|
if (Gbl.Action.UsesAJAX ||
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.WebService.IsWebService)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-02-18 18:27:45 +01:00
|
|
|
|
/***** Don't adjust anything when current action is not a menu option
|
|
|
|
|
(except some actions just after login) *****/
|
|
|
|
|
if (!JustAfterLogin && // Not just after login
|
|
|
|
|
Gbl.Action.Act != Act_GetSuperAction (Gbl.Action.Act)) // It is not a menu option
|
|
|
|
|
return;
|
|
|
|
|
|
2019-02-18 14:41:46 +01:00
|
|
|
|
/***** Adjustment 1:
|
|
|
|
|
-------------
|
|
|
|
|
If I have no password in database,
|
|
|
|
|
the only action possible
|
|
|
|
|
is to show a form to change my account *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (!Gbl.Usrs.Me.UsrDat.Password[0])
|
|
|
|
|
{
|
2019-02-18 14:41:46 +01:00
|
|
|
|
Gbl.Action.Act = ActFrmMyAcc;
|
|
|
|
|
Tab_SetCurrentTab ();
|
|
|
|
|
return;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-18 14:41:46 +01:00
|
|
|
|
/***** Adjustment 2:
|
|
|
|
|
-------------
|
|
|
|
|
Just after login, check if my password seems good.
|
|
|
|
|
If my password is not enough secure,
|
|
|
|
|
the only action possible
|
|
|
|
|
is to show a form to change my account *****/
|
2016-12-05 13:26:12 +01:00
|
|
|
|
if (Gbl.Action.Act == ActLogIn)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (!Pwd_FastCheckIfPasswordSeemsGood (Gbl.Usrs.Me.LoginPlainPassword))
|
|
|
|
|
{
|
2019-02-15 21:09:18 +01:00
|
|
|
|
Gbl.Action.Act = ActFrmMyAcc;
|
2015-01-04 15:48:24 +01:00
|
|
|
|
Tab_SetCurrentTab ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-18 14:41:46 +01:00
|
|
|
|
/***** Adjustment 3:
|
|
|
|
|
-------------
|
|
|
|
|
If I have no nickname or email in database,
|
|
|
|
|
the only action possible
|
|
|
|
|
is to show a form to change my account *****/
|
2014-12-03 20:06:16 +01:00
|
|
|
|
if (!Gbl.Usrs.Me.UsrDat.Nickname[0] ||
|
2015-07-15 12:32:28 +02:00
|
|
|
|
!Gbl.Usrs.Me.UsrDat.Email[0])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-02-18 14:41:46 +01:00
|
|
|
|
Gbl.Action.Act = ActFrmMyAcc;
|
|
|
|
|
Tab_SetCurrentTab ();
|
|
|
|
|
return;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-18 14:41:46 +01:00
|
|
|
|
/***** Check if I am a teacher in any course *****/
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
2019-02-18 14:41:46 +01:00
|
|
|
|
IAmATeacherInAnyCrs = (Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) | // I am a non-editing teacher...
|
|
|
|
|
(1 << Rol_TCH))); // ...or a teacher in any course
|
|
|
|
|
|
|
|
|
|
/***** Adjustment 4:
|
|
|
|
|
-------------
|
|
|
|
|
If I haven't filled
|
|
|
|
|
- my sex
|
|
|
|
|
- my first name
|
|
|
|
|
- my surname 1
|
|
|
|
|
- my country
|
|
|
|
|
- my institution
|
|
|
|
|
or if I'm a teacher and I haven't filled
|
2021-03-07 21:21:04 +01:00
|
|
|
|
- my center
|
2019-02-18 14:41:46 +01:00
|
|
|
|
- my department,
|
|
|
|
|
the only action possible
|
|
|
|
|
is to show a form to change my shared record card *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if ( Gbl.Usrs.Me.UsrDat.Sex == Usr_SEX_UNKNOWN ||
|
2021-02-15 16:25:55 +01:00
|
|
|
|
!Gbl.Usrs.Me.UsrDat.FrstName[0] ||
|
2019-02-18 14:41:46 +01:00
|
|
|
|
!Gbl.Usrs.Me.UsrDat.Surname1 [0] ||
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.CtyCod <= 0 ||
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.InsCod < 0 ||
|
|
|
|
|
(IAmATeacherInAnyCrs && (Gbl.Usrs.Me.UsrDat.Tch.CtrCod < 0 ||
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.Tch.DptCod < 0)))
|
2019-12-23 22:13:02 +01:00
|
|
|
|
{
|
|
|
|
|
Gbl.Action.Act = ActReqEdiRecSha;
|
|
|
|
|
Tab_SetCurrentTab ();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-02-18 14:41:46 +01:00
|
|
|
|
/***** Adjustment 5:
|
|
|
|
|
-------------
|
2019-03-26 11:53:21 +01:00
|
|
|
|
If any of my settings about privacy is unknown
|
2019-02-18 14:41:46 +01:00
|
|
|
|
the only action possible
|
2019-03-26 11:53:21 +01:00
|
|
|
|
is to show a form to change my settings *****/
|
2019-03-22 15:21:46 +01:00
|
|
|
|
if (Gbl.Usrs.Me.UsrDat.PhotoVisibility == Pri_VISIBILITY_UNKNOWN ||
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.BaPrfVisibility == Pri_VISIBILITY_UNKNOWN ||
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.ExPrfVisibility == Pri_VISIBILITY_UNKNOWN)
|
2019-12-23 22:13:02 +01:00
|
|
|
|
{
|
|
|
|
|
Gbl.Action.Act = ActReqEdiSet;
|
|
|
|
|
Tab_SetCurrentTab ();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-01-18 10:21:18 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** If I belong to current course *****/
|
|
|
|
|
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
|
|
|
|
|
{
|
2019-02-18 14:41:46 +01:00
|
|
|
|
/***** Adjustment 6:
|
|
|
|
|
-------------
|
|
|
|
|
If I have not accepted my enrolment in the current course,
|
|
|
|
|
the only action possible
|
|
|
|
|
is to show a form to ask for enrolment *****/
|
|
|
|
|
if (!Gbl.Usrs.Me.UsrDat.Accepted)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-04-24 15:10:07 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs)
|
2017-05-20 12:04:12 +02:00
|
|
|
|
{
|
|
|
|
|
case Rol_STD:
|
2019-02-18 14:41:46 +01:00
|
|
|
|
Gbl.Action.Act = ActReqAccEnrStd;
|
2017-05-20 12:04:12 +02:00
|
|
|
|
break;
|
2017-05-21 21:23:13 +02:00
|
|
|
|
case Rol_NET:
|
2019-02-18 14:41:46 +01:00
|
|
|
|
Gbl.Action.Act = ActReqAccEnrNET;
|
2017-05-21 18:08:35 +02:00
|
|
|
|
break;
|
2017-05-20 12:04:12 +02:00
|
|
|
|
case Rol_TCH:
|
2019-02-18 14:41:46 +01:00
|
|
|
|
Gbl.Action.Act = ActReqAccEnrTch;
|
2017-05-20 12:04:12 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-02-18 02:42:15 +01:00
|
|
|
|
break;
|
2017-05-20 12:04:12 +02:00
|
|
|
|
}
|
2019-02-18 14:41:46 +01:00
|
|
|
|
Tab_SetCurrentTab ();
|
|
|
|
|
return;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-18 14:41:46 +01:00
|
|
|
|
/***** Depending on the role I am logged in the current course... *****/
|
2017-06-04 18:18:54 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_STD:
|
2019-02-18 14:41:46 +01:00
|
|
|
|
/***** Adjustment 7:
|
|
|
|
|
-------------
|
|
|
|
|
If there are some group types
|
|
|
|
|
with available groups in which I must register,
|
|
|
|
|
the only action possible
|
|
|
|
|
is show a form to register in groups *****/
|
2019-02-18 18:27:45 +01:00
|
|
|
|
if (JustAfterLogin) // Only after login because the following query may be slow
|
2021-06-25 20:05:58 +02:00
|
|
|
|
if (Grp_DB_CheckIfAvailableGrpTyp (-1L)) // This query may be slow
|
2019-02-18 18:27:45 +01:00
|
|
|
|
{
|
|
|
|
|
Gbl.Action.Act = ActReqSelGrp;
|
|
|
|
|
Tab_SetCurrentTab ();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-02-18 14:41:46 +01:00
|
|
|
|
|
|
|
|
|
/***** Adjustment 8:
|
|
|
|
|
-------------
|
|
|
|
|
If I have no photo
|
|
|
|
|
and current action is not available for unknown users,
|
|
|
|
|
then update number of clicks without photo.
|
|
|
|
|
If limit of clicks is reached,
|
|
|
|
|
the only action possible
|
|
|
|
|
is to show a form to send my photo *****/
|
|
|
|
|
if (!Gbl.Usrs.Me.MyPhotoExists)
|
2022-11-06 18:11:10 +01:00
|
|
|
|
if (!(ActLst_Actions[Gbl.Action.Act].PermissionCrsIfIBelong & (1 << Rol_UNK)))
|
2019-02-18 14:41:46 +01:00
|
|
|
|
if ((Gbl.Usrs.Me.NumAccWithoutPhoto =
|
|
|
|
|
Pho_UpdateMyClicksWithoutPhoto ()) > Pho_MAX_CLICKS_WITHOUT_PHOTO)
|
2019-02-18 09:40:46 +01:00
|
|
|
|
{
|
2019-02-18 14:41:46 +01:00
|
|
|
|
/* If limit of clicks has been reached,
|
|
|
|
|
the only action possible is show a form to send my photo */
|
|
|
|
|
Gbl.Action.Act = ActReqMyPho;
|
2019-02-18 09:40:46 +01:00
|
|
|
|
Tab_SetCurrentTab ();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if it is mandatory to read any information about course *****/
|
2016-01-17 15:10:54 +01:00
|
|
|
|
if (Gbl.Action.Act == ActMnu) // Do the following check sometimes, for example when the user changes the current tab
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Crs.Info.ShowMsgMustBeRead = Inf_GetIfIMustReadAnyCrsInfoInThisCrs ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2017-05-21 21:23:13 +02:00
|
|
|
|
case Rol_NET:
|
2017-05-20 12:04:12 +02:00
|
|
|
|
break;
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_TCH:
|
2019-02-18 14:41:46 +01:00
|
|
|
|
/***** Adjustment 9:
|
|
|
|
|
-------------
|
|
|
|
|
If current course has tests and pluggable is unknown,
|
|
|
|
|
the only action possible is configure tests *****/
|
2021-10-26 09:23:06 +02:00
|
|
|
|
if (TstCfg_CheckIfPluggableIsUnknownAndCrsHasTests ())
|
2019-02-18 14:41:46 +01:00
|
|
|
|
{
|
|
|
|
|
Gbl.Action.Act = ActCfgTst;
|
|
|
|
|
Tab_SetCurrentTab ();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-14 19:22:38 +01:00
|
|
|
|
|
2019-02-18 14:41:46 +01:00
|
|
|
|
/***** Adjustment 10:
|
|
|
|
|
--------------
|
2019-04-03 21:49:10 +02:00
|
|
|
|
Just after login with all checks OK ==> go to default action *****/
|
2019-02-18 14:41:46 +01:00
|
|
|
|
if (JustAfterLogin)
|
2019-02-14 19:22:38 +01:00
|
|
|
|
{
|
2022-11-06 18:11:10 +01:00
|
|
|
|
Gbl.Action.Act = ActLst_DEFAULT_ACTION_AFTER_LOGIN;
|
2019-02-18 14:41:46 +01:00
|
|
|
|
Tab_SetCurrentTab ();
|
2019-02-14 19:22:38 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|