2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_user.c: users
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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 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 *********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-15 03:34:48 +01:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <ctype.h> // For isalnum, isdigit, etc.
|
|
|
|
|
#include <limits.h> // For maximum values
|
|
|
|
|
#include <linux/limits.h> // For PATH_MAX
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2019-11-15 03:34:48 +01:00
|
|
|
|
#include <stdio.h> // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <stdlib.h> // For exit, system, malloc, free, rand, etc.
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
#include <sys/wait.h> // For the macro WEXITSTATUS
|
|
|
|
|
#include <unistd.h> // For access, lstat, getpid, chdir, symlink, unlink
|
|
|
|
|
|
2014-12-12 22:39:55 +01:00
|
|
|
|
#include "swad_account.h"
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2021-11-06 21:54:35 +01:00
|
|
|
|
#include "swad_admin.h"
|
|
|
|
|
#include "swad_admin_database.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_agenda.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_announcement.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2015-11-21 20:23:28 +01:00
|
|
|
|
#include "swad_calendar.h"
|
2021-11-03 11:35:21 +01:00
|
|
|
|
#include "swad_center_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_config.h"
|
2023-02-08 14:25:42 +01:00
|
|
|
|
#include "swad_constant.h"
|
2021-05-20 23:45:36 +02:00
|
|
|
|
#include "swad_connected_database.h"
|
2021-11-03 11:35:21 +01:00
|
|
|
|
#include "swad_country_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_course.h"
|
|
|
|
|
#include "swad_database.h"
|
2021-11-03 11:35:21 +01:00
|
|
|
|
#include "swad_degree_database.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_department.h"
|
2016-06-16 19:30:29 +02:00
|
|
|
|
#include "swad_duplicate.h"
|
2017-03-30 11:20:06 +02:00
|
|
|
|
#include "swad_enrolment.h"
|
2021-11-03 21:31:16 +01:00
|
|
|
|
#include "swad_enrolment_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_figure.h"
|
2020-05-03 20:58:03 +02:00
|
|
|
|
#include "swad_figure_cache.h"
|
2019-02-22 14:04:54 +01:00
|
|
|
|
#include "swad_follow.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_group.h"
|
2015-10-06 20:34:49 +02:00
|
|
|
|
#include "swad_help.h"
|
2023-06-06 22:18:31 +02:00
|
|
|
|
#include "swad_hidden_visible.h"
|
2016-11-14 16:47:46 +01:00
|
|
|
|
#include "swad_hierarchy.h"
|
2023-09-22 14:47:56 +02:00
|
|
|
|
#include "swad_hierarchy_type.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_ID.h"
|
2021-11-03 11:35:21 +01:00
|
|
|
|
#include "swad_institution_database.h"
|
2017-05-07 18:06:34 +02:00
|
|
|
|
#include "swad_language.h"
|
2021-09-23 01:49:25 +02:00
|
|
|
|
#include "swad_mail_database.h"
|
2021-09-30 20:11:00 +02:00
|
|
|
|
#include "swad_message.h"
|
2016-06-03 13:42:28 +02:00
|
|
|
|
#include "swad_MFU.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_nickname.h"
|
2021-09-30 00:04:29 +02:00
|
|
|
|
#include "swad_nickname_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_notification.h"
|
|
|
|
|
#include "swad_parameter.h"
|
|
|
|
|
#include "swad_password.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_photo.h"
|
2016-12-09 13:59:33 +01:00
|
|
|
|
#include "swad_privacy.h"
|
2022-01-02 23:44:27 +01:00
|
|
|
|
#include "swad_profile.h"
|
2016-12-07 00:41:36 +01:00
|
|
|
|
#include "swad_QR.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_record.h"
|
2021-10-12 22:13:16 +02:00
|
|
|
|
#include "swad_record_database.h"
|
2016-12-13 13:32:19 +01:00
|
|
|
|
#include "swad_role.h"
|
2022-10-19 18:07:49 +02:00
|
|
|
|
#include "swad_session.h"
|
2021-10-15 18:01:53 +02:00
|
|
|
|
#include "swad_session_database.h"
|
2019-03-26 11:53:21 +01:00
|
|
|
|
#include "swad_setting.h"
|
2015-01-04 15:48:24 +01:00
|
|
|
|
#include "swad_tab.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_user.h"
|
2021-11-03 11:35:21 +01:00
|
|
|
|
#include "swad_user_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Public constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-12-08 16:43:13 +01:00
|
|
|
|
const char *Usr_StringsSexIcons[Usr_NUM_SEXS] =
|
|
|
|
|
{
|
2019-11-22 01:04:03 +01:00
|
|
|
|
[Usr_SEX_UNKNOWN] = "?",
|
|
|
|
|
[Usr_SEX_FEMALE ] = "♀",
|
|
|
|
|
[Usr_SEX_MALE ] = "♂",
|
|
|
|
|
[Usr_SEX_ALL ] = "*",
|
2018-12-08 16:43:13 +01:00
|
|
|
|
};
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const char *Usr_StringsSexDB[Usr_NUM_SEXS] =
|
|
|
|
|
{
|
2019-11-22 01:04:03 +01:00
|
|
|
|
[Usr_SEX_UNKNOWN] = "unknown",
|
|
|
|
|
[Usr_SEX_FEMALE ] = "female",
|
|
|
|
|
[Usr_SEX_MALE ] = "male",
|
|
|
|
|
[Usr_SEX_ALL ] = "all",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
2017-05-26 20:11:24 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-11-03 21:31:16 +01:00
|
|
|
|
static const char *Usr_IconsClassPhotoOrList[Set_NUM_USR_LIST_TYPES] =
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-11-03 21:31:16 +01:00
|
|
|
|
[Set_USR_LIST_UNKNOWN ] = "",
|
|
|
|
|
[Set_USR_LIST_AS_CLASS_PHOTO] = "th.svg",
|
|
|
|
|
[Set_USR_LIST_AS_LISTING ] = "list-ol.svg",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
2017-05-26 20:11:24 +02:00
|
|
|
|
static const char *Usr_NameSelUnsel[Rol_NUM_ROLES] =
|
|
|
|
|
{
|
2020-05-03 20:58:03 +02:00
|
|
|
|
[Rol_GST] = "SEL_UNSEL_GSTS",
|
|
|
|
|
[Rol_STD] = "SEL_UNSEL_STDS",
|
|
|
|
|
[Rol_NET] = "SEL_UNSEL_NETS",
|
|
|
|
|
[Rol_TCH] = "SEL_UNSEL_TCHS",
|
2017-05-26 20:11:24 +02:00
|
|
|
|
};
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static const char *Usr_ParUsrCod[Rol_NUM_ROLES] =
|
2017-05-26 20:11:24 +02:00
|
|
|
|
{
|
2020-05-03 20:58:03 +02:00
|
|
|
|
[Rol_UNK] = "UsrCodAll", // here means all users
|
|
|
|
|
[Rol_GST] = "UsrCodGst",
|
|
|
|
|
[Rol_STD] = "UsrCodStd",
|
|
|
|
|
[Rol_NET] = "UsrCodNET",
|
|
|
|
|
[Rol_TCH] = "UsrCodTch",
|
2017-05-26 20:11:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
2016-07-25 16:08:25 +02:00
|
|
|
|
#define Usr_NUM_MAIN_FIELDS_DATA_ADM 7
|
2020-04-29 02:34:54 +02:00
|
|
|
|
#define Usr_NUM_ALL_FIELDS_DATA_GST 14
|
|
|
|
|
#define Usr_NUM_ALL_FIELDS_DATA_STD 10
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#define Usr_NUM_ALL_FIELDS_DATA_TCH 11
|
|
|
|
|
const char *Usr_UsrDatMainFieldNames[Usr_NUM_MAIN_FIELDS_DATA_USR];
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-04-11 09:55:35 +02:00
|
|
|
|
/****************************** Private variables ****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void (*Usr_FuncParsBigList) (void *Args); // Used to pass pointer to function
|
2019-04-11 09:55:35 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Usr_GetMyLastData (void);
|
2022-09-24 18:30:26 +02:00
|
|
|
|
static void Usr_GetUsrCommentsFromString (char *Str,struct Usr_Data *UsrDat);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static Usr_Sex_t Usr_GetSexFromStr (const char *Str);
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Usr_GetParOtherUsrIDNickOrEMail (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
static bool Usr_ChkUsrAndGetUsrDataFromDirectLogin (void);
|
|
|
|
|
static bool Usr_ChkUsrAndGetUsrDataFromSession (void);
|
2016-03-01 03:16:29 +01:00
|
|
|
|
static void Usr_ShowAlertUsrDoesNotExistsOrWrongPassword (void);
|
|
|
|
|
static void Usr_ShowAlertThereAreMoreThanOneUsr (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-04 14:22:04 +02:00
|
|
|
|
static void Usr_SetMyPrefsAndRoles (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Usr_PutLinkToLogOut (__attribute__((unused)) void *Args);
|
2018-10-09 19:18:43 +02:00
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
static void Usr_WriteRowGstAllData (struct Usr_Data *UsrDat);
|
|
|
|
|
static void Usr_WriteRowStdAllData (struct Usr_Data *UsrDat,char *GroupNames);
|
|
|
|
|
static void Usr_WriteRowTchAllData (struct Usr_Data *UsrDat);
|
|
|
|
|
static void Usr_WriteRowAdmData (unsigned NumUsr,struct Usr_Data *UsrDat);
|
|
|
|
|
static void Usr_WriteMainUsrDataExceptUsrID (struct Usr_Data *UsrDat,
|
2016-07-27 14:58:26 +02:00
|
|
|
|
const char *BgColor);
|
2022-09-24 18:30:26 +02:00
|
|
|
|
static void Usr_WriteEmail (struct Usr_Data *UsrDat,const char *BgColor);
|
2016-04-23 13:23:09 +02:00
|
|
|
|
static void Usr_WriteUsrData (const char *BgColor,
|
|
|
|
|
const char *Data,const char *Link,
|
|
|
|
|
bool NonBreak,bool Accepted);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
static void Usr_GetGstsLst (Hie_Level_t Level);
|
2016-06-23 13:10:43 +02:00
|
|
|
|
static void Usr_AllocateUsrsList (Rol_Role_t Role);
|
2016-07-04 12:50:17 +02:00
|
|
|
|
|
2019-04-11 09:55:35 +02:00
|
|
|
|
static void Usr_PutButtonToConfirmIWantToSeeBigList (unsigned NumUsrs,
|
2023-03-10 00:13:55 +01:00
|
|
|
|
void (*FuncPars) (void *Args),void *Args,
|
2019-04-11 09:55:35 +02:00
|
|
|
|
const char *OnSubmit);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Usr_PutParsConfirmIWantToSeeBigList (void *Args);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Usr_BuildParName (char **ParName,
|
|
|
|
|
const char *ParRoot,
|
|
|
|
|
const char *ParSuffix);
|
2019-11-15 03:34:48 +01:00
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
static void Usr_AllocateListSelectedEncryptedUsrCods (struct Usr_SelectedUsrs *SelectedUsrs,
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Rol_Role_t Role);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Usr_AllocateListOtherRecipients (void);
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Set_FormToSelectUsrListType (void (*FuncPars) (void *Args),void *Args,
|
2021-11-03 21:31:16 +01:00
|
|
|
|
Set_ShowUsrsType_t ListType);
|
2019-11-15 03:34:48 +01:00
|
|
|
|
static void Usr_PutCheckboxToSelectAllUsers (Rol_Role_t Role,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
struct Usr_SelectedUsrs *SelectedUsrs);
|
2016-06-23 13:10:43 +02:00
|
|
|
|
static Usr_Sex_t Usr_GetSexOfUsrsLst (Rol_Role_t Role);
|
2017-05-30 17:34:49 +02:00
|
|
|
|
static void Usr_PutCheckboxToSelectUser (Rol_Role_t Role,
|
|
|
|
|
const char *EncryptedUsrCod,
|
2019-11-15 03:34:48 +01:00
|
|
|
|
bool UsrIsTheMsgSender,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
struct Usr_SelectedUsrs *SelectedUsrs);
|
2015-10-02 01:04:28 +02:00
|
|
|
|
static void Usr_PutCheckboxListWithPhotos (void);
|
2015-09-30 23:10:15 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Usr_ListMainDataGsts (bool PutCheckBoxToSelectUsr);
|
|
|
|
|
static void Usr_ListMainDataStds (bool PutCheckBoxToSelectUsr);
|
2019-11-15 03:34:48 +01:00
|
|
|
|
static void Usr_ListMainDataTchs (Rol_Role_t Role,
|
|
|
|
|
bool PutCheckBoxToSelectUsr);
|
|
|
|
|
static void Usr_ListUsrsForSelection (Rol_Role_t Role,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
struct Usr_SelectedUsrs *SelectedUsrs);
|
2017-05-26 01:12:15 +02:00
|
|
|
|
static void Usr_ListRowsAllDataTchs (Rol_Role_t Role,
|
|
|
|
|
const char *FieldNames[Usr_NUM_ALL_FIELDS_DATA_TCH],
|
|
|
|
|
unsigned NumColumns);
|
2015-04-02 18:39:49 +02:00
|
|
|
|
|
2015-09-17 16:54:02 +02:00
|
|
|
|
static void Usr_PutLinkToSeeAdmins (void);
|
|
|
|
|
static void Usr_PutLinkToSeeGuests (void);
|
2016-03-18 21:28:45 +01:00
|
|
|
|
|
2019-03-12 13:23:46 +01:00
|
|
|
|
static bool Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole,
|
|
|
|
|
bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]);
|
|
|
|
|
static void Usr_PutOptionsListUsrs (const bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]);
|
2019-03-12 09:27:04 +01:00
|
|
|
|
static void Usr_ShowOneListUsrsOption (Usr_ListUsrsOption_t ListUsrsAction,
|
|
|
|
|
const char *Label);
|
|
|
|
|
static Usr_ListUsrsOption_t Usr_GetListUsrsOption (Usr_ListUsrsOption_t DefaultAction);
|
2019-03-11 00:51:54 +01:00
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Usr_PutIconsListGsts (__attribute__((unused)) void *Args);
|
|
|
|
|
static void Usr_PutIconsListStds (__attribute__((unused)) void *Args);
|
|
|
|
|
static void Usr_PutIconsListTchs (__attribute__((unused)) void *Args);
|
2016-11-07 00:46:13 +01:00
|
|
|
|
|
2016-03-18 21:28:45 +01:00
|
|
|
|
static void Usr_PutIconToPrintGsts (void);
|
|
|
|
|
static void Usr_PutIconToPrintStds (void);
|
|
|
|
|
static void Usr_PutIconToPrintTchs (void);
|
|
|
|
|
static void Usr_PutIconToShowGstsAllData (void);
|
|
|
|
|
static void Usr_PutIconToShowStdsAllData (void);
|
|
|
|
|
static void Usr_PutIconToShowTchsAllData (void);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Usr_ShowGstsAllDataPars (__attribute__((unused)) void *Args);
|
|
|
|
|
static void Usr_ShowStdsAllDataPars (__attribute__((unused)) void *Args);
|
|
|
|
|
static void Usr_ShowTchsAllDataPars (__attribute__((unused)) void *Args);
|
2015-04-02 18:39:49 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType,
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Rol_Role_t Role,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
struct Usr_SelectedUsrs *SelectedUsrs,
|
2019-11-15 03:34:48 +01:00
|
|
|
|
bool PutCheckBoxToSelectUsr);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2022-01-02 23:44:27 +01:00
|
|
|
|
static void Usr_GetAndShowNumUsrsInCrss (Rol_Role_t Role);
|
|
|
|
|
static void Usr_GetAndShowNumUsrsNotBelongingToAnyCrs (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**** Show alert about number of clicks remaining before sending my photo ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Usr_InformAboutNumClicksBeforePhoto (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_You_must_send_your_photo_because_;
|
|
|
|
|
extern const char *Txt_You_can_only_perform_X_further_actions_;
|
2017-05-30 09:42:01 +02:00
|
|
|
|
extern const char *Txt_Upload_photo;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (Gbl.Usrs.Me.NumAccWithoutPhoto)
|
|
|
|
|
{
|
2014-12-12 22:39:55 +01:00
|
|
|
|
if (Gbl.Usrs.Me.NumAccWithoutPhoto >= Pho_MAX_CLICKS_WITHOUT_PHOTO)
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_send_your_photo_because_);
|
2018-04-24 13:21:53 +02:00
|
|
|
|
else if (Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ale_ShowAlertAndButton (ActReqMyPho,NULL,NULL,
|
|
|
|
|
NULL,NULL,
|
2019-02-17 01:14:55 +01:00
|
|
|
|
Btn_CONFIRM_BUTTON,Txt_Upload_photo,
|
|
|
|
|
Ale_WARNING,Txt_You_can_only_perform_X_further_actions_,
|
|
|
|
|
Pho_MAX_CLICKS_WITHOUT_PHOTO - Gbl.Usrs.Me.NumAccWithoutPhoto);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Create data for a user ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void Usr_UsrDataConstructor (struct Usr_Data *UsrDat)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Allocate memory for the comments *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((UsrDat->Comments = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Initialize to zero the data of the user *****/
|
|
|
|
|
Usr_ResetUsrDataExceptUsrCodAndIDs (UsrDat);
|
|
|
|
|
UsrDat->IDs.Num = 0;
|
|
|
|
|
UsrDat->IDs.List = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Reset user's data except UsrCod and ID *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// UsrCod and ID are not changed
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void Usr_ResetUsrDataExceptUsrCodAndIDs (struct Usr_Data *UsrDat)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
UsrDat->EnUsrCod[0] = '\0';
|
2014-12-01 23:55:08 +01:00
|
|
|
|
UsrDat->Nickname[0] = '\0';
|
|
|
|
|
UsrDat->Password[0] = '\0';
|
2021-04-24 15:10:07 +02:00
|
|
|
|
UsrDat->Roles.InCurrentCrs = Rol_UNK;// not yet got from database
|
|
|
|
|
UsrDat->Roles.InCrss = -1; // not yet got from database
|
2019-03-07 22:15:47 +01:00
|
|
|
|
UsrDat->Accepted = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
UsrDat->Sex = Usr_SEX_UNKNOWN;
|
2016-01-18 10:21:18 +01:00
|
|
|
|
UsrDat->Surname1[0] = '\0';
|
|
|
|
|
UsrDat->Surname2[0] = '\0';
|
2021-02-15 16:25:55 +01:00
|
|
|
|
UsrDat->FrstName[0] = '\0';
|
2016-01-18 10:21:18 +01:00
|
|
|
|
UsrDat->FullName[0] = '\0';
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
UsrDat->Email[0] = '\0';
|
|
|
|
|
UsrDat->EmailConfirmed = false;
|
|
|
|
|
|
|
|
|
|
UsrDat->Photo[0] = '\0';
|
2019-03-22 15:21:46 +01:00
|
|
|
|
UsrDat->PhotoVisibility = Pri_PHOTO_VIS_DEFAULT;
|
|
|
|
|
UsrDat->BaPrfVisibility = Pri_BASIC_PROFILE_VIS_DEFAULT;
|
|
|
|
|
UsrDat->ExPrfVisibility = Pri_EXTENDED_PROFILE_VIS_DEFAULT;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
UsrDat->CtyCod = -1L;
|
|
|
|
|
UsrDat->StrBirthday[0] = '\0';
|
2016-01-18 10:21:18 +01:00
|
|
|
|
UsrDat->Birthday.Day = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
UsrDat->Birthday.Month = 0;
|
2016-01-18 10:21:18 +01:00
|
|
|
|
UsrDat->Birthday.Year = 0;
|
2020-04-29 16:43:07 +02:00
|
|
|
|
UsrDat->Phone[0][0] =
|
|
|
|
|
UsrDat->Phone[1][0] = '\0';
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (UsrDat->Comments)
|
|
|
|
|
UsrDat->Comments[0] = '\0';
|
|
|
|
|
|
2016-01-18 10:21:18 +01:00
|
|
|
|
UsrDat->InsCtyCod = -1L;
|
|
|
|
|
UsrDat->InsCod = -1L;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
UsrDat->Tch.CtrCod = -1L;
|
|
|
|
|
UsrDat->Tch.DptCod = -1L;
|
2016-01-18 10:21:18 +01:00
|
|
|
|
UsrDat->Tch.Office[0] = '\0';
|
2014-12-01 23:55:08 +01:00
|
|
|
|
UsrDat->Tch.OfficePhone[0] = '\0';
|
|
|
|
|
|
2021-12-02 08:39:18 +01:00
|
|
|
|
UsrDat->Prefs.Language = Lan_LANGUAGE_UNKNOWN; // Language unknown
|
|
|
|
|
UsrDat->Prefs.FirstDayOfWeek = Cal_FIRST_DAY_OF_WEEK_DEFAULT; // Default first day of week
|
|
|
|
|
UsrDat->Prefs.DateFormat = Dat_FORMAT_DEFAULT ; // Default date format
|
|
|
|
|
UsrDat->Prefs.Theme = The_THEME_DEFAULT;
|
|
|
|
|
UsrDat->Prefs.IconSet = Ico_ICON_SET_DEFAULT;
|
|
|
|
|
UsrDat->Prefs.Menu = Mnu_MENU_DEFAULT;
|
|
|
|
|
UsrDat->Prefs.SideCols = Cfg_DEFAULT_COLUMNS;
|
2021-12-31 14:51:44 +01:00
|
|
|
|
UsrDat->Prefs.PhotoShape = PhoSha_SHAPE_DEFAULT;
|
2023-06-07 00:51:41 +02:00
|
|
|
|
UsrDat->Prefs.RefuseAcceptCookies = Coo_REFUSE; // By default, don't accept third party cookies
|
|
|
|
|
UsrDat->NtfEvents.SendEmail = 0; // By default, don't notify anything
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Reset my last data *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Usr_ResetMyLastData (void)
|
|
|
|
|
{
|
2019-04-01 23:15:17 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastHie.Level = Hie_UNK;
|
2023-07-11 19:12:24 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastHie.HieCod = -1L;
|
2019-04-01 23:15:17 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastAct = ActUnk;
|
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastRole = Rol_UNK;
|
2019-04-03 21:49:10 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastTime = 0;
|
2019-04-01 23:15:17 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastAccNotif = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Free memory used to store the data of a user ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void Usr_UsrDataDestructor (struct Usr_Data *UsrDat)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Free memory allocated for comments *****/
|
|
|
|
|
if (UsrDat->Comments)
|
|
|
|
|
{
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (UsrDat->Comments);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
UsrDat->Comments = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free memory allocated for list of IDs *****/
|
|
|
|
|
ID_FreeListIDs (UsrDat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/*************** Get all user's data from a given user's code ****************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Input: UsrDat->UsrCod must hold user's code
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void Usr_GetAllUsrDataFromUsrCod (struct Usr_Data *UsrDat,
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Usr_GetPrefs_t GetPrefs,
|
|
|
|
|
Usr_GetRoleInCurrentCrs_t GetRoleInCurrentCrs)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
ID_GetListIDsFromUsrCod (UsrDat);
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Usr_GetUsrDataFromUsrCod (UsrDat,GetPrefs,GetRoleInCurrentCrs);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Allocate memory for the list of users' codes ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void Usr_AllocateListUsrCods (struct Usr_ListUsrCods *ListUsrCods)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((ListUsrCods->Lst = malloc (ListUsrCods->NumUsrs *
|
|
|
|
|
sizeof (*ListUsrCods->Lst))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Free memory for the list of users' codes *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void Usr_FreeListUsrCods (struct Usr_ListUsrCods *ListUsrCods)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
if (ListUsrCods->NumUsrs && ListUsrCods->Lst)
|
|
|
|
|
{
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (ListUsrCods->Lst);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
ListUsrCods->Lst = NULL;
|
|
|
|
|
ListUsrCods->NumUsrs = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-10 23:56:42 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Check if I am a given user *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-04-04 13:46:51 +02:00
|
|
|
|
Usr_MeOrOther_t Usr_ItsMe (long UsrCod)
|
2018-10-10 23:56:42 +02:00
|
|
|
|
{
|
2023-04-04 13:46:51 +02:00
|
|
|
|
return (Gbl.Usrs.Me.Logged &&
|
|
|
|
|
UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) ? Usr_ME :
|
|
|
|
|
Usr_OTHER;
|
2018-10-10 23:56:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2016-01-20 21:18:38 +01:00
|
|
|
|
/******** Get user's code from database using encrypted user's code **********/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Input: UsrDat->EncryptedUsrCod must hold user's encrypted code
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void Usr_GetUsrCodFromEncryptedUsrCod (struct Usr_Data *UsrDat)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if (UsrDat->EnUsrCod[0])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get user's code from database *****/
|
2021-11-05 23:41:26 +01:00
|
|
|
|
UsrDat->UsrCod = Usr_DB_GetUsrCodFromEncryptedUsrCod (UsrDat->EnUsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
UsrDat->UsrCod = -1L;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Get user's data from database giving a user's code *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// UsrDat->UsrCod must contain an existing user's code
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void Usr_GetUsrDataFromUsrCod (struct Usr_Data *UsrDat,
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Usr_GetPrefs_t GetPrefs,
|
|
|
|
|
Usr_GetRoleInCurrentCrs_t GetRoleInCurrentCrs)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
|
|
|
|
/***** Get user's data from database *****/
|
2021-11-06 21:54:35 +01:00
|
|
|
|
if (Usr_DB_GetUsrDataFromUsrCod (&mysql_res,UsrDat->UsrCod,GetPrefs))
|
2019-03-19 13:22:14 +01:00
|
|
|
|
{
|
2021-11-06 21:54:35 +01:00
|
|
|
|
/***** Read user's data *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2017-01-17 03:10:43 +01:00
|
|
|
|
|
2021-11-06 21:54:35 +01:00
|
|
|
|
/* Get encrypted user's code (row[0])
|
|
|
|
|
and encrypted password (row[1]) */
|
|
|
|
|
Str_Copy (UsrDat->EnUsrCod,row[0],sizeof (UsrDat->EnUsrCod) - 1);
|
|
|
|
|
Str_Copy (UsrDat->Password,row[1],sizeof (UsrDat->Password) - 1);
|
2019-03-19 13:22:14 +01:00
|
|
|
|
|
2021-11-06 21:54:35 +01:00
|
|
|
|
/* Get roles */
|
|
|
|
|
switch (GetRoleInCurrentCrs)
|
|
|
|
|
{
|
|
|
|
|
case Usr_DONT_GET_ROLE_IN_CURRENT_CRS:
|
|
|
|
|
UsrDat->Roles.InCurrentCrs = Rol_UNK;
|
|
|
|
|
UsrDat->Roles.InCrss = -1; // Force roles to be got from database
|
|
|
|
|
break;
|
|
|
|
|
case Usr_GET_ROLE_IN_CURRENT_CRS:
|
|
|
|
|
UsrDat->Roles.InCurrentCrs = Rol_GetRoleUsrInCrs (UsrDat->UsrCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-11-06 21:54:35 +01:00
|
|
|
|
UsrDat->Roles.InCrss = -1; // Force roles to be got from database
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-05-01 01:52:35 +02:00
|
|
|
|
|
2021-11-06 21:54:35 +01:00
|
|
|
|
/* Get name (row[2], row[3], row[4]) */
|
|
|
|
|
Str_Copy (UsrDat->Surname1,row[2],sizeof (UsrDat->Surname1) - 1);
|
|
|
|
|
Str_Copy (UsrDat->Surname2,row[3],sizeof (UsrDat->Surname2) - 1);
|
|
|
|
|
Str_Copy (UsrDat->FrstName,row[4],sizeof (UsrDat->FrstName) - 1);
|
|
|
|
|
Str_ConvertToTitleType (UsrDat->Surname1 );
|
|
|
|
|
Str_ConvertToTitleType (UsrDat->Surname2 );
|
|
|
|
|
Str_ConvertToTitleType (UsrDat->FrstName);
|
|
|
|
|
Usr_BuildFullName (UsrDat); // Create full name using FirstName, Surname1 and Surname2
|
|
|
|
|
|
|
|
|
|
/* Get sex (row[5]) */
|
|
|
|
|
UsrDat->Sex = Usr_GetSexFromStr (row[5]);
|
|
|
|
|
|
|
|
|
|
/* Get photo (row[6]) */
|
|
|
|
|
Str_Copy (UsrDat->Photo,row[6],sizeof (UsrDat->Photo) - 1);
|
|
|
|
|
|
|
|
|
|
/* Get photo visibility (row[7]) */
|
|
|
|
|
UsrDat->PhotoVisibility = Pri_GetVisibilityFromStr (row[7]);
|
|
|
|
|
|
|
|
|
|
/* Get profile visibility (row[8], row[9]) */
|
|
|
|
|
UsrDat->BaPrfVisibility = Pri_GetVisibilityFromStr (row[8]);
|
|
|
|
|
UsrDat->ExPrfVisibility = Pri_GetVisibilityFromStr (row[9]);
|
|
|
|
|
|
|
|
|
|
/* Get country (row[10]), institution country (row[11]),
|
|
|
|
|
institution (row[12]), department (row[13]) and center (row[14]) */
|
|
|
|
|
UsrDat->CtyCod = Str_ConvertStrCodToLongCod (row[10]);
|
|
|
|
|
UsrDat->InsCtyCod = Str_ConvertStrCodToLongCod (row[11]);
|
|
|
|
|
UsrDat->InsCod = Str_ConvertStrCodToLongCod (row[12]);
|
|
|
|
|
UsrDat->Tch.DptCod = Str_ConvertStrCodToLongCod (row[13]);
|
|
|
|
|
UsrDat->Tch.CtrCod = Str_ConvertStrCodToLongCod (row[14]);
|
|
|
|
|
|
|
|
|
|
/* Get office (row[15]) and office phone (row[16]) */
|
|
|
|
|
Str_Copy (UsrDat->Tch.Office ,row[15],sizeof (UsrDat->Tch.Office ) - 1);
|
|
|
|
|
Str_Copy (UsrDat->Tch.OfficePhone,row[16],sizeof (UsrDat->Tch.OfficePhone) - 1);
|
|
|
|
|
|
|
|
|
|
/* Get phones (row[17]) and row[18] */
|
|
|
|
|
Str_Copy (UsrDat->Phone[0],row[17],sizeof (UsrDat->Phone[0]) - 1);
|
|
|
|
|
Str_Copy (UsrDat->Phone[1],row[18],sizeof (UsrDat->Phone[1]) - 1);
|
|
|
|
|
|
|
|
|
|
/* Get birthday (row[19]) */
|
|
|
|
|
Dat_GetDateFromYYYYMMDD (&(UsrDat->Birthday),row[19]);
|
|
|
|
|
Dat_ConvDateToDateStr (&(UsrDat->Birthday),UsrDat->StrBirthday);
|
|
|
|
|
|
|
|
|
|
/* Get comments (row[20]) */
|
|
|
|
|
Usr_GetUsrCommentsFromString (row[20] ? row[20] :
|
|
|
|
|
"",
|
|
|
|
|
UsrDat);
|
|
|
|
|
|
|
|
|
|
/* Get on which events the user wants to be notified inside the platform (row[21]) */
|
|
|
|
|
if (sscanf (row[21],"%u",&UsrDat->NtfEvents.CreateNotif) != 1)
|
|
|
|
|
UsrDat->NtfEvents.CreateNotif = (unsigned) -1; // 0xFF..FF
|
|
|
|
|
|
|
|
|
|
/* Get on which events the user wants to be notified by email (row[22]) */
|
|
|
|
|
if (sscanf (row[22],"%u",&UsrDat->NtfEvents.SendEmail) != 1)
|
|
|
|
|
UsrDat->NtfEvents.SendEmail = 0;
|
|
|
|
|
if (UsrDat->NtfEvents.SendEmail >= (1 << Ntf_NUM_NOTIFY_EVENTS)) // Maximum binary value for NotifyEvents is 000...0011...11
|
|
|
|
|
UsrDat->NtfEvents.SendEmail = 0;
|
|
|
|
|
|
|
|
|
|
/***** Get user's settings *****/
|
|
|
|
|
if (GetPrefs == Usr_GET_PREFS)
|
|
|
|
|
{
|
2021-12-02 19:07:51 +01:00
|
|
|
|
/* Get language (row[23]),
|
|
|
|
|
first day of week (row[24]),
|
|
|
|
|
date format (row[25]),
|
|
|
|
|
theme (row[26]),
|
|
|
|
|
icon set (row[27]),
|
|
|
|
|
menu (row[28]),
|
|
|
|
|
if user wants to show side columns (row[29]),
|
|
|
|
|
user settings on user photo shape (row[30]),
|
|
|
|
|
and if user accepts third party cookies (row[31]) */
|
|
|
|
|
UsrDat->Prefs.Language = Lan_GetLanguageFromStr (row[23]);
|
2021-11-06 21:54:35 +01:00
|
|
|
|
UsrDat->Prefs.FirstDayOfWeek = Cal_GetFirstDayOfWeekFromStr (row[24]);
|
2021-12-02 19:07:51 +01:00
|
|
|
|
UsrDat->Prefs.DateFormat = Dat_GetDateFormatFromStr (row[25]);
|
|
|
|
|
UsrDat->Prefs.Theme = The_GetThemeFromStr (row[26]);
|
|
|
|
|
UsrDat->Prefs.IconSet = Ico_GetIconSetFromStr (row[27]);
|
|
|
|
|
UsrDat->Prefs.Menu = Mnu_GetMenuFromStr (row[28]);
|
|
|
|
|
UsrDat->Prefs.SideCols = Set_GetSideColsFromStr (row[29]);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
UsrDat->Prefs.PhotoShape = PhoSha_GetShapeFromStr (row[30]);
|
2023-06-07 00:51:41 +02:00
|
|
|
|
UsrDat->Prefs.RefuseAcceptCookies = (row[31][0] == 'Y') ? Coo_ACCEPT :
|
|
|
|
|
Coo_REFUSE;
|
2021-11-06 21:54:35 +01:00
|
|
|
|
}
|
2019-03-19 13:22:14 +01:00
|
|
|
|
}
|
2021-11-06 21:54:35 +01:00
|
|
|
|
else
|
|
|
|
|
Err_WrongUserExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2016-11-16 23:19:52 +01:00
|
|
|
|
/***** Get nickname and email *****/
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Nck_DB_GetNicknameFromUsrCod (UsrDat->UsrCod,UsrDat->Nickname);
|
2015-11-16 14:54:12 +01:00
|
|
|
|
Mai_GetEmailFromUsrCod (UsrDat);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Get the comments in the record of a user from a string ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
static void Usr_GetUsrCommentsFromString (char *Str,struct Usr_Data *UsrDat)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Check that memory for comments is allocated *****/
|
|
|
|
|
if (UsrDat->Comments)
|
|
|
|
|
/***** Copy comments from Str to Comments *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (UsrDat->Comments,Str,Cns_MAX_BYTES_TEXT - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Get user's last data from database giving a user's code **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Usr_GetMyLastData (void)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned UnsignedNum;
|
2019-04-01 13:15:15 +02:00
|
|
|
|
long ActCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2018-11-02 11:33:58 +01:00
|
|
|
|
/***** Get user's last data from database *****/
|
2021-11-06 21:54:35 +01:00
|
|
|
|
if (Usr_DB_GetMyLastData (&mysql_res))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2019-04-01 13:15:15 +02:00
|
|
|
|
/* Get last type of search (row[0]) */
|
2017-01-29 12:42:19 +01:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.WhatToSearch = Sch_SEARCH_UNKNOWN;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (sscanf (row[0],"%u",&UnsignedNum) == 1)
|
|
|
|
|
if (UnsignedNum < Sch_NUM_WHAT_TO_SEARCH)
|
|
|
|
|
Gbl.Usrs.Me.UsrLast.WhatToSearch = (Sch_WhatToSearch_t) UnsignedNum;
|
2017-01-29 12:42:19 +01:00
|
|
|
|
if (Gbl.Usrs.Me.UsrLast.WhatToSearch == Sch_SEARCH_UNKNOWN)
|
|
|
|
|
Gbl.Usrs.Me.UsrLast.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-01 23:15:17 +02:00
|
|
|
|
/* Get last hierarchy: scope (row[1]) and code (row[2]) */
|
2023-07-11 19:12:24 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastHie.Level = Hie_GetLevelFromDBStr (row[1]);
|
|
|
|
|
switch (Gbl.Usrs.Me.UsrLast.LastHie.Level)
|
2019-04-01 23:15:17 +02:00
|
|
|
|
{
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_SYS: // System
|
2023-07-11 19:12:24 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastHie.HieCod = -1L;
|
2019-04-01 23:15:17 +02:00
|
|
|
|
break;
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_CTY: // Country
|
|
|
|
|
case Hie_INS: // Institution
|
|
|
|
|
case Hie_CTR: // Center
|
|
|
|
|
case Hie_DEG: // Degree
|
|
|
|
|
case Hie_CRS: // Course
|
2023-07-11 19:12:24 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastHie.HieCod = Str_ConvertStrCodToLongCod (row[2]);
|
|
|
|
|
if (Gbl.Usrs.Me.UsrLast.LastHie.HieCod <= 0)
|
2019-04-01 23:15:17 +02:00
|
|
|
|
{
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastHie.Level = Hie_UNK;
|
2023-07-11 19:12:24 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastHie.HieCod = -1L;
|
2019-04-01 23:15:17 +02:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastHie.Level = Hie_UNK;
|
2023-07-11 19:12:24 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastHie.HieCod = -1L;
|
2019-04-01 23:15:17 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-01 13:15:15 +02:00
|
|
|
|
/* Get last action (row[3]) */
|
|
|
|
|
ActCod = Str_ConvertStrCodToLongCod (row[3]);
|
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastAct = Act_GetActionFromActCod (ActCod);
|
|
|
|
|
|
2019-04-01 23:15:17 +02:00
|
|
|
|
/* Get last role (row[4]) */
|
2019-04-01 13:15:15 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastRole = Rol_ConvertUnsignedStrToRole (row[4]);
|
|
|
|
|
|
2019-04-03 21:49:10 +02:00
|
|
|
|
/* Get last access to platform (row[5]) */
|
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastTime = 0L;
|
2019-04-01 13:15:15 +02:00
|
|
|
|
if (row[5])
|
2019-04-03 21:49:10 +02:00
|
|
|
|
sscanf (row[5],"%ld",&(Gbl.Usrs.Me.UsrLast.LastTime));
|
|
|
|
|
|
|
|
|
|
/* Get last access to notifications (row[6]) */
|
|
|
|
|
Gbl.Usrs.Me.UsrLast.LastAccNotif = 0L;
|
|
|
|
|
if (row[6])
|
|
|
|
|
sscanf (row[6],"%ld",&(Gbl.Usrs.Me.UsrLast.LastAccNotif));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2021-11-06 21:54:35 +01:00
|
|
|
|
else // No user's last data found
|
|
|
|
|
{
|
|
|
|
|
/***** Create entry for me in table of user's last data *****/
|
|
|
|
|
Usr_ResetMyLastData ();
|
|
|
|
|
Usr_DB_InsertMyLastData ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Get sex from string **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static Usr_Sex_t Usr_GetSexFromStr (const char *Str)
|
|
|
|
|
{
|
|
|
|
|
Usr_Sex_t Sex;
|
|
|
|
|
|
2019-12-15 20:02:34 +01:00
|
|
|
|
for (Sex = (Usr_Sex_t) 0;
|
|
|
|
|
Sex <= (Usr_Sex_t) (Usr_NUM_SEXS - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Sex++)
|
|
|
|
|
if (!strcasecmp (Str,Usr_StringsSexDB[Sex]))
|
|
|
|
|
return Sex;
|
|
|
|
|
|
|
|
|
|
return Usr_SEX_UNKNOWN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Build full name using FirstName, Surname1 and Surname2 ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void Usr_BuildFullName (struct Usr_Data *UsrDat)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (UsrDat->FullName,UsrDat->FrstName,sizeof (UsrDat->FullName) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (UsrDat->Surname1[0])
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (UsrDat->FullName," " ,sizeof (UsrDat->FullName) - 1);
|
|
|
|
|
Str_Concat (UsrDat->FullName,UsrDat->Surname1,sizeof (UsrDat->FullName) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
if (UsrDat->Surname2[0])
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (UsrDat->FullName," " ,sizeof (UsrDat->FullName) - 1);
|
|
|
|
|
Str_Concat (UsrDat->FullName,UsrDat->Surname2,sizeof (UsrDat->FullName) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-03-05 15:12:48 +01:00
|
|
|
|
/********* Write user name in two lines. 1: first name, 2: surnames **********/
|
2014-12-01 23:55:08 +01:00
|
|
|