mirror of https://github.com/acanas/swad-core.git
Version 16.103.23
This commit is contained in:
parent
96f3bb963b
commit
5d1eca20fd
|
@ -190,13 +190,14 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 16.103.2 (2016-12-17)"
|
#define Log_PLATFORM_VERSION "SWAD 16.103.3 (2016-12-17)"
|
||||||
#define CSS_FILE "swad16.103.1.css"
|
#define CSS_FILE "swad16.103.1.css"
|
||||||
#define JS_FILE "swad16.101.js"
|
#define JS_FILE "swad16.101.js"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 16.103.3: Dec 17, 2016 Code refactoring in user enrollment. (211149 lines)
|
||||||
Version 16.103.2: Dec 17, 2016 Code refactoring in user enrollment. (211133 lines)
|
Version 16.103.2: Dec 17, 2016 Code refactoring in user enrollment. (211133 lines)
|
||||||
Version 16.103.1: Dec 16, 2016 Changes in layout of tabs. (211123 lines)
|
Version 16.103.1: Dec 16, 2016 Changes in layout of tabs. (211123 lines)
|
||||||
Version 16.103: Dec 16, 2016 Contextual help on course info. (211130 lines)
|
Version 16.103: Dec 16, 2016 Contextual help on course info. (211130 lines)
|
||||||
|
|
|
@ -166,54 +166,34 @@ void Enr_PutLinkToRequestSignUp (void)
|
||||||
/***************** Modify the role of a user in a course *********************/
|
/***************** Modify the role of a user in a course *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat,
|
void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole)
|
||||||
Rol_Role_t NewRole,
|
|
||||||
Cns_QuietOrVerbose_t QuietOrVerbose)
|
|
||||||
{
|
{
|
||||||
extern const char *Txt_The_role_of_THE_USER_X_in_the_course_Y_has_changed_from_A_to_B;
|
|
||||||
extern const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
|
||||||
char Query[256];
|
char Query[256];
|
||||||
Rol_Role_t OldRole;
|
|
||||||
|
|
||||||
/***** Change user's role if different *****/
|
/***** Check if user's role is allowed *****/
|
||||||
OldRole = Rol_GetRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod);
|
switch (NewRole)
|
||||||
if (NewRole != OldRole) // The role must be updated
|
|
||||||
{
|
{
|
||||||
/***** Check if user's role is allowed *****/
|
case Rol_STUDENT:
|
||||||
switch (NewRole)
|
case Rol_TEACHER:
|
||||||
{
|
break;
|
||||||
case Rol_STUDENT:
|
default:
|
||||||
case Rol_TEACHER:
|
Lay_ShowErrorAndExit ("Wrong role.");
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Lay_ShowErrorAndExit ("Wrong role.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Update the role of a user in a course *****/
|
|
||||||
sprintf (Query,"UPDATE crs_usr SET Role='%u'"
|
|
||||||
" WHERE CrsCod='%ld' AND UsrCod='%ld'",
|
|
||||||
(unsigned) NewRole,Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod);
|
|
||||||
DB_QueryUPDATE (Query,"can not modify user's role in course");
|
|
||||||
|
|
||||||
/***** Create notification for this user.
|
|
||||||
If this user wants to receive notifications by email,
|
|
||||||
activate the sending of a notification *****/
|
|
||||||
Enr_NotifyAfterEnrollment (UsrDat,NewRole);
|
|
||||||
|
|
||||||
/***** Show info message *****/
|
|
||||||
if (QuietOrVerbose == Cns_VERBOSE)
|
|
||||||
{
|
|
||||||
sprintf (Gbl.Message,Txt_The_role_of_THE_USER_X_in_the_course_Y_has_changed_from_A_to_B,
|
|
||||||
UsrDat->FullName,Gbl.CurrentCrs.Crs.FullName,
|
|
||||||
Txt_ROLES_SINGUL_abc[OldRole][UsrDat->Sex],
|
|
||||||
Txt_ROLES_SINGUL_abc[NewRole][UsrDat->Sex]);
|
|
||||||
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
UsrDat->RoleInCurrentCrsDB = NewRole;
|
|
||||||
UsrDat->Roles = -1; // Force roles to be got from database
|
|
||||||
Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); // Get roles
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***** Update the role of a user in a course *****/
|
||||||
|
sprintf (Query,"UPDATE crs_usr SET Role='%u'"
|
||||||
|
" WHERE CrsCod='%ld' AND UsrCod='%ld'",
|
||||||
|
(unsigned) NewRole,Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod);
|
||||||
|
DB_QueryUPDATE (Query,"can not modify user's role in course");
|
||||||
|
|
||||||
|
/***** Create notification for this user.
|
||||||
|
If this user wants to receive notifications by email,
|
||||||
|
activate the sending of a notification *****/
|
||||||
|
Enr_NotifyAfterEnrollment (UsrDat,NewRole);
|
||||||
|
|
||||||
|
UsrDat->RoleInCurrentCrsDB = NewRole;
|
||||||
|
UsrDat->Roles = -1; // Force roles to be got from database
|
||||||
|
Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); // Get roles
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1635,8 +1615,12 @@ static void Enr_RegisterUsr (struct UsrData *UsrDat,Rol_Role_t RegRemRole,
|
||||||
{
|
{
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
|
if (Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
false)) // User does belong to current course, modify his/her role
|
false)) // User does belong to current course
|
||||||
Enr_ModifyRoleInCurrentCrs (UsrDat,RegRemRole,Cns_QUIET);
|
{
|
||||||
|
if (RegRemRole != UsrDat->RoleInCurrentCrsDB) // The role must be updated
|
||||||
|
/* Modify role */
|
||||||
|
Enr_ModifyRoleInCurrentCrs (UsrDat,RegRemRole);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
/* Register user */
|
/* Register user */
|
||||||
Enr_RegisterUsrInCurrentCrs (UsrDat,RegRemRole,
|
Enr_RegisterUsrInCurrentCrs (UsrDat,RegRemRole,
|
||||||
|
@ -3466,8 +3450,11 @@ void Enr_AcceptRegisterMeInCrs (void)
|
||||||
|
|
||||||
void Enr_CreateNewUsr (void)
|
void Enr_CreateNewUsr (void)
|
||||||
{
|
{
|
||||||
|
extern const char *Txt_The_role_of_THE_USER_X_in_the_course_Y_has_changed_from_A_to_B;
|
||||||
|
extern const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||||
extern const char *Txt_THE_USER_X_has_been_enrolled_in_the_course_Y;
|
extern const char *Txt_THE_USER_X_has_been_enrolled_in_the_course_Y;
|
||||||
extern const char *Txt_The_ID_X_is_not_valid;
|
extern const char *Txt_The_ID_X_is_not_valid;
|
||||||
|
Rol_Role_t OldRole;
|
||||||
Rol_Role_t NewRole;
|
Rol_Role_t NewRole;
|
||||||
|
|
||||||
/***** Get user's ID from form *****/
|
/***** Get user's ID from form *****/
|
||||||
|
@ -3496,8 +3483,22 @@ void Enr_CreateNewUsr (void)
|
||||||
{
|
{
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
false)) // User does belong to current course, modify his/her role
|
false)) // User does belong to current course
|
||||||
Enr_ModifyRoleInCurrentCrs (&Gbl.Usrs.Other.UsrDat,NewRole,Cns_VERBOSE);
|
{
|
||||||
|
OldRole = Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB; // Remember old role before changing it
|
||||||
|
if (NewRole != OldRole) // The role must be updated
|
||||||
|
{
|
||||||
|
/* Modify role */
|
||||||
|
Enr_ModifyRoleInCurrentCrs (&Gbl.Usrs.Other.UsrDat,NewRole);
|
||||||
|
|
||||||
|
/* Show success message */
|
||||||
|
sprintf (Gbl.Message,Txt_The_role_of_THE_USER_X_in_the_course_Y_has_changed_from_A_to_B,
|
||||||
|
Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName,
|
||||||
|
Txt_ROLES_SINGUL_abc[OldRole][Gbl.Usrs.Other.UsrDat.Sex],
|
||||||
|
Txt_ROLES_SINGUL_abc[NewRole][Gbl.Usrs.Other.UsrDat.Sex]);
|
||||||
|
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Register user */
|
/* Register user */
|
||||||
|
@ -3533,12 +3534,15 @@ void Enr_CreateNewUsr (void)
|
||||||
|
|
||||||
void Enr_ModifyUsr (void)
|
void Enr_ModifyUsr (void)
|
||||||
{
|
{
|
||||||
|
extern const char *Txt_The_role_of_THE_USER_X_in_the_course_Y_has_changed_from_A_to_B;
|
||||||
|
extern const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||||
extern const char *Txt_THE_USER_X_has_been_enrolled_in_the_course_Y;
|
extern const char *Txt_THE_USER_X_has_been_enrolled_in_the_course_Y;
|
||||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||||
char UnsignedStr[10+1];
|
char UnsignedStr[10+1];
|
||||||
unsigned UnsignedNum;
|
unsigned UnsignedNum;
|
||||||
bool ItsMe;
|
bool ItsMe;
|
||||||
Enr_RegRemOneUsrAction_t RegRemAction;
|
Enr_RegRemOneUsrAction_t RegRemAction;
|
||||||
|
Rol_Role_t OldRole;
|
||||||
Rol_Role_t NewRole;
|
Rol_Role_t NewRole;
|
||||||
bool Error = false;
|
bool Error = false;
|
||||||
|
|
||||||
|
@ -3571,8 +3575,22 @@ void Enr_ModifyUsr (void)
|
||||||
/***** Register user in current course in database *****/
|
/***** Register user in current course in database *****/
|
||||||
if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
false)) // User does belong to current course, modify his/her role
|
false)) // User does belong to current course
|
||||||
Enr_ModifyRoleInCurrentCrs (&Gbl.Usrs.Other.UsrDat,NewRole,Cns_VERBOSE);
|
{
|
||||||
|
OldRole = Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB; // Remember old role before changing it
|
||||||
|
if (NewRole != OldRole) // The role must be updated
|
||||||
|
{
|
||||||
|
/* Modify role */
|
||||||
|
Enr_ModifyRoleInCurrentCrs (&Gbl.Usrs.Other.UsrDat,NewRole);
|
||||||
|
|
||||||
|
/* Show success message */
|
||||||
|
sprintf (Gbl.Message,Txt_The_role_of_THE_USER_X_in_the_course_Y_has_changed_from_A_to_B,
|
||||||
|
Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName,
|
||||||
|
Txt_ROLES_SINGUL_abc[OldRole][Gbl.Usrs.Other.UsrDat.Sex],
|
||||||
|
Txt_ROLES_SINGUL_abc[NewRole][Gbl.Usrs.Other.UsrDat.Sex]);
|
||||||
|
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Register user */
|
/* Register user */
|
||||||
|
|
|
@ -72,9 +72,7 @@ void Enr_PutButtonToEnrollStudents (void);
|
||||||
|
|
||||||
void Enr_PutLinkToRequestSignUp (void);
|
void Enr_PutLinkToRequestSignUp (void);
|
||||||
|
|
||||||
void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat,
|
void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole);
|
||||||
Rol_Role_t NewRole,
|
|
||||||
Cns_QuietOrVerbose_t QuietOrVerbose);
|
|
||||||
void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
|
void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
|
||||||
Enr_KeepOrSetAccepted_t KeepOrSetAccepted);
|
Enr_KeepOrSetAccepted_t KeepOrSetAccepted);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue