mirror of https://github.com/acanas/swad-core.git
Version 20.91.3: Jun 11, 2021 Queries moved to module swad_enrolment_database.
This commit is contained in:
parent
ca9420971c
commit
486382daaa
|
@ -988,7 +988,7 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
|
|||
Dup_DB_RemoveUsrFromDuplicated (UsrDat->UsrCod);
|
||||
|
||||
/***** Remove user from the tables of courses and users *****/
|
||||
Set_DB_RemCrsUsrSettings (UsrDat->UsrCod);
|
||||
Set_DB_RemUsrFromAllCrssSettings (UsrDat->UsrCod);
|
||||
Enr_DB_RemUsrFromAllCrss (UsrDat->UsrCod);
|
||||
|
||||
if (QuietOrVerbose == Cns_VERBOSE)
|
||||
|
|
|
@ -203,3 +203,23 @@ void Acc_DB_UpdateUsrData (const struct UsrData *UsrDat)
|
|||
"",
|
||||
UsrDat->UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Update institution, center and department ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Acc_DB_UpdateMyInstitutionCenterDepartment (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);
|
||||
}
|
||||
|
|
|
@ -52,5 +52,6 @@ bool Acc_DB_CheckIfEmailAlreadyExists (const char NewEmail[Cns_MAX_BYTES_EMAIL_A
|
|||
|
||||
long Acc_DB_CreateNewUsr (const struct UsrData *UsrDat);
|
||||
void Acc_DB_UpdateUsrData (const struct UsrData *UsrDat);
|
||||
void Acc_DB_UpdateMyInstitutionCenterDepartment (void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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.91.2 (2021-06-11)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.91.3 (2021-06-11)"
|
||||
#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.3: Jun 11, 2021 Queries moved to module swad_enrolment_database. (313173 lines)
|
||||
Version 20.91.2: Jun 11, 2021 Queries moved to module swad_enrolment_database. (313143 lines)
|
||||
Version 20.91.1: Jun 10, 2021 Queries moved to module swad_enrolment_database. (313145 lines)
|
||||
Version 20.91: Jun 09, 2021 New module swad_enrolment_database for database queries related to user's enrolment. (313063 lines)
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "swad_notice.h"
|
||||
#include "swad_project.h"
|
||||
#include "swad_search.h"
|
||||
#include "swad_setting.h"
|
||||
#include "swad_survey.h"
|
||||
#include "swad_test.h"
|
||||
|
||||
|
@ -1842,7 +1843,7 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
|
|||
Enr_DB_RemCrsRequests (CrsCod);
|
||||
|
||||
/***** Remove possible users remaining in the course (teachers) *****/
|
||||
Enr_DB_RemAllUsrsFromCrsSettings (CrsCod);
|
||||
Set_DB_RemAllUsrsFromCrsSettings (CrsCod);
|
||||
Enr_DB_RemAllUsrsFromCrs (CrsCod);
|
||||
|
||||
/***** Remove directories of the course *****/
|
||||
|
|
|
@ -153,8 +153,7 @@ static void Enr_PutLinkToRemAllStdsThisCrs (void);
|
|||
|
||||
static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected);
|
||||
|
||||
static void Enr_RemoveEnrolmentRequest (long CrsCod,long UsrCod);
|
||||
static void Enr_RemoveExpiredEnrolmentRequests (void);
|
||||
static void Enr_RemUsrEnrolmentRequestInCrs (long UsrCod,long CrsCod);
|
||||
|
||||
static void Enr_ReqRegRemUsr (Rol_Role_t Role);
|
||||
static void Enr_ReqAnotherUsrIDToRegisterRemove (Rol_Role_t Role);
|
||||
|
@ -296,10 +295,11 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
|
|||
}
|
||||
|
||||
/***** Register user in current course in database *****/
|
||||
Enr_DB_InsertUsrInCurrentCrs (UsrDat->UsrCod,NewRole,KeepOrSetAccepted);
|
||||
Enr_DB_InsertUsrInCurrentCrs (UsrDat->UsrCod,Gbl.Hierarchy.Crs.CrsCod,
|
||||
NewRole,KeepOrSetAccepted);
|
||||
|
||||
/***** Register last prefs in current course in database *****/
|
||||
Set_DB_InsertUsrInCurrentCrsSettings (UsrDat->UsrCod);
|
||||
Set_DB_InsertUsrInCrsSettings (UsrDat->UsrCod,Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/***** Flush caches *****/
|
||||
Usr_FlushCachesUsr ();
|
||||
|
@ -344,7 +344,7 @@ static void Enr_NotifyAfterEnrolment (struct UsrData *UsrDat,Rol_Role_t NewRole)
|
|||
}
|
||||
|
||||
/***** Remove possible enrolment request ******/
|
||||
Enr_RemoveEnrolmentRequest (Gbl.Hierarchy.Crs.CrsCod,UsrDat->UsrCod);
|
||||
Enr_RemUsrEnrolmentRequestInCrs (UsrDat->UsrCod,Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/***** Remove old enrolment notifications before inserting the new one ******/
|
||||
Ntf_MarkNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLMENT_STD,-1,UsrDat->UsrCod);
|
||||
|
@ -1917,8 +1917,8 @@ void Enr_SignUpInCrs (void)
|
|||
Err_WrongRoleExit ();
|
||||
|
||||
/***** Try to get and old request of the same user (me) in the current course *****/
|
||||
ReqCod = Enr_DB_GetUsrEnrolmentRequestInCrs (Gbl.Hierarchy.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
ReqCod = Enr_DB_GetUsrEnrolmentRequestInCrs (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/***** Request user in current course in database *****/
|
||||
if (ReqCod > 0) // Old request exists in database
|
||||
|
@ -2024,7 +2024,8 @@ void Enr_AskIfRejectSignUp (void)
|
|||
Rec_ShowSharedRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/* Remove inscription request because it has not sense */
|
||||
Enr_RemoveEnrolmentRequest (Gbl.Hierarchy.Crs.CrsCod,Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
Enr_RemUsrEnrolmentRequestInCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
}
|
||||
else // User does not belong to this course
|
||||
{
|
||||
|
@ -2082,7 +2083,8 @@ void Enr_RejectSignUp (void)
|
|||
}
|
||||
|
||||
/* Remove inscription request */
|
||||
Enr_RemoveEnrolmentRequest (Gbl.Hierarchy.Crs.CrsCod,Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
Enr_RemUsrEnrolmentRequestInCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/* Confirmation message */
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_Enrolment_of_X_rejected,
|
||||
|
@ -2171,7 +2173,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
Act_Action_t NextAction;
|
||||
|
||||
/***** Remove expired enrolment requests *****/
|
||||
Enr_RemoveExpiredEnrolmentRequests ();
|
||||
Enr_DB_RemoveExpiredEnrolmentRequests ();
|
||||
|
||||
/***** Get scope *****/
|
||||
Gbl.Scope.Allowed = 1 << HieLvl_SYS |
|
||||
|
@ -2373,7 +2375,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
else // User does not exists or user already belongs to course ==> remove pair from crs_requests table
|
||||
Enr_RemoveEnrolmentRequest (Crs.CrsCod,UsrDat.UsrCod);
|
||||
Enr_RemUsrEnrolmentRequestInCrs (UsrDat.UsrCod,Crs.CrsCod);
|
||||
}
|
||||
|
||||
/* End table */
|
||||
|
@ -2393,12 +2395,12 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
/********************* Remove a request for enrolment ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Enr_RemoveEnrolmentRequest (long CrsCod,long UsrCod)
|
||||
static void Enr_RemUsrEnrolmentRequestInCrs (long UsrCod,long CrsCod)
|
||||
{
|
||||
long ReqCod;
|
||||
|
||||
/***** Get request code *****/
|
||||
ReqCod = Enr_DB_GetUsrEnrolmentRequestInCrs (CrsCod,UsrCod);
|
||||
ReqCod = Enr_DB_GetUsrEnrolmentRequestInCrs (UsrCod,CrsCod);
|
||||
|
||||
if (ReqCod > 0)
|
||||
{
|
||||
|
@ -2411,32 +2413,6 @@ static void Enr_RemoveEnrolmentRequest (long CrsCod,long UsrCod)
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Remove expired requests for enrolment ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Enr_RemoveExpiredEnrolmentRequests (void)
|
||||
{
|
||||
/***** Mark possible notifications as removed
|
||||
Important: do this before removing the request *****/
|
||||
DB_QueryUPDATE ("can not set notification(s) as removed",
|
||||
"UPDATE ntf_notifications,"
|
||||
"crs_requests"
|
||||
" SET ntf_notifications.Status=(ntf_notifications.Status | %u)"
|
||||
" WHERE ntf_notifications.NotifyEvent=%u"
|
||||
" AND ntf_notifications.Cod=crs_requests.ReqCod"
|
||||
" AND crs_requests.RequestTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
|
||||
(unsigned) Ntf_STATUS_BIT_REMOVED,
|
||||
(unsigned) Ntf_EVENT_ENROLMENT_REQUEST,
|
||||
Cfg_TIME_TO_DELETE_ENROLMENT_REQUESTS);
|
||||
|
||||
/***** Remove expired requests for enrolment *****/
|
||||
DB_QueryDELETE ("can not remove expired requests for enrolment",
|
||||
"DELETE LOW_PRIORITY FROM crs_requests"
|
||||
" WHERE RequestTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
|
||||
Cfg_TIME_TO_DELETE_ENROLMENT_REQUESTS);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Write a form to admin one user ***********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -2821,14 +2797,7 @@ static void Enr_RegisterAdmin (struct UsrData *UsrDat,HieLvl_Level_t Scope,long
|
|||
else // User was not administrator of current institution/center/degree
|
||||
{
|
||||
/***** Insert or replace administrator in current institution/center/degree *****/
|
||||
DB_QueryREPLACE ("can not create administrator",
|
||||
"REPLACE INTO usr_admins"
|
||||
" (UsrCod,Scope,Cod)"
|
||||
" VALUES"
|
||||
" (%ld,'%s',%ld)",
|
||||
UsrDat->UsrCod,
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
Enr_DB_InsertAdmin (UsrDat->UsrCod,Scope,Cod);
|
||||
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_enroled_as_administrator_of_Y,
|
||||
UsrDat->FullName,InsCtrDegName);
|
||||
|
@ -3102,7 +3071,7 @@ void Enr_AcceptRegisterMeInCrs (void)
|
|||
extern const char *Txt_You_have_confirmed_your_enrolment_in_the_course_X;
|
||||
|
||||
/***** Confirm my enrolment *****/
|
||||
Enr_DB_AcceptUsrInCrs (Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
Enr_DB_AcceptUsrInCrs (Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/***** Mark all notifications about enrolment (as student or as teacher)
|
||||
in current course as removed *****/
|
||||
|
@ -3546,18 +3515,8 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
|
|||
Ntf_MarkNotifInCrsAsRemoved (UsrDat->UsrCod,Crs->CrsCod);
|
||||
|
||||
/***** Remove user from the tables of courses-users *****/
|
||||
DB_QueryDELETE ("can not remove a user from a course",
|
||||
"DELETE FROM crs_user_settings"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
UsrDat->UsrCod,
|
||||
Crs->CrsCod);
|
||||
DB_QueryDELETE ("can not remove a user from a course",
|
||||
"DELETE FROM crs_users"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
Crs->CrsCod,
|
||||
UsrDat->UsrCod);
|
||||
Set_DB_RemUsrFromCrsSettings (UsrDat->UsrCod,Crs->CrsCod);
|
||||
Enr_DB_RemUsrFromCrs (UsrDat->UsrCod,Crs->CrsCod);
|
||||
|
||||
/***** Flush caches *****/
|
||||
Usr_FlushCachesUsr ();
|
||||
|
|
|
@ -84,7 +84,7 @@ extern struct Globals Gbl;
|
|||
/*************** Register user in current course in database *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_InsertUsrInCurrentCrs (long UsrCod,Rol_Role_t NewRole,
|
||||
void Enr_DB_InsertUsrInCurrentCrs (long UsrCod,long CrsCod,Rol_Role_t NewRole,
|
||||
Enr_KeepOrSetAccepted_t KeepOrSetAccepted)
|
||||
{
|
||||
DB_QueryINSERT ("can not register user in course",
|
||||
|
@ -92,38 +92,18 @@ void Enr_DB_InsertUsrInCurrentCrs (long UsrCod,Rol_Role_t NewRole,
|
|||
" (CrsCod,UsrCod,Role,Accepted)"
|
||||
" VALUES"
|
||||
" (%ld,%ld,%u,'%c')",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
CrsCod,
|
||||
UsrCod,
|
||||
(unsigned) NewRole,
|
||||
KeepOrSetAccepted == Enr_SET_ACCEPTED_TO_TRUE ? 'Y' :
|
||||
'N');
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** 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)
|
||||
void Enr_DB_AcceptUsrInCrs (long UsrCod,long CrsCod)
|
||||
{
|
||||
/***** Set enrolment of a user to "accepted" in the current course *****/
|
||||
DB_QueryUPDATE ("can not confirm user's enrolment",
|
||||
|
@ -131,10 +111,48 @@ void Enr_DB_AcceptUsrInCrs (long UsrCod)
|
|||
" SET Accepted='Y'"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
CrsCod,
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Remove user from course **************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemUsrFromCrs (long UsrCod,long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a user from a course",
|
||||
"DELETE FROM crs_users"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
CrsCod,
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ 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 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);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Set a user's acceptation to true in the current course ************/
|
||||
/*****************************************************************************/
|
||||
|
@ -688,7 +706,7 @@ unsigned Enr_DB_GetEnrolmentRequestByCod (MYSQL_RES **mysql_res,long ReqCod)
|
|||
/********** Try to get an enrolment request from a user in a course **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
long Enr_DB_GetUsrEnrolmentRequestInCrs (long CrsCod,long UsrCod)
|
||||
long Enr_DB_GetUsrEnrolmentRequestInCrs (long UsrCod,long CrsCod)
|
||||
{
|
||||
return
|
||||
DB_QuerySELECTCode ("can not get enrolment request",
|
||||
|
@ -773,39 +791,61 @@ void Enr_DB_RemUsrRequests (long UsrCod)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Remove all users from settings in a course ******************/
|
||||
/******************* Remove expired requests for enrolment ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemAllUsrsFromCrsSettings (long CrsCod)
|
||||
void Enr_DB_RemoveExpiredEnrolmentRequests (void)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove users from a course settings",
|
||||
"DELETE FROM crs_user_settings"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
/***** Mark possible notifications as removed
|
||||
Important: do this before removing the request *****/
|
||||
DB_QueryUPDATE ("can not set notification(s) as removed",
|
||||
"UPDATE ntf_notifications,"
|
||||
"crs_requests"
|
||||
" SET ntf_notifications.Status=(ntf_notifications.Status | %u)"
|
||||
" WHERE ntf_notifications.NotifyEvent=%u"
|
||||
" AND ntf_notifications.Cod=crs_requests.ReqCod"
|
||||
" AND crs_requests.RequestTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
|
||||
(unsigned) Ntf_STATUS_BIT_REMOVED,
|
||||
(unsigned) Ntf_EVENT_ENROLMENT_REQUEST,
|
||||
Cfg_TIME_TO_DELETE_ENROLMENT_REQUESTS);
|
||||
|
||||
/***** Remove expired requests for enrolment *****/
|
||||
DB_QueryDELETE ("can not remove expired requests for enrolment",
|
||||
"DELETE LOW_PRIORITY FROM crs_requests"
|
||||
" WHERE RequestTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
|
||||
Cfg_TIME_TO_DELETE_ENROLMENT_REQUESTS);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Remove all users from settings in a course ******************/
|
||||
/** Insert/replace user as administrator of an institution, center or degree */
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemAllUsrsFromCrs (long CrsCod)
|
||||
void Enr_DB_InsertAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove users from a course",
|
||||
"DELETE FROM crs_users"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryREPLACE ("can not create administrator",
|
||||
"REPLACE INTO usr_admins"
|
||||
" (UsrCod,Scope,Cod)"
|
||||
" VALUES"
|
||||
" (%ld,'%s',%ld)",
|
||||
UsrCod,
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Remove a user from a course ************************/
|
||||
/***** Remove user as administrator of an institution, center or degree ******/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemUsrFromAllCrss (long UsrCod)
|
||||
void Enr_DB_RemAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a user from all courses",
|
||||
"DELETE FROM crs_users"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
DB_QueryDELETE ("can not remove an administrator",
|
||||
"DELETE FROM usr_admins"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Scope='%s'"
|
||||
" AND Cod=%ld",
|
||||
UsrCod,
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -833,19 +873,3 @@ void Enr_DB_RemAdmins (HieLvl_Level_t Scope,long Cod)
|
|||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***** Remove user as administrator of an institution, center or degree ******/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove an administrator",
|
||||
"DELETE FROM usr_admins"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Scope='%s'"
|
||||
" AND Cod=%ld",
|
||||
UsrCod,
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
}
|
||||
|
|
|
@ -45,28 +45,26 @@
|
|||
/****************************** Public prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_InsertUsrInCurrentCrs (long UsrCod,Rol_Role_t NewRole,
|
||||
void Enr_DB_InsertUsrInCurrentCrs (long UsrCod,long CrsCod,Rol_Role_t NewRole,
|
||||
Enr_KeepOrSetAccepted_t KeepOrSetAccepted);
|
||||
|
||||
void Enr_DB_UpdateInstitutionCenterDepartment (void);
|
||||
|
||||
void Enr_DB_AcceptUsrInCrs (long UsrCod);
|
||||
void Enr_DB_AcceptUsrInCrs (long UsrCod,long CrsCod);
|
||||
void Enr_DB_RemUsrFromCrs (long UsrCod,long CrsCod);
|
||||
void Enr_DB_RemUsrFromAllCrss (long UsrCod);
|
||||
void Enr_DB_RemAllUsrsFromCrs (long CrsCod);
|
||||
|
||||
unsigned Enr_DB_GetEnrolmentRequests (MYSQL_RES **mysql_res,unsigned RolesSelected);
|
||||
unsigned Enr_DB_GetEnrolmentRequestByCod (MYSQL_RES **mysql_res,long ReqCod);
|
||||
long Enr_DB_GetUsrEnrolmentRequestInCrs (long CrsCod,long UsrCod);
|
||||
long Enr_DB_GetUsrEnrolmentRequestInCrs (long UsrCod,long CrsCod);
|
||||
long Enr_DB_CreateMyEnrolmentRequestInCurrentCrs (Rol_Role_t NewRole);
|
||||
void Enr_DB_UpdateMyEnrolmentRequestInCurrentCrs (long ReqCod,Rol_Role_t NewRole);
|
||||
void Enr_DB_RemRequest (long ReqCod);
|
||||
void Enr_DB_RemCrsRequests (long CrsCod);
|
||||
void Enr_DB_RemUsrRequests (long UsrCod);
|
||||
void Enr_DB_RemoveExpiredEnrolmentRequests (void);
|
||||
|
||||
void Enr_DB_RemAllUsrsFromCrsSettings (long CrsCod);
|
||||
void Enr_DB_RemAllUsrsFromCrs (long CrsCod);
|
||||
void Enr_DB_RemUsrFromAllCrss (long UsrCod);
|
||||
|
||||
void Enr_DB_InsertAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
||||
void Enr_DB_RemAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
||||
void Enr_DB_RemUsrAsAdmin (long UsrCod);
|
||||
void Enr_DB_RemAdmins (HieLvl_Level_t Scope,long Cod);
|
||||
void Enr_DB_RemAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "swad_account.h"
|
||||
#include "swad_account_database.h"
|
||||
#include "swad_action.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_config.h"
|
||||
|
@ -4088,7 +4089,7 @@ void Rec_ChgCountryOfMyInstitution (void)
|
|||
}
|
||||
|
||||
/***** Update institution, center and department *****/
|
||||
Enr_DB_UpdateInstitutionCenterDepartment ();
|
||||
Acc_DB_UpdateMyInstitutionCenterDepartment ();
|
||||
|
||||
/***** Show form again *****/
|
||||
Rec_ShowMySharedRecordAndMore ();
|
||||
|
@ -4126,7 +4127,7 @@ void Rec_UpdateMyInstitution (void)
|
|||
Gbl.Usrs.Me.UsrDat.Tch.DptCod = (NumDpts ? -1L : 0);
|
||||
|
||||
/***** Update institution, center and department *****/
|
||||
Enr_DB_UpdateInstitutionCenterDepartment ();
|
||||
Acc_DB_UpdateMyInstitutionCenterDepartment ();
|
||||
|
||||
/***** Show form again *****/
|
||||
Rec_ShowMySharedRecordAndMore ();
|
||||
|
@ -4159,7 +4160,7 @@ void Rec_UpdateMyCenter (void)
|
|||
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = Ctr.CtrCod;
|
||||
|
||||
/***** Update institution, center and department *****/
|
||||
Enr_DB_UpdateInstitutionCenterDepartment ();
|
||||
Acc_DB_UpdateMyInstitutionCenterDepartment ();
|
||||
|
||||
/***** Show form again *****/
|
||||
Rec_ShowMySharedRecordAndMore ();
|
||||
|
@ -4190,7 +4191,7 @@ void Rec_UpdateMyDepartment (void)
|
|||
|
||||
/***** Update institution, center and department *****/
|
||||
Gbl.Usrs.Me.UsrDat.Tch.DptCod = Dpt.DptCod;
|
||||
Enr_DB_UpdateInstitutionCenterDepartment ();
|
||||
Acc_DB_UpdateMyInstitutionCenterDepartment ();
|
||||
|
||||
/***** Show form again *****/
|
||||
Rec_ShowMySharedRecordAndMore ();
|
||||
|
|
|
@ -404,7 +404,7 @@ void Set_EndOneSettingSelector (void)
|
|||
/************ Register last prefs in current course in database **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Set_DB_InsertUsrInCurrentCrsSettings (long UsrCod)
|
||||
void Set_DB_InsertUsrInCrsSettings (long UsrCod,long CrsCod)
|
||||
{
|
||||
extern const char *Usr_StringsUsrListTypeInDB[Usr_NUM_USR_LIST_TYPES];
|
||||
|
||||
|
@ -420,7 +420,7 @@ void Set_DB_InsertUsrInCurrentCrsSettings (long UsrCod)
|
|||
"0,FROM_UNIXTIME(%ld),0,"
|
||||
"'%s',%u,'%c')",
|
||||
UsrCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
CrsCod,
|
||||
(long) (time_t) 0, // The user never accessed to tests in this course
|
||||
Usr_StringsUsrListTypeInDB[Usr_SHOW_USRS_TYPE_DEFAULT],
|
||||
Usr_CLASS_PHOTO_COLS_DEF,
|
||||
|
@ -429,13 +429,40 @@ void Set_DB_InsertUsrInCurrentCrsSettings (long UsrCod)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Remove a user from course settings *********************/
|
||||
/****************** Remove a user from a courses setting *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Set_DB_RemCrsUsrSettings (long UsrCod)
|
||||
void Set_DB_RemUsrFromCrsSettings (long UsrCod,long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a user from a course",
|
||||
"DELETE FROM crs_user_settings"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
UsrCod,
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Remove a user from all courses settings *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Set_DB_RemUsrFromAllCrssSettings (long UsrCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a user from all courses",
|
||||
"DELETE FROM crs_user_settings"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Remove all users from settings in a course ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Set_DB_RemAllUsrsFromCrsSettings (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove users from a course settings",
|
||||
"DELETE FROM crs_user_settings"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,9 @@ void Set_EndSettingsHead (void);
|
|||
void Set_BeginOneSettingSelector (void);
|
||||
void Set_EndOneSettingSelector (void);
|
||||
|
||||
void Set_DB_InsertUsrInCurrentCrsSettings (long UsrCod);
|
||||
void Set_DB_RemCrsUsrSettings (long UsrCod);
|
||||
void Set_DB_InsertUsrInCrsSettings (long UsrCod,long CrsCod);
|
||||
void Set_DB_RemUsrFromCrsSettings (long UsrCod,long CrsCod);
|
||||
void Set_DB_RemUsrFromAllCrssSettings (long UsrCod);
|
||||
void Set_DB_RemAllUsrsFromCrsSettings (long CrsCod);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue