2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_announcement.c: Global announcement
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Copyright (C) 1999-2023 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General 3 License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************************** Headers *********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2022-10-19 18:07:49 +02:00
|
|
|
|
#include "swad_alert.h"
|
2015-11-01 20:21:59 +01:00
|
|
|
|
#include "swad_announcement.h"
|
2021-05-11 11:08:21 +02:00
|
|
|
|
#include "swad_announcement_database.h"
|
2021-11-28 00:49:23 +01:00
|
|
|
|
#include "swad_autolink.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_parameter.h"
|
2023-03-10 17:21:04 +01:00
|
|
|
|
#include "swad_parameter_code.h"
|
2016-12-13 13:32:19 +01:00
|
|
|
|
#include "swad_role.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-11-21 16:47:07 +01:00
|
|
|
|
/***************************** Private prototypes ****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 13:40:21 +02:00
|
|
|
|
static void Ann_PutIconToAddNewAnnouncement (__attribute__((unused)) void *Args);
|
2016-03-21 17:03:12 +01:00
|
|
|
|
static void Ann_PutButtonToAddNewAnnouncement (void);
|
2023-03-22 09:48:03 +01:00
|
|
|
|
|
|
|
|
|
static void Ann_GetAnnouncementDataFromRow (MYSQL_RES *mysql_res,
|
|
|
|
|
struct Ann_Announcement *Announcement);
|
|
|
|
|
|
|
|
|
|
static void Ann_DrawAnAnnouncement (struct Ann_Announcement *Announcement,
|
2015-11-02 18:55:24 +01:00
|
|
|
|
bool ShowAllAnnouncements,
|
2016-03-21 17:03:12 +01:00
|
|
|
|
bool ICanEdit);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Ann_PutParAnnCod (void *AnnCod);
|
2016-12-26 18:26:40 +01:00
|
|
|
|
static void Ann_PutSubjectMessage (const char *Field,const char *Label,
|
|
|
|
|
unsigned Rows);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Show global announcements ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ann_ShowAllAnnouncements (void)
|
|
|
|
|
{
|
2020-09-26 17:20:01 +02:00
|
|
|
|
extern const char *Hlp_COMMUNICATION_Announcements;
|
2015-11-01 21:19:33 +01:00
|
|
|
|
extern const char *Txt_Announcements;
|
2015-11-01 18:54:10 +01:00
|
|
|
|
extern const char *Txt_No_announcements;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
2023-03-22 09:48:03 +01:00
|
|
|
|
struct Ann_Announcement Announcement;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumAnnouncements;
|
|
|
|
|
unsigned NumAnn;
|
2017-06-04 18:18:54 +02:00
|
|
|
|
bool ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
2015-11-01 18:54:10 +01:00
|
|
|
|
|
|
|
|
|
/***** Get announcements from database *****/
|
2016-03-21 17:03:12 +01:00
|
|
|
|
if (ICanEdit)
|
2015-11-01 21:19:33 +01:00
|
|
|
|
/* Select all announcements */
|
2021-05-11 11:08:21 +02:00
|
|
|
|
NumAnnouncements = Ann_DB_GetAllAnnouncements (&mysql_res);
|
2015-11-01 21:19:33 +01:00
|
|
|
|
else if (Gbl.Usrs.Me.Logged)
|
2016-03-24 18:57:25 +01:00
|
|
|
|
/* Select only announcements I can see */
|
2021-05-11 11:08:21 +02:00
|
|
|
|
NumAnnouncements = Ann_DB_GetAnnouncementsICanSee (&mysql_res);
|
2015-11-01 21:19:33 +01:00
|
|
|
|
else // No user logged
|
|
|
|
|
/* Select only active announcements for unknown users */
|
2021-05-11 11:08:21 +02:00
|
|
|
|
NumAnnouncements = Ann_DB_GetAnnouncementsForUnknownUsers (&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxBegin ("550px",Txt_Announcements,
|
2017-06-11 22:26:40 +02:00
|
|
|
|
ICanEdit ? Ann_PutIconToAddNewAnnouncement :
|
2020-03-26 02:54:30 +01:00
|
|
|
|
NULL,NULL,
|
2020-09-26 17:20:01 +02:00
|
|
|
|
Hlp_COMMUNICATION_Announcements,Box_NOT_CLOSABLE);
|
2015-11-01 18:54:10 +01:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
if (!NumAnnouncements)
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_announcements);
|
2015-11-01 18:54:10 +01:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
/***** Show the announcements *****/
|
|
|
|
|
for (NumAnn = 0;
|
|
|
|
|
NumAnn < NumAnnouncements;
|
|
|
|
|
NumAnn++)
|
|
|
|
|
{
|
2023-03-22 09:48:03 +01:00
|
|
|
|
/* Get announcement data */
|
|
|
|
|
Ann_GetAnnouncementDataFromRow (mysql_res,&Announcement);
|
2021-05-11 11:08:21 +02:00
|
|
|
|
|
|
|
|
|
/* Show the announcement */
|
2023-03-22 09:48:03 +01:00
|
|
|
|
Ann_DrawAnAnnouncement (&Announcement,
|
|
|
|
|
true, // Show all announcements
|
|
|
|
|
ICanEdit);
|
2021-05-11 11:08:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Button to add new announcement *****/
|
|
|
|
|
if (ICanEdit)
|
|
|
|
|
Ann_PutButtonToAddNewAnnouncement ();
|
2016-03-21 17:03:12 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2015-11-01 18:54:10 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-21 17:03:12 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Put icon to add a new announcement *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 13:40:21 +02:00
|
|
|
|
static void Ann_PutIconToAddNewAnnouncement (__attribute__((unused)) void *Args)
|
2016-03-21 17:03:12 +01:00
|
|
|
|
{
|
2022-06-29 18:04:45 +02:00
|
|
|
|
Ico_PutContextualIconToAdd (ActWriAnn,NULL,NULL,NULL);
|
2016-03-21 17:03:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Put button to add a new announcement ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Ann_PutButtonToAddNewAnnouncement (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_announcement;
|
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActWriAnn);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Btn_PutConfirmButton (Txt_New_announcement);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2016-03-21 17:03:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Show global announcements ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumAnnouncements;
|
|
|
|
|
unsigned NumAnn;
|
2023-03-22 09:48:03 +01:00
|
|
|
|
struct Ann_Announcement Announcement;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Select announcements not seen *****/
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
2021-05-11 11:08:21 +02:00
|
|
|
|
NumAnnouncements = Ann_DB_GetAnnouncementsNotSeen (&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show the announcements *****/
|
|
|
|
|
if (NumAnnouncements)
|
|
|
|
|
{
|
2019-10-23 21:37:01 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"CM\"");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
for (NumAnn = 0;
|
|
|
|
|
NumAnn < NumAnnouncements;
|
|
|
|
|
NumAnn++)
|
|
|
|
|
{
|
2023-03-22 09:48:03 +01:00
|
|
|
|
/* Get announcement data */
|
|
|
|
|
Ann_GetAnnouncementDataFromRow (mysql_res,&Announcement);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
/* Show the announcement */
|
2023-03-22 09:48:03 +01:00
|
|
|
|
Ann_DrawAnAnnouncement (&Announcement,
|
|
|
|
|
false, // Don't show all announcements
|
|
|
|
|
false); // I can not edit
|
2021-05-11 11:08:21 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2023-03-22 09:48:03 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Get announcement data from row ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Ann_GetAnnouncementDataFromRow (MYSQL_RES *mysql_res,
|
|
|
|
|
struct Ann_Announcement *Announcement)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned UnsignedNum;
|
|
|
|
|
|
2023-03-23 19:56:18 +01:00
|
|
|
|
/***** Get next row from result *****/
|
2023-03-22 09:48:03 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Get announcement code (row[0]) *****/
|
|
|
|
|
if (sscanf (row[0],"%ld",&Announcement->AnnCod) != 1)
|
|
|
|
|
Err_WrongAnnouncementExit ();
|
|
|
|
|
|
|
|
|
|
/***** Get status of the announcement (row[1]) *****/
|
|
|
|
|
Announcement->Status = Ann_OBSOLETE_ANNOUNCEMENT;
|
|
|
|
|
if (sscanf (row[1],"%u",&UnsignedNum) == 1)
|
|
|
|
|
if (UnsignedNum < Ann_NUM_STATUS)
|
|
|
|
|
Announcement->Status = (Ann_Status_t) UnsignedNum;
|
|
|
|
|
|
|
|
|
|
/***** Get roles (row[2]) *****/
|
|
|
|
|
if (sscanf (row[2],"%u",&Announcement->Roles) != 1)
|
|
|
|
|
Err_ShowErrorAndExit ("Error when reading roles of announcement.");
|
|
|
|
|
|
|
|
|
|
/***** Get the subject (row[3]), the content (row[4]), and insert links *****/
|
|
|
|
|
Str_Copy (Announcement->Subject,row[3],sizeof (Announcement->Subject) - 1);
|
|
|
|
|
Str_Copy (Announcement->Content,row[4],sizeof (Announcement->Content) - 1);
|
|
|
|
|
ALn_InsertLinks (Announcement->Content,Cns_MAX_BYTES_TEXT,50);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Draw an announcement as a yellow note ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-22 09:48:03 +01:00
|
|
|
|
static void Ann_DrawAnAnnouncement (struct Ann_Announcement *Announcement,
|
2015-11-02 18:55:24 +01:00
|
|
|
|
bool ShowAllAnnouncements,
|
2016-03-21 17:03:12 +01:00
|
|
|
|
bool ICanEdit)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Users;
|
|
|
|
|
extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
|
|
|
|
extern const char *Txt_Do_not_show_again;
|
2015-11-01 20:21:59 +01:00
|
|
|
|
static const char *ContainerClass[Ann_NUM_STATUS] =
|
|
|
|
|
{
|
2021-12-27 12:58:20 +01:00
|
|
|
|
[Ann_ACTIVE_ANNOUNCEMENT ] = "NOTICE_BOX NOTICE_BOX_WIDE",
|
|
|
|
|
[Ann_OBSOLETE_ANNOUNCEMENT] = "NOTICE_BOX NOTICE_BOX_WIDE LIGHT",
|
2015-11-01 20:21:59 +01:00
|
|
|
|
};
|
2022-07-21 19:30:03 +02:00
|
|
|
|
static Act_Action_t ActionHideUnhide[2] =
|
|
|
|
|
{
|
|
|
|
|
[false] = ActHidAnn, // Visible ==> action to hide
|
|
|
|
|
[true ] = ActUnhAnn, // Hidden ==> action to unhide
|
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Rol_Role_t Role;
|
2015-11-01 21:19:33 +01:00
|
|
|
|
bool SomeRolesAreSelected;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin yellow note *****/
|
2023-03-22 09:48:03 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"%s\"",ContainerClass[Announcement->Status]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
if (ICanEdit)
|
2015-11-01 20:21:59 +01:00
|
|
|
|
{
|
2022-07-21 19:30:03 +02:00
|
|
|
|
/***** Icon to remove announcement *****/
|
2021-05-11 11:08:21 +02:00
|
|
|
|
Ico_PutContextualIconToRemove (ActRemAnn,NULL,
|
2023-03-22 09:48:03 +01:00
|
|
|
|
Ann_PutParAnnCod,&Announcement->AnnCod);
|
2021-05-11 11:08:21 +02:00
|
|
|
|
|
2022-07-21 19:30:03 +02:00
|
|
|
|
/***** Icon to hide/unhide the announcement *****/
|
|
|
|
|
Ico_PutContextualIconToHideUnhide (ActionHideUnhide,NULL, // TODO: Put anchor
|
2023-03-22 09:48:03 +01:00
|
|
|
|
Ann_PutParAnnCod,&Announcement->AnnCod,
|
|
|
|
|
Announcement->Status == Ann_OBSOLETE_ANNOUNCEMENT);
|
2015-11-01 20:21:59 +01:00
|
|
|
|
}
|
2015-11-01 18:54:10 +01:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
/***** Write the subject of the announcement *****/
|
2021-12-27 12:58:20 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"NOTICE_SUBJECT NOTICE_SUBJECT_%s\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2023-03-22 09:48:03 +01:00
|
|
|
|
HTM_Txt (Announcement->Subject);
|
2021-05-11 11:08:21 +02:00
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
/***** Write the content of the announcement *****/
|
2021-12-27 12:58:20 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"NOTICE_TEXT NOTICE_TEXT_%s\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2023-03-22 09:48:03 +01:00
|
|
|
|
HTM_Txt (Announcement->Content);
|
2021-05-11 11:08:21 +02:00
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
/***** Write announcement foot *****/
|
|
|
|
|
/* Begin container for foot */
|
2021-12-26 16:22:58 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"NOTICE_USERS\"");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
if (ShowAllAnnouncements)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-05-11 11:08:21 +02:00
|
|
|
|
/* Users' roles who can view this announcement */
|
|
|
|
|
HTM_TxtColon (Txt_Users);
|
2021-12-27 12:58:20 +01:00
|
|
|
|
for (Role = Rol_UNK, SomeRolesAreSelected = false;
|
2021-05-11 11:08:21 +02:00
|
|
|
|
Role <= Rol_TCH;
|
|
|
|
|
Role++)
|
2023-03-22 09:48:03 +01:00
|
|
|
|
if (Announcement->Roles & (1 << Role))
|
2021-05-11 11:08:21 +02:00
|
|
|
|
{
|
|
|
|
|
if (SomeRolesAreSelected)
|
|
|
|
|
HTM_Comma ();
|
|
|
|
|
SomeRolesAreSelected = true;
|
|
|
|
|
HTM_TxtF (" %s",Txt_ROLES_PLURAL_abc[Role][Usr_SEX_UNKNOWN]);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2021-05-11 11:08:21 +02:00
|
|
|
|
else
|
|
|
|
|
/***** Put form to mark announcement as seen *****/
|
|
|
|
|
Lay_PutContextualLinkIconText (ActAnnSee,NULL,
|
2023-03-22 09:48:03 +01:00
|
|
|
|
Ann_PutParAnnCod,&Announcement->AnnCod,
|
2021-12-22 00:20:06 +01:00
|
|
|
|
"times.svg",Ico_BLACK,
|
2021-12-22 18:54:43 +01:00
|
|
|
|
Txt_Do_not_show_again,NULL);
|
2021-05-11 11:08:21 +02:00
|
|
|
|
|
|
|
|
|
/* End container for foot */
|
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** End yellow note *****/
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-11 20:16:15 +01:00
|
|
|
|
/******************** Params used to edit an assignment **********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Ann_PutParAnnCod (void *AnnCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2023-03-10 00:13:55 +01:00
|
|
|
|
if (AnnCod)
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Ann,*((long *) AnnCod));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Show form to create a new announcement ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ann_ShowFormAnnouncement (void)
|
|
|
|
|
{
|
2020-09-26 17:20:01 +02:00
|
|
|
|
extern const char *Hlp_COMMUNICATION_Announcements;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_New_announcement;
|
|
|
|
|
extern const char *Txt_MSG_Subject;
|
2017-04-19 14:27:52 +02:00
|
|
|
|
extern const char *Txt_MSG_Content;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Users;
|
|
|
|
|
extern const char *Txt_Create_announcement;
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActRcvAnn);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
/***** Begin box and table *****/
|
|
|
|
|
Box_BoxTableBegin (NULL,Txt_New_announcement,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
Hlp_COMMUNICATION_Announcements,Box_NOT_CLOSABLE,2);
|
|
|
|
|
|
|
|
|
|
/***** Announcement subject and body *****/
|
|
|
|
|
Ann_PutSubjectMessage ("Subject",Txt_MSG_Subject, 2);
|
|
|
|
|
Ann_PutSubjectMessage ("Content",Txt_MSG_Content,20);
|
|
|
|
|
|
|
|
|
|
/***** Users' roles who can view the announcement *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
2022-04-05 01:00:24 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RT FORM_IN_%s\"",The_GetSuffix ());
|
2021-05-11 11:08:21 +02:00
|
|
|
|
HTM_TxtColonNBSP (Txt_Users);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
2022-04-05 01:00:24 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT DAT_%s\"",The_GetSuffix ());
|
2021-05-11 11:08:21 +02:00
|
|
|
|
Rol_WriteSelectorRoles (1 << Rol_UNK |
|
|
|
|
|
1 << Rol_GST |
|
|
|
|
|
1 << Rol_STD |
|
|
|
|
|
1 << Rol_NET |
|
|
|
|
|
1 << Rol_TCH,
|
|
|
|
|
1 << Rol_UNK |
|
|
|
|
|
1 << Rol_GST |
|
|
|
|
|
1 << Rol_STD |
|
|
|
|
|
1 << Rol_NET |
|
|
|
|
|
1 << Rol_TCH,
|
|
|
|
|
false,false);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** End table, send button and end box *****/
|
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_announcement);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-04-11 17:33:14 +02:00
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-26 18:26:40 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Put form field for message subject or message content ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Ann_PutSubjectMessage (const char *Field,const char *Label,
|
|
|
|
|
unsigned Rows)
|
|
|
|
|
{
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/***** Subject or content *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
/* Label */
|
|
|
|
|
Frm_LabelColumn ("RT",Field,Label);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
/* Data */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2021-12-17 00:17:35 +01:00
|
|
|
|
HTM_TEXTAREA_Begin ("id=\"%s\" name=\"%s\" cols=\"75\" rows=\"%u\""
|
2022-03-30 00:46:18 +02:00
|
|
|
|
" class=\"INPUT_%s\"",
|
2021-12-17 00:17:35 +01:00
|
|
|
|
Field,Field,Rows,
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-05-11 11:08:21 +02:00
|
|
|
|
HTM_TEXTAREA_End ();
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2016-12-26 18:26:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Receive a new announcement from a form and store it in database ******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ann_ReceiveAnnouncement (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Announcement_created;
|
|
|
|
|
unsigned Roles;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
|
|
|
|
char Content[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data from form *****/
|
|
|
|
|
/* Get the subject of the announcement */
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_GetParHTML ("Subject",Subject,Cns_MAX_BYTES_SUBJECT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the content of the announcement */
|
|
|
|
|
Par_GetParAndChangeFormat ("Content",Content,Cns_MAX_BYTES_TEXT,
|
|
|
|
|
Str_TO_RIGOROUS_HTML,true);
|
|
|
|
|
|
|
|
|
|
/* Get users who can view this announcement */
|
2016-03-24 16:49:36 +01:00
|
|
|
|
Roles = Rol_GetSelectedRoles ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Create a new announcement in database *****/
|
2021-05-11 11:08:21 +02:00
|
|
|
|
Ann_DB_CreateAnnouncement (Roles,Subject,Content);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message of success *****/
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Announcement_created);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Refresh list of announcements *****/
|
|
|
|
|
Ann_ShowAllAnnouncements ();
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-01 20:21:59 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Mark as hidden a global announcement that was active ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ann_HideActiveAnnouncement (void)
|
|
|
|
|
{
|
|
|
|
|
long AnnCod;
|
|
|
|
|
|
|
|
|
|
/***** Get the code of the global announcement to hide *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
AnnCod = ParCod_GetAndCheckPar (ParCod_Ann);
|
2015-11-01 20:21:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Set global announcement as hidden *****/
|
2021-05-11 11:08:21 +02:00
|
|
|
|
Ann_DB_HideAnnouncement (AnnCod);
|
2015-11-01 20:21:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Mark as active a global announcement that was hidden ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ann_RevealHiddenAnnouncement (void)
|
|
|
|
|
{
|
|
|
|
|
long AnnCod;
|
|
|
|
|
|
|
|
|
|
/***** Get the code of the global announcement to show *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
AnnCod = ParCod_GetAndCheckPar (ParCod_Ann);
|
2015-11-01 20:21:59 +01:00
|
|
|
|
|
2021-05-11 11:08:21 +02:00
|
|
|
|
/***** Set global announcement as not hidden *****/
|
|
|
|
|
Ann_DB_UnhideAnnouncement (AnnCod);
|
2015-11-01 20:21:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Remove a global announcement *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ann_RemoveAnnouncement (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Announcement_removed;
|
|
|
|
|
long AnnCod;
|
|
|
|
|
|
|
|
|
|
/***** Get the code of the global announcement *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
AnnCod = ParCod_GetAndCheckPar (ParCod_Ann);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove users who have seen the announcement *****/
|
2021-05-11 11:08:21 +02:00
|
|
|
|
Ann_DB_RemoveUsrsWhoSawAnnouncement (AnnCod);
|
|
|
|
|
|
|
|
|
|
/***** Remove the announcement *****/
|
|
|
|
|
Ann_DB_RemoveAnnouncement (AnnCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message of success *****/
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Announcement_removed);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Refresh list of announcements *****/
|
|
|
|
|
Ann_ShowAllAnnouncements ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Create a new announcement **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ann_MarkAnnouncementAsSeen (void)
|
|
|
|
|
{
|
|
|
|
|
long AnnCod;
|
|
|
|
|
|
|
|
|
|
/***** Get the code of the global announcement *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
AnnCod = ParCod_GetAndCheckPar (ParCod_Ann);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark announcement as seen *****/
|
2021-05-11 11:08:21 +02:00
|
|
|
|
Ann_DB_MarkAnnouncementAsSeenByMe (AnnCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show other announcements again *****/
|
|
|
|
|
Ann_ShowMyAnnouncementsNotMarkedAsSeen ();
|
|
|
|
|
}
|