2021-03-07 21:21:04 +01:00
|
|
|
|
// swad_scope.c: scope (platform, center, degree, course...)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2021-02-09 12:43:45 +01:00
|
|
|
|
Copyright (C) 1999-2021 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 3 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 *********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-11-23 00:44:39 +01:00
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_config.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
2019-11-05 08:46:38 +01:00
|
|
|
|
#include "swad_HTML.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_parameter.h"
|
|
|
|
|
#include "swad_scope.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/** Put a selector to choice between ranges when getting users for listing ***/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-27 03:16:55 +02:00
|
|
|
|
void Sco_PutSelectorScope (const char *ParamName,HTM_SubmitOnChange_t SubmitOnChange)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-12-15 23:54:57 +01:00
|
|
|
|
extern const char *The_ClassInput[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_System;
|
|
|
|
|
extern const char *Txt_Country;
|
|
|
|
|
extern const char *Txt_Institution;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_Center;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Degree;
|
|
|
|
|
extern const char *Txt_Course;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
HieLvl_Level_t Scope;
|
2019-11-06 08:59:15 +01:00
|
|
|
|
unsigned ScopeUnsigned;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool WriteScope;
|
|
|
|
|
|
2020-04-27 03:16:55 +02:00
|
|
|
|
HTM_SELECT_Begin (SubmitOnChange,
|
2021-12-15 23:54:57 +01:00
|
|
|
|
"id=\"%s\" name=\"%s\" class=\"%s\"",
|
|
|
|
|
ParamName,ParamName,The_ClassInput[Gbl.Prefs.Theme]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-11-09 14:41:13 +01:00
|
|
|
|
for (Scope = (HieLvl_Level_t) 0;
|
|
|
|
|
Scope <= (HieLvl_Level_t) (HieLvl_NUM_LEVELS - 1);
|
|
|
|
|
Scope++)
|
|
|
|
|
if ((Gbl.Scope.Allowed & (1 << Scope)))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-11-09 14:41:13 +01:00
|
|
|
|
/* Don't put forbidden options in selectable list */
|
|
|
|
|
WriteScope = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
switch (Scope)
|
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_SYS:
|
2021-11-09 14:41:13 +01:00
|
|
|
|
WriteScope = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_CTY:
|
2021-11-09 14:41:13 +01:00
|
|
|
|
if (Gbl.Hierarchy.Cty.CtyCod > 0)
|
|
|
|
|
WriteScope = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_INS:
|
2021-11-09 14:41:13 +01:00
|
|
|
|
if (Gbl.Hierarchy.Ins.InsCod > 0)
|
|
|
|
|
WriteScope = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_CTR:
|
2021-11-09 14:41:13 +01:00
|
|
|
|
if (Gbl.Hierarchy.Ctr.CtrCod > 0)
|
|
|
|
|
WriteScope = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_DEG:
|
2021-11-09 14:41:13 +01:00
|
|
|
|
if (Gbl.Hierarchy.Deg.DegCod > 0)
|
|
|
|
|
WriteScope = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_CRS:
|
2021-11-09 14:41:13 +01:00
|
|
|
|
if (Gbl.Hierarchy.Level == HieLvl_CRS)
|
|
|
|
|
WriteScope = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongScopeExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
2021-11-09 14:41:13 +01:00
|
|
|
|
|
|
|
|
|
if (WriteScope)
|
|
|
|
|
{
|
|
|
|
|
/***** Write allowed option *****/
|
|
|
|
|
ScopeUnsigned = (unsigned) Scope;
|
|
|
|
|
switch (Scope)
|
|
|
|
|
{
|
|
|
|
|
case HieLvl_SYS:
|
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned,
|
|
|
|
|
Gbl.Scope.Current == Scope,false,
|
|
|
|
|
"%s: %s",
|
|
|
|
|
Txt_System,
|
|
|
|
|
Cfg_PLATFORM_SHORT_NAME);
|
|
|
|
|
break;
|
|
|
|
|
case HieLvl_CTY:
|
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned,
|
|
|
|
|
Gbl.Scope.Current == Scope,false,
|
|
|
|
|
"%s: %s",
|
|
|
|
|
Txt_Country,
|
|
|
|
|
Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
|
|
|
|
|
break;
|
|
|
|
|
case HieLvl_INS:
|
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned,
|
|
|
|
|
Gbl.Scope.Current == Scope,false,
|
|
|
|
|
"%s: %s",
|
|
|
|
|
Txt_Institution,
|
|
|
|
|
Gbl.Hierarchy.Ins.ShrtName);
|
|
|
|
|
break;
|
|
|
|
|
case HieLvl_CTR:
|
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned,
|
|
|
|
|
Gbl.Scope.Current == Scope,false,
|
|
|
|
|
"%s: %s",
|
|
|
|
|
Txt_Center,
|
|
|
|
|
Gbl.Hierarchy.Ctr.ShrtName);
|
|
|
|
|
break;
|
|
|
|
|
case HieLvl_DEG:
|
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned,
|
|
|
|
|
Gbl.Scope.Current == Scope,false,
|
|
|
|
|
"%s: %s",
|
|
|
|
|
Txt_Degree,
|
|
|
|
|
Gbl.Hierarchy.Deg.ShrtName);
|
|
|
|
|
break;
|
|
|
|
|
case HieLvl_CRS:
|
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned,
|
|
|
|
|
Gbl.Scope.Current == Scope,false,
|
|
|
|
|
"%s: %s",
|
|
|
|
|
Txt_Course,
|
|
|
|
|
Gbl.Hierarchy.Crs.ShrtName);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Err_WrongScopeExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-05 08:46:38 +01:00
|
|
|
|
HTM_SELECT_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-11-27 14:10:31 +01:00
|
|
|
|
/********************** Put hidden parameter scope ***************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
void Sco_PutParamCurrentScope (void *Scope)
|
2019-04-11 09:55:35 +02:00
|
|
|
|
{
|
2020-04-09 21:36:21 +02:00
|
|
|
|
if (Scope)
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Sco_PutParamScope ("ScopeUsr",*((HieLvl_Level_t *) Scope));
|
2019-04-11 09:55:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
void Sco_PutParamScope (const char *ParamName,HieLvl_Level_t Scope)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,ParamName,(unsigned) Scope);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-11-27 14:10:31 +01:00
|
|
|
|
/*************************** Get parameter scope *****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-06-24 20:34:58 +02:00
|
|
|
|
void Sco_GetScope (const char *ParamName)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-01-29 12:42:19 +01:00
|
|
|
|
/***** Get parameter with scope *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Current = (HieLvl_Level_t)
|
2017-01-29 21:41:08 +01:00
|
|
|
|
Par_GetParToUnsignedLong (ParamName,
|
|
|
|
|
0,
|
2021-05-27 23:30:16 +02:00
|
|
|
|
HieLvl_NUM_LEVELS - 1,
|
|
|
|
|
(unsigned long) HieLvl_UNK);
|
2016-11-27 14:10:31 +01:00
|
|
|
|
|
|
|
|
|
/***** Adjust scope avoiding impossible or forbidden scopes *****/
|
|
|
|
|
Sco_AdjustScope ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Adjust scope avoiding impossible or forbidden scopes ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Sco_AdjustScope (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Is scope is unknow, use default scope *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Gbl.Scope.Current == HieLvl_UNK)
|
2016-06-24 20:34:58 +02:00
|
|
|
|
Gbl.Scope.Current = Gbl.Scope.Default;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-06-24 20:34:58 +02:00
|
|
|
|
/***** Avoid impossible scopes *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Gbl.Scope.Current == HieLvl_CRS && Gbl.Hierarchy.Crs.CrsCod <= 0)
|
|
|
|
|
Gbl.Scope.Current = HieLvl_DEG;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Gbl.Scope.Current == HieLvl_DEG && Gbl.Hierarchy.Deg.DegCod <= 0)
|
|
|
|
|
Gbl.Scope.Current = HieLvl_CTR;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Gbl.Scope.Current == HieLvl_CTR && Gbl.Hierarchy.Ctr.CtrCod <= 0)
|
|
|
|
|
Gbl.Scope.Current = HieLvl_INS;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Gbl.Scope.Current == HieLvl_INS && Gbl.Hierarchy.Ins.InsCod <= 0)
|
|
|
|
|
Gbl.Scope.Current = HieLvl_CTY;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Gbl.Scope.Current == HieLvl_CTY && Gbl.Hierarchy.Cty.CtyCod <= 0)
|
|
|
|
|
Gbl.Scope.Current = HieLvl_SYS;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-06-24 20:34:58 +02:00
|
|
|
|
/***** Avoid forbidden scopes *****/
|
|
|
|
|
if ((Gbl.Scope.Allowed & (1 << Gbl.Scope.Current)) == 0)
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Current = HieLvl_UNK;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Set allowed scopes when listing guests *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Sco_SetScopesForListingGuests (void)
|
|
|
|
|
{
|
2017-06-04 18:18:54 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-04-07 21:44:24 +02:00
|
|
|
|
case Rol_CTR_ADM:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_CTR;
|
|
|
|
|
Gbl.Scope.Default = HieLvl_CTR;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-04-07 21:44:24 +02:00
|
|
|
|
case Rol_INS_ADM:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_INS |
|
|
|
|
|
1 << HieLvl_CTR;
|
|
|
|
|
Gbl.Scope.Default = HieLvl_INS;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-04-07 21:44:24 +02:00
|
|
|
|
case Rol_SYS_ADM:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_SYS |
|
|
|
|
|
1 << HieLvl_CTY |
|
|
|
|
|
1 << HieLvl_INS |
|
|
|
|
|
1 << HieLvl_CTR;
|
|
|
|
|
Gbl.Scope.Default = HieLvl_SYS;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Gbl.Scope.Allowed = 0;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Default = HieLvl_UNK;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Set allowed scopes when listing students *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Sco_SetScopesForListingStudents (void)
|
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Default = HieLvl_CRS;
|
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:
|
2017-05-22 20:37:46 +02:00
|
|
|
|
case Rol_NET:
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_TCH:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_CRS;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-04-07 21:44:24 +02:00
|
|
|
|
case Rol_DEG_ADM:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_DEG |
|
|
|
|
|
1 << HieLvl_CRS;
|
2015-09-20 19:20:05 +02:00
|
|
|
|
break;
|
|
|
|
|
case Rol_CTR_ADM:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_CTR |
|
|
|
|
|
1 << HieLvl_DEG |
|
|
|
|
|
1 << HieLvl_CRS;
|
2015-09-20 19:20:05 +02:00
|
|
|
|
break;
|
|
|
|
|
case Rol_INS_ADM:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_INS |
|
|
|
|
|
1 << HieLvl_CTR |
|
|
|
|
|
1 << HieLvl_DEG |
|
|
|
|
|
1 << HieLvl_CRS;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-04-07 21:44:24 +02:00
|
|
|
|
case Rol_SYS_ADM:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_SYS |
|
|
|
|
|
1 << HieLvl_CTY |
|
|
|
|
|
1 << HieLvl_INS |
|
|
|
|
|
1 << HieLvl_CTR |
|
|
|
|
|
1 << HieLvl_DEG |
|
|
|
|
|
1 << HieLvl_CRS;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Gbl.Scope.Allowed = 0;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Default = HieLvl_UNK;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-23 00:44:39 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-10-27 15:06:11 +02:00
|
|
|
|
/*********************** Get scope from unsigned string **********************/
|
2015-11-23 00:44:39 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
HieLvl_Level_t Sco_GetScopeFromUnsignedStr (const char *UnsignedStr)
|
2015-11-23 00:44:39 +01:00
|
|
|
|
{
|
|
|
|
|
unsigned UnsignedNum;
|
|
|
|
|
|
|
|
|
|
if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1)
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (UnsignedNum < HieLvl_NUM_LEVELS)
|
|
|
|
|
return (HieLvl_Level_t) UnsignedNum;
|
2015-11-23 00:44:39 +01:00
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
return HieLvl_UNK;
|
2015-11-23 00:44:39 +01:00
|
|
|
|
}
|
2016-10-27 15:06:11 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Get scope from database string **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
HieLvl_Level_t Sco_GetScopeFromDBStr (const char *ScopeDBStr)
|
2016-10-27 15:06:11 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
HieLvl_Level_t Scope;
|
2016-10-27 15:06:11 +02:00
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
for (Scope = (HieLvl_Level_t) 0;
|
|
|
|
|
Scope <= (HieLvl_Level_t) (HieLvl_NUM_LEVELS - 1);
|
2016-10-27 15:06:11 +02:00
|
|
|
|
Scope++)
|
2019-04-01 23:15:17 +02:00
|
|
|
|
if (!strcmp (Sco_GetDBStrFromScope (Scope),ScopeDBStr))
|
2016-10-27 15:06:11 +02:00
|
|
|
|
return Scope;
|
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
return HieLvl_UNK;
|
2016-10-27 15:06:11 +02:00
|
|
|
|
}
|
2019-04-01 23:15:17 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Get scope from database string **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
const char *Sco_GetDBStrFromScope (HieLvl_Level_t Scope)
|
2019-04-01 23:15:17 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
static const char *Sco_ScopeDB[HieLvl_NUM_LEVELS] =
|
2019-04-01 23:15:17 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
[HieLvl_UNK] = "Unk",
|
|
|
|
|
[HieLvl_SYS] = "Sys",
|
|
|
|
|
[HieLvl_CTY] = "Cty",
|
|
|
|
|
[HieLvl_INS] = "Ins",
|
|
|
|
|
[HieLvl_CTR] = "Ctr",
|
|
|
|
|
[HieLvl_DEG] = "Deg",
|
|
|
|
|
[HieLvl_CRS] = "Crs",
|
2019-04-01 23:15:17 +02:00
|
|
|
|
};
|
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Scope >= HieLvl_NUM_LEVELS)
|
|
|
|
|
Scope = HieLvl_UNK;
|
2019-04-01 23:15:17 +02:00
|
|
|
|
|
|
|
|
|
return Sco_ScopeDB[Scope];
|
|
|
|
|
}
|
2021-09-10 10:19:46 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Get current scope code *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
long Sco_GetCurrentCod (void)
|
|
|
|
|
{
|
|
|
|
|
switch (Gbl.Scope.Current)
|
|
|
|
|
{
|
|
|
|
|
case HieLvl_SYS:
|
|
|
|
|
return -1L;
|
|
|
|
|
case HieLvl_CTY:
|
|
|
|
|
return Gbl.Hierarchy.Cty.CtyCod;
|
|
|
|
|
case HieLvl_INS:
|
|
|
|
|
return Gbl.Hierarchy.Ins.InsCod;
|
|
|
|
|
case HieLvl_CTR:
|
|
|
|
|
return Gbl.Hierarchy.Ctr.CtrCod;
|
|
|
|
|
case HieLvl_DEG:
|
|
|
|
|
return Gbl.Hierarchy.Deg.DegCod;
|
|
|
|
|
case HieLvl_CRS:
|
|
|
|
|
return Gbl.Hierarchy.Crs.CrsCod;
|
|
|
|
|
default:
|
|
|
|
|
Err_WrongScopeExit ();
|
|
|
|
|
return -1L; // Not reached
|
|
|
|
|
}
|
|
|
|
|
}
|