swad-core/swad_hierarchy.c

800 lines
25 KiB
C
Raw Normal View History

// swad_hierarchy.c: hierarchy (system, institution, center, degree, course)
2016-12-10 22:21:04 +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
2016-12-10 22:21:04 +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-11-18 14:21:01 +01:00
#define _GNU_SOURCE // For asprintf
2019-12-29 20:11:57 +01:00
#include <stdio.h> // For asprintf
2020-01-03 22:16:51 +01:00
#include <stdlib.h> // For free
2016-12-10 22:21:04 +01:00
2019-12-30 12:25:45 +01:00
#include "swad_database.h"
2018-11-09 20:47:39 +01:00
#include "swad_form.h"
2016-12-10 22:21:04 +01:00
#include "swad_global.h"
2021-02-11 22:57:09 +01:00
#include "swad_hierarchy.h"
2019-10-23 19:05:05 +02:00
#include "swad_HTML.h"
2016-12-10 22:21:04 +01:00
#include "swad_logo.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/*************************** Public constants ********************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private types *********************************/
/*****************************************************************************/
/*****************************************************************************/
2019-12-30 12:25:45 +01:00
/*************************** Private constants *******************************/
/*****************************************************************************/
/*****************************************************************************/
/*************************** Private prototypes ******************************/
2016-12-10 22:21:04 +01:00
/*****************************************************************************/
2017-03-27 01:14:38 +02:00
/*****************************************************************************/
/********** List pending institutions, centers, degrees and courses **********/
2017-03-27 01:14:38 +02:00
/*****************************************************************************/
void Hie_SeePending (void)
{
/***** List countries with pending institutions *****/
Cty_SeeCtyWithPendingInss ();
/***** List institutions with pending centers *****/
2017-03-27 01:14:38 +02:00
Ins_SeeInsWithPendingCtrs ();
/***** List centers with pending degrees *****/
2017-03-27 01:14:38 +02:00
Ctr_SeeCtrWithPendingDegs ();
/***** List degrees with pending courses *****/
Deg_SeeDegWithPendingCrss ();
}
2016-12-10 22:21:04 +01:00
/*****************************************************************************/
/*** Write menu to select country, institution, center, degree and course ****/
2016-12-10 22:21:04 +01:00
/*****************************************************************************/
void Hie_WriteMenuHierarchy (void)
{
extern const char *Txt_Country;
extern const char *Txt_Institution;
extern const char *Txt_Center;
2016-12-10 22:21:04 +01:00
extern const char *Txt_Degree;
extern const char *Txt_Course;
2019-10-20 22:00:28 +02:00
/***** Begin table *****/
2019-10-23 19:05:05 +02:00
HTM_TABLE_BeginCenterPadding (2);
2016-12-10 22:21:04 +01:00
/***** Write a 1st selector
with all the countries *****/
2019-10-23 19:05:05 +02:00
HTM_TR_Begin (NULL);
2019-10-07 15:15:55 +02:00
2019-12-27 21:10:39 +01:00
/* Label */
2019-12-27 15:45:19 +01:00
Frm_LabelColumn ("RT","cty",Txt_Country);
2019-10-07 15:15:55 +02:00
2019-12-27 21:10:39 +01:00
/* Data */
2019-12-26 22:29:04 +01:00
HTM_TD_Begin ("class=\"LT\"");
2016-12-10 22:21:04 +01:00
Cty_WriteSelectorOfCountry ();
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 15:15:55 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2016-12-10 22:21:04 +01:00
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Cty.CtyCod > 0)
2016-12-10 22:21:04 +01:00
{
/***** Write a 2nd selector
with the institutions of selected country *****/
2019-10-23 19:05:05 +02:00
HTM_TR_Begin (NULL);
2019-10-07 15:15:55 +02:00
2019-12-27 21:10:39 +01:00
/* Label */
2019-12-27 15:45:19 +01:00
Frm_LabelColumn ("RT","ins",Txt_Institution);
2019-10-07 15:15:55 +02:00
2019-12-27 21:10:39 +01:00
/* Data */
2019-12-26 22:29:04 +01:00
HTM_TD_Begin ("class=\"LT\"");
2016-12-10 22:21:04 +01:00
Ins_WriteSelectorOfInstitution ();
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 15:15:55 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2016-12-10 22:21:04 +01:00
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ins.InsCod > 0)
2016-12-10 22:21:04 +01:00
{
/***** Write a 3rd selector
with all the centers of selected institution *****/
2019-10-23 19:05:05 +02:00
HTM_TR_Begin (NULL);
2019-10-07 15:15:55 +02:00
2019-12-27 21:10:39 +01:00
/* Label */
Frm_LabelColumn ("RT","ctr",Txt_Center);
2019-10-07 15:15:55 +02:00
2019-12-27 21:10:39 +01:00
/* Data */
2019-12-26 22:29:04 +01:00
HTM_TD_Begin ("class=\"LT\"");
Ctr_WriteSelectorOfCenter ();
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 15:15:55 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2016-12-10 22:21:04 +01:00
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ctr.CtrCod > 0)
2016-12-10 22:21:04 +01:00
{
/***** Write a 4th selector
with all the degrees of selected center *****/
2019-10-23 19:05:05 +02:00
HTM_TR_Begin (NULL);
2019-10-07 15:15:55 +02:00
2019-12-27 21:10:39 +01:00
/* Label */
2019-12-27 15:45:19 +01:00
Frm_LabelColumn ("RT","deg",Txt_Degree);
2019-10-07 15:15:55 +02:00
2019-12-27 21:10:39 +01:00
/* Data */
2019-12-26 22:29:04 +01:00
HTM_TD_Begin ("class=\"LT\"");
2016-12-10 22:21:04 +01:00
Deg_WriteSelectorOfDegree ();
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 15:15:55 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2016-12-10 22:21:04 +01:00
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Deg.DegCod > 0)
2016-12-10 22:21:04 +01:00
{
/***** Write a 5th selector
with all the courses of selected degree *****/
2019-10-23 19:05:05 +02:00
HTM_TR_Begin (NULL);
2019-10-07 15:15:55 +02:00
2019-12-27 21:10:39 +01:00
/* Label */
2019-12-27 15:45:19 +01:00
Frm_LabelColumn ("RT","crs",Txt_Course);
2019-10-07 15:15:55 +02:00
2019-12-27 21:10:39 +01:00
/* Data */
2019-12-26 22:29:04 +01:00
HTM_TD_Begin ("class=\"LT\"");
2016-12-10 22:21:04 +01:00
Crs_WriteSelectorOfCourse ();
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 15:15:55 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2016-12-10 22:21:04 +01:00
}
}
}
}
2017-06-12 14:16:33 +02:00
/***** End table *****/
2019-10-23 19:05:05 +02:00
HTM_TABLE_End ();
2016-12-10 22:21:04 +01:00
}
/*****************************************************************************/
/************* Write hierarchy breadcrumb in the top of the page *************/
/*****************************************************************************/
2018-10-09 17:56:18 +02:00
void Hie_WriteHierarchyInBreadcrumb (void)
2016-12-10 22:21:04 +01:00
{
extern const char *The_ClassBreadcrumb[The_NUM_THEMES];
extern const char *Txt_System;
extern const char *Txt_Country;
extern const char *Txt_Institution;
extern const char *Txt_Center;
2016-12-10 22:21:04 +01:00
extern const char *Txt_Degree;
const char *ClassTxt = The_ClassBreadcrumb[Gbl.Prefs.Theme];
2019-11-18 14:21:01 +01:00
char *ClassLink;
/***** Create CSS class of links *****/
if (asprintf (&ClassLink,"BT_LINK %s",ClassTxt) < 0)
Lay_NotEnoughMemoryExit ();
2016-12-10 22:21:04 +01:00
/***** Form to go to the system *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC %s\"",ClassTxt);
2019-11-14 08:59:11 +01:00
HTM_NBSP ();
2016-12-10 22:21:04 +01:00
Frm_BeginFormGoTo (ActMnu);
2019-11-03 13:19:32 +01:00
Par_PutHiddenParamUnsigned (NULL,"NxtTab",(unsigned) TabSys);
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (Txt_System,ClassLink,NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (Txt_System);
2019-11-18 14:21:01 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2016-12-10 22:21:04 +01:00
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected...
2016-12-10 22:21:04 +01:00
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC %s\"",ClassTxt);
2016-12-10 22:21:04 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ("&nbsp;&gt;&nbsp;");
2016-12-10 22:21:04 +01:00
/***** Form to go to see institutions of this country *****/
Frm_BeginFormGoTo (ActSeeIns);
2019-04-03 20:57:04 +02:00
Cty_PutParamCtyCod (Gbl.Hierarchy.Cty.CtyCod);
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language],ClassLink,NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
2019-11-18 14:21:01 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2016-12-10 22:21:04 +01:00
}
else
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC BC_SEMIOFF %s\"",ClassTxt);
2016-12-10 22:21:04 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ("&nbsp;&gt;&nbsp;");
2016-12-10 22:21:04 +01:00
/***** Form to go to select countries *****/
Frm_BeginFormGoTo (ActSeeCty);
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (Txt_Country,ClassLink,NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (Txt_Country);
2019-11-18 14:21:01 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2016-12-10 22:21:04 +01:00
}
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected...
2016-12-10 22:21:04 +01:00
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC %s\"",ClassTxt);
2016-12-10 22:21:04 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ("&nbsp;&gt;&nbsp;");
2016-12-10 22:21:04 +01:00
/***** Form to see centers of this institution *****/
Frm_BeginFormGoTo (ActSeeCtr);
2019-04-03 20:57:04 +02:00
Ins_PutParamInsCod (Gbl.Hierarchy.Ins.InsCod);
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (Gbl.Hierarchy.Ins.FullName,ClassLink,NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (Gbl.Hierarchy.Ins.ShrtName);
2019-11-18 14:21:01 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2016-12-10 22:21:04 +01:00
}
2019-04-03 20:57:04 +02:00
else if (Gbl.Hierarchy.Cty.CtyCod > 0)
2016-12-10 22:21:04 +01:00
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC BC_SEMIOFF %s\"",ClassTxt);
2016-12-10 22:21:04 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ("&nbsp;&gt;&nbsp;");
2016-12-10 22:21:04 +01:00
/***** Form to go to select institutions *****/
Frm_BeginFormGoTo (ActSeeIns);
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (Txt_Institution,ClassLink,NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (Txt_Institution);
2019-11-18 14:21:01 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2016-12-10 22:21:04 +01:00
}
else
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC BC_OFF %s\"",ClassTxt);
2016-12-10 22:21:04 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ("&nbsp;&gt;&nbsp;");
2016-12-10 22:21:04 +01:00
/***** Hidden institution *****/
2019-11-10 12:36:37 +01:00
HTM_Txt (Txt_Institution);
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2016-12-10 22:21:04 +01:00
}
if (Gbl.Hierarchy.Ctr.CtrCod > 0) // Center selected...
2016-12-10 22:21:04 +01:00
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC %s\"",ClassTxt);
2016-12-10 22:21:04 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ("&nbsp;&gt;&nbsp;");
2016-12-10 22:21:04 +01:00
/***** Form to see degrees of this center *****/
Frm_BeginFormGoTo (ActSeeDeg);
2019-04-03 20:57:04 +02:00
Ctr_PutParamCtrCod (Gbl.Hierarchy.Ctr.CtrCod);
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (Gbl.Hierarchy.Ctr.FullName,ClassLink,NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (Gbl.Hierarchy.Ctr.ShrtName);
2019-11-18 14:21:01 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2016-12-10 22:21:04 +01:00
}
2019-04-03 20:57:04 +02:00
else if (Gbl.Hierarchy.Ins.InsCod > 0)
2016-12-10 22:21:04 +01:00
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC BC_SEMIOFF %s\"",ClassTxt);
2016-12-10 22:21:04 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ("&nbsp;&gt;&nbsp;");
2016-12-10 22:21:04 +01:00
/***** Form to go to select centers *****/
Frm_BeginFormGoTo (ActSeeCtr);
HTM_BUTTON_SUBMIT_Begin (Txt_Center,ClassLink,NULL);
HTM_Txt (Txt_Center);
2019-11-18 14:21:01 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2016-12-10 22:21:04 +01:00
}
else
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC BC_OFF %s\"",ClassTxt);
2016-12-10 22:21:04 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ("&nbsp;&gt;&nbsp;");
2016-12-10 22:21:04 +01:00
/***** Hidden center *****/
HTM_Txt (Txt_Center);
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2016-12-10 22:21:04 +01:00
}
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Deg.DegCod > 0) // Degree selected...
2016-12-10 22:21:04 +01:00
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC %s\"",ClassTxt);
2016-12-10 22:21:04 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ("&nbsp;&gt;&nbsp;");
2016-12-10 22:21:04 +01:00
/***** Form to go to see courses of this degree *****/
Frm_BeginFormGoTo (ActSeeCrs);
2019-04-03 20:57:04 +02:00
Deg_PutParamDegCod (Gbl.Hierarchy.Deg.DegCod);
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (Gbl.Hierarchy.Deg.FullName,ClassLink,NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (Gbl.Hierarchy.Deg.ShrtName);
2019-11-18 14:21:01 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2016-12-10 22:21:04 +01:00
}
2019-04-03 20:57:04 +02:00
else if (Gbl.Hierarchy.Ctr.CtrCod > 0)
2016-12-10 22:21:04 +01:00
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC BC_SEMIOFF %s\"",ClassTxt);
2016-12-10 22:21:04 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ("&nbsp;&gt;&nbsp;");
2016-12-10 22:21:04 +01:00
/***** Form to go to select degrees *****/
Frm_BeginFormGoTo (ActSeeDeg);
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (Txt_Degree,ClassLink,NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (Txt_Degree);
2019-11-18 14:21:01 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2016-12-10 22:21:04 +01:00
}
else
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC BC_OFF %s\"",ClassTxt);
2016-12-10 22:21:04 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ("&nbsp;&gt;&nbsp;");
2016-12-10 22:21:04 +01:00
/***** Hidden degree *****/
2019-11-10 12:36:37 +01:00
HTM_Txt (Txt_Degree);
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2016-12-10 22:21:04 +01:00
}
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"BC%s %s\"",
2021-02-11 22:57:09 +01:00
(Gbl.Hierarchy.Level == Hie_Lvl_CRS) ? "" :
2019-10-24 00:04:40 +02:00
((Gbl.Hierarchy.Deg.DegCod > 0) ? " BC_SEMIOFF" :
" BC_OFF"),
ClassTxt);
2016-12-10 22:21:04 +01:00
/***** Separator *****/
2019-11-11 00:15:44 +01:00
HTM_Txt ("&nbsp;&gt;&nbsp;");
2016-12-10 22:21:04 +01:00
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2019-11-18 14:21:01 +01:00
/***** Free memory used for CSS class of links *****/
free (ClassLink);
2016-12-10 22:21:04 +01:00
}
/*****************************************************************************/
/*************** Write course full name in the top of the page ***************/
/*****************************************************************************/
void Hie_WriteBigNameCtyInsCtrDegCrs (void)
{
extern const char *The_ClassCourse[The_NUM_THEMES];
extern const char *Txt_TAGLINE;
2019-11-11 10:59:24 +01:00
HTM_TxtF ("<h1 id=\"main_title\" class=\"%s\">",
The_ClassCourse[Gbl.Prefs.Theme]);
2016-12-10 22:21:04 +01:00
/***** Logo *****/
2019-04-03 20:57:04 +02:00
switch (Gbl.Hierarchy.Level)
{
2021-02-11 22:57:09 +01:00
case Hie_Lvl_SYS: // System
2019-10-29 21:41:54 +01:00
Ico_PutIcon ("swad64x64.png",Cfg_PLATFORM_FULL_NAME,"ICO40x40 TOP_LOGO");
2019-04-03 20:57:04 +02:00
break;
2021-02-11 22:57:09 +01:00
case Hie_Lvl_CTY: // Country
2019-04-03 20:57:04 +02:00
Cty_DrawCountryMap (&Gbl.Hierarchy.Cty,"COUNTRY_MAP_TITLE");
break;
2021-02-11 22:57:09 +01:00
case Hie_Lvl_INS: // Institution
Lgo_DrawLogo (Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod,
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.ShrtName,40,"TOP_LOGO",false);
break;
case Hie_Lvl_CTR: // Center
2021-02-11 22:57:09 +01:00
Lgo_DrawLogo (Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.ShrtName,40,"TOP_LOGO",false);
break;
2021-02-11 22:57:09 +01:00
case Hie_Lvl_DEG: // Degree
case Hie_Lvl_CRS: // Course
Lgo_DrawLogo (Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod,
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Deg.ShrtName,40,"TOP_LOGO",false);
break;
default:
break;
}
2016-12-10 22:21:04 +01:00
/***** Text *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("id=\"big_name_container\"");
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Cty.CtyCod > 0)
2019-10-23 20:07:56 +02:00
{
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("id=\"big_full_name\"");
2021-02-11 22:57:09 +01:00
HTM_Txt ( (Gbl.Hierarchy.Level == Hie_Lvl_CRS) ? Gbl.Hierarchy.Crs.FullName :// Full name
((Gbl.Hierarchy.Level == Hie_Lvl_DEG) ? Gbl.Hierarchy.Deg.FullName :
((Gbl.Hierarchy.Level == Hie_Lvl_CTR) ? Gbl.Hierarchy.Ctr.FullName :
((Gbl.Hierarchy.Level == Hie_Lvl_INS) ? Gbl.Hierarchy.Ins.FullName :
2019-10-23 20:07:56 +02:00
Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]))));
HTM_DIV_End ();
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"NOT_SHOWN\"");
2019-11-11 00:15:44 +01:00
HTM_Txt (" / "); // To separate
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("id=\"big_short_name\"");
2021-02-11 22:57:09 +01:00
HTM_Txt ( (Gbl.Hierarchy.Level == Hie_Lvl_CRS) ? Gbl.Hierarchy.Crs.ShrtName :// Short name
((Gbl.Hierarchy.Level == Hie_Lvl_DEG) ? Gbl.Hierarchy.Deg.ShrtName :
((Gbl.Hierarchy.Level == Hie_Lvl_CTR) ? Gbl.Hierarchy.Ctr.ShrtName :
((Gbl.Hierarchy.Level == Hie_Lvl_INS) ? Gbl.Hierarchy.Ins.ShrtName :
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]))));
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
}
2016-12-10 22:21:04 +01:00
else // No country specified ==> home page
2019-10-23 20:07:56 +02:00
{
2019-11-11 00:15:44 +01:00
HTM_DIV_Begin ("id=\"big_full_name\""); // Full name
2019-11-11 10:59:24 +01:00
HTM_TxtF ("%s:&nbsp;%s",Cfg_PLATFORM_SHORT_NAME,Txt_TAGLINE);
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"NOT_SHOWN\"");
2019-11-11 00:15:44 +01:00
HTM_Txt (" / "); // To separate
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2019-10-24 00:04:40 +02:00
2019-11-11 00:15:44 +01:00
HTM_DIV_Begin ("id=\"big_short_name\""); // Short name
HTM_Txt (Cfg_PLATFORM_SHORT_NAME);
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
}
HTM_DIV_End ();
2019-11-11 00:15:44 +01:00
HTM_TxtF ("</h1>");
2016-12-10 22:21:04 +01:00
}
2019-04-01 23:15:17 +02:00
/*****************************************************************************/
/**************** Copy last hierarchy to current hierarchy *******************/
/*****************************************************************************/
void Hie_SetHierarchyFromUsrLastHierarchy (void)
{
/***** Initialize all codes to -1 *****/
2019-04-03 20:57:04 +02:00
Hie_ResetHierarchy ();
2019-04-01 23:15:17 +02:00
/***** Copy last hierarchy scope and code to current hierarchy *****/
switch (Gbl.Usrs.Me.UsrLast.LastHie.Scope)
{
2021-02-11 22:57:09 +01:00
case Hie_Lvl_CTY: // Country
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Cty.CtyCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
2019-04-01 23:15:17 +02:00
break;
2021-02-11 22:57:09 +01:00
case Hie_Lvl_INS: // Institution
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.InsCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
2019-04-01 23:15:17 +02:00
break;
case Hie_Lvl_CTR: // Center
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.CtrCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
2019-04-01 23:15:17 +02:00
break;
2021-02-11 22:57:09 +01:00
case Hie_Lvl_DEG: // Degree
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Deg.DegCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
2019-04-01 23:15:17 +02:00
break;
2021-02-11 22:57:09 +01:00
case Hie_Lvl_CRS: // Course
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
2019-04-01 23:15:17 +02:00
break;
default:
break;
}
/****** Initialize again current course, degree, center... ******/
2019-04-01 23:15:17 +02:00
Hie_InitHierarchy ();
}
2016-12-10 22:21:04 +01:00
/*****************************************************************************/
/**** Initialize current country, institution, center, degree and course *****/
2016-12-10 22:21:04 +01:00
/*****************************************************************************/
void Hie_InitHierarchy (void)
{
/***** If course code is available, get course data *****/
2019-04-04 10:45:15 +02:00
if (Gbl.Hierarchy.Crs.CrsCod > 0)
2016-12-10 22:21:04 +01:00
{
2020-01-05 14:09:28 +01:00
if (Crs_GetDataOfCourseByCod (&Gbl.Hierarchy.Crs)) // Course found
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Deg.DegCod = Gbl.Hierarchy.Crs.DegCod;
2016-12-10 22:21:04 +01:00
else
2019-04-03 20:57:04 +02:00
Hie_ResetHierarchy ();
2016-12-10 22:21:04 +01:00
}
/***** If degree code is available, get degree data *****/
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Deg.DegCod > 0)
2016-12-10 22:21:04 +01:00
{
2020-01-05 12:52:03 +01:00
if (Deg_GetDataOfDegreeByCod (&Gbl.Hierarchy.Deg)) // Degree found
2016-12-10 22:21:04 +01:00
{
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Ctr.CtrCod = Gbl.Hierarchy.Deg.CtrCod;
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.InsCod = Deg_GetInsCodOfDegreeByCod (Gbl.Hierarchy.Deg.DegCod);
2016-12-10 22:21:04 +01:00
}
else
2019-04-03 20:57:04 +02:00
Hie_ResetHierarchy ();
2016-12-10 22:21:04 +01:00
}
/***** If center code is available, get center data *****/
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ctr.CtrCod > 0)
2016-12-10 22:21:04 +01:00
{
if (Ctr_GetDataOfCenterByCod (&Gbl.Hierarchy.Ctr)) // Center found
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.InsCod = Gbl.Hierarchy.Ctr.InsCod;
2016-12-10 22:21:04 +01:00
else
2019-04-03 20:57:04 +02:00
Hie_ResetHierarchy ();
2016-12-10 22:21:04 +01:00
}
/***** If institution code is available, get institution data *****/
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ins.InsCod > 0)
2016-12-10 22:21:04 +01:00
{
2020-01-07 00:09:30 +01:00
if (Ins_GetDataOfInstitutionByCod (&Gbl.Hierarchy.Ins)) // Institution found
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Cty.CtyCod = Gbl.Hierarchy.Ins.CtyCod;
2016-12-10 22:21:04 +01:00
else
2019-04-03 20:57:04 +02:00
Hie_ResetHierarchy ();
2016-12-10 22:21:04 +01:00
}
/***** If country code is available, get country data *****/
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Cty.CtyCod > 0)
2020-01-07 22:07:06 +01:00
if (!Cty_GetDataOfCountryByCod (&Gbl.Hierarchy.Cty)) // Country not found
2019-04-03 20:57:04 +02:00
Hie_ResetHierarchy ();
2016-12-10 22:21:04 +01:00
2019-04-03 20:57:04 +02:00
/***** Set current hierarchy level and code
depending on course code, degree code, etc. *****/
2019-04-04 10:45:15 +02:00
if (Gbl.Hierarchy.Crs.CrsCod > 0) // Course selected
2019-04-03 20:57:04 +02:00
{
2021-02-11 22:57:09 +01:00
Gbl.Hierarchy.Level = Hie_Lvl_CRS;
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cod = Gbl.Hierarchy.Crs.CrsCod;
2019-04-03 20:57:04 +02:00
}
else if (Gbl.Hierarchy.Deg.DegCod > 0) // Degree selected
{
2021-02-11 22:57:09 +01:00
Gbl.Hierarchy.Level = Hie_Lvl_DEG;
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cod = Gbl.Hierarchy.Deg.DegCod;
2019-04-03 20:57:04 +02:00
}
else if (Gbl.Hierarchy.Ctr.CtrCod > 0) // Center selected
2019-04-03 20:57:04 +02:00
{
2021-02-11 22:57:09 +01:00
Gbl.Hierarchy.Level = Hie_Lvl_CTR;
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cod = Gbl.Hierarchy.Ctr.CtrCod;
2019-04-03 20:57:04 +02:00
}
else if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected
{
2021-02-11 22:57:09 +01:00
Gbl.Hierarchy.Level = Hie_Lvl_INS;
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cod = Gbl.Hierarchy.Ins.InsCod;
2019-04-03 20:57:04 +02:00
}
else if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected
{
2021-02-11 22:57:09 +01:00
Gbl.Hierarchy.Level = Hie_Lvl_CTY;
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cod = Gbl.Hierarchy.Cty.CtyCod;
2019-04-03 20:57:04 +02:00
}
else
{
2021-02-11 22:57:09 +01:00
Gbl.Hierarchy.Level = Hie_Lvl_SYS;
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cod = -1L;
2019-04-03 20:57:04 +02:00
}
2019-04-01 23:15:17 +02:00
2016-12-10 22:21:04 +01:00
/***** Initialize paths *****/
2021-02-11 22:57:09 +01:00
if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected
2016-12-10 22:21:04 +01:00
{
/***** Paths of course directories *****/
snprintf (Gbl.Crs.PathPriv,sizeof (Gbl.Crs.PathPriv),"%s/%ld",
2019-04-04 10:45:15 +02:00
Cfg_PATH_CRS_PRIVATE,Gbl.Hierarchy.Crs.CrsCod);
snprintf (Gbl.Crs.PathRelPubl,sizeof (Gbl.Crs.PathRelPubl),"%s/%ld",
2019-04-04 10:45:15 +02:00
Cfg_PATH_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod);
snprintf (Gbl.Crs.PathURLPubl,sizeof (Gbl.Crs.PathURLPubl),"%s/%ld",
2019-04-04 10:45:15 +02:00
Cfg_URL_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod);
2016-12-10 22:21:04 +01:00
/***** If any of the course directories does not exist, create it *****/
2019-04-04 10:45:15 +02:00
if (!Fil_CheckIfPathExists (Gbl.Crs.PathPriv))
Fil_CreateDirIfNotExists (Gbl.Crs.PathPriv);
if (!Fil_CheckIfPathExists (Gbl.Crs.PathRelPubl))
Fil_CreateDirIfNotExists (Gbl.Crs.PathRelPubl);
2016-12-10 22:21:04 +01:00
/***** Count number of groups in current course
(used in some actions) *****/
2019-04-04 10:45:15 +02:00
Gbl.Crs.Grps.NumGrps = Grp_CountNumGrpsInCurrentCrs ();
2016-12-10 22:21:04 +01:00
}
}
2019-04-03 20:57:04 +02:00
/*****************************************************************************/
/******* Reset current country, institution, center, degree and course *******/
2019-04-03 20:57:04 +02:00
/*****************************************************************************/
void Hie_ResetHierarchy (void)
{
/***** Country *****/
Gbl.Hierarchy.Cty.CtyCod = -1L;
/***** Institution *****/
Gbl.Hierarchy.Ins.InsCod = -1L;
/***** Center *****/
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.CtrCod = -1L;
Gbl.Hierarchy.Ctr.InsCod = -1L;
Gbl.Hierarchy.Ctr.PlcCod = -1L;
/***** Degree *****/
Gbl.Hierarchy.Deg.DegCod = -1L;
/***** Course *****/
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod = -1L;
2019-04-03 20:57:04 +02:00
/***** Hierarchy level and code *****/
2021-02-11 22:57:09 +01:00
Gbl.Hierarchy.Level = Hie_Lvl_UNK;
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Cod = -1L;
}
2019-12-30 12:25:45 +01:00
/*****************************************************************************/
/***** Write institutions, centers and degrees administrated by an admin *****/
2019-12-30 12:25:45 +01:00
/*****************************************************************************/
void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
{
extern const char *Txt_all_degrees;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumRow;
unsigned NumRows;
2021-02-11 23:27:48 +01:00
struct Hie_Hierarchy Hie;
2019-12-30 12:25:45 +01:00
/***** Get institutions, centers, degrees admin by user from database *****/
NumRows = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get institutions, centers, degrees"
" admin by a user",
"(SELECT %u AS S," // row[0]
"-1 AS Cod," // row[1]
"'' AS FullName" // row[2]
" FROM usr_admins"
" WHERE UsrCod=%ld"
" AND Scope='%s')"
" UNION "
"(SELECT %u AS S," // row[0]
"usr_admins.Cod," // row[1]
"ins_instits.FullName" // row[2]
" FROM usr_admins,"
"ins_instits"
" WHERE usr_admins.UsrCod=%ld"
" AND usr_admins.Scope='%s'"
" AND usr_admins.Cod=ins_instits.InsCod)"
" UNION "
"(SELECT %u AS S," // row[0]
"usr_admins.Cod," // row[1]
"ctr_centers.FullName" // row[2]
" FROM usr_admins,"
"ctr_centers"
" WHERE usr_admins.UsrCod=%ld"
" AND usr_admins.Scope='%s'"
" AND usr_admins.Cod=ctr_centers.CtrCod)"
" UNION "
"(SELECT %u AS S," // row[0]
"usr_admins.Cod," // row[1]
"deg_degrees.FullName" // row[2]
" FROM usr_admins,"
"deg_degrees"
" WHERE usr_admins.UsrCod=%ld"
" AND usr_admins.Scope='%s'"
" AND usr_admins.Cod=deg_degrees.DegCod)"
" ORDER BY S,"
"FullName",
(unsigned) Hie_Lvl_SYS,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_SYS),
(unsigned) Hie_Lvl_INS,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_INS),
(unsigned) Hie_Lvl_CTR,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_CTR),
(unsigned) Hie_Lvl_DEG,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_DEG));
2019-12-30 12:25:45 +01:00
if (NumRows)
/***** Get the list of degrees *****/
for (NumRow = 1;
NumRow <= NumRows;
NumRow++)
{
HTM_TR_Begin (NULL);
/***** Indent *****/
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
Ico_PutIcon (NumRow == NumRows ? "subend20x20.gif" :
"submid20x20.gif",
"","ICO25x25");
HTM_TD_End ();
/***** Write institution, center, degree *****/
2019-12-30 12:25:45 +01:00
HTM_TD_Begin ("colspan=\"%u\" class=\"DAT_SMALL_NOBR LT COLOR%u\"",
ColSpan - 1,Gbl.RowEvenOdd);
/* Get next institution, center, degree */
2019-12-30 12:25:45 +01:00
row = mysql_fetch_row (mysql_res);
/* Get scope */
switch (Sco_GetScopeFromUnsignedStr (row[0]))
{
2021-02-11 22:57:09 +01:00
case Hie_Lvl_SYS: // System
2019-12-30 12:25:45 +01:00
Ico_PutIcon ("swad64x64.png",Txt_all_degrees,"ICO16x16");
HTM_TxtF ("&nbsp;%s",Txt_all_degrees);
break;
2021-02-11 22:57:09 +01:00
case Hie_Lvl_INS: // Institution
2021-02-11 23:27:48 +01:00
Hie.Ins.InsCod = Str_ConvertStrCodToLongCod (row[1]);
if (Hie.Ins.InsCod > 0)
2019-12-30 12:25:45 +01:00
{
/* Get data of institution */
2021-02-11 23:27:48 +01:00
Ins_GetDataOfInstitutionByCod (&Hie.Ins);
2019-12-30 12:25:45 +01:00
/* Write institution logo and name */
2021-02-11 23:27:48 +01:00
Ins_DrawInstitutionLogoAndNameWithLink (&Hie.Ins,ActSeeInsInf,
2019-12-30 12:25:45 +01:00
"BT_LINK DAT_SMALL_NOBR","LT");
}
break;
case Hie_Lvl_CTR: // Center
2021-02-11 23:27:48 +01:00
Hie.Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[1]);
if (Hie.Ctr.CtrCod > 0)
2019-12-30 12:25:45 +01:00
{
/* Get data of center */
Ctr_GetDataOfCenterByCod (&Hie.Ctr);
2019-12-30 12:25:45 +01:00
/* Write center logo and name */
Ctr_DrawCenterLogoAndNameWithLink (&Hie.Ctr,ActSeeCtrInf,
2019-12-30 12:25:45 +01:00
"BT_LINK DAT_SMALL_NOBR","LT");
}
break;
2021-02-11 22:57:09 +01:00
case Hie_Lvl_DEG: // Degree
2021-02-11 23:27:48 +01:00
Hie.Deg.DegCod = Str_ConvertStrCodToLongCod (row[1]);
if (Hie.Deg.DegCod > 0)
2019-12-30 12:25:45 +01:00
{
/* Get data of degree */
2021-02-11 23:27:48 +01:00
Deg_GetDataOfDegreeByCod (&Hie.Deg);
2019-12-30 12:25:45 +01:00
/* Write degree logo and name */
2021-02-11 23:27:48 +01:00
Deg_DrawDegreeLogoAndNameWithLink (&Hie.Deg,ActSeeDegInf,
2019-12-30 12:25:45 +01:00
"BT_LINK DAT_SMALL_NOBR","LT");
}
break;
default: // There are no administrators in other scopes
Lay_WrongScopeExit ();
break;
}
HTM_TD_End ();
HTM_TR_End ();
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/********************* Build a "Go to <where>" message ***********************/
/*****************************************************************************/
// Where is a hierarchy member (country, institution, center, degree or course
2019-12-30 12:25:45 +01:00
// Hie_FreeGoToMsg() must be called after calling this function
char *Hie_BuildGoToMsg (const char *Where)
{
extern const char *Txt_Go_to_X;
2019-12-30 21:47:07 +01:00
return Str_BuildStringStr (Txt_Go_to_X,Where);
2019-12-30 12:25:45 +01:00
}
void Hie_FreeGoToMsg (void)
{
2019-12-30 21:47:07 +01:00
Str_FreeString ();
2019-12-30 12:25:45 +01:00
}