diff --git a/swad_announcement.c b/swad_announcement.c index 45b6d2150..5b774d0ca 100644 --- a/swad_announcement.c +++ b/swad_announcement.c @@ -57,9 +57,9 @@ extern struct Globals Gbl; /***************************** Internal prototypes ***************************/ /*****************************************************************************/ -static void Ann_ListAnnouncements (void); -static void Ann_ShowAnnouncement (long AnnCod,const char *Subject,const char *Content, - unsigned Roles,bool ShowAllAnnouncements); +static void Ann_DrawAnAnnouncement (long AnnCod,const char *Subject,const char *Content, + unsigned Roles,bool ShowAllAnnouncements, + bool ICanEditAnnouncements); static void Ann_PutHiddenParamAnnCod (long AnnCod); static long Ann_GetParamAnnCod (void); static void Ann_CreateAnnouncement (unsigned Roles,const char *Subject,const char *Content); @@ -71,25 +71,8 @@ static void Ann_CreateAnnouncement (unsigned Roles,const char *Subject,const cha void Ann_ShowAllAnnouncements (void) { extern const char *Txt_New_announcement; - - /***** Put link (form) to create a new announcement *****/ - if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) - { - fprintf (Gbl.F.Out,"
"); - Act_PutContextualLink (ActWriAnn,NULL,"new",Txt_New_announcement); - fprintf (Gbl.F.Out,"
"); - } - - /***** List announcements *****/ - Ann_ListAnnouncements (); - } - -/*****************************************************************************/ -/************************** Show global announcements ************************/ -/*****************************************************************************/ - -static void Ann_ListAnnouncements (void) - { + extern const char *Txt_All_announcements; + extern const char *Txt_No_announcements; char Query[256]; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -99,12 +82,27 @@ static void Ann_ListAnnouncements (void) unsigned Roles; char Subject[Cns_MAX_BYTES_SUBJECT+1]; char Content[Cns_MAX_BYTES_TEXT+1]; + bool ICanEditAnnouncements = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); - /***** Select announcements *****/ + /***** Put link (form) to create a new announcement *****/ + if (ICanEditAnnouncements) + { + fprintf (Gbl.F.Out,"
"); + Act_PutContextualLink (ActWriAnn,NULL,"new",Txt_New_announcement); + fprintf (Gbl.F.Out,"
"); + } + + /***** Get announcements from database *****/ sprintf (Query,"SELECT AnnCod,Roles,Subject,Content FROM announcements" " ORDER BY AnnCod DESC"); NumAnnouncements = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get announcements"); + if (NumAnnouncements) + /***** Start frame *****/ + Lay_StartRoundFrame ("550px",Txt_All_announcements); + else + Lay_ShowAlert (Lay_INFO,Txt_No_announcements); + /***** Show the announcements *****/ for (NumAnn = 0; NumAnn < NumAnnouncements; @@ -130,8 +128,16 @@ static void Ann_ListAnnouncements (void) Str_InsertLinkInURLs (Content,Cns_MAX_BYTES_TEXT,50); /* Show the announcement */ - Ann_ShowAnnouncement (AnnCod,Subject,Content,Roles,true); + Ann_DrawAnAnnouncement (AnnCod,Subject,Content,Roles,true, + ICanEditAnnouncements); } + + /***** End frame *****/ + if (NumAnnouncements) + Lay_EndRoundFrame (); + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); } /*****************************************************************************/ @@ -184,7 +190,7 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void) Str_InsertLinkInURLs (Content,Cns_MAX_BYTES_TEXT,50); /* Show the announcement */ - Ann_ShowAnnouncement (AnnCod,Subject,Content,0,false); + Ann_DrawAnAnnouncement (AnnCod,Subject,Content,0,false,false); } fprintf (Gbl.F.Out,""); @@ -195,8 +201,9 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void) /****************** Draw an announcement as a yellow note ********************/ /*****************************************************************************/ -static void Ann_ShowAnnouncement (long AnnCod,const char *Subject,const char *Content, - unsigned Roles,bool ShowAllAnnouncements) +static void Ann_DrawAnAnnouncement (long AnnCod,const char *Subject,const char *Content, + unsigned Roles,bool ShowAllAnnouncements, + bool ICanEditAnnouncements) { extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *Txt_Users; @@ -210,6 +217,23 @@ static void Ann_ShowAnnouncement (long AnnCod,const char *Subject,const char *Co fprintf (Gbl.F.Out,"
"); + if (ICanEditAnnouncements) + { + /* Form to remove announcement */ + Act_FormStart (ActRemAnn); + Ann_PutHiddenParamAnnCod (AnnCod); + fprintf (Gbl.F.Out,"
" + "" + "
", + Gbl.Prefs.IconsURL, + Txt_Remove, + Txt_Remove); + Act_FormEnd (); + } + /***** Write the content of the announcement *****/ fprintf (Gbl.F.Out,"
%s
", Subject); @@ -238,20 +262,6 @@ static void Ann_ShowAnnouncement (long AnnCod,const char *Subject,const char *Co fprintf (Gbl.F.Out," %s",Txt_ROLES_PLURAL_abc[Role][Usr_SEX_UNKNOWN]); } fprintf (Gbl.F.Out,"

"); - - /* Form to remove announcement */ - Act_FormStart (ActRemAnn); - Ann_PutHiddenParamAnnCod (AnnCod); - Act_LinkFormSubmit (Txt_Remove,The_ClassForm[Gbl.Prefs.Theme]); - fprintf (Gbl.F.Out,"\"%s\"" - " %s", - Gbl.Prefs.IconsURL, - Txt_Remove, - Txt_Remove, - Txt_Remove); - Act_FormEnd (); } else { diff --git a/swad_changelog.h b/swad_changelog.h index 491e070ab..f1b7aaa21 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -109,11 +109,12 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.33 (2015/11/01)" +#define Log_PLATFORM_VERSION "SWAD 15.33.1 (2015/11/01)" // 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 15.33.1: Nov 01, 2015 New layout of announcements. (186755 lines) Version 15.33: Nov 01, 2015 New layout of notices. (186708 lines) Version 15.32.2: Oct 31, 2015 Fixed bug in form submit. (186618 lines) Version 15.32.1: Oct 31, 2015 Dates in holidays are shown in big-endian. diff --git a/swad_notice.c b/swad_notice.c index ac5e4863a..daa307a6f 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -66,12 +66,12 @@ const unsigned Not_MaxCharsURLOnScreen[Not_NUM_TYPES_LISTING] = /*****************************************************************************/ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, - bool ICanEditNotices, long NotCod, time_t TimeUTC, const char *Content, long UsrCod, - Not_Status_t NoticeStatus); + Not_Status_t NoticeStatus, + bool ICanEditNotices); static long Not_InsertNoticeInDB (const char *Content); static void Not_UpdateNumUsrsNotifiedByEMailAboutNotice (long NotCod,unsigned NumUsrsToBeNotifiedByEMail); static void Not_PutHiddenParamNotCod (long NotCod); @@ -284,9 +284,9 @@ void Not_ShowANotice (void) void Not_ShowNotices (Not_Listing_t TypeNoticesListing) { - extern const char *Txt_No_notices; extern const char *Txt_New_notice; extern const char *Txt_All_notices; + extern const char *Txt_No_notices; char Query[512]; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -305,12 +305,9 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing) /***** A course must be selected (Gbl.CurrentCrs.Crs.CrsCod > 0) *****/ if (Gbl.CurrentCrs.Crs.CrsCod > 0) { - ICanEditNotices = ( - TypeNoticesListing == Not_LIST_FULL_NOTICES && + ICanEditNotices = (TypeNoticesListing == Not_LIST_FULL_NOTICES && (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER || - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) - ); - + Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)); if (ICanEditNotices) { @@ -352,9 +349,10 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing) NoticeStatus = (Not_Status_t) UnsignedNum; /* Draw the notice */ - Not_DrawANotice (TypeNoticesListing,ICanEditNotices, + Not_DrawANotice (TypeNoticesListing, Gbl.CurrentCrs.Notices.HighlightNotCod, - TimeUTC,Content,UsrCod,NoticeStatus); + TimeUTC,Content,UsrCod,NoticeStatus, + ICanEditNotices); } /* Free structure that stores the query result */ @@ -386,11 +384,10 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing) { if (NumNotices) { + /***** Start frame *****/ sprintf (StrWidth,"%upx", Not_ContainerWidth[Not_LIST_FULL_NOTICES] + 50); - Lay_StartRoundFrameTable (StrWidth,2,Txt_All_notices); - fprintf (Gbl.F.Out,"" - ""); + Lay_StartRoundFrame (StrWidth,Txt_All_notices); } else Lay_ShowAlert (Lay_INFO,Txt_No_notices); @@ -449,17 +446,15 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing) NoticeStatus = (Not_Status_t) UnsignedNum; /* Draw the notice */ - Not_DrawANotice (TypeNoticesListing,ICanEditNotices, + Not_DrawANotice (TypeNoticesListing, NotCod, - TimeUTC,Content,UsrCod,NoticeStatus); + TimeUTC,Content,UsrCod,NoticeStatus, + ICanEditNotices); } if (TypeNoticesListing == Not_LIST_FULL_NOTICES && NumNotices) - { - fprintf (Gbl.F.Out,"" - ""); - Lay_EndRoundFrameTable (); - } + /***** End frame *****/ + Lay_EndRoundFrame (); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -476,12 +471,12 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing) /*****************************************************************************/ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, - bool ICanEditNotices, long NotCod, time_t TimeUTC, const char *Content, long UsrCod, - Not_Status_t NoticeStatus) + Not_Status_t NoticeStatus, + bool ICanEditNotices) { extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *Txt_NOTICE_Active_SINGULAR; @@ -524,7 +519,7 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, { if (ICanEditNotices) { - /* Form to delete notice */ + /* Form to remove notice */ Act_FormStart (ActRemNot); Not_PutHiddenParamNotCod (NotCod); fprintf (Gbl.F.Out,"
" diff --git a/swad_text.c b/swad_text.c index fb9e352eb..a644935f7 100644 --- a/swad_text.c +++ b/swad_text.c @@ -2002,6 +2002,27 @@ const char *Txt_All = "Tudo"; #endif +const char *Txt_All_announcements = +#if L==0 + "Tots els anuncis"; +#elif L==1 + "Alle Bekanntmachungen"; +#elif L==2 + "All announcements"; +#elif L==3 + "Todos los anuncios"; +#elif L==4 + "Tous les annonces"; +#elif L==5 + "Todos los anuncios"; // Okoteve traducción +#elif L==6 + "Tutti i annunci"; +#elif L==7 + "Wszystkie ogłoszenia"; +#elif L==8 + "Todos os anúncios"; +#endif + const char *Txt_all_degrees = #if L==0 "Totes les titulacions"; @@ -22925,6 +22946,27 @@ const char *Txt_No = "Não"; #endif +const char *Txt_No_announcements = +#if L==0 + "No hay anuncis"; +#elif L==1 + "Keine Bekanntmachungen"; +#elif L==2 + "No announcements"; +#elif L==3 + "No hay anuncios"; +#elif L==4 + "Il n'y a pas d'annonces"; +#elif L==5 + "No hay anuncios"; // Okoteve traducción +#elif L==6 + "Non ci sono annunci"; +#elif L==7 + "Brak ogłoszenia"; +#elif L==8 + "Não há anúncios"; +#endif + const char *Txt_No_announcements_of_exams_of_X = // Warning: it is very important to include %s in the following sentences #if L==0 "No hay convocatorias de examen de %s."; // Necessita traduccio