diff --git a/swad_changelog.h b/swad_changelog.h index d5f83bb5a..e212d014e 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -178,14 +178,16 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.71.9 (2016-11-26)" +#define Log_PLATFORM_VERSION "SWAD 16.72 (2016-11-27)" #define CSS_FILE "swad16.69.css" #define JS_FILE "swad16.46.1.js" // 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 /* - Version 16.71.9: Nov 26, 2016 Fixed bug in list of students, reported by Javier Fernández Baldomero. (207641 lines) + Version 16.72: Nov 27, 2016 Link to show all users' data. + Code refactoring in scopes. (207698 lines) + Version 16.71.9: Nov 27, 2016 Fixed bug in list of students, reported by Javier Fernández Baldomero. (207641 lines) Version 16.71.8: Nov 26, 2016 Contextual help on email to students. Contextual help on global announcements. (207634 lines) Version 16.71.7: Nov 26, 2016 Code refactoring in timetable. (207626 lines) diff --git a/swad_scope.c b/swad_scope.c index 26906668c..95acd470f 100644 --- a/swad_scope.c +++ b/swad_scope.c @@ -177,7 +177,7 @@ void Sco_PutSelectorScope (const char *ParamName,bool SendOnChange) } /*****************************************************************************/ -/************* Put hidden parameter with location range *********************/ +/********************** Put hidden parameter scope ***************************/ /*****************************************************************************/ void Sco_PutParamScope (const char *ParamName,Sco_Scope_t Scope) @@ -186,7 +186,7 @@ void Sco_PutParamScope (const char *ParamName,Sco_Scope_t Scope) } /*****************************************************************************/ -/************************* Get users range for listing ***********************/ +/*************************** Get parameter scope *****************************/ /*****************************************************************************/ void Sco_GetScope (const char *ParamName) @@ -195,7 +195,20 @@ void Sco_GetScope (const char *ParamName) /***** Get parameter location range if exists *****/ Par_GetParToText (ParamName,UnsignedStr,10); - if ((Gbl.Scope.Current = Sco_GetScopeFromUnsignedStr (UnsignedStr)) == Sco_SCOPE_UNK) + Gbl.Scope.Current = Sco_GetScopeFromUnsignedStr (UnsignedStr); + + /***** Adjust scope avoiding impossible or forbidden scopes *****/ + Sco_AdjustScope (); + } + +/*****************************************************************************/ +/*********** Adjust scope avoiding impossible or forbidden scopes ************/ +/*****************************************************************************/ + +void Sco_AdjustScope (void) + { + /***** Is scope is unknow, use default scope *****/ + if (Gbl.Scope.Current == Sco_SCOPE_UNK) Gbl.Scope.Current = Gbl.Scope.Default; /***** Avoid impossible scopes *****/ @@ -237,11 +250,11 @@ void Sco_SetScopesForListingGuests (void) Gbl.Scope.Default = Sco_SCOPE_INS; break; case Rol_SYS_ADM: - Gbl.Scope.Allowed = 1 << Sco_SCOPE_SYS | - 1 << Sco_SCOPE_CTY | + Gbl.Scope.Allowed = 1 << Sco_SCOPE_SYS | + 1 << Sco_SCOPE_CTY | 1 << Sco_SCOPE_INS | 1 << Sco_SCOPE_CTR; - Gbl.Scope.Default = Sco_SCOPE_INS; + Gbl.Scope.Default = Sco_SCOPE_SYS; break; default: Gbl.Scope.Allowed = 0; diff --git a/swad_scope.h b/swad_scope.h index 1ca451f1c..6a2d91ffc 100644 --- a/swad_scope.h +++ b/swad_scope.h @@ -57,6 +57,8 @@ typedef enum void Sco_PutSelectorScope (const char *ParamName,bool SendOnChange); void Sco_PutParamScope (const char *ParamName,Sco_Scope_t Scope); void Sco_GetScope (const char *ParamName); +void Sco_AdjustScope (void); + void Sco_SetScopesForListingGuests (void); void Sco_SetScopesForListingStudents (void); diff --git a/swad_statistic.c b/swad_statistic.c index 3ce0824a1..3b4e3c238 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -3868,18 +3868,9 @@ void Sta_PutIconToShowFigure (void) static void Sta_PutParamsToShowFigure (void) { - if (Gbl.CurrentCrs.Crs.CrsCod > 0) - Gbl.Scope.Current = Sco_SCOPE_CRS; - else if (Gbl.CurrentDeg.Deg.DegCod > 0) - Gbl.Scope.Current = Sco_SCOPE_DEG; - else if (Gbl.CurrentCtr.Ctr.CtrCod > 0) - Gbl.Scope.Current = Sco_SCOPE_CTR; - else if (Gbl.CurrentIns.Ins.InsCod > 0) - Gbl.Scope.Current = Sco_SCOPE_INS; - else if (Gbl.CurrentCty.Cty.CtyCod > 0) - Gbl.Scope.Current = Sco_SCOPE_CTY; - else - Gbl.Scope.Current = Sco_SCOPE_SYS; + /***** Set default scope (used only if Gbl.Scope.Current is unknown) *****/ + Gbl.Scope.Default = Sco_SCOPE_CRS; + Sco_AdjustScope (); Sta_PutHiddenParamFigures (); } diff --git a/swad_user.c b/swad_user.c index 60f1750cd..d5a9aee9a 100644 --- a/swad_user.c +++ b/swad_user.c @@ -187,8 +187,11 @@ static void Usr_PutIconToPrintGsts (void); static void Usr_PutIconToPrintStds (void); static void Usr_PutIconToPrintTchs (void); static void Usr_PutIconToShowGstsAllData (void); +static void Usr_PutLinkToShowGstsAllData (void); static void Usr_PutIconToShowStdsAllData (void); +static void Usr_PutLinkToShowStdsAllData (void); static void Usr_PutIconToShowTchsAllData (void); +static void Usr_PutLinkToShowTchsAllData (void); static void Usr_ShowGstsAllDataParams (void); static void Usr_ShowStdsAllDataParams (void); static void Usr_ShowTchsAllDataParams (void); @@ -5255,6 +5258,8 @@ void Usr_PutExtraParamsUsrList (Act_Action_t NextAction) } break; case ActSeeUseGbl: + /* Used in selector of "Class photo"/"List" + in STATS > Figures > Institutions */ Sta_PutHiddenParamFigures (); break; case ActSeePhoDeg: @@ -6790,18 +6795,24 @@ void Usr_SeeGuests (void) /***** Form to select type of list of users *****/ Usr_ShowFormsToSelectUsrListType (ActLstGst); - /***** Draw a class photo with students of the course *****/ + /***** Draw a class photo with guests *****/ + switch (Gbl.Usrs.Me.ListType) + { + case Usr_CLASS_PHOTO: + Lay_WriteHeaderClassPhoto (false,true, + (Gbl.Scope.Current == Sco_SCOPE_CTR || + Gbl.Scope.Current == Sco_SCOPE_INS) ? Gbl.CurrentIns.Ins.InsCod : + -1L, + -1L, + -1L); + break; + case Usr_LIST: + Usr_PutLinkToShowGstsAllData (); + break; + } + /* Start form */ Act_FormStart (ActSeeRecSevGst); - Grp_PutParamsCodGrps (); - - if (Gbl.Usrs.Me.ListType == Usr_CLASS_PHOTO) - Lay_WriteHeaderClassPhoto (false,true, - (Gbl.Scope.Current == Sco_SCOPE_CTR || - Gbl.Scope.Current == Sco_SCOPE_INS) ? Gbl.CurrentIns.Ins.InsCod : - -1L, - -1L, - -1L); /* Start table */ fprintf (Gbl.F.Out,""); @@ -6940,6 +6951,26 @@ void Usr_SeeStudents (void) Usr_ShowFormsToSelectUsrListType (ActLstStd); /***** Draw a class photo with students of the course *****/ + switch (Gbl.Usrs.Me.ListType) + { + case Usr_CLASS_PHOTO: + Lay_WriteHeaderClassPhoto (false,true, + (Gbl.Scope.Current == Sco_SCOPE_CRS || + Gbl.Scope.Current == Sco_SCOPE_DEG || + Gbl.Scope.Current == Sco_SCOPE_CTR || + Gbl.Scope.Current == Sco_SCOPE_INS) ? Gbl.CurrentIns.Ins.InsCod : + -1L, + (Gbl.Scope.Current == Sco_SCOPE_CRS || + Gbl.Scope.Current == Sco_SCOPE_DEG) ? Gbl.CurrentDeg.Deg.DegCod : + -1L, + Gbl.Scope.Current == Sco_SCOPE_CRS ? Gbl.CurrentCrs.Crs.CrsCod : + -1L); + break; + case Usr_LIST: + Usr_PutLinkToShowStdsAllData (); + break; + } + /* Start form */ if (ICanViewRecords) { @@ -6947,19 +6978,6 @@ void Usr_SeeStudents (void) Grp_PutParamsCodGrps (); } - if (Gbl.Usrs.Me.ListType == Usr_CLASS_PHOTO) - Lay_WriteHeaderClassPhoto (false,true, - (Gbl.Scope.Current == Sco_SCOPE_CRS || - Gbl.Scope.Current == Sco_SCOPE_DEG || - Gbl.Scope.Current == Sco_SCOPE_CTR || - Gbl.Scope.Current == Sco_SCOPE_INS) ? Gbl.CurrentIns.Ins.InsCod : - -1L, - (Gbl.Scope.Current == Sco_SCOPE_CRS || - Gbl.Scope.Current == Sco_SCOPE_DEG) ? Gbl.CurrentDeg.Deg.DegCod : - -1L, - Gbl.Scope.Current == Sco_SCOPE_CRS ? Gbl.CurrentCrs.Crs.CrsCod : - -1L); - /* Start table */ fprintf (Gbl.F.Out,"
"); @@ -7087,23 +7105,31 @@ void Usr_SeeTeachers (void) Usr_ShowFormsToSelectUsrListType (ActLstTch); /***** Draw a class photo with teachers of the course *****/ + switch (Gbl.Usrs.Me.ListType) + { + case Usr_CLASS_PHOTO: + Lay_WriteHeaderClassPhoto (false,true, + (Gbl.Scope.Current == Sco_SCOPE_CRS || + Gbl.Scope.Current == Sco_SCOPE_DEG || + Gbl.Scope.Current == Sco_SCOPE_CTR || + Gbl.Scope.Current == Sco_SCOPE_INS) ? Gbl.CurrentIns.Ins.InsCod : + -1L, + (Gbl.Scope.Current == Sco_SCOPE_CRS || + Gbl.Scope.Current == Sco_SCOPE_DEG) ? Gbl.CurrentDeg.Deg.DegCod : + -1L, + Gbl.Scope.Current == Sco_SCOPE_CRS ? Gbl.CurrentCrs.Crs.CrsCod : + -1L); + break; + case Usr_LIST: + if (Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM) + Usr_PutLinkToShowTchsAllData (); + break; + } + /* Start form */ if (ICanViewRecords) Act_FormStart (ActSeeRecSevTch); - if (Gbl.Usrs.Me.ListType == Usr_CLASS_PHOTO) - Lay_WriteHeaderClassPhoto (false,true, - (Gbl.Scope.Current == Sco_SCOPE_CRS || - Gbl.Scope.Current == Sco_SCOPE_DEG || - Gbl.Scope.Current == Sco_SCOPE_CTR || - Gbl.Scope.Current == Sco_SCOPE_INS) ? Gbl.CurrentIns.Ins.InsCod : - -1L, - (Gbl.Scope.Current == Sco_SCOPE_CRS || - Gbl.Scope.Current == Sco_SCOPE_DEG) ? Gbl.CurrentDeg.Deg.DegCod : - -1L, - Gbl.Scope.Current == Sco_SCOPE_CRS ? Gbl.CurrentCrs.Crs.CrsCod : - -1L); - /* Start table */ fprintf (Gbl.F.Out,"
"); @@ -7244,6 +7270,10 @@ static void Usr_PutIconToPrintTchs (void) NULL); } +/*****************************************************************************/ +/**************** Functions used to list all data of users *******************/ +/*****************************************************************************/ + static void Usr_PutIconToShowGstsAllData (void) { extern const char *Txt_Show_all_data; @@ -7254,6 +7284,16 @@ static void Usr_PutIconToShowGstsAllData (void) NULL); } +static void Usr_PutLinkToShowGstsAllData (void) + { + extern const char *Txt_Show_all_data; + + Lay_PutContextualLink (ActLstGstAll,Usr_ShowGstsAllDataParams, + "table64x64.gif", + Txt_Show_all_data,Txt_Show_all_data, + NULL); + } + static void Usr_PutIconToShowStdsAllData (void) { extern const char *Txt_Show_all_data; @@ -7264,6 +7304,16 @@ static void Usr_PutIconToShowStdsAllData (void) NULL); } +static void Usr_PutLinkToShowStdsAllData (void) + { + extern const char *Txt_Show_all_data; + + Lay_PutContextualLink (ActLstStdAll,Usr_ShowStdsAllDataParams, + "table64x64.gif", + Txt_Show_all_data,Txt_Show_all_data, + NULL); + } + static void Usr_PutIconToShowTchsAllData (void) { extern const char *Txt_Show_all_data; @@ -7274,6 +7324,16 @@ static void Usr_PutIconToShowTchsAllData (void) NULL); } +static void Usr_PutLinkToShowTchsAllData (void) + { + extern const char *Txt_Show_all_data; + + Lay_PutContextualLink (ActLstTchAll,Usr_ShowTchsAllDataParams, + "table64x64.gif", + Txt_Show_all_data,Txt_Show_all_data, + NULL); + } + static void Usr_ShowGstsAllDataParams (void) { Usr_PutParamListWithPhotos ();