diff --git a/swad_changelog.h b/swad_changelog.h
index cc153d805..af712ff72 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -156,13 +156,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 16.47.3 (2016-11-06)"
+#define Log_PLATFORM_VERSION "SWAD 16.47.4 (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.4: Nov 06, 2016 Code refactoring in notices. (206153 lines)
Version 16.47.3: Nov 06, 2016 Icon in list of institutions to show figure (statistics). (206155 lines)
Version 16.47.2: Nov 06, 2016 Icon in list of countries to show figure (statistics). (206141 lines)
Version 16.47.1: Nov 06, 2016 Icon in list of notices to show figure (statistics). (206129 lines)
diff --git a/swad_global.h b/swad_global.h
index f1580702a..ddf52d248 100644
--- a/swad_global.h
+++ b/swad_global.h
@@ -463,7 +463,6 @@ struct Globals
struct
{
long HighlightNotCod; // Notice code of a notice to be highlighted
- bool ICanEdit;
} Notices;
} CurrentCrs;
struct
diff --git a/swad_layout.c b/swad_layout.c
index ebc9a9d6a..7f87cd5c7 100644
--- a/swad_layout.c
+++ b/swad_layout.c
@@ -947,8 +947,7 @@ static void Lay_ShowLeftColumn (void)
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
{
fprintf (Gbl.F.Out,"
");
- Not_ShowNotices (Not_LIST_BRIEF_NOTICES,
- false); // Nobody can not edit notices here
+ Not_ShowNotices (Not_LIST_BRIEF_NOTICES);
fprintf (Gbl.F.Out,"
");
}
diff --git a/swad_notice.c b/swad_notice.c
index aba74f7ff..868bcfdcc 100644
--- a/swad_notice.c
+++ b/swad_notice.c
@@ -66,17 +66,18 @@ const unsigned Not_MaxCharsURLOnScreen[Not_NUM_TYPES_LISTING] =
/***************************** Private prototypes ****************************/
/*****************************************************************************/
+static bool Not_CheckIfICanEditNotices (void);
+
static void Not_PutIconsNotices (void);
static void Not_PutIconToAddNewNotice (void);
static void Not_PutButtonToAddNewNotice (void);
-static void Not_GetDataAndShowNotice (long NotCod,bool ICanEdit);
+static void Not_GetDataAndShowNotice (long NotCod);
static void Not_DrawANotice (Not_Listing_t TypeNoticesListing,
long NotCod,
time_t TimeUTC,
const char *Content,
long UsrCod,
- Not_Status_t Status,
- bool ICanEdit);
+ Not_Status_t Status);
static long Not_InsertNoticeInDB (const char *Content);
static void Not_UpdateNumUsrsNotifiedByEMailAboutNotice (long NotCod,unsigned NumUsrsToBeNotifiedByEMail);
static long Not_GetParamNotCod (void);
@@ -124,8 +125,7 @@ void Not_ShowFormNotice (void)
Act_FormEnd ();
/***** Show all notices *****/
- Not_ShowNotices (Not_LIST_FULL_NOTICES,
- true); // I can create a new notice ==> I can edit notices
+ Not_ShowNotices (Not_LIST_FULL_NOTICES);
}
/*****************************************************************************/
@@ -213,15 +213,22 @@ void Not_ListNoticesAfterRemoval (void)
void Not_ListFullNotices (void)
{
- bool ICanEdit = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER ||
- Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM);
-
/***** Show highlighted notice *****/
if (Gbl.CurrentCrs.Notices.HighlightNotCod > 0)
- Not_GetDataAndShowNotice (Gbl.CurrentCrs.Notices.HighlightNotCod,ICanEdit);
+ Not_GetDataAndShowNotice (Gbl.CurrentCrs.Notices.HighlightNotCod);
/***** Show all notices *****/
- Not_ShowNotices (Not_LIST_FULL_NOTICES,ICanEdit);
+ 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);
}
/*****************************************************************************/
@@ -287,14 +294,12 @@ void Not_RequestRemNotice (void)
Act_FormStart (ActRemNot);
Not_PutHiddenParamNotCod (NotCod);
Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_remove_the_following_notice);
- Not_GetDataAndShowNotice (NotCod,
- false); // Do not edit this notice
+ Not_GetDataAndShowNotice (NotCod);
Lay_PutRemoveButton (Txt_Remove);
Act_FormEnd ();
/***** Show all notices *****/
- Not_ShowNotices (Not_LIST_FULL_NOTICES,
- true); // I can remove notices ==> I can edit notices
+ Not_ShowNotices (Not_LIST_FULL_NOTICES);
}
/*****************************************************************************/
@@ -348,7 +353,7 @@ void Not_GetNotCodToHighlight (void)
/***************************** Show the notices ******************************/
/*****************************************************************************/
-void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEdit)
+void Not_ShowNotices (Not_Listing_t TypeNoticesListing)
{
extern const char *Txt_All_notices;
extern const char *Txt_Notices;
@@ -396,7 +401,6 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEdit)
/***** Start frame *****/
sprintf (StrWidth,"%upx",
Not_ContainerWidth[Not_LIST_FULL_NOTICES] + 50);
- Gbl.CurrentCrs.Notices.ICanEdit = ICanEdit;
Lay_StartRoundFrame (StrWidth,
Gbl.CurrentCrs.Notices.HighlightNotCod > 0 ? Txt_All_notices :
Txt_Notices,
@@ -438,8 +442,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEdit)
/* Draw the notice */
Not_DrawANotice (TypeNoticesListing,
NotCod,
- TimeUTC,Content,UsrCod,Status,
- ICanEdit);
+ TimeUTC,Content,UsrCod,Status);
}
switch (TypeNoticesListing)
@@ -466,7 +469,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEdit)
break;
case Not_LIST_FULL_NOTICES:
/***** Button to add new notice *****/
- if (ICanEdit)
+ if (Not_CheckIfICanEditNotices ())
Not_PutButtonToAddNewNotice ();
/***** End frame *****/
@@ -491,7 +494,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEdit)
static void Not_PutIconsNotices (void)
{
/***** Put icon to add a new notice *****/
- if (Gbl.CurrentCrs.Notices.ICanEdit)
+ if (Not_CheckIfICanEditNotices ())
Not_PutIconToAddNewNotice ();
/***** Put icon to show a figure *****/
@@ -530,7 +533,7 @@ static void Not_PutButtonToAddNewNotice (void)
/******************** Get data of a notice and show it ***********************/
/*****************************************************************************/
-static void Not_GetDataAndShowNotice (long NotCod,bool ICanEdit)
+static void Not_GetDataAndShowNotice (long NotCod)
{
char Query[512];
MYSQL_RES *mysql_res;
@@ -571,8 +574,7 @@ static void Not_GetDataAndShowNotice (long NotCod,bool ICanEdit)
/***** Draw the notice *****/
Not_DrawANotice (Not_LIST_FULL_NOTICES,
NotCod,
- TimeUTC,Content,UsrCod,Status,
- ICanEdit);
+ TimeUTC,Content,UsrCod,Status);
}
/***** Free structure that stores the query result *****/
@@ -588,8 +590,7 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing,
time_t TimeUTC,
const char *Content,
long UsrCod,
- Not_Status_t Status,
- bool ICanEdit)
+ Not_Status_t Status)
{
extern const char *The_ClassForm[The_NUM_THEMES];
extern const char *Txt_NOTICE_Active_SINGULAR;
@@ -631,7 +632,7 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing,
/* Write symbol to indicate if notice is obsolete or active */
if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
{
- if (ICanEdit)
+ if (Not_CheckIfICanEditNotices ())
{
/* Form to remove notice */
Act_FormStart (ActReqRemNot);
diff --git a/swad_notice.h b/swad_notice.h
index 0858bfa9f..1c87b9c21 100644
--- a/swad_notice.h
+++ b/swad_notice.h
@@ -67,7 +67,7 @@ void Not_RequestRemNotice (void);
void Not_RemoveNotice (void);
void Not_GetNotCodToHighlight (void);
-void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEdit);
+void Not_ShowNotices (Not_Listing_t TypeNoticesListing);
void Not_GetSummaryAndContentNotice (char *SummaryStr,char **ContentStr,
long NotCod,unsigned MaxChars,bool GetContent);
unsigned Not_GetNumNotices (Sco_Scope_t Scope,Not_Status_t Status,unsigned *NumNotif);