diff --git a/swad_centre.c b/swad_centre.c index a5aed6a0..a12cbcff 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -80,13 +80,15 @@ static void Ctr_PutIconsToPrintAndUpload (void); static void Ctr_PutIconToChangePhoto (void); static void Ctr_ListCentres (void); -static void Ctr_PutIconToEditFrames (void); +static bool Ctr_CheckIfICanEditCentres (void); +static void Ctr_PutIconsListCentres (void); +static void Ctr_PutIconToEditCentres (void); static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr); static void Ctr_GetParamCtrOrderType (void); static void Ctr_GetPhotoAttribution (long CtrCod,char **PhotoAttribution); static void Ctr_FreePhotoAttribution (char **PhotoAttribution); static void Ctr_ListCentresForEdition (void); -static bool Ctr_CheckIfICanEdit (struct Centre *Ctr); +static bool Ctr_CheckIfICanEditACentre (struct Centre *Ctr); static Ctr_StatusTxt_t Ctr_GetStatusTxtFromStatusBits (Ctr_Status_t Status); static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt); @@ -734,12 +736,10 @@ static void Ctr_ListCentres (void) extern const char *Txt_Create_another_centre; extern const char *Txt_Create_centre; unsigned NumCtr; - bool ICanEdit = (Gbl.Usrs.Me.LoggedRole >= Rol__GUEST_); /***** Start frame *****/ sprintf (Gbl.Title,Txt_Centres_of_INSTITUTION_X,Gbl.CurrentIns.Ins.FullName); - Lay_StartRoundFrame (NULL,Gbl.Title,ICanEdit ? Ctr_PutIconToEditFrames : - NULL); + Lay_StartRoundFrame (NULL,Gbl.Title,Ctr_PutIconsListCentres); if (Gbl.Ctrs.Num) // There are centres in the current institution { @@ -760,7 +760,7 @@ static void Ctr_ListCentres (void) Lay_ShowAlert (Lay_INFO,Txt_No_centres); /***** Button to create centre *****/ - if (ICanEdit) + if (Ctr_CheckIfICanEditCentres ()) { Act_FormStart (ActEdiCtr); Lay_PutConfirmButton (Gbl.Ctrs.Num ? Txt_Create_another_centre : @@ -772,11 +772,35 @@ static void Ctr_ListCentres (void) Lay_EndRoundFrame (); } +/*****************************************************************************/ +/*********************** Check if I can edit centres *************************/ +/*****************************************************************************/ + +static bool Ctr_CheckIfICanEditCentres (void) + { + return (bool) (Gbl.Usrs.Me.LoggedRole >= Rol__GUEST_); + } + +/*****************************************************************************/ +/***************** Put contextual icons in list of centres *******************/ +/*****************************************************************************/ + +static void Ctr_PutIconsListCentres (void) + { + /***** Put icon to edit centres *****/ + if (Ctr_CheckIfICanEditCentres ()) + Ctr_PutIconToEditCentres (); + + /***** Put icon to show a figure *****/ + Gbl.Stat.FigureType = Sta_HIERARCHY; + Sta_PutIconToShowFigure (); + } + /*****************************************************************************/ /********************** Put link (form) to edit centres **********************/ /*****************************************************************************/ -static void Ctr_PutIconToEditFrames (void) +static void Ctr_PutIconToEditCentres (void) { extern const char *Txt_Edit; @@ -1354,7 +1378,7 @@ static void Ctr_ListCentresForEdition (void) { Ctr = &Gbl.Ctrs.Lst[NumCtr]; - ICanEdit = Ctr_CheckIfICanEdit (Ctr); + ICanEdit = Ctr_CheckIfICanEditACentre (Ctr); /* Put icon to remove centre */ fprintf (Gbl.F.Out,"" @@ -1545,9 +1569,9 @@ static void Ctr_ListCentresForEdition (void) /************** Check if I can edit, remove, etc. a centre *******************/ /*****************************************************************************/ -static bool Ctr_CheckIfICanEdit (struct Centre *Ctr) +static bool Ctr_CheckIfICanEditACentre (struct Centre *Ctr) { - return (bool) (Gbl.Usrs.Me.LoggedRole >= Rol_INS_ADM || // I am an institution administrator or higher + return (bool) (Gbl.Usrs.Me.LoggedRole >= Rol_INS_ADM || // I am an institution administrator or higher ((Ctr->Status & Ctr_STATUS_BIT_PENDING) != 0 && // Centre is not yet activated Gbl.Usrs.Me.UsrDat.UsrCod == Ctr->RequesterUsrCod)); // I am the requester } diff --git a/swad_changelog.h b/swad_changelog.h index 95edbf95..5bf3d353 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -156,13 +156,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.47.6 (2016-11-06)" +#define Log_PLATFORM_VERSION "SWAD 16.47.7 (2016-11-06)" #define CSS_FILE "swad16.32.1.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.47.7: Nov 06, 2016 Icon in list of centres to show figure (statistics). (206191 lines) Version 16.47.6: Nov 06, 2016 Code refactoring in countries. (206171 lines) Version 16.47.5: Nov 06, 2016 Code refactoring in countries. (206162 lines) Version 16.47.4: Nov 06, 2016 Code refactoring in notices. (206153 lines) diff --git a/swad_country.c b/swad_country.c index 1e0f9a3d..baf1ac4f 100644 --- a/swad_country.c +++ b/swad_country.c @@ -68,7 +68,7 @@ static void Cty_PutIconToPrint (void); static bool Cty_CheckIfICanEditCountries (void); -static void Cty_PutIconsCountries (void); +static void Cty_PutIconsListCountries (void); static void Cty_PutIconToEditCountries (void); static unsigned Cty_GetNumUsrsWhoClaimToBelongToCty (long CtyCod); @@ -515,7 +515,7 @@ void Cty_ListCountries2 (void) const char *BgColor; /***** Table head *****/ - Lay_StartRoundFrame (NULL,Txt_Countries,Cty_PutIconsCountries); + Lay_StartRoundFrame (NULL,Txt_Countries,Cty_PutIconsListCountries); fprintf (Gbl.F.Out,"" ""); for (Order = Cty_ORDER_BY_COUNTRY; @@ -696,14 +696,14 @@ void Cty_ListCountries2 (void) static bool Cty_CheckIfICanEditCountries (void) { - return (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); + return (bool) (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); } /*****************************************************************************/ /***************** Put contextual icons in list of countries *****************/ /*****************************************************************************/ -static void Cty_PutIconsCountries (void) +static void Cty_PutIconsListCountries (void) { /***** Put icon to edit countries *****/ if (Cty_CheckIfICanEditCountries ()) diff --git a/swad_institution.c b/swad_institution.c index 0aea34b7..88190190 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -68,7 +68,7 @@ static void Ins_PutIconsToPrintAndUpload (void); static void Ins_ListInstitutions (void); static bool Ins_CheckIfICanEditInstitutions (void); -static void Ins_PutIconsInstitutions (void); +static void Ins_PutIconsListInstitutions (void); static void Ins_PutIconToEditInstitutions (void); static void Ins_ListOneInstitutionForSeeing (struct Instit *Ins,unsigned NumIns); static void Ins_PutHeadInstitutionsForSeeing (bool OrderSelectable); @@ -662,7 +662,7 @@ static void Ins_ListInstitutions (void) /***** Start frame *****/ sprintf (Gbl.Title,Txt_Institutions_of_COUNTRY_X,Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]); - Lay_StartRoundFrame (NULL,Gbl.Title,Ins_PutIconsInstitutions); + Lay_StartRoundFrame (NULL,Gbl.Title,Ins_PutIconsListInstitutions); if (Gbl.Inss.Num) // There are institutions in the current country { @@ -700,16 +700,16 @@ static void Ins_ListInstitutions (void) static bool Ins_CheckIfICanEditInstitutions (void) { - return (Gbl.Usrs.Me.LoggedRole >= Rol__GUEST_); + return (bool) (Gbl.Usrs.Me.LoggedRole >= Rol__GUEST_); } /*****************************************************************************/ /*************** Put contextual icons in list of institutions ****************/ /*****************************************************************************/ -static void Ins_PutIconsInstitutions (void) +static void Ins_PutIconsListInstitutions (void) { - /***** Put icon to edit countries *****/ + /***** Put icon to edit institutions *****/ if (Ins_CheckIfICanEditInstitutions ()) Ins_PutIconToEditInstitutions (); diff --git a/swad_notice.c b/swad_notice.c index 868bcfdc..d48e572c 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -67,8 +67,7 @@ const unsigned Not_MaxCharsURLOnScreen[Not_NUM_TYPES_LISTING] = /*****************************************************************************/ static bool Not_CheckIfICanEditNotices (void); - -static void Not_PutIconsNotices (void); +static void Not_PutIconsListNotices (void); static void Not_PutIconToAddNewNotice (void); static void Not_PutButtonToAddNewNotice (void); static void Not_GetDataAndShowNotice (long NotCod); @@ -221,16 +220,6 @@ void Not_ListFullNotices (void) Not_ShowNotices (Not_LIST_FULL_NOTICES); } -/*****************************************************************************/ -/*********************** Check if I can edit notices *************************/ -/*****************************************************************************/ - -static bool Not_CheckIfICanEditNotices (void) - { - return (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER || - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); - } - /*****************************************************************************/ /***************** Mark as hidden a notice that was active *******************/ /*****************************************************************************/ @@ -404,7 +393,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing) Lay_StartRoundFrame (StrWidth, Gbl.CurrentCrs.Notices.HighlightNotCod > 0 ? Txt_All_notices : Txt_Notices, - Not_PutIconsNotices); + Not_PutIconsListNotices); if (!NumNotices) Lay_ShowAlert (Lay_INFO,Txt_No_notices); } @@ -487,11 +476,21 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing) } } +/*****************************************************************************/ +/*********************** Check if I can edit notices *************************/ +/*****************************************************************************/ + +static bool Not_CheckIfICanEditNotices (void) + { + return (bool) (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER || + Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); + } + /*****************************************************************************/ /****************** Put contextual icons in list of notices ******************/ /*****************************************************************************/ -static void Not_PutIconsNotices (void) +static void Not_PutIconsListNotices (void) { /***** Put icon to add a new notice *****/ if (Not_CheckIfICanEditNotices ())