mirror of https://github.com/acanas/swad-core.git
Version 21.53: Nov 06, 2021 Queries moved to module swad_user_database and other modules.
This commit is contained in:
parent
01e2b94d53
commit
6d51efdb13
|
@ -1859,7 +1859,7 @@ int swad__findUsers (struct soap *soap,
|
||||||
{
|
{
|
||||||
/***** Create temporary table with candidate users *****/
|
/***** Create temporary table with candidate users *****/
|
||||||
// Search is faster (aproximately x2) using temporary tables
|
// Search is faster (aproximately x2) using temporary tables
|
||||||
Usr_CreateTmpTableAndSearchCandidateUsrs (SearchQuery);
|
Usr_DB_CreateTmpTableAndSearchCandidateUsrs (SearchQuery);
|
||||||
|
|
||||||
/***** Search for users *****/
|
/***** Search for users *****/
|
||||||
Usr_SearchListUsrs (Role);
|
Usr_SearchListUsrs (Role);
|
||||||
|
@ -1868,7 +1868,7 @@ int swad__findUsers (struct soap *soap,
|
||||||
Usr_FreeUsrsList (Role);
|
Usr_FreeUsrsList (Role);
|
||||||
|
|
||||||
/***** Drop temporary table with candidate users *****/
|
/***** Drop temporary table with candidate users *****/
|
||||||
Usr_DropTmpTableWithCandidateUsrs ();
|
Usr_DB_DropTmpTableWithCandidateUsrs ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
FilterTooShort = true;
|
FilterTooShort = true;
|
||||||
|
|
18
swad_admin.c
18
swad_admin.c
|
@ -207,6 +207,24 @@ void Adm_AddAdmToDeg (void)
|
||||||
Enr_AddAdm (HieLvl_DEG,Gbl.Hierarchy.Deg.DegCod,Gbl.Hierarchy.Deg.FullName);
|
Enr_AddAdm (HieLvl_DEG,Gbl.Hierarchy.Deg.DegCod,Gbl.Hierarchy.Deg.FullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************** Get list with data of administrators *******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Adm_GetAdmsLst (HieLvl_Level_t Scope)
|
||||||
|
{
|
||||||
|
char *Query = NULL;
|
||||||
|
|
||||||
|
/***** Build query *****/
|
||||||
|
Usr_DB_BuildQueryToGetAdmsLst (Scope,&Query);
|
||||||
|
|
||||||
|
/***** Get list of administrators from database *****/
|
||||||
|
Usr_GetListUsrsFromQuery (Query,Rol_DEG_ADM,Scope);
|
||||||
|
|
||||||
|
/***** Free query string *****/
|
||||||
|
free (Query);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************* Add an administrator to current degree ******************/
|
/******************* Add an administrator to current degree ******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -51,6 +51,8 @@ void Adm_AddAdmToIns (void);
|
||||||
void Adm_AddAdmToCtr (void);
|
void Adm_AddAdmToCtr (void);
|
||||||
void Adm_AddAdmToDeg (void);
|
void Adm_AddAdmToDeg (void);
|
||||||
|
|
||||||
|
void Adm_GetAdmsLst (HieLvl_Level_t Scope);
|
||||||
|
|
||||||
void Adm_ReqRemAdmOfIns (void);
|
void Adm_ReqRemAdmOfIns (void);
|
||||||
void Adm_ReqRemAdmOfCtr (void);
|
void Adm_ReqRemAdmOfCtr (void);
|
||||||
void Adm_ReqRemAdmOfDeg (void);
|
void Adm_ReqRemAdmOfDeg (void);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "swad_admin.h"
|
#include "swad_admin.h"
|
||||||
#include "swad_admin_database.h"
|
#include "swad_admin_database.h"
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
|
#include "swad_error.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -113,6 +114,23 @@ bool Adm_DB_CheckIfUsrIsAdm (long UsrCod,HieLvl_Level_t Scope,long Cod)
|
||||||
Cod);
|
Cod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************** Check if a user is a superuser (global admin) ****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
bool Adm_DB_CheckIfUsrIsSuperuser (long UsrCod)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
DB_QueryEXISTS ("can not check if a user is superuser",
|
||||||
|
"SELECT EXISTS"
|
||||||
|
"(SELECT *"
|
||||||
|
" FROM usr_admins"
|
||||||
|
" WHERE UsrCod=%ld"
|
||||||
|
" AND Scope='%s')",
|
||||||
|
UsrCod,
|
||||||
|
Sco_GetDBStrFromScope (HieLvl_SYS));
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***** Remove user as administrator of an institution, center or degree ******/
|
/***** Remove user as administrator of an institution, center or degree ******/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -45,6 +45,7 @@ void Adm_DB_InsertAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
||||||
|
|
||||||
unsigned Adm_DB_GetAdmsCurrentScopeExceptMe (MYSQL_RES **mysql_res);
|
unsigned Adm_DB_GetAdmsCurrentScopeExceptMe (MYSQL_RES **mysql_res);
|
||||||
bool Adm_DB_CheckIfUsrIsAdm (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
bool Adm_DB_CheckIfUsrIsAdm (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
||||||
|
bool Adm_DB_CheckIfUsrIsSuperuser (long UsrCod);
|
||||||
|
|
||||||
void Adm_DB_RemAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
void Adm_DB_RemAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
||||||
void Adm_DB_RemUsrAsAdmin (long UsrCod);
|
void Adm_DB_RemUsrAsAdmin (long UsrCod);
|
||||||
|
|
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
||||||
|
|
||||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 21.52.3 (2021-11-06)"
|
#define Log_PLATFORM_VERSION "SWAD 21.53 (2021-11-06)"
|
||||||
#define CSS_FILE "swad20.45.css"
|
#define CSS_FILE "swad20.45.css"
|
||||||
#define JS_FILE "swad20.69.1.js"
|
#define JS_FILE "swad20.69.1.js"
|
||||||
/*
|
/*
|
||||||
TODO: Rename CENTRE to CENTER in help wiki.
|
TODO: Rename CENTRE to CENTER in help wiki.
|
||||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||||
|
|
||||||
|
Version 21.53: Nov 06, 2021 Queries moved to module swad_user_database and other modules. (321926 lines)
|
||||||
Version 21.52.3: Nov 06, 2021 Queries moved to module swad_user_database. (321894 lines)
|
Version 21.52.3: Nov 06, 2021 Queries moved to module swad_user_database. (321894 lines)
|
||||||
Version 21.52.2: Nov 06, 2021 Query refactoring related to SELECT DISTINCT and UNION. (321899 lines)
|
Version 21.52.2: Nov 06, 2021 Query refactoring related to SELECT DISTINCT and UNION. (321899 lines)
|
||||||
Version 21.52.1: Nov 06, 2021 Fixed database query in departments. (321828 lines)
|
Version 21.52.1: Nov 06, 2021 Fixed database query in departments. (321828 lines)
|
||||||
|
|
102
swad_search.c
102
swad_search.c
|
@ -146,64 +146,68 @@ static void Sch_PutFormToSearchWithWhatToSearchAndScope (Act_Action_t Action,Hie
|
||||||
Sch_WhatToSearch_t WhatToSearch;
|
Sch_WhatToSearch_t WhatToSearch;
|
||||||
unsigned WTS;
|
unsigned WTS;
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin container *****/
|
||||||
HTM_DIV_Begin ("class=\"CM\"");
|
HTM_DIV_Begin ("class=\"CM\"");
|
||||||
Box_BoxBegin (NULL,Txt_Search,
|
|
||||||
Crs_PutIconToSelectMyCourses,NULL,
|
|
||||||
Hlp_START_Search,Box_NOT_CLOSABLE);
|
|
||||||
|
|
||||||
/***** Begin form *****/
|
/***** Begin box *****/
|
||||||
Frm_BeginForm (Action);
|
Box_BoxBegin (NULL,Txt_Search,
|
||||||
|
Crs_PutIconToSelectMyCourses,NULL,
|
||||||
|
Hlp_START_Search,Box_NOT_CLOSABLE);
|
||||||
|
|
||||||
/***** Scope (whole platform, current country, current institution,
|
/***** Begin form *****/
|
||||||
current center, current degree or current course) *****/
|
Frm_BeginForm (Action);
|
||||||
HTM_DIV_Begin ("class=\"CM\"");
|
|
||||||
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
|
||||||
HTM_TxtColonNBSP (Txt_Scope);
|
|
||||||
Gbl.Scope.Allowed = 1 << HieLvl_SYS |
|
|
||||||
1 << HieLvl_CTY |
|
|
||||||
1 << HieLvl_INS |
|
|
||||||
1 << HieLvl_CTR |
|
|
||||||
1 << HieLvl_DEG |
|
|
||||||
1 << HieLvl_CRS;
|
|
||||||
Gbl.Scope.Default = DefaultScope;
|
|
||||||
Sco_GetScope ("ScopeSch");
|
|
||||||
Sco_PutSelectorScope ("ScopeSch",HTM_DONT_SUBMIT_ON_CHANGE);
|
|
||||||
HTM_LABEL_End ();
|
|
||||||
HTM_DIV_End ();
|
|
||||||
|
|
||||||
/***** String to find *****/
|
/***** Scope (whole platform, current country, current institution,
|
||||||
Sch_PutInputStringToSearch ("");
|
current center, current degree or current course) *****/
|
||||||
|
HTM_DIV_Begin ("class=\"CM\"");
|
||||||
|
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
||||||
|
HTM_TxtColonNBSP (Txt_Scope);
|
||||||
|
Gbl.Scope.Allowed = 1 << HieLvl_SYS |
|
||||||
|
1 << HieLvl_CTY |
|
||||||
|
1 << HieLvl_INS |
|
||||||
|
1 << HieLvl_CTR |
|
||||||
|
1 << HieLvl_DEG |
|
||||||
|
1 << HieLvl_CRS;
|
||||||
|
Gbl.Scope.Default = DefaultScope;
|
||||||
|
Sco_GetScope ("ScopeSch");
|
||||||
|
Sco_PutSelectorScope ("ScopeSch",HTM_DONT_SUBMIT_ON_CHANGE);
|
||||||
|
HTM_LABEL_End ();
|
||||||
|
HTM_DIV_End ();
|
||||||
|
|
||||||
/***** What to search? *****/
|
/***** String to find *****/
|
||||||
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
Sch_PutInputStringToSearch ("");
|
||||||
HTM_TxtF (" %s ",Txt_SEARCH_X_in_Y);
|
|
||||||
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
|
|
||||||
"name=\"WhatToSearch\" class=\"WHAT_TO_SEARCH\"");
|
|
||||||
for (WhatToSearch = (Sch_WhatToSearch_t) 0;
|
|
||||||
WhatToSearch <= (Sch_WhatToSearch_t) (Sch_NUM_WHAT_TO_SEARCH - 1);
|
|
||||||
WhatToSearch++)
|
|
||||||
if (Sch_CheckIfIHavePermissionToSearch (WhatToSearch))
|
|
||||||
{
|
|
||||||
WTS = (unsigned) WhatToSearch;
|
|
||||||
HTM_OPTION (HTM_Type_UNSIGNED,&WTS,
|
|
||||||
Gbl.Search.WhatToSearch == WhatToSearch,false,
|
|
||||||
"%s",Titles[WhatToSearch]);
|
|
||||||
}
|
|
||||||
HTM_SELECT_End ();
|
|
||||||
HTM_LABEL_End ();
|
|
||||||
|
|
||||||
/***** Magnifying glass icon *****/
|
/***** What to search? *****/
|
||||||
Sch_PutMagnifyingGlassButton ("search.svg");
|
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
||||||
|
HTM_TxtF (" %s ",Txt_SEARCH_X_in_Y);
|
||||||
|
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
|
||||||
|
"name=\"WhatToSearch\" class=\"WHAT_TO_SEARCH\"");
|
||||||
|
for (WhatToSearch = (Sch_WhatToSearch_t) 0;
|
||||||
|
WhatToSearch <= (Sch_WhatToSearch_t) (Sch_NUM_WHAT_TO_SEARCH - 1);
|
||||||
|
WhatToSearch++)
|
||||||
|
if (Sch_CheckIfIHavePermissionToSearch (WhatToSearch))
|
||||||
|
{
|
||||||
|
WTS = (unsigned) WhatToSearch;
|
||||||
|
HTM_OPTION (HTM_Type_UNSIGNED,&WTS,
|
||||||
|
Gbl.Search.WhatToSearch == WhatToSearch,false,
|
||||||
|
"%s",Titles[WhatToSearch]);
|
||||||
|
}
|
||||||
|
HTM_SELECT_End ();
|
||||||
|
HTM_LABEL_End ();
|
||||||
|
|
||||||
/***** Send button *****/
|
/***** Magnifying glass icon *****/
|
||||||
Btn_PutButton (Btn_CONFIRM_BUTTON,Txt_Search);
|
Sch_PutMagnifyingGlassButton ("search.svg");
|
||||||
|
|
||||||
/***** End form *****/
|
/***** Send button *****/
|
||||||
Frm_EndForm ();
|
Btn_PutButton (Btn_CONFIRM_BUTTON,Txt_Search);
|
||||||
|
|
||||||
/***** End box *****/
|
/***** End form *****/
|
||||||
Box_BoxEnd ();
|
Frm_EndForm ();
|
||||||
|
|
||||||
|
/***** End box *****/
|
||||||
|
Box_BoxEnd ();
|
||||||
|
|
||||||
|
/***** End container *****/
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1381
swad_user.c
1381
swad_user.c
File diff suppressed because it is too large
Load Diff
|
@ -349,11 +349,11 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat,
|
||||||
void Usr_GetListUsrs (HieLvl_Level_t Scope,Rol_Role_t Role);
|
void Usr_GetListUsrs (HieLvl_Level_t Scope,Rol_Role_t Role);
|
||||||
|
|
||||||
void Usr_SearchListUsrs (Rol_Role_t Role);
|
void Usr_SearchListUsrs (Rol_Role_t Role);
|
||||||
void Usr_CreateTmpTableAndSearchCandidateUsrs (const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1]);
|
|
||||||
void Usr_DropTmpTableWithCandidateUsrs (void);
|
|
||||||
|
|
||||||
void Usr_GetUnorderedStdsCodesInDeg (long DegCod);
|
void Usr_GetUnorderedStdsCodesInDeg (long DegCod);
|
||||||
|
|
||||||
|
void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,HieLvl_Level_t Scope);
|
||||||
|
|
||||||
void Usr_CopyBasicUsrDataFromList (struct UsrData *UsrDat,
|
void Usr_CopyBasicUsrDataFromList (struct UsrData *UsrDat,
|
||||||
const struct UsrInList *UsrInList);
|
const struct UsrInList *UsrInList);
|
||||||
void Usr_FreeUsrsList (Rol_Role_t Role);
|
void Usr_FreeUsrsList (Rol_Role_t Role);
|
||||||
|
|
1097
swad_user_database.c
1097
swad_user_database.c
File diff suppressed because it is too large
Load Diff
|
@ -45,7 +45,7 @@
|
||||||
// #include "swad_privacy_visibility_type.h"
|
// #include "swad_privacy_visibility_type.h"
|
||||||
// #include "swad_role_type.h"
|
// #include "swad_role_type.h"
|
||||||
// #include "swad_scope.h"
|
// #include "swad_scope.h"
|
||||||
// #include "swad_search.h"
|
#include "swad_search.h"
|
||||||
// #include "swad_string.h"
|
// #include "swad_string.h"
|
||||||
// #include "swad_theme.h"
|
// #include "swad_theme.h"
|
||||||
|
|
||||||
|
@ -61,20 +61,37 @@
|
||||||
/****************************** Public prototypes ****************************/
|
/****************************** Public prototypes ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
//------------------------------- User's data ---------------------------------
|
||||||
void Usr_DB_UpdateMyOffice (void);
|
void Usr_DB_UpdateMyOffice (void);
|
||||||
void Usr_DB_UpdateMyOfficePhone (void);
|
void Usr_DB_UpdateMyOfficePhone (void);
|
||||||
void Usr_DB_UpdateMyLastWhatToSearch (void);
|
|
||||||
|
|
||||||
bool Usr_DB_ChkIfUsrCodExists (long UsrCod);
|
bool Usr_DB_ChkIfUsrCodExists (long UsrCod);
|
||||||
long Usr_DB_GetUsrCodFromEncryptedUsrCod (const char EncryptedUsrCod[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1]);
|
long Usr_DB_GetUsrCodFromEncryptedUsrCod (const char EncryptedUsrCod[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1]);
|
||||||
|
unsigned Usr_DB_GetUsrDataFromUsrCod (MYSQL_RES **mysql_res,long UsrCod,
|
||||||
|
Usr_GetPrefs_t GetPrefs);
|
||||||
bool Usr_DB_FindStrInUsrsNames (const char *Str);
|
bool Usr_DB_FindStrInUsrsNames (const char *Str);
|
||||||
|
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);
|
||||||
void Usr_DB_BuildQueryToGetGstsLst (HieLvl_Level_t Scope,char **Query);
|
void Usr_DB_BuildQueryToGetGstsLst (HieLvl_Level_t Scope,char **Query);
|
||||||
|
void Usr_DB_BuildQueryToSearchListUsrs (Rol_Role_t Role,char **Query);
|
||||||
void Usr_DB_BuildQueryToGetUnorderedStdsCodesInDeg (long DegCod,char **Query);
|
void Usr_DB_BuildQueryToGetUnorderedStdsCodesInDeg (long DegCod,char **Query);
|
||||||
unsigned Usr_DB_GetNumUsrsWhoChoseAnOption (const char *SubQuery);
|
unsigned Usr_DB_GetNumUsrsWhoChoseAnOption (const char *SubQuery);
|
||||||
unsigned Usr_DB_GetOldUsrs (MYSQL_RES **mysql_res,time_t SecondsWithoutAccess);
|
unsigned Usr_DB_GetOldUsrs (MYSQL_RES **mysql_res,time_t SecondsWithoutAccess);
|
||||||
|
void Usr_DB_CreateTmpTableAndSearchCandidateUsrs (const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1]);
|
||||||
|
void Usr_DB_DropTmpTableWithCandidateUsrs (void);
|
||||||
|
|
||||||
|
void Usr_DB_RemoveUsrData (long UsrCod);
|
||||||
|
|
||||||
|
//------------------------------ 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);
|
void Usr_DB_RemoveUsrLastData (long UsrCod);
|
||||||
void Usr_DB_RemoveUsrData (long UsrCod);
|
|
||||||
|
|
||||||
//------------------------------ Birthdays today ------------------------------
|
//------------------------------ Birthdays today ------------------------------
|
||||||
void Usr_DB_MarkMyBirthdayAsCongratulated (void);
|
void Usr_DB_MarkMyBirthdayAsCongratulated (void);
|
||||||
|
|
Loading…
Reference in New Issue