2021-11-03 11:35:21 +01:00
|
|
|
|
// swad_user_database.h: users, operations with database
|
|
|
|
|
|
|
|
|
|
#ifndef _SWAD_USR_DB
|
|
|
|
|
#define _SWAD_USR_DB
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance in Spanish),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
|
|
|
|
Copyright (C) 1999-2021 Antonio Ca<EFBFBD>as Vargas
|
|
|
|
|
|
|
|
|
|
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 <mysql/mysql.h> // To access MySQL databases
|
|
|
|
|
#include <stdbool.h> // For boolean type
|
|
|
|
|
#include <sys/types.h> // For time_t
|
|
|
|
|
|
|
|
|
|
#include "swad_cryptography.h"
|
2021-11-06 21:54:35 +01:00
|
|
|
|
#include "swad_search.h"
|
2021-11-03 11:35:21 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Public prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-11-06 21:54:35 +01:00
|
|
|
|
//------------------------------- User's data ---------------------------------
|
2021-11-03 11:35:21 +01:00
|
|
|
|
void Usr_DB_UpdateMyOffice (void);
|
|
|
|
|
void Usr_DB_UpdateMyOfficePhone (void);
|
|
|
|
|
|
|
|
|
|
bool Usr_DB_ChkIfUsrCodExists (long UsrCod);
|
2021-11-05 23:41:26 +01:00
|
|
|
|
long Usr_DB_GetUsrCodFromEncryptedUsrCod (const char EncryptedUsrCod[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1]);
|
2021-11-08 19:16:51 +01:00
|
|
|
|
long Usr_DB_GetUsrCodFromNick (const char *NickWithoutArr);
|
2021-11-08 17:18:36 +01:00
|
|
|
|
long Usr_DB_GetUsrCodFromNickPwd (const char *NickWithoutArr,const char *Password);
|
2021-11-08 19:16:51 +01:00
|
|
|
|
long Usr_DB_GetUsrCodFromEmail (const char *Email);
|
2021-11-08 17:18:36 +01:00
|
|
|
|
long Usr_DB_GetUsrCodFromEmailPwd (const char *Email,const char *Password);
|
2021-11-08 19:16:51 +01:00
|
|
|
|
long Usr_DB_GetUsrCodFromID (const char *ID);
|
2021-11-08 17:18:36 +01:00
|
|
|
|
long Usr_DB_GetUsrCodFromIDPwd (const char *ID,const char *Password);
|
2021-11-06 21:54:35 +01:00
|
|
|
|
unsigned Usr_DB_GetUsrDataFromUsrCod (MYSQL_RES **mysql_res,long UsrCod,
|
|
|
|
|
Usr_GetPrefs_t GetPrefs);
|
2021-11-08 17:18:36 +01:00
|
|
|
|
unsigned Usr_DB_GetSomeUsrDataFromUsrCod (MYSQL_RES **mysql_res,long UsrCod);
|
2021-11-03 11:35:21 +01:00
|
|
|
|
bool Usr_DB_FindStrInUsrsNames (const char *Str);
|
2021-11-06 21:54:35 +01:00
|
|
|
|
void Usr_DB_BuildQueryToGetUsrsLst (HieLvl_Level_t Scope,Rol_Role_t Role,char **Query);
|
|
|
|
|
void Usr_DB_BuildQueryToGetUsrsLstCrs (char **Query,Rol_Role_t Role);
|
|
|
|
|
void Usr_DB_BuildQueryToGetAdmsLst (HieLvl_Level_t Scope,char **Query);
|
2021-11-06 12:30:24 +01:00
|
|
|
|
void Usr_DB_BuildQueryToGetGstsLst (HieLvl_Level_t Scope,char **Query);
|
2021-11-06 21:54:35 +01:00
|
|
|
|
void Usr_DB_BuildQueryToSearchListUsrs (Rol_Role_t Role,char **Query);
|
2021-11-06 12:13:05 +01:00
|
|
|
|
void Usr_DB_BuildQueryToGetUnorderedStdsCodesInDeg (long DegCod,char **Query);
|
2021-11-03 11:35:21 +01:00
|
|
|
|
unsigned Usr_DB_GetNumUsrsWhoChoseAnOption (const char *SubQuery);
|
|
|
|
|
unsigned Usr_DB_GetOldUsrs (MYSQL_RES **mysql_res,time_t SecondsWithoutAccess);
|
2021-11-06 21:54:35 +01:00
|
|
|
|
void Usr_DB_CreateTmpTableAndSearchCandidateUsrs (const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1]);
|
|
|
|
|
void Usr_DB_DropTmpTableWithCandidateUsrs (void);
|
2021-11-03 11:35:21 +01:00
|
|
|
|
|
|
|
|
|
void Usr_DB_RemoveUsrData (long UsrCod);
|
|
|
|
|
|
2021-11-06 21:54:35 +01:00
|
|
|
|
//------------------------------ User's last data -----------------------------
|
|
|
|
|
void Usr_DB_InsertMyLastData (void);
|
|
|
|
|
void Usr_DB_UpdateMyLastData (void);
|
|
|
|
|
void Usr_DB_UpdateMyLastWhatToSearch (void);
|
|
|
|
|
|
|
|
|
|
bool Usr_DB_CheckMyLastData (void);
|
|
|
|
|
unsigned Usr_DB_GetMyLastData (MYSQL_RES **mysql_res);
|
|
|
|
|
|
|
|
|
|
void Usr_DB_RemoveUsrLastData (long UsrCod);
|
|
|
|
|
|
2021-11-03 23:37:01 +01:00
|
|
|
|
//------------------------------ Birthdays today ------------------------------
|
|
|
|
|
void Usr_DB_MarkMyBirthdayAsCongratulated (void);
|
|
|
|
|
bool Usr_DB_CheckIfMyBirthdayHasNotBeenCongratulated (void);
|
|
|
|
|
void Usr_DB_DeleteOldBirthdays (void);
|
|
|
|
|
|
2021-11-03 11:35:21 +01:00
|
|
|
|
#endif
|