mirror of https://github.com/acanas/swad-core.git
Version 20.91: Jun 09, 2021 New module swad_enrolment_database for database queries related to user's enrolment.
This commit is contained in:
parent
b9cd39c3a5
commit
b40c74e613
6
Makefile
6
Makefile
|
@ -42,9 +42,9 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_agenda.o \
|
|||
swad_database.o swad_date.o swad_degree.o swad_degree_config.o \
|
||||
swad_degree_database.o swad_degree_type.o swad_department.o \
|
||||
swad_department_database.o swad_duplicate.o swad_duplicate_database.o \
|
||||
swad_enrolment.o swad_error.o swad_exam.o swad_exam_log.o \
|
||||
swad_exam_print.o swad_exam_result.o swad_exam_session.o \
|
||||
swad_exam_set.o \
|
||||
swad_enrolment.o swad_enrolment_database.o swad_error.o swad_exam.o \
|
||||
swad_exam_log.o swad_exam_print.o swad_exam_result.o \
|
||||
swad_exam_session.o swad_exam_set.o \
|
||||
swad_figure.o swad_figure_cache.o swad_file.o swad_file_browser.o \
|
||||
swad_file_extension.o swad_file_MIME.o swad_firewall.o swad_follow.o \
|
||||
swad_follow_database.o swad_form.o swad_forum.o \
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "swad_connected_database.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_duplicate_database.h"
|
||||
#include "swad_enrolment.h"
|
||||
#include "swad_enrolment_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam_print.h"
|
||||
#include "swad_follow.h"
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "swad_center_config.h"
|
||||
#include "swad_center_database.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_enrolment_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_figure_cache.h"
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.90.1 (2021-06-09)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.91 (2021-06-09)"
|
||||
#define CSS_FILE "swad20.45.css"
|
||||
#define JS_FILE "swad20.69.1.js"
|
||||
/*
|
||||
TODO: Rename CENTRE to CENTER in help wiki.
|
||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||
|
||||
Version 20.91: Jun 09, 2021 New module swad_enrolment_database for database queries related to user's enrolment. (313063 lines)
|
||||
Version 20.90.1: Jun 09, 2021 Queries moved to module swad_duplicate_database. (312962 lines)
|
||||
Version 20.90: Jun 05, 2021 New module swad_duplicate_database for database queries related to duplicate users. (? lines)
|
||||
Version 20.89.1: Jun 05, 2021 Queries moved to module swad_department_database. (312869 lines)
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "swad_course_config.h"
|
||||
#include "swad_course_database.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_enrolment_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_figure_cache.h"
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "swad_degree.h"
|
||||
#include "swad_degree_config.h"
|
||||
#include "swad_degree_database.h"
|
||||
#include "swad_enrolment_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_figure_cache.h"
|
||||
|
|
|
@ -25,19 +25,8 @@
|
|||
/*********************************** Headers *********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// #include "swad_account.h"
|
||||
// #include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
// #include "swad_duplicate.h"
|
||||
// #include "swad_enrolment.h"
|
||||
// #include "swad_error.h"
|
||||
// #include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
// #include "swad_HTML.h"
|
||||
// #include "swad_layout.h"
|
||||
// #include "swad_profile.h"
|
||||
// #include "swad_role_type.h"
|
||||
// #include "swad_user.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
|
|
178
swad_enrolment.c
178
swad_enrolment.c
|
@ -37,6 +37,7 @@
|
|||
#include "swad_database.h"
|
||||
#include "swad_duplicate.h"
|
||||
#include "swad_enrolment.h"
|
||||
#include "swad_enrolment_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam_print.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -139,9 +140,9 @@ static void Enr_PutActionRemUsrAsDegAdm (bool *OptionChecked,bool ItsMe);
|
|||
static void Enr_PutActionRemUsrAsCtrAdm (bool *OptionChecked,bool ItsMe);
|
||||
static void Enr_PutActionRemUsrAsInsAdm (bool *OptionChecked,bool ItsMe);
|
||||
static void Enr_PutActionRemUsrAcc (bool *OptionChecked,bool ItsMe);
|
||||
static void Enr_StartRegRemOneUsrAction (Enr_RegRemOneUsrAction_t RegRemOneUsrAction,
|
||||
static void Enr_RegRemOneUsrActionBegin (Enr_RegRemOneUsrAction_t RegRemOneUsrAction,
|
||||
bool *OptionChecked);
|
||||
static void Enr_EndRegRemOneUsrAction (void);
|
||||
static void Enr_RegRemOneUsrActionEnd (void);
|
||||
|
||||
static void Enr_RegisterUsr (struct UsrData *UsrDat,Rol_Role_t RegRemRole,
|
||||
struct ListCodGrps *LstGrps,unsigned *NumUsrsRegistered);
|
||||
|
@ -403,17 +404,21 @@ void Enr_WriteFormToReqAnotherUsrID (Act_Action_t NextAction,void (*FuncParams)
|
|||
Frm_BeginForm (NextAction);
|
||||
if (FuncParams)
|
||||
FuncParams ();
|
||||
|
||||
/***** Label *****/
|
||||
HTM_LABEL_Begin ("for=\"OtherUsrIDNickOrEMail\" class=\"%s RM\"",
|
||||
The_ClassFormInBox[Gbl.Prefs.Theme]);
|
||||
HTM_TxtColonNBSP (Txt_nick_email_or_ID);
|
||||
HTM_LABEL_End ();
|
||||
|
||||
/***** Input box to enter user *****/
|
||||
HTM_INPUT_TEXT ("OtherUsrIDNickOrEMail",Cns_MAX_CHARS_EMAIL_ADDRESS,"",
|
||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||
"id=\"OtherUsrIDNickOrEMail\" size=\"18\" required=\"required\"");
|
||||
|
||||
/***** Send button*****/
|
||||
Btn_PutConfirmButton (Txt_Continue);
|
||||
|
||||
Frm_EndForm ();
|
||||
}
|
||||
|
||||
|
@ -609,26 +614,6 @@ void Enr_FilterUsrDat (struct UsrData *UsrDat)
|
|||
UsrDat->Birthday.Day = 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Update institution, center and department ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_UpdateInstitutionCenterDepartment (void)
|
||||
{
|
||||
DB_QueryUPDATE ("can not update institution, center and department",
|
||||
"UPDATE usr_data"
|
||||
" SET InsCtyCod=%ld,"
|
||||
"InsCod=%ld,"
|
||||
"CtrCod=%ld,"
|
||||
"DptCod=%ld"
|
||||
" WHERE UsrCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.InsCtyCod,
|
||||
Gbl.Usrs.Me.UsrDat.InsCod,
|
||||
Gbl.Usrs.Me.UsrDat.Tch.CtrCod,
|
||||
Gbl.Usrs.Me.UsrDat.Tch.DptCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Form to request the user's ID of another user ****************/
|
||||
/*****************************************************************************/
|
||||
|
@ -1634,13 +1619,13 @@ static void Enr_PutActionModifyOneUsr (bool *OptionChecked,
|
|||
extern const char *Txt_Register_me_in_X;
|
||||
extern const char *Txt_Register_USER_in_the_course_X;
|
||||
|
||||
Enr_StartRegRemOneUsrAction (Enr_REGISTER_MODIFY_ONE_USR_IN_CRS,OptionChecked);
|
||||
Enr_RegRemOneUsrActionBegin (Enr_REGISTER_MODIFY_ONE_USR_IN_CRS,OptionChecked);
|
||||
HTM_TxtF (UsrBelongsToCrs ? (ItsMe ? Txt_Modify_me_in_the_course_X :
|
||||
Txt_Modify_user_in_the_course_X) :
|
||||
(ItsMe ? Txt_Register_me_in_X :
|
||||
Txt_Register_USER_in_the_course_X),
|
||||
Gbl.Hierarchy.Crs.ShrtName);
|
||||
Enr_EndRegRemOneUsrAction ();
|
||||
Enr_RegRemOneUsrActionEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1651,10 +1636,10 @@ static void Enr_PutActionRegOneDegAdm (bool *OptionChecked)
|
|||
{
|
||||
extern const char *Txt_Register_USER_as_an_administrator_of_the_degree_X;
|
||||
|
||||
Enr_StartRegRemOneUsrAction (Enr_REGISTER_ONE_DEGREE_ADMIN,OptionChecked);
|
||||
Enr_RegRemOneUsrActionBegin (Enr_REGISTER_ONE_DEGREE_ADMIN,OptionChecked);
|
||||
HTM_TxtF (Txt_Register_USER_as_an_administrator_of_the_degree_X,
|
||||
Gbl.Hierarchy.Deg.ShrtName);
|
||||
Enr_EndRegRemOneUsrAction ();
|
||||
Enr_RegRemOneUsrActionEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1665,10 +1650,10 @@ static void Enr_PutActionRegOneCtrAdm (bool *OptionChecked)
|
|||
{
|
||||
extern const char *Txt_Register_USER_as_an_administrator_of_the_center_X;
|
||||
|
||||
Enr_StartRegRemOneUsrAction (Enr_REGISTER_ONE_CENTER_ADMIN,OptionChecked);
|
||||
Enr_RegRemOneUsrActionBegin (Enr_REGISTER_ONE_CENTER_ADMIN,OptionChecked);
|
||||
HTM_TxtF (Txt_Register_USER_as_an_administrator_of_the_center_X,
|
||||
Gbl.Hierarchy.Ctr.ShrtName);
|
||||
Enr_EndRegRemOneUsrAction ();
|
||||
Enr_RegRemOneUsrActionEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1679,10 +1664,10 @@ static void Enr_PutActionRegOneInsAdm (bool *OptionChecked)
|
|||
{
|
||||
extern const char *Txt_Register_USER_as_an_administrator_of_the_institution_X;
|
||||
|
||||
Enr_StartRegRemOneUsrAction (Enr_REGISTER_ONE_INSTITUTION_ADMIN,OptionChecked);
|
||||
Enr_RegRemOneUsrActionBegin (Enr_REGISTER_ONE_INSTITUTION_ADMIN,OptionChecked);
|
||||
HTM_TxtF (Txt_Register_USER_as_an_administrator_of_the_institution_X,
|
||||
Gbl.Hierarchy.Ins.ShrtName);
|
||||
Enr_EndRegRemOneUsrAction ();
|
||||
Enr_RegRemOneUsrActionEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1693,9 +1678,9 @@ static void Enr_PutActionRepUsrAsDup (bool *OptionChecked)
|
|||
{
|
||||
extern const char *Txt_Report_possible_duplicate_user;
|
||||
|
||||
Enr_StartRegRemOneUsrAction (Enr_REPORT_USR_AS_POSSIBLE_DUPLICATE,OptionChecked);
|
||||
Enr_RegRemOneUsrActionBegin (Enr_REPORT_USR_AS_POSSIBLE_DUPLICATE,OptionChecked);
|
||||
HTM_Txt (Txt_Report_possible_duplicate_user);
|
||||
Enr_EndRegRemOneUsrAction ();
|
||||
Enr_RegRemOneUsrActionEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1707,11 +1692,11 @@ static void Enr_PutActionRemUsrFromCrs (bool *OptionChecked,bool ItsMe)
|
|||
extern const char *Txt_Remove_me_from_THE_COURSE_X;
|
||||
extern const char *Txt_Remove_USER_from_THE_COURSE_X;
|
||||
|
||||
Enr_StartRegRemOneUsrAction (Enr_REMOVE_ONE_USR_FROM_CRS,OptionChecked);
|
||||
Enr_RegRemOneUsrActionBegin (Enr_REMOVE_ONE_USR_FROM_CRS,OptionChecked);
|
||||
HTM_TxtF (ItsMe ? Txt_Remove_me_from_THE_COURSE_X :
|
||||
Txt_Remove_USER_from_THE_COURSE_X,
|
||||
Gbl.Hierarchy.Crs.ShrtName);
|
||||
Enr_EndRegRemOneUsrAction ();
|
||||
Enr_RegRemOneUsrActionEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1723,11 +1708,11 @@ static void Enr_PutActionRemUsrAsDegAdm (bool *OptionChecked,bool ItsMe)
|
|||
extern const char *Txt_Remove_me_as_an_administrator_of_the_degree_X;
|
||||
extern const char *Txt_Remove_USER_as_an_administrator_of_the_degree_X;
|
||||
|
||||
Enr_StartRegRemOneUsrAction (Enr_REMOVE_ONE_DEGREE_ADMIN,OptionChecked);
|
||||
Enr_RegRemOneUsrActionBegin (Enr_REMOVE_ONE_DEGREE_ADMIN,OptionChecked);
|
||||
HTM_TxtF (ItsMe ? Txt_Remove_me_as_an_administrator_of_the_degree_X :
|
||||
Txt_Remove_USER_as_an_administrator_of_the_degree_X,
|
||||
Gbl.Hierarchy.Deg.ShrtName);
|
||||
Enr_EndRegRemOneUsrAction ();
|
||||
Enr_RegRemOneUsrActionEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1739,11 +1724,11 @@ static void Enr_PutActionRemUsrAsCtrAdm (bool *OptionChecked,bool ItsMe)
|
|||
extern const char *Txt_Remove_me_as_an_administrator_of_the_center_X;
|
||||
extern const char *Txt_Remove_USER_as_an_administrator_of_the_center_X;
|
||||
|
||||
Enr_StartRegRemOneUsrAction (Enr_REMOVE_ONE_CENTER_ADMIN,OptionChecked);
|
||||
Enr_RegRemOneUsrActionBegin (Enr_REMOVE_ONE_CENTER_ADMIN,OptionChecked);
|
||||
HTM_TxtF (ItsMe ? Txt_Remove_me_as_an_administrator_of_the_center_X :
|
||||
Txt_Remove_USER_as_an_administrator_of_the_center_X,
|
||||
Gbl.Hierarchy.Ctr.ShrtName);
|
||||
Enr_EndRegRemOneUsrAction ();
|
||||
Enr_RegRemOneUsrActionEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1755,11 +1740,11 @@ static void Enr_PutActionRemUsrAsInsAdm (bool *OptionChecked,bool ItsMe)
|
|||
extern const char *Txt_Remove_me_as_an_administrator_of_the_institution_X;
|
||||
extern const char *Txt_Remove_USER_as_an_administrator_of_the_institution_X;
|
||||
|
||||
Enr_StartRegRemOneUsrAction (Enr_REMOVE_ONE_INSTITUTION_ADMIN,OptionChecked);
|
||||
Enr_RegRemOneUsrActionBegin (Enr_REMOVE_ONE_INSTITUTION_ADMIN,OptionChecked);
|
||||
HTM_TxtF (ItsMe ? Txt_Remove_me_as_an_administrator_of_the_institution_X :
|
||||
Txt_Remove_USER_as_an_administrator_of_the_institution_X,
|
||||
Gbl.Hierarchy.Ins.ShrtName);
|
||||
Enr_EndRegRemOneUsrAction ();
|
||||
Enr_RegRemOneUsrActionEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1771,17 +1756,17 @@ static void Enr_PutActionRemUsrAcc (bool *OptionChecked,bool ItsMe)
|
|||
extern const char *Txt_Eliminate_my_user_account;
|
||||
extern const char *Txt_Eliminate_user_account;
|
||||
|
||||
Enr_StartRegRemOneUsrAction (Enr_ELIMINATE_ONE_USR_FROM_PLATFORM,OptionChecked);
|
||||
Enr_RegRemOneUsrActionBegin (Enr_ELIMINATE_ONE_USR_FROM_PLATFORM,OptionChecked);
|
||||
HTM_Txt (ItsMe ? Txt_Eliminate_my_user_account :
|
||||
Txt_Eliminate_user_account);
|
||||
Enr_EndRegRemOneUsrAction ();
|
||||
Enr_RegRemOneUsrActionEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Put start/end of action to register/remove one user ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Enr_StartRegRemOneUsrAction (Enr_RegRemOneUsrAction_t RegRemOneUsrAction,
|
||||
static void Enr_RegRemOneUsrActionBegin (Enr_RegRemOneUsrAction_t RegRemOneUsrAction,
|
||||
bool *OptionChecked)
|
||||
{
|
||||
HTM_LI_Begin (NULL);
|
||||
|
@ -1790,11 +1775,12 @@ static void Enr_StartRegRemOneUsrAction (Enr_RegRemOneUsrAction_t RegRemOneUsrAc
|
|||
"value=\"%u\"%s",
|
||||
(unsigned) RegRemOneUsrAction,
|
||||
*OptionChecked ? "" : " checked=\"checked\"");
|
||||
|
||||
if (!*OptionChecked)
|
||||
*OptionChecked = true;
|
||||
}
|
||||
|
||||
static void Enr_EndRegRemOneUsrAction (void)
|
||||
static void Enr_RegRemOneUsrActionEnd (void)
|
||||
{
|
||||
HTM_LABEL_End ();
|
||||
HTM_LI_End ();
|
||||
|
@ -3792,7 +3778,7 @@ void Enr_AcceptRegisterMeInCrs (void)
|
|||
extern const char *Txt_You_have_confirmed_your_enrolment_in_the_course_X;
|
||||
|
||||
/***** Confirm my enrolment *****/
|
||||
Enr_AcceptUsrInCrs (Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
Enr_DB_AcceptUsrInCrs (Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
|
||||
/***** Mark all notifications about enrolment (as student or as teacher)
|
||||
in current course as removed *****/
|
||||
|
@ -4131,22 +4117,6 @@ void Enr_ModifyUsr2 (void)
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Set a user's acceptation to true in the current course ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_AcceptUsrInCrs (long UsrCod)
|
||||
{
|
||||
/***** Set enrolment of a user to "accepted" in the current course *****/
|
||||
DB_QueryUPDATE ("can not confirm user's enrolment",
|
||||
"UPDATE crs_users"
|
||||
" SET Accepted='Y'"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Ask if really wanted to remove a user *******************/
|
||||
/*****************************************************************************/
|
||||
|
@ -4308,66 +4278,6 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
|
|||
Ale_CreateAlertUserNotFoundOrYouDoNotHavePermission ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Remove all users' requests for inscription in a course **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemCrsRequests (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove requests for inscription to a course",
|
||||
"DELETE FROM crs_requests"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Remove user's requests for inscription from a course ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemUsrRequests (long UsrCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove user's requests for inscription",
|
||||
"DELETE FROM crs_requests"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Remove all users from settings in a course ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemAllUsrsFromCrsSettings (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove users from a course settings",
|
||||
"DELETE FROM crs_user_settings"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Remove all users from settings in a course ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemAllUsrsFromCrs (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove users from a course",
|
||||
"DELETE FROM crs_users"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Remove a user from a course ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemUsrFromAllCrss (long UsrCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a user from all courses",
|
||||
"DELETE FROM crs_users"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/** Ask if really wanted to remove an administrator from current institution */
|
||||
/*****************************************************************************/
|
||||
|
@ -4441,29 +4351,3 @@ static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,HieLvl_Level_t Scope,
|
|||
Ale_ShowAlert (Ale_ERROR,Txt_THE_USER_X_is_not_an_administrator_of_Y,
|
||||
UsrDat->FullName,InsCtrDegName);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******* Remove user as administrator of any degree/center/institution *******/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemUsrAsAdmin (long UsrCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a user as administrator",
|
||||
"DELETE FROM usr_admins"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Remove administrators of an institution, center or degree *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemAdmins (HieLvl_Level_t Scope,long Cod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove administrators",
|
||||
"DELETE FROM usr_admins"
|
||||
" WHERE Scope='%s'"
|
||||
" AND Cod=%ld",
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,6 @@ void Enr_GetNotifEnrolment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
long CrsCod,long UsrCod);
|
||||
void Enr_UpdateUsrData (struct UsrData *UsrDat);
|
||||
void Enr_FilterUsrDat (struct UsrData *UsrDat);
|
||||
void Enr_UpdateInstitutionCenterDepartment (void);
|
||||
|
||||
void Enr_ReqAdminStds (void);
|
||||
void Enr_ReqAdminNonEditingTchs (void);
|
||||
|
@ -143,14 +142,4 @@ void Enr_CreateNewUsr2 (void);
|
|||
void Enr_ModifyUsr1 (void);
|
||||
void Enr_ModifyUsr2 (void);
|
||||
|
||||
void Enr_AcceptUsrInCrs (long UsrCod);
|
||||
|
||||
void Enr_DB_RemCrsRequests (long CrsCod);
|
||||
void Enr_DB_RemUsrRequests (long UsrCod);
|
||||
void Enr_DB_RemAllUsrsFromCrsSettings (long CrsCod);
|
||||
void Enr_DB_RemAllUsrsFromCrs (long CrsCod);
|
||||
void Enr_DB_RemUsrFromAllCrss (long UsrCod);
|
||||
void Enr_DB_RemUsrAsAdmin (long UsrCod);
|
||||
void Enr_DB_RemAdmins (HieLvl_Level_t Scope,long Cod);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,203 @@
|
|||
// swad_enrolment_database.h: enrolment (registration) or removing of users, operations with database
|
||||
|
||||
/*
|
||||
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.
|
||||
Copyright (C) 1999-2021 Antonio Cañas Vargas
|
||||
|
||||
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 *********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// #define _GNU_SOURCE // For asprintf
|
||||
// #include <stdio.h> // For asprintf
|
||||
// #include <stdlib.h> // For exit, system, malloc, free, rand, etc.
|
||||
// #include <string.h> // For string functions
|
||||
|
||||
// #include "swad_account.h"
|
||||
// #include "swad_announcement.h"
|
||||
// #include "swad_attendance_database.h"
|
||||
// #include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
// #include "swad_duplicate.h"
|
||||
#include "swad_enrolment.h"
|
||||
#include "swad_enrolment_database.h"
|
||||
// #include "swad_error.h"
|
||||
// #include "swad_exam_print.h"
|
||||
// #include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
// #include "swad_hierarchy.h"
|
||||
// #include "swad_HTML.h"
|
||||
// #include "swad_ID.h"
|
||||
// #include "swad_match.h"
|
||||
// #include "swad_message.h"
|
||||
// #include "swad_notification.h"
|
||||
// #include "swad_parameter.h"
|
||||
// #include "swad_photo.h"
|
||||
// #include "swad_role.h"
|
||||
// #include "swad_test_print.h"
|
||||
// #include "swad_user.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Private types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
extern struct Globals Gbl;
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Private global variables *************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Update institution, center and department ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_UpdateInstitutionCenterDepartment (void)
|
||||
{
|
||||
DB_QueryUPDATE ("can not update institution, center and department",
|
||||
"UPDATE usr_data"
|
||||
" SET InsCtyCod=%ld,"
|
||||
"InsCod=%ld,"
|
||||
"CtrCod=%ld,"
|
||||
"DptCod=%ld"
|
||||
" WHERE UsrCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.InsCtyCod,
|
||||
Gbl.Usrs.Me.UsrDat.InsCod,
|
||||
Gbl.Usrs.Me.UsrDat.Tch.CtrCod,
|
||||
Gbl.Usrs.Me.UsrDat.Tch.DptCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Set a user's acceptation to true in the current course ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_AcceptUsrInCrs (long UsrCod)
|
||||
{
|
||||
/***** Set enrolment of a user to "accepted" in the current course *****/
|
||||
DB_QueryUPDATE ("can not confirm user's enrolment",
|
||||
"UPDATE crs_users"
|
||||
" SET Accepted='Y'"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Remove all users' requests for inscription in a course **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemCrsRequests (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove requests for inscription to a course",
|
||||
"DELETE FROM crs_requests"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Remove user's requests for inscription from a course ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemUsrRequests (long UsrCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove user's requests for inscription",
|
||||
"DELETE FROM crs_requests"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Remove all users from settings in a course ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemAllUsrsFromCrsSettings (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove users from a course settings",
|
||||
"DELETE FROM crs_user_settings"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Remove all users from settings in a course ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemAllUsrsFromCrs (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove users from a course",
|
||||
"DELETE FROM crs_users"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Remove a user from a course ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemUsrFromAllCrss (long UsrCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a user from all courses",
|
||||
"DELETE FROM crs_users"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******* Remove user as administrator of any degree/center/institution *******/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemUsrAsAdmin (long UsrCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a user as administrator",
|
||||
"DELETE FROM usr_admins"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Remove administrators of an institution, center or degree *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemAdmins (HieLvl_Level_t Scope,long Cod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove administrators",
|
||||
"DELETE FROM usr_admins"
|
||||
" WHERE Scope='%s'"
|
||||
" AND Cod=%ld",
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
// swad_enrolment_database.h: enrolment (registration) or removing of users, operations with database
|
||||
|
||||
#ifndef _SWAD_ENR_DB
|
||||
#define _SWAD_ENR_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ñ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 "swad_course.h"
|
||||
#include "swad_hierarchy.h"
|
||||
// #include "swad_notification.h"
|
||||
// #include "swad_user.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************** Public types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_UpdateInstitutionCenterDepartment (void);
|
||||
|
||||
void Enr_DB_AcceptUsrInCrs (long UsrCod);
|
||||
|
||||
void Enr_DB_RemCrsRequests (long CrsCod);
|
||||
void Enr_DB_RemUsrRequests (long UsrCod);
|
||||
void Enr_DB_RemAllUsrsFromCrsSettings (long CrsCod);
|
||||
void Enr_DB_RemAllUsrsFromCrs (long CrsCod);
|
||||
void Enr_DB_RemUsrFromAllCrss (long UsrCod);
|
||||
void Enr_DB_RemUsrAsAdmin (long UsrCod);
|
||||
void Enr_DB_RemAdmins (HieLvl_Level_t Scope,long Cod);
|
||||
|
||||
#endif
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "swad_database.h"
|
||||
#include "swad_department.h"
|
||||
#include "swad_enrolment_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_figure_cache.h"
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_department.h"
|
||||
#include "swad_enrolment.h"
|
||||
#include "swad_enrolment_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_follow_database.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -4088,7 +4088,7 @@ void Rec_ChgCountryOfMyInstitution (void)
|
|||
}
|
||||
|
||||
/***** Update institution, center and department *****/
|
||||
Enr_UpdateInstitutionCenterDepartment ();
|
||||
Enr_DB_UpdateInstitutionCenterDepartment ();
|
||||
|
||||
/***** Show form again *****/
|
||||
Rec_ShowMySharedRecordAndMore ();
|
||||
|
@ -4126,7 +4126,7 @@ void Rec_UpdateMyInstitution (void)
|
|||
Gbl.Usrs.Me.UsrDat.Tch.DptCod = (NumDpts ? -1L : 0);
|
||||
|
||||
/***** Update institution, center and department *****/
|
||||
Enr_UpdateInstitutionCenterDepartment ();
|
||||
Enr_DB_UpdateInstitutionCenterDepartment ();
|
||||
|
||||
/***** Show form again *****/
|
||||
Rec_ShowMySharedRecordAndMore ();
|
||||
|
@ -4159,7 +4159,7 @@ void Rec_UpdateMyCenter (void)
|
|||
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = Ctr.CtrCod;
|
||||
|
||||
/***** Update institution, center and department *****/
|
||||
Enr_UpdateInstitutionCenterDepartment ();
|
||||
Enr_DB_UpdateInstitutionCenterDepartment ();
|
||||
|
||||
/***** Show form again *****/
|
||||
Rec_ShowMySharedRecordAndMore ();
|
||||
|
@ -4190,7 +4190,7 @@ void Rec_UpdateMyDepartment (void)
|
|||
|
||||
/***** Update institution, center and department *****/
|
||||
Gbl.Usrs.Me.UsrDat.Tch.DptCod = Dpt.DptCod;
|
||||
Enr_UpdateInstitutionCenterDepartment ();
|
||||
Enr_DB_UpdateInstitutionCenterDepartment ();
|
||||
|
||||
/***** Show form again *****/
|
||||
Rec_ShowMySharedRecordAndMore ();
|
||||
|
|
Loading…
Reference in New Issue