Version 16.47.4

This commit is contained in:
Antonio Cañas Vargas 2016-11-06 22:37:12 +01:00
parent 40d7ece537
commit 3f2eef5093
5 changed files with 31 additions and 31 deletions

View File

@ -156,13 +156,14 @@
/****************************** Public constants *****************************/ /****************************** 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 CSS_FILE "swad16.32.1.css"
#define JS_FILE "swad16.46.1.js" #define JS_FILE "swad16.46.1.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.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.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.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) Version 16.47.1: Nov 06, 2016 Icon in list of notices to show figure (statistics). (206129 lines)

View File

@ -463,7 +463,6 @@ struct Globals
struct struct
{ {
long HighlightNotCod; // Notice code of a notice to be highlighted long HighlightNotCod; // Notice code of a notice to be highlighted
bool ICanEdit;
} Notices; } Notices;
} CurrentCrs; } CurrentCrs;
struct struct

View File

@ -947,8 +947,7 @@ static void Lay_ShowLeftColumn (void)
if (Gbl.CurrentCrs.Crs.CrsCod > 0) if (Gbl.CurrentCrs.Crs.CrsCod > 0)
{ {
fprintf (Gbl.F.Out,"<div class=\"LEFT_RIGHT_CELL\">"); fprintf (Gbl.F.Out,"<div class=\"LEFT_RIGHT_CELL\">");
Not_ShowNotices (Not_LIST_BRIEF_NOTICES, Not_ShowNotices (Not_LIST_BRIEF_NOTICES);
false); // Nobody can not edit notices here
fprintf (Gbl.F.Out,"</div>"); fprintf (Gbl.F.Out,"</div>");
} }

View File

@ -66,17 +66,18 @@ const unsigned Not_MaxCharsURLOnScreen[Not_NUM_TYPES_LISTING] =
/***************************** Private prototypes ****************************/ /***************************** Private prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
static bool Not_CheckIfICanEditNotices (void);
static void Not_PutIconsNotices (void); static void Not_PutIconsNotices (void);
static void Not_PutIconToAddNewNotice (void); static void Not_PutIconToAddNewNotice (void);
static void Not_PutButtonToAddNewNotice (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, static void Not_DrawANotice (Not_Listing_t TypeNoticesListing,
long NotCod, long NotCod,
time_t TimeUTC, time_t TimeUTC,
const char *Content, const char *Content,
long UsrCod, long UsrCod,
Not_Status_t Status, Not_Status_t Status);
bool ICanEdit);
static long Not_InsertNoticeInDB (const char *Content); static long Not_InsertNoticeInDB (const char *Content);
static void Not_UpdateNumUsrsNotifiedByEMailAboutNotice (long NotCod,unsigned NumUsrsToBeNotifiedByEMail); static void Not_UpdateNumUsrsNotifiedByEMailAboutNotice (long NotCod,unsigned NumUsrsToBeNotifiedByEMail);
static long Not_GetParamNotCod (void); static long Not_GetParamNotCod (void);
@ -124,8 +125,7 @@ void Not_ShowFormNotice (void)
Act_FormEnd (); Act_FormEnd ();
/***** Show all notices *****/ /***** Show all notices *****/
Not_ShowNotices (Not_LIST_FULL_NOTICES, Not_ShowNotices (Not_LIST_FULL_NOTICES);
true); // I can create a new notice ==> I can edit notices
} }
/*****************************************************************************/ /*****************************************************************************/
@ -213,15 +213,22 @@ void Not_ListNoticesAfterRemoval (void)
void Not_ListFullNotices (void) void Not_ListFullNotices (void)
{ {
bool ICanEdit = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM);
/***** Show highlighted notice *****/ /***** Show highlighted notice *****/
if (Gbl.CurrentCrs.Notices.HighlightNotCod > 0) if (Gbl.CurrentCrs.Notices.HighlightNotCod > 0)
Not_GetDataAndShowNotice (Gbl.CurrentCrs.Notices.HighlightNotCod,ICanEdit); Not_GetDataAndShowNotice (Gbl.CurrentCrs.Notices.HighlightNotCod);
/***** Show all notices *****/ /***** 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); Act_FormStart (ActRemNot);
Not_PutHiddenParamNotCod (NotCod); Not_PutHiddenParamNotCod (NotCod);
Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_remove_the_following_notice); Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_remove_the_following_notice);
Not_GetDataAndShowNotice (NotCod, Not_GetDataAndShowNotice (NotCod);
false); // Do not edit this notice
Lay_PutRemoveButton (Txt_Remove); Lay_PutRemoveButton (Txt_Remove);
Act_FormEnd (); Act_FormEnd ();
/***** Show all notices *****/ /***** Show all notices *****/
Not_ShowNotices (Not_LIST_FULL_NOTICES, Not_ShowNotices (Not_LIST_FULL_NOTICES);
true); // I can remove notices ==> I can edit notices
} }
/*****************************************************************************/ /*****************************************************************************/
@ -348,7 +353,7 @@ void Not_GetNotCodToHighlight (void)
/***************************** Show the notices ******************************/ /***************************** 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_All_notices;
extern const char *Txt_Notices; extern const char *Txt_Notices;
@ -396,7 +401,6 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEdit)
/***** Start frame *****/ /***** Start frame *****/
sprintf (StrWidth,"%upx", sprintf (StrWidth,"%upx",
Not_ContainerWidth[Not_LIST_FULL_NOTICES] + 50); Not_ContainerWidth[Not_LIST_FULL_NOTICES] + 50);
Gbl.CurrentCrs.Notices.ICanEdit = ICanEdit;
Lay_StartRoundFrame (StrWidth, Lay_StartRoundFrame (StrWidth,
Gbl.CurrentCrs.Notices.HighlightNotCod > 0 ? Txt_All_notices : Gbl.CurrentCrs.Notices.HighlightNotCod > 0 ? Txt_All_notices :
Txt_Notices, Txt_Notices,
@ -438,8 +442,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEdit)
/* Draw the notice */ /* Draw the notice */
Not_DrawANotice (TypeNoticesListing, Not_DrawANotice (TypeNoticesListing,
NotCod, NotCod,
TimeUTC,Content,UsrCod,Status, TimeUTC,Content,UsrCod,Status);
ICanEdit);
} }
switch (TypeNoticesListing) switch (TypeNoticesListing)
@ -466,7 +469,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEdit)
break; break;
case Not_LIST_FULL_NOTICES: case Not_LIST_FULL_NOTICES:
/***** Button to add new notice *****/ /***** Button to add new notice *****/
if (ICanEdit) if (Not_CheckIfICanEditNotices ())
Not_PutButtonToAddNewNotice (); Not_PutButtonToAddNewNotice ();
/***** End frame *****/ /***** End frame *****/
@ -491,7 +494,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEdit)
static void Not_PutIconsNotices (void) static void Not_PutIconsNotices (void)
{ {
/***** Put icon to add a new notice *****/ /***** Put icon to add a new notice *****/
if (Gbl.CurrentCrs.Notices.ICanEdit) if (Not_CheckIfICanEditNotices ())
Not_PutIconToAddNewNotice (); Not_PutIconToAddNewNotice ();
/***** Put icon to show a figure *****/ /***** Put icon to show a figure *****/
@ -530,7 +533,7 @@ static void Not_PutButtonToAddNewNotice (void)
/******************** Get data of a notice and show it ***********************/ /******************** 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]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -571,8 +574,7 @@ static void Not_GetDataAndShowNotice (long NotCod,bool ICanEdit)
/***** Draw the notice *****/ /***** Draw the notice *****/
Not_DrawANotice (Not_LIST_FULL_NOTICES, Not_DrawANotice (Not_LIST_FULL_NOTICES,
NotCod, NotCod,
TimeUTC,Content,UsrCod,Status, TimeUTC,Content,UsrCod,Status);
ICanEdit);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -588,8 +590,7 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing,
time_t TimeUTC, time_t TimeUTC,
const char *Content, const char *Content,
long UsrCod, long UsrCod,
Not_Status_t Status, Not_Status_t Status)
bool ICanEdit)
{ {
extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *The_ClassForm[The_NUM_THEMES];
extern const char *Txt_NOTICE_Active_SINGULAR; 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 */ /* Write symbol to indicate if notice is obsolete or active */
if (TypeNoticesListing == Not_LIST_FULL_NOTICES) if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
{ {
if (ICanEdit) if (Not_CheckIfICanEditNotices ())
{ {
/* Form to remove notice */ /* Form to remove notice */
Act_FormStart (ActReqRemNot); Act_FormStart (ActReqRemNot);

View File

@ -67,7 +67,7 @@ void Not_RequestRemNotice (void);
void Not_RemoveNotice (void); void Not_RemoveNotice (void);
void Not_GetNotCodToHighlight (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, void Not_GetSummaryAndContentNotice (char *SummaryStr,char **ContentStr,
long NotCod,unsigned MaxChars,bool GetContent); long NotCod,unsigned MaxChars,bool GetContent);
unsigned Not_GetNumNotices (Sco_Scope_t Scope,Not_Status_t Status,unsigned *NumNotif); unsigned Not_GetNumNotices (Sco_Scope_t Scope,Not_Status_t Status,unsigned *NumNotif);