swad-core/swad_global.c

481 lines
17 KiB
C
Raw Normal View History

2014-12-01 23:55:08 +01:00
// swad_global.c: global variables
/*
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.
2019-01-07 21:52:19 +01:00
Copyright (C) 1999-2019 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 ***********************************/
/*****************************************************************************/
#include <linux/stddef.h> // For NULL
2016-06-04 14:21:01 +02:00
#include <locale.h> // For setlocale
2014-12-01 23:55:08 +01:00
#include <stdlib.h> // For exit, system, malloc, calloc, free, etc
#include <string.h> // For string functions
#include <sys/time.h> // For gettimeofday
#include <sys/types.h> // For getpid
#include <unistd.h> // For getpid
#include "swad_action.h"
2019-05-16 14:02:06 +02:00
#include "swad_API.h"
2015-11-21 20:23:28 +01:00
#include "swad_calendar.h"
2019-01-02 15:10:51 +01:00
#include "swad_classroom.h"
2014-12-01 23:55:08 +01:00
#include "swad_config.h"
#include "swad_constant.h"
#include "swad_exam.h"
2019-02-22 14:04:54 +01:00
#include "swad_follow.h"
2014-12-01 23:55:08 +01:00
#include "swad_global.h"
#include "swad_icon.h"
2016-03-30 10:50:31 +02:00
#include "swad_parameter.h"
2017-09-17 16:58:09 +02:00
#include "swad_project.h"
2017-06-20 14:43:26 +02:00
#include "swad_role.h"
2019-03-26 11:53:21 +01:00
#include "swad_setting.h"
2014-12-01 23:55:08 +01:00
#include "swad_theme.h"
/*****************************************************************************/
/****************************** Public variables *****************************/
/*****************************************************************************/
struct Globals Gbl; // All the global parameters and variables must be in this structure
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/******************************* Private types *******************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private variables *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
/*****************************************************************************/
/************* Intialize globals variables when starting program *************/
/*****************************************************************************/
void Gbl_InitializeGlobals (void)
{
extern const char *The_ThemeId[The_NUM_THEMES];
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
2018-12-09 10:46:57 +01:00
extern const unsigned Txt_Current_CGI_SWAD_Language;
2016-06-23 13:51:37 +02:00
Rol_Role_t Role;
2014-12-01 23:55:08 +01:00
2016-06-04 14:21:01 +02:00
Gbl.Layout.WritingHTMLStart =
Gbl.Layout.HTMLStartWritten =
Gbl.Layout.DivsEndWritten =
Gbl.Layout.HTMLEndWritten = false;
if (!setlocale (LC_ALL,"es_ES.utf8")) // TODO: this should be internationalized!!!!!!!
2016-06-04 13:25:14 +02:00
exit (1);
2014-12-01 23:55:08 +01:00
gettimeofday (&Gbl.tvStart, &Gbl.tz);
2015-10-27 19:00:21 +01:00
Dat_GetStartExecutionTimeUTC ();
2014-12-01 23:55:08 +01:00
Dat_GetAndConvertCurrentDateTime ();
Gbl.Config.DatabasePassword[0] = '\0';
Gbl.Config.SMTPPassword[0] = '\0';
Gbl.TimeGenerationInMicroseconds = Gbl.TimeSendInMicroseconds = 0L;
Gbl.PID = getpid ();
Sta_GetRemoteAddr ();
2019-02-11 21:35:36 +01:00
2016-04-04 14:48:12 +02:00
Cry_CreateUniqueNameEncrypted (Gbl.UniqueNameEncrypted);
2014-12-01 23:55:08 +01:00
2015-10-27 19:00:21 +01:00
srand ((unsigned int) Gbl.StartExecutionTimeUTC); // Initialize seed for rand()
2014-12-01 23:55:08 +01:00
Gbl.WebService.IsWebService = false;
2016-03-30 14:25:04 +02:00
Gbl.Params.ContentLength = 0;
Gbl.Params.QueryString = NULL;
Gbl.Params.List = NULL;
Gbl.Params.GetMethod = false;
2016-03-30 10:50:31 +02:00
2014-12-01 23:55:08 +01:00
Gbl.F.Out = stdout;
Gbl.F.Tmp = NULL;
Gbl.F.XML = NULL;
2016-10-03 14:12:01 +02:00
Gbl.F.Rep = NULL; // Report
2014-12-01 23:55:08 +01:00
2017-05-09 11:39:08 +02:00
Gbl.Form.Num = -1; // Number of form. It's increased by 1 at the begin of each form
Gbl.Form.Inside = false; // Set to true inside a form to avoid nested forms
2014-12-01 23:55:08 +01:00
2019-07-04 10:13:51 +02:00
Gbl.Box.Nested = -1; // -1 means no box open
2019-03-09 20:12:44 +01:00
Gbl.Alerts.Num = 0; // No pending alerts to be shown
2014-12-01 23:55:08 +01:00
Gbl.DB.DatabaseIsOpen = false;
Gbl.DB.LockedTables = false;
Gbl.HiddenParamsInsertedIntoDB = false;
2018-12-09 10:46:57 +01:00
Gbl.Prefs.Language = Txt_Current_CGI_SWAD_Language;
2015-11-21 20:23:28 +01:00
Gbl.Prefs.FirstDayOfWeek = Cal_FIRST_DAY_OF_WEEK_DEFAULT; // Default first day of week
2017-05-04 11:03:44 +02:00
Gbl.Prefs.DateFormat = Dat_FORMAT_DEFAULT; // Default date format
Gbl.Prefs.Menu = Mnu_MENU_DEFAULT; // Default menu
Gbl.Prefs.Theme = The_THEME_DEFAULT; // Default theme
Gbl.Prefs.IconSet = Ico_ICON_SET_DEFAULT; // Default icon set
2019-01-09 01:41:54 +01:00
snprintf (Gbl.Prefs.URLTheme,sizeof (Gbl.Prefs.URLTheme),
2019-03-20 01:36:36 +01:00
"%s/%s",
Cfg_URL_ICON_THEMES_PUBLIC,
2018-10-18 02:02:32 +02:00
The_ThemeId[Gbl.Prefs.Theme]);
2019-01-09 01:41:54 +01:00
snprintf (Gbl.Prefs.URLIconSet,sizeof (Gbl.Prefs.URLIconSet),
2019-03-20 01:36:36 +01:00
"%s/%s",
Cfg_URL_ICON_SETS_PUBLIC,
2018-10-18 02:02:32 +02:00
Ico_IconSetId[Gbl.Prefs.IconSet]);
2014-12-01 23:55:08 +01:00
Gbl.Session.NumSessions = 0;
Gbl.Session.IsOpen = false;
Gbl.Session.HasBeenDisconnected = false;
2018-11-09 20:47:39 +01:00
Gbl.Session.Id[0] = '\0';
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.UsrIdLogin[0] = '\0';
Gbl.Usrs.Me.LoginPlainPassword[0] = '\0';
Gbl.Usrs.Me.UsrDat.UsrCod = -1L;
Gbl.Usrs.Me.UsrDat.UsrIDNickOrEmail[0] = '\0';
Usr_UsrDataConstructor (&Gbl.Usrs.Me.UsrDat);
Usr_ResetMyLastData ();
Gbl.Session.Id[0] = '\0';
Gbl.Usrs.Me.Logged = false;
2017-06-04 18:18:54 +02:00
Gbl.Usrs.Me.Role.Available = 0;
Gbl.Usrs.Me.Role.FromSession =
Gbl.Usrs.Me.Role.Logged =
Gbl.Usrs.Me.Role.LoggedBeforeCloseSession =
Gbl.Usrs.Me.Role.Max = Rol_UNK;
Gbl.Usrs.Me.Role.HasChanged = false;
2015-01-20 20:03:38 +01:00
Gbl.Usrs.Me.IBelongToCurrentIns = false;
Gbl.Usrs.Me.IBelongToCurrentCtr = false;
Gbl.Usrs.Me.IBelongToCurrentDeg = false;
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.IBelongToCurrentCrs = false;
Gbl.Usrs.Me.MyPhotoExists = false;
Gbl.Usrs.Me.NumAccWithoutPhoto = 0;
Gbl.Usrs.Me.TimeLastAccToThisFileBrowser = LONG_MAX; // Initialized to a big value, so by default files are not shown as recent or new
2016-10-28 10:03:37 +02:00
Gbl.Usrs.Me.MyInss.Filled = false;
Gbl.Usrs.Me.MyCtrs.Filled = false;
Gbl.Usrs.Me.MyDegs.Filled = false;
Gbl.Usrs.Me.MyCrss.Filled = false;
Gbl.Usrs.Me.MyCrss.Num = 0;
2016-11-16 23:19:52 +01:00
Gbl.Usrs.Me.ConfirmEmailJustSent = false; // An email to confirm my email address has not just been sent
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Other.UsrDat.UsrCod = -1L;
Gbl.Usrs.Other.UsrDat.UsrIDNickOrEmail[0] = '\0';
Usr_UsrDataConstructor (&Gbl.Usrs.Other.UsrDat);
2017-05-09 20:56:02 +02:00
Gbl.Action.Act = ActUnk;
Gbl.Action.Original = ActUnk; // Used in some actions to know what action gave rise to the current action
2016-01-17 15:10:54 +01:00
Gbl.Action.UsesAJAX = false;
2017-02-05 22:23:41 +01:00
Gbl.Action.IsAJAXAutoRefresh = false;
2016-01-17 15:10:54 +01:00
Gbl.Action.Tab = TabUnk;
2014-12-01 23:55:08 +01:00
2019-03-11 13:33:34 +01:00
Gbl.Usrs.Selected.Filled = false; // Lists of encrypted codes of users selected from form are not filled
2019-03-12 09:27:04 +01:00
Gbl.Usrs.Selected.Option = Usr_OPTION_UNKNOWN;
2016-06-23 13:51:37 +02:00
for (Role = (Rol_Role_t) 0;
Role < Rol_NUM_ROLES;
Role++)
{
Gbl.Usrs.LstUsrs[Role].Lst = NULL;
Gbl.Usrs.LstUsrs[Role].NumUsrs = 0;
2019-03-11 13:33:34 +01:00
Gbl.Usrs.Selected.List[Role] = NULL;
2016-06-23 13:51:37 +02:00
}
2017-05-23 18:15:59 +02:00
Gbl.Usrs.ListOtherRecipients = NULL;
2014-12-01 23:55:08 +01:00
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.NumExaAnns = 0;
Gbl.ExamAnns.Lst = NULL;
2019-03-25 19:05:10 +01:00
Gbl.ExamAnns.NewExaCod = -1L;
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.HighlightExaCod = -1L;
Gbl.ExamAnns.HighlightDate[0] = '\0'; // No exam announcements highlighted
2014-12-01 23:55:08 +01:00
Gbl.Msg.Subject[0] = '\0';
Gbl.Msg.ShowOnlyUnreadMsgs = false;
Gbl.Msg.ExpandedMsgCod = -1L;
2019-04-03 20:57:04 +02:00
/***** Reset current hierarchy *****/
Hie_ResetHierarchy ();
2014-12-01 23:55:08 +01:00
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.ShrtName[0] = '\0';
Gbl.Hierarchy.Ins.FullName[0] = '\0';
Gbl.Hierarchy.Ins.WWW[0] = '\0';
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Ins.Ctrs.Num = Gbl.Hierarchy.Ins.NumDpts = Gbl.Hierarchy.Ins.NumDegs = 0;
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.NumUsrs = 0;
2014-12-01 23:55:08 +01:00
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.ShrtName[0] = '\0';
Gbl.Hierarchy.Ctr.FullName[0] = '\0';
Gbl.Hierarchy.Ctr.Degs.Num = 0;
Gbl.Hierarchy.Ctr.Degs.Lst = NULL;
2014-12-01 23:55:08 +01:00
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Deg.ShrtName[0] = Gbl.Hierarchy.Deg.FullName[0] = '\0';
2014-12-01 23:55:08 +01:00
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.ShrtName[0] = Gbl.Hierarchy.Crs.FullName[0] = '\0';
Gbl.Crs.Info.ShowMsgMustBeRead = 0;
Gbl.Crs.Notices.HighlightNotCod = -1L; // No notice highlighted
2019-04-01 23:15:17 +02:00
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cty.Inss.Num = 0;
Gbl.Hierarchy.Cty.Inss.Lst = NULL;
Gbl.Hierarchy.Cty.Inss.SelectedOrder = Ins_ORDER_DEFAULT;
2014-12-01 23:55:08 +01:00
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Sys.Ctys.Num = 0;
Gbl.Hierarchy.Sys.Ctys.Lst = NULL;
Gbl.Hierarchy.Sys.Ctys.SelectedOrder = Cty_ORDER_DEFAULT;
2014-12-01 23:55:08 +01:00
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Ins.Ctrs.Num = 0;
Gbl.Hierarchy.Ins.Ctrs.Lst = NULL;
Gbl.Hierarchy.Ins.Ctrs.SelectedOrder = Ctr_ORDER_DEFAULT;
2014-12-01 23:55:08 +01:00
Gbl.Dpts.Num = 0;
Gbl.Dpts.Lst = NULL;
2017-01-29 12:42:19 +01:00
Gbl.Dpts.SelectedOrder = Dpt_ORDER_DEFAULT;
2014-12-01 23:55:08 +01:00
Gbl.Plcs.Num = 0;
Gbl.Plcs.Lst = NULL;
2017-01-29 12:42:19 +01:00
Gbl.Plcs.SelectedOrder = Plc_ORDER_DEFAULT;
2014-12-01 23:55:08 +01:00
Gbl.Hlds.LstIsRead = false; // List is not read
Gbl.Hlds.Num = 0;
Gbl.Hlds.Lst = NULL;
2017-01-29 12:42:19 +01:00
Gbl.Hlds.SelectedOrder = Hld_DEFAULT_ORDER_TYPE;
2014-12-01 23:55:08 +01:00
2019-04-04 10:45:15 +02:00
Gbl.DegTypes.Num = 0;
Gbl.DegTypes.Lst = NULL;
2014-12-01 23:55:08 +01:00
2019-04-04 10:45:15 +02:00
Gbl.Crs.Grps.NumGrps = 0;
Gbl.Crs.Grps.WhichGrps = Grp_WHICH_GROUPS_DEFAULT;
Gbl.Crs.Grps.GrpTypes.LstGrpTypes = NULL;
Gbl.Crs.Grps.GrpTypes.Num = 0;
Gbl.Crs.Grps.GrpTypes.NestedCalls = 0;
Gbl.Crs.Grps.GrpTyp.GrpTypName[0] = '\0';
Gbl.Crs.Grps.GrpTyp.MandatoryEnrolment = true;
Gbl.Crs.Grps.GrpTyp.MultipleEnrolment = false;
Gbl.Crs.Grps.GrpTyp.MustBeOpened = false;
Gbl.Crs.Grps.GrpTyp.OpenTimeUTC = (time_t) 0;
Gbl.Crs.Grps.GrpCod = -1L; // -1L stands for the whole course
Gbl.Crs.Grps.GrpName[0] = '\0';
Gbl.Crs.Grps.ClaCod = -1L; // -1L stands for no classroom assigned
Gbl.Crs.Grps.MaxStudents = Grp_NUM_STUDENTS_NOT_LIMITED;
Gbl.Crs.Grps.Open = false;
Gbl.Crs.Grps.LstGrpsSel.GrpCods = NULL;
Gbl.Crs.Grps.LstGrpsSel.NumGrps = 0;
Gbl.Crs.Grps.LstGrpsSel.NestedCalls = 0;
2014-12-01 23:55:08 +01:00
Gbl.Usrs.ClassPhoto.AllGroups = true;
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Name[0] = '\0';
Gbl.Crs.Records.Field.NumLines = Rec_MIN_LINES_IN_EDITION_FIELD;
Gbl.Crs.Records.Field.Visibility = Rec_HIDDEN_FIELD;
2014-12-01 23:55:08 +01:00
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst = NULL;
Gbl.Crs.Records.LstFields.Num = 0;
Gbl.Crs.Records.LstFields.NestedCalls = 0;
2014-12-01 23:55:08 +01:00
2016-05-30 15:25:21 +02:00
Gbl.Syllabus.EditionIsActive = false;
Gbl.Syllabus.WhichSyllabus = Syl_DEFAULT_WHICH_SYLLABUS;
2014-12-01 23:55:08 +01:00
2017-01-29 12:42:19 +01:00
Gbl.Search.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
2014-12-01 23:55:08 +01:00
Gbl.Search.Str[0] = '\0';
2017-02-27 01:41:46 +01:00
Gbl.Search.LogSearch = false;
2014-12-01 23:55:08 +01:00
Gbl.Asgs.LstIsRead = false; // List is not read
Gbl.Asgs.Num = 0;
Gbl.Asgs.LstAsgCods = NULL;
2017-01-29 12:42:19 +01:00
Gbl.Asgs.SelectedOrder = Asg_ORDER_DEFAULT;
2014-12-01 23:55:08 +01:00
2017-10-10 01:26:45 +02:00
/* Projects */
2019-10-25 22:48:34 +02:00
Gbl.Prjs.Config.Editable = Prj_EDITABLE_DEFAULT;
2017-10-10 12:37:09 +02:00
Gbl.Prjs.Filter.My_All = Prj_FILTER_WHOSE_PROJECTS_DEFAULT;
2019-10-25 01:15:11 +02:00
Gbl.Prjs.Filter.Assign = Prj_FILTER_ASSIGNED_DEFAULT |
Prj_FILTER_NONASSIG_DEFAULT;
Gbl.Prjs.Filter.Hidden = Prj_FILTER_HIDDEN_DEFAULT |
2017-10-10 12:37:09 +02:00
Prj_FILTER_VISIBL_DEFAULT;
2019-10-25 01:15:11 +02:00
Gbl.Prjs.Filter.Faulti = Prj_FILTER_FAULTY_DEFAULT |
Prj_FILTER_FAULTLESS_DEFAULT;
2017-10-10 12:37:09 +02:00
Gbl.Prjs.Filter.DptCod = Prj_FILTER_DPT_DEFAULT;
2017-09-17 16:58:09 +02:00
Gbl.Prjs.LstIsRead = false; // List is not read
Gbl.Prjs.Num = 0;
Gbl.Prjs.LstPrjCods = NULL;
Gbl.Prjs.SelectedOrder = Prj_ORDER_DEFAULT;
2017-10-10 01:26:45 +02:00
Gbl.Prjs.PrjCod = -1L;
2017-09-17 16:58:09 +02:00
2014-12-01 23:55:08 +01:00
Gbl.AttEvents.LstIsRead = false; // List is not read
Gbl.AttEvents.Num = 0;
Gbl.AttEvents.Lst = NULL;
2017-01-29 12:42:19 +01:00
Gbl.AttEvents.SelectedOrder = Att_ORDER_DEFAULT;
2014-12-01 23:55:08 +01:00
Gbl.AttEvents.AttCod = -1L;
2018-10-18 11:10:04 +02:00
Gbl.AttEvents.StrAttCodsSelected = NULL;
2014-12-01 23:55:08 +01:00
Gbl.Mails.Num = 0;
Gbl.Mails.Lst = NULL;
2017-01-29 12:42:19 +01:00
Gbl.Mails.SelectedOrder = Mai_ORDER_DEFAULT;
2014-12-01 23:55:08 +01:00
Gbl.Banners.Num = 0;
Gbl.Banners.Lst = NULL;
2019-04-20 12:31:43 +02:00
Gbl.Banners.BanCodToEdit = -1L;
2014-12-01 23:55:08 +01:00
Gbl.Banners.BanCodClicked = 0L;
Gbl.Links.Num = 0;
Gbl.Links.Lst = NULL;
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_UNKNOWN;
2017-01-29 12:42:19 +01:00
Gbl.Usrs.Listing.RecsPerPag = Rec_DEF_RECORDS_PER_PAGE;
2017-05-30 11:43:50 +02:00
Gbl.Usrs.Listing.WithPhotos = Usr_LIST_WITH_PHOTOS_DEF;
2014-12-01 23:55:08 +01:00
Gbl.Usrs.ClassPhoto.Cols = Usr_CLASS_PHOTO_COLS_DEF;
2016-04-06 22:27:33 +02:00
/* Statistics */
2017-01-29 21:41:08 +01:00
Gbl.Stat.ClicksGroupedBy = Sta_CLICKS_GROUPED_BY_DEFAULT;
Gbl.Stat.CountType = Sta_COUNT_TYPE_DEFAULT;
Gbl.Stat.Role = Sta_ROLE_DEFAULT;
Gbl.Stat.NumAction = Sta_NUM_ACTION_DEFAULT;
Gbl.Stat.RowsPerPage = Sta_DEF_ROWS_PER_PAGE;
2019-11-09 23:10:12 +01:00
Gbl.Figures.FigureType = Fig_FIGURE_TYPE_DEF;
2014-12-01 23:55:08 +01:00
2019-04-03 20:57:04 +02:00
Gbl.Scope.Current = Hie_CRS;
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Connected.TimeToRefreshInMs = Con_MAX_TIME_TO_REFRESH_CONNECTED_IN_MS;
2016-04-06 22:27:33 +02:00
/* Tests */
2014-12-01 23:55:08 +01:00
Gbl.Test.Config.Pluggable = Tst_PLUGGABLE_UNKNOWN;
Gbl.Test.NumQsts = Tst_CONFIG_DEFAULT_DEF_QUESTIONS;
2016-11-21 13:15:08 +01:00
Gbl.Test.AllowTeachers = false; // Must the test result be saved?
2016-04-06 22:27:33 +02:00
Gbl.Test.AllAnsTypes = false;
2014-12-01 23:55:08 +01:00
Gbl.Test.ListAnsTypes[0] = '\0';
2016-04-06 22:27:33 +02:00
Gbl.Test.Tags.Num = 0;
Gbl.Test.Tags.All = false;
Gbl.Test.Tags.List = NULL;
2017-07-18 20:34:32 +02:00
/* Games for remote control */
Gbl.Games.ListQuestions = NULL;
2017-02-24 03:38:18 +01:00
/* Public activity */
2019-03-12 21:25:55 +01:00
Gbl.Timeline.WhichUsrs = TL_DEFAULT_WHICH_USRS;
2017-02-24 03:38:18 +01:00
2016-04-06 22:27:33 +02:00
/* Forums */
2017-04-17 19:03:21 +02:00
Gbl.Forum.ForumSet = For_DEFAULT_FORUM_SET;
2017-04-18 19:55:56 +02:00
Gbl.Forum.ForumSelected.Type = For_FORUM_UNKNOWN;
2017-04-18 01:25:44 +02:00
Gbl.Forum.ForumSelected.Location = -1L;
Gbl.Forum.ForumSelected.ThrCod = -1L;
2017-04-18 09:55:25 +02:00
Gbl.Forum.ForumSelected.PstCod = -1L;
2017-04-18 13:17:40 +02:00
Gbl.Forum.ThreadsOrder = For_DEFAULT_ORDER;
2014-12-01 23:55:08 +01:00
Gbl.Forum.ThreadToMove = -1L;
2016-04-06 22:27:33 +02:00
/* User nickname */
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.UsrDat.Nickname[0] = '\0';
/* File browser */
2015-10-03 00:38:01 +02:00
Gbl.FileBrowser.Id = 0;
2015-01-26 12:39:48 +01:00
Gbl.FileBrowser.Type = Brw_UNKNOWN;
2019-04-25 14:39:51 +02:00
Gbl.FileBrowser.FilFolLnk.Type = Brw_IS_UNKNOWN;
2014-12-01 23:55:08 +01:00
Gbl.FileBrowser.UploadingWithDropzone = false;
2017-03-21 00:57:11 +01:00
/* Agenda */
2017-03-21 14:36:22 +01:00
Gbl.Agenda.Past__FutureEvents = Agd_DEFAULT_PAST___EVENTS |
Agd_DEFAULT_FUTURE_EVENTS;
Gbl.Agenda.PrivatPublicEvents = Agd_DEFAULT_PRIVAT_EVENTS |
Agd_DEFAULT_PUBLIC_EVENTS;
Gbl.Agenda.HiddenVisiblEvents = Agd_DEFAULT_HIDDEN_EVENTS |
Agd_DEFAULT_VISIBL_EVENTS;
2017-03-21 00:57:11 +01:00
Gbl.Agenda.SelectedOrder = Agd_ORDER_DEFAULT;
2017-03-21 14:36:22 +01:00
Gbl.Agenda.AgdCodToEdit = -1L;
2017-03-21 00:57:11 +01:00
2014-12-01 23:55:08 +01:00
/* To alternate colors where listing rows */
Gbl.RowEvenOdd = 0;
2015-09-04 17:43:18 +02:00
Gbl.ColorRows[0] = "COLOR0"; // Darker
Gbl.ColorRows[1] = "COLOR1"; // Lighter
2014-12-01 23:55:08 +01:00
2019-05-16 14:02:06 +02:00
Gbl.WebService.Function = API_unknown;
2016-11-23 23:58:46 +01:00
2017-06-20 14:43:26 +02:00
/* Flush caches */
Cty_FlushCacheCountryName ();
Ins_FlushCacheShortNameOfInstitution ();
Ins_FlushCacheFullNameAndCtyOfInstitution ();
Usr_FlushCacheUsrIsSuperuser ();
Usr_FlushCacheUsrBelongsToIns ();
Usr_FlushCacheUsrBelongsToCtr ();
Usr_FlushCacheUsrBelongsToDeg ();
Usr_FlushCacheUsrBelongsToCrs ();
Usr_FlushCacheUsrBelongsToCurrentCrs ();
Usr_FlushCacheUsrHasAcceptedInCurrentCrs ();
Usr_FlushCacheUsrSharesAnyOfMyCrs ();
Rol_FlushCacheRoleUsrInCrs ();
2019-04-11 15:24:05 +02:00
Prj_FlushCacheMyRolesInProject ();
2017-06-20 14:43:26 +02:00
Grp_FlushCacheIBelongToGrp ();
Grp_FlushCacheUsrSharesAnyOfMyGrpsInCurrentCrs ();
2019-02-22 14:04:54 +01:00
Fol_FlushCacheFollow ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************* Free memory, close files, remove lock file, etc. **************/
/*****************************************************************************/
void Gbl_Cleanup (void)
{
2017-05-22 11:49:16 +02:00
Rol_Role_t Role;
2016-04-23 23:39:07 +02:00
2016-01-17 15:10:54 +01:00
if (!Gbl.Action.UsesAJAX &&
2014-12-01 23:55:08 +01:00
!Gbl.WebService.IsWebService &&
2018-04-24 13:21:53 +02:00
Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB)
2014-12-01 23:55:08 +01:00
Ses_RemoveHiddenParFromThisSession ();
2016-09-22 01:28:31 +02:00
Usr_FreeMyCourses ();
2016-10-28 10:03:37 +02:00
Usr_FreeMyDegrees ();
Usr_FreeMyCentres ();
Usr_FreeMyInstits ();
Usr_FreeMyCountrs ();
2014-12-01 23:55:08 +01:00
Usr_UsrDataDestructor (&Gbl.Usrs.Me.UsrDat);
Usr_UsrDataDestructor (&Gbl.Usrs.Other.UsrDat);
Rec_FreeListFields ();
Grp_FreeListGrpTypesAndGrps ();
Grp_FreeListCodSelectedGrps ();
2019-04-07 12:17:10 +02:00
Crs_FreeListCoursesInCurrentDegree ();
2019-04-03 20:57:04 +02:00
Deg_FreeListDegs (&Gbl.Hierarchy.Ctr.Degs);
2016-03-20 22:31:57 +01:00
DT_FreeListDegreeTypes ();
2014-12-01 23:55:08 +01:00
Ins_FreeListInstitutions ();
Ctr_FreeListCentres ();
Cty_FreeListCountries ();
Dpt_FreeListDepartments ();
Plc_FreeListPlaces ();
Hld_FreeListHolidays ();
Lnk_FreeListLinks ();
Plg_FreeListPlugins ();
2017-05-22 11:49:16 +02:00
for (Role = (Rol_Role_t) 0;
Role < Rol_NUM_ROLES;
Role++)
Usr_FreeUsrsList (Role);
2014-12-01 23:55:08 +01:00
Usr_FreeListOtherRecipients ();
2016-07-04 14:03:04 +02:00
Usr_FreeListsSelectedUsrsCods ();
2014-12-01 23:55:08 +01:00
Syl_FreeListItemsSyllabus ();
Tst_FreeTagsList ();
Exa_FreeMemExamAnnouncement ();
Exa_FreeListExamAnnouncements ();
if (Gbl.F.Tmp)
fclose (Gbl.F.Tmp);
Fil_CloseXMLFile ();
2016-10-03 14:12:01 +02:00
Fil_CloseReportFile ();
2016-03-30 16:33:08 +02:00
Par_FreeParams ();
2019-03-09 20:12:44 +01:00
Ale_ResetAllAlerts ();
2014-12-01 23:55:08 +01:00
}