diff --git a/swad_changelog.h b/swad_changelog.h
index 7962153a..50a2ea7d 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -426,6 +426,8 @@ Lo de mutear anuncios, en principio prefiero hacer una opci
// TODO: Change in usability of Announcements of exams, suggested by Javier Fernández Baldomero.
+// TODO: Los usuarios que no tienes permiso para ver su perfil público, se debería mostrar algo, una mínima ficha sin tinmeline o algo así
+
// TODO: "Se podría poner un botón para seguir a todos los relacionados contigo en las asignaturas, en lugar de tener que agregarlos uno a uno" Suggested by José María girao Miras.
/*****************************************************************************/
@@ -447,10 +449,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
-#define Log_PLATFORM_VERSION "SWAD 18.69.2 (2019-03-10)"
+#define Log_PLATFORM_VERSION "SWAD 18.70 (2019-03-10)"
#define CSS_FILE "swad18.68.3.css"
#define JS_FILE "swad18.64.js"
/*
+ Version 18.70: Mar 10, 2019 Code refactoring in one user administration. (238819 lines)
Version 18.69.2: Mar 10, 2019 Changes related to alerts. (238842 lines)
Version 18.69.1: Mar 09, 2019 Changes in forms to register/remove users. (238805 lines)
Version 18.69: Mar 09, 2019 Code refactoring related to alerts. (238779 lines)
diff --git a/swad_enrolment.c b/swad_enrolment.c
index 1ed08e58..03115c48 100644
--- a/swad_enrolment.c
+++ b/swad_enrolment.c
@@ -115,12 +115,26 @@ static void Enr_NotifyAfterEnrolment (struct UsrData *UsrDat,Rol_Role_t NewRole)
static void Enr_ReqAdminUsrs (Rol_Role_t Role);
static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role);
-
static void Enr_PutAreaToEnterUsrsIDs (void);
static void Enr_PutActionsRegRemSeveralUsrs (void);
static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role);
+static void Enr_PutActionModifyOneUsr (bool *OptionChecked,
+ bool UsrBelongsToCrs,bool ItsMe);
+static void Enr_PutActionRegOneDegAdm (bool *OptionChecked);
+static void Enr_PutActionRegOneCtrAdm (bool *OptionChecked);
+static void Enr_PutActionRegOneInsAdm (bool *OptionChecked);
+static void Enr_PutActionRepUsrAsDup (bool *OptionChecked);
+static void Enr_PutActionRemUsrFromCrs (bool *OptionChecked,bool ItsMe);
+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,
+ bool *OptionChecked);
+static void Enr_EndRegRemOneUsrAction (void);
+
static void Enr_RegisterUsr (struct UsrData *UsrDat,Rol_Role_t RegRemRole,
struct ListCodGrps *LstGrps,unsigned *NumUsrsRegistered);
@@ -926,349 +940,6 @@ static void Enr_PutAreaToEnterUsrsIDs (void)
Tbl_EndTable ();
}
-/*****************************************************************************/
-/*** Put different actions to register/remove users to/from current course ***/
-/*****************************************************************************/
-// Returns true if at least one action can be shown
-
-bool Enr_PutActionsRegRemOneUsr (bool ItsMe)
- {
- extern const char *The_ClassFormInBox[The_NUM_THEMES];
- extern const char *Txt_Modify_me_in_the_course_X;
- extern const char *Txt_Modify_user_in_the_course_X;
- extern const char *Txt_Register_me_in_X;
- extern const char *Txt_Register_USER_in_the_course_X;
- extern const char *Txt_Report_possible_duplicate_user;
- extern const char *Txt_Register_USER_as_an_administrator_of_the_degree_X;
- extern const char *Txt_Register_USER_as_an_administrator_of_the_centre_X;
- extern const char *Txt_Register_USER_as_an_administrator_of_the_institution_X;
- extern const char *Txt_Remove_me_from_THE_COURSE_X;
- extern const char *Txt_Remove_USER_from_THE_COURSE_X;
- 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;
- extern const char *Txt_Remove_me_as_an_administrator_of_the_centre_X;
- extern const char *Txt_Remove_USER_as_an_administrator_of_the_centre_X;
- 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;
- extern const char *Txt_Eliminate_my_user_account;
- extern const char *Txt_Eliminate_user_account;
- unsigned NumOptionsShown = 0;
- bool UsrBelongsToCrs = false;
- bool UsrIsDegAdmin = false;
- bool UsrIsCtrAdmin = false;
- bool UsrIsInsAdmin = false;
- bool OptionChecked = false;
-
- /***** Check if the other user belongs to the current course *****/
- if (Gbl.CurrentCrs.Crs.CrsCod > 0)
- UsrBelongsToCrs = Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat);
-
- if (Gbl.CurrentIns.Ins.InsCod > 0)
- {
- /***** Check if the other user is administrator of the current institution *****/
- UsrIsInsAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
- Sco_SCOPE_INS,
- Gbl.CurrentIns.Ins.InsCod);
-
- if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
- {
- /***** Check if the other user is administrator of the current centre *****/
- UsrIsCtrAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
- Sco_SCOPE_CTR,
- Gbl.CurrentCtr.Ctr.CtrCod);
-
- if (Gbl.CurrentDeg.Deg.DegCod > 0)
- /***** Check if the other user is administrator of the current degree *****/
- UsrIsDegAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
- Sco_SCOPE_DEG,
- Gbl.CurrentDeg.Deg.DegCod);
- }
- }
-
- /***** Start list of options *****/
- fprintf (Gbl.F.Out,"
",
- The_ClassFormInBox[Gbl.Prefs.Theme]);
-
- /***** Register user in course / Modify user's data *****/
- if (Gbl.CurrentCrs.Crs.CrsCod > 0 &&
- Gbl.Usrs.Me.Role.Logged >= Rol_STD)
- {
- fprintf (Gbl.F.Out,"
"
- ""
- ""
- "
");
-
- NumOptionsShown++;
- }
-
- if (Gbl.CurrentIns.Ins.InsCod > 0)
- {
- if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
- {
- if (Gbl.CurrentDeg.Deg.DegCod > 0)
- /***** Register user as administrator of degree *****/
- if (!UsrIsDegAdmin &&
- Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM)
- {
- fprintf (Gbl.F.Out,"
"
- ""
- ""
- "
");
-
- NumOptionsShown++;
- }
-
- /***** Register user as administrator of centre *****/
- if (!UsrIsCtrAdmin &&
- Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM)
- {
- fprintf (Gbl.F.Out,"
"
- ""
- ""
- "
");
-
- NumOptionsShown++;
- }
- }
-
- /***** Register user as administrator of institution *****/
- if (!UsrIsInsAdmin &&
- Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
- {
- fprintf (Gbl.F.Out,"
"
- ""
- ""
- "
");
-
- NumOptionsShown++;
- }
- }
-
- /***** Report user as possible duplicate *****/
- if (!ItsMe && Gbl.Usrs.Me.Role.Logged >= Rol_TCH)
- {
- fprintf (Gbl.F.Out,"
"
- ""
- ""
- "
",
- (unsigned) Enr_REPORT_USR_AS_POSSIBLE_DUPLICATE,
- Txt_Report_possible_duplicate_user);
-
- NumOptionsShown++;
- }
-
- /***** Remove user from the course *****/
- if (UsrBelongsToCrs)
- {
- fprintf (Gbl.F.Out,"
"
- ""
- ""
- "
");
-
- NumOptionsShown++;
- }
-
- if (Gbl.CurrentIns.Ins.InsCod > 0)
- {
- if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
- {
- if (Gbl.CurrentIns.Ins.InsCod > 0)
- /***** Remove user as an administrator of the degree *****/
- if (UsrIsDegAdmin &&
- (ItsMe || Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM))
- {
- fprintf (Gbl.F.Out,"
"
- ""
- ""
- "
");
-
- NumOptionsShown++;
- }
-
- /***** Remove user as an administrator of the centre *****/
- if (UsrIsCtrAdmin &&
- (ItsMe || Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM))
- {
- fprintf (Gbl.F.Out,"
"
- ""
- ""
- "
");
-
- NumOptionsShown++;
- }
- }
-
- /***** Remove user as an administrator of the institution *****/
- if (UsrIsInsAdmin &&
- (ItsMe || Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM))
- {
- fprintf (Gbl.F.Out,"
"
- ""
- ""
- "
");
-
- NumOptionsShown++;
- }
- }
-
- /***** Eliminate user completely from platform *****/
- if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Other.UsrDat.UsrCod))
- {
- fprintf (Gbl.F.Out,"
"
- ""
- ""
- "
",
- (unsigned) Enr_ELIMINATE_ONE_USR_FROM_PLATFORM,
- ItsMe ? Txt_Eliminate_my_user_account :
- Txt_Eliminate_user_account);
-
- NumOptionsShown++;
- }
-
- /***** End list of options *****/
- fprintf (Gbl.F.Out,"
");
-
- return (NumOptionsShown ? true :
- false);
- }
-
/*****************************************************************************/
/*** Put different actions to register/remove users to/from current course ***/
/*****************************************************************************/
@@ -1784,6 +1455,333 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
Grp_FreeListGrpTypesAndGrps ();
}
+/*****************************************************************************/
+/*** Put different actions to register/remove users to/from current course ***/
+/*****************************************************************************/
+// Returns true if at least one action can be shown
+
+bool Enr_PutActionsRegRemOneUsr (bool ItsMe)
+ {
+ extern const char *The_ClassFormInBox[The_NUM_THEMES];
+ bool OptionsShown = false;
+ bool UsrBelongsToCrs = false;
+ bool UsrIsDegAdmin = false;
+ bool UsrIsCtrAdmin = false;
+ bool UsrIsInsAdmin = false;
+ bool OptionChecked = false;
+
+ /***** Check if the other user belongs to the current course *****/
+ if (Gbl.CurrentCrs.Crs.CrsCod > 0)
+ UsrBelongsToCrs = Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat);
+
+ if (Gbl.CurrentIns.Ins.InsCod > 0)
+ {
+ /***** Check if the other user is administrator of the current institution *****/
+ UsrIsInsAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
+ Sco_SCOPE_INS,
+ Gbl.CurrentIns.Ins.InsCod);
+
+ if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
+ {
+ /***** Check if the other user is administrator of the current centre *****/
+ UsrIsCtrAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
+ Sco_SCOPE_CTR,
+ Gbl.CurrentCtr.Ctr.CtrCod);
+
+ if (Gbl.CurrentDeg.Deg.DegCod > 0)
+ /***** Check if the other user is administrator of the current degree *****/
+ UsrIsDegAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
+ Sco_SCOPE_DEG,
+ Gbl.CurrentDeg.Deg.DegCod);
+ }
+ }
+
+ /***** Start list of options *****/
+ fprintf (Gbl.F.Out,"
",
+ The_ClassFormInBox[Gbl.Prefs.Theme]);
+
+ /***** Register user in course / Modify user's data *****/
+ if (Gbl.CurrentCrs.Crs.CrsCod > 0 && Gbl.Usrs.Me.Role.Logged >= Rol_STD)
+ {
+ Enr_PutActionModifyOneUsr (&OptionChecked,UsrBelongsToCrs,ItsMe);
+ OptionsShown = true;
+ }
+
+ if (Gbl.CurrentIns.Ins.InsCod > 0)
+ {
+ if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
+ {
+ if (Gbl.CurrentDeg.Deg.DegCod > 0)
+ /***** Register user as administrator of degree *****/
+ if (!UsrIsDegAdmin && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM)
+ {
+ Enr_PutActionRegOneDegAdm (&OptionChecked);
+ OptionsShown = true;
+ }
+
+ /***** Register user as administrator of centre *****/
+ if (!UsrIsCtrAdmin && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM)
+ {
+ Enr_PutActionRegOneCtrAdm (&OptionChecked);
+ OptionsShown = true;
+ }
+ }
+
+ /***** Register user as administrator of institution *****/
+ if (!UsrIsInsAdmin && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
+ {
+ Enr_PutActionRegOneInsAdm (&OptionChecked);
+ OptionsShown = true;
+ }
+ }
+
+ /***** Report user as possible duplicate *****/
+ if (!ItsMe && Gbl.Usrs.Me.Role.Logged >= Rol_TCH)
+ {
+ Enr_PutActionRepUsrAsDup (&OptionChecked);
+ OptionsShown = true;
+ }
+
+ /***** Remove user from the course *****/
+ if (UsrBelongsToCrs)
+ {
+ Enr_PutActionRemUsrFromCrs (&OptionChecked,ItsMe);
+ OptionsShown = true;
+ }
+
+ if (Gbl.CurrentIns.Ins.InsCod > 0)
+ {
+ if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
+ {
+ if (Gbl.CurrentIns.Ins.InsCod > 0)
+ /***** Remove user as an administrator of the degree *****/
+ if (UsrIsDegAdmin && (ItsMe || Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM))
+ {
+ Enr_PutActionRemUsrAsDegAdm (&OptionChecked,ItsMe);
+ OptionsShown = true;
+ }
+
+ /***** Remove user as an administrator of the centre *****/
+ if (UsrIsCtrAdmin && (ItsMe || Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM))
+ {
+ Enr_PutActionRemUsrAsCtrAdm (&OptionChecked,ItsMe);
+ OptionsShown = true;
+ }
+ }
+
+ /***** Remove user as an administrator of the institution *****/
+ if (UsrIsInsAdmin && (ItsMe || Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM))
+ {
+ Enr_PutActionRemUsrAsInsAdm (&OptionChecked,ItsMe);
+ OptionsShown = true;
+ }
+ }
+
+ /***** Eliminate user completely from platform *****/
+ if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Other.UsrDat.UsrCod))
+ {
+ Enr_PutActionRemUsrAcc (&OptionChecked,ItsMe);
+ OptionsShown = true;
+ }
+
+ /***** End list of options *****/
+ fprintf (Gbl.F.Out,"