2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_notice.c: notices (yellow notes)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2024-02-07 00:40:28 +01:00
|
|
|
|
Copyright (C) 1999-2024 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 Public 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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-03-25 19:05:10 +01:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <linux/limits.h> // For PATH_MAX
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2019-03-25 19:05:10 +01:00
|
|
|
|
#include <stdio.h> // For sscanf, asprintf, etc.
|
2021-04-23 22:57:57 +02:00
|
|
|
|
#include <stdlib.h> // For free
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
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"
|
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"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_figure.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"
|
2023-06-06 22:18:31 +02:00
|
|
|
|
#include "swad_hidden_visible.h"
|
2023-09-22 14:47:56 +02:00
|
|
|
|
#include "swad_hierarchy_type.h"
|
2019-10-23 20:07:56 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_notice.h"
|
2021-09-30 23:17:10 +02:00
|
|
|
|
#include "swad_notice_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_notification.h"
|
2021-10-01 09:11:58 +02:00
|
|
|
|
#include "swad_notification_database.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"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_RSS.h"
|
2019-03-12 21:25:55 +01:00
|
|
|
|
#include "swad_timeline.h"
|
2021-02-27 14:25:17 +01:00
|
|
|
|
#include "swad_timeline_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define Not_MAX_CHARS_ON_NOTICE 40 // Maximum number of characters in notices (when not expanded)
|
|
|
|
|
|
2024-03-20 09:39:04 +01:00
|
|
|
|
static unsigned Not_MaxCharsURLOnScreen[Not_NUM_TYPES_LISTING] =
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-11-22 01:04:03 +01:00
|
|
|
|
[Not_LIST_BRIEF_NOTICES] = 15,
|
|
|
|
|
[Not_LIST_FULL_NOTICES ] = 50,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-11-27 13:06:18 +01:00
|
|
|
|
static void Not_PutLinkToRSSFile (void);
|
|
|
|
|
|
2024-04-19 12:00:30 +02:00
|
|
|
|
static Usr_Can_t Not_CheckIfICanEditNotices (void);
|
2020-04-08 19:42:03 +02:00
|
|
|
|
static void Not_PutIconsListNotices (__attribute__((unused)) void *Args);
|
2016-03-21 15:10:00 +01:00
|
|
|
|
static void Not_PutIconToAddNewNotice (void);
|
2016-11-06 22:37:12 +01:00
|
|
|
|
static void Not_GetDataAndShowNotice (long NotCod);
|
2023-03-23 18:06:03 +01:00
|
|
|
|
static void Not_GetNoticeDataFromRow (MYSQL_RES *mysql_res,
|
|
|
|
|
struct Not_Notice *Notice,
|
|
|
|
|
Not_Listing_t TypeNoticesListing);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Not_DrawANotice (Not_Listing_t TypeNoticesListing,
|
2023-03-23 18:06:03 +01:00
|
|
|
|
struct Not_Notice *Notice,
|
2023-11-27 14:41:02 +01:00
|
|
|
|
Lay_Highlight_t Highlight);
|
2021-09-30 23:17:10 +02:00
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Not_PutParNotCod (void *NotCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Write a new notice ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Not_ShowFormNotice (void)
|
|
|
|
|
{
|
2020-09-26 17:20:01 +02:00
|
|
|
|
extern const char *Hlp_COMMUNICATION_Notices;
|
2016-12-27 13:56:44 +01:00
|
|
|
|
extern const char *Txt_The_notice_will_appear_as_a_yellow_note_;
|
2023-04-20 01:22:07 +02:00
|
|
|
|
extern const char *Txt_Notice;
|
2023-05-09 17:31:35 +02:00
|
|
|
|
extern const char *Txt_Create;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-11-03 21:58:51 +01:00
|
|
|
|
/***** Help message *****/
|
2019-02-16 18:11:52 +01:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_The_notice_will_appear_as_a_yellow_note_,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].FullName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2023-05-09 17:31:35 +02:00
|
|
|
|
Frm_BeginForm (ActNewNot);
|
2015-03-24 17:47:26 +01:00
|
|
|
|
|
2021-06-29 15:25:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (Txt_Notice,NULL,NULL,
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Hlp_COMMUNICATION_Notices,Box_NOT_CLOSABLE);
|
2015-03-24 17:47:26 +01:00
|
|
|
|
|
2021-06-29 15:25:42 +02:00
|
|
|
|
/***** Message body *****/
|
2024-05-17 00:04:18 +02:00
|
|
|
|
HTM_TEXTAREA_Begin (HTM_ENABLED,HTM_READWRITE,HTM_REQUIRED,
|
2024-05-09 19:11:16 +02:00
|
|
|
|
"name=\"Content\" cols=\"30\" rows=\"10\""
|
2024-05-14 10:19:48 +02:00
|
|
|
|
" class=\"INPUT_%s\" autofocus=\"autofocus\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-06-29 15:25:42 +02:00
|
|
|
|
HTM_TEXTAREA_End ();
|
2015-03-24 17:47:26 +01:00
|
|
|
|
|
2021-06-29 15:25:42 +02:00
|
|
|
|
/***** Send button and end box *****/
|
2023-05-09 17:31:35 +02:00
|
|
|
|
Box_BoxWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create);
|
2015-03-24 17:47:26 +01:00
|
|
|
|
|
2015-04-11 17:33:14 +02:00
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-11-03 21:58:51 +01:00
|
|
|
|
|
|
|
|
|
/***** Show all notices *****/
|
2024-02-07 00:40:28 +01:00
|
|
|
|
HTM_BR ();
|
2019-03-24 23:17:32 +01:00
|
|
|
|
Not_ShowNotices (Not_LIST_FULL_NOTICES,
|
|
|
|
|
-1L); // No notice highlighted
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******* Receive a new notice from a form and store it in database ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Not_ReceiveNotice (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Notice_created;
|
|
|
|
|
long NotCod;
|
|
|
|
|
unsigned NumUsrsToBeNotifiedByEMail;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Content[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the text of the notice *****/
|
|
|
|
|
Par_GetParAndChangeFormat ("Content",Content,Cns_MAX_BYTES_TEXT,
|
2023-05-30 23:18:59 +02:00
|
|
|
|
Str_TO_RIGOROUS_HTML,Str_REMOVE_SPACES);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Create a new notice in database *****/
|
2021-06-29 15:25:42 +02:00
|
|
|
|
NotCod = Not_DB_InsertNotice (Content);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update RSS of current course *****/
|
2023-09-22 14:47:56 +02:00
|
|
|
|
RSS_UpdateRSSFileForACrs (&Gbl.Hierarchy.Node[Hie_CRS]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message of success *****/
|
2019-02-16 18:11:52 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Notice_created);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-11-16 23:19:52 +01:00
|
|
|
|
/***** Notify by email about the new notice *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_NOTICE,NotCod)))
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Not_DB_UpdateNumUsrsNotifiedByEMailAboutNotice (NotCod,NumUsrsToBeNotifiedByEMail);
|
2015-12-29 01:28:17 +01:00
|
|
|
|
|
2015-12-31 14:25:28 +01:00
|
|
|
|
/***** Create a new social note about the new notice *****/
|
2022-05-30 19:03:56 +02:00
|
|
|
|
TmlNot_StoreAndPublishNote (TmlNot_NOTICE,NotCod);
|
2019-03-24 23:17:32 +01:00
|
|
|
|
|
|
|
|
|
/***** Set notice to be highlighted *****/
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Crs.Notices.HighlightNotCod = NotCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-03 22:13:01 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* List notices after removing one of them *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Not_ListNoticesAfterRemoval (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Notice_removed;
|
|
|
|
|
|
|
|
|
|
/***** Message of success *****/
|
2019-02-16 18:11:52 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Notice_removed);
|
2015-11-03 22:13:01 +01:00
|
|
|
|
|
|
|
|
|
/***** List remaining notices *****/
|
|
|
|
|
Not_ListFullNotices ();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* List notices ********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-11-03 22:13:01 +01:00
|
|
|
|
void Not_ListFullNotices (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-11-03 21:58:51 +01:00
|
|
|
|
/***** Show all notices *****/
|
2019-03-24 23:17:32 +01:00
|
|
|
|
Not_ShowNotices (Not_LIST_FULL_NOTICES,
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Crs.Notices.HighlightNotCod); // Highlight notice
|
2019-03-24 23:17:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Get highlighted notice code ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-04-23 23:54:23 +02:00
|
|
|
|
void Not_GetHighlightNotCod (void)
|
2019-03-24 23:17:32 +01:00
|
|
|
|
{
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Gbl.Crs.Notices.HighlightNotCod = ParCod_GetPar (ParCod_Not);
|
2016-11-06 22:37:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Mark as hidden a notice that was active *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-03-20 09:39:04 +01:00
|
|
|
|
void Not_HideNotice (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
long NotCod;
|
|
|
|
|
|
|
|
|
|
/***** Get the code of the notice to hide *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
NotCod = ParCod_GetAndCheckPar (ParCod_Not);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Set notice as hidden *****/
|
2021-09-30 23:17:10 +02:00
|
|
|
|
Not_DB_ChangeNoticeStatus (NotCod,Not_OBSOLETE_NOTICE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update RSS of current course *****/
|
2023-09-22 14:47:56 +02:00
|
|
|
|
RSS_UpdateRSSFileForACrs (&Gbl.Hierarchy.Node[Hie_CRS]);
|
2019-03-24 23:17:32 +01:00
|
|
|
|
|
|
|
|
|
/***** Set notice to be highlighted *****/
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Crs.Notices.HighlightNotCod = NotCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Mark as active a notice that was hidden ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-03-20 09:39:04 +01:00
|
|
|
|
void Not_UnhideNotice (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
long NotCod;
|
|
|
|
|
|
2015-11-01 20:21:59 +01:00
|
|
|
|
/***** Get the code of the notice to reveal *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
NotCod = ParCod_GetAndCheckPar (ParCod_Not);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-11-01 20:21:59 +01:00
|
|
|
|
/***** Set notice as active *****/
|
2021-09-30 23:17:10 +02:00
|
|
|
|
Not_DB_ChangeNoticeStatus (NotCod,Not_ACTIVE_NOTICE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update RSS of current course *****/
|
2023-09-22 14:47:56 +02:00
|
|
|
|
RSS_UpdateRSSFileForACrs (&Gbl.Hierarchy.Node[Hie_CRS]);
|
2019-03-24 23:17:32 +01:00
|
|
|
|
|
|
|
|
|
/***** Set notice to be highlighted *****/
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Crs.Notices.HighlightNotCod = NotCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-03 21:58:51 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Request the removal of a notice ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-17 12:51:11 +01:00
|
|
|
|
void Not_ReqRemNotice (void)
|
2015-11-03 21:58:51 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_following_notice;
|
2019-03-24 23:17:32 +01:00
|
|
|
|
long NotCod;
|
2015-11-03 21:58:51 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the code of the notice to remove *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
NotCod = ParCod_GetAndCheckPar (ParCod_Not);
|
2015-11-03 21:58:51 +01:00
|
|
|
|
|
2017-04-28 12:17:22 +02:00
|
|
|
|
/***** Show question and button to remove this notice *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/* Begin alert */
|
2023-11-05 19:44:03 +01:00
|
|
|
|
Ale_ShowAlertAndButtonBegin (Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_following_notice);
|
2016-11-14 10:30:33 +01:00
|
|
|
|
|
2024-02-07 00:40:28 +01:00
|
|
|
|
/* Show notice */
|
|
|
|
|
Not_GetDataAndShowNotice (NotCod);
|
2017-04-28 12:17:22 +02:00
|
|
|
|
|
|
|
|
|
/* End alert */
|
2023-11-05 19:44:03 +01:00
|
|
|
|
Ale_ShowAlertAndButtonEnd (ActRemNot,NULL,NULL,
|
2024-02-07 00:40:28 +01:00
|
|
|
|
Not_PutParNotCod,&NotCod,
|
|
|
|
|
Btn_REMOVE_BUTTON,Act_GetActionText (ActRemNot));
|
2015-11-03 21:58:51 +01:00
|
|
|
|
|
|
|
|
|
/***** Show all notices *****/
|
2019-03-24 23:17:32 +01:00
|
|
|
|
Not_ShowNotices (Not_LIST_FULL_NOTICES,
|
|
|
|
|
NotCod); // Highlight notice to be removed
|
2015-11-03 21:58:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2015-11-01 20:21:59 +01:00
|
|
|
|
/******************************* Remove a notice *****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-11-03 21:58:51 +01:00
|
|
|
|
void Not_RemoveNotice (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
long NotCod;
|
|
|
|
|
|
2015-11-03 21:58:51 +01:00
|
|
|
|
/***** Get the code of the notice to remove *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
NotCod = ParCod_GetAndCheckPar (ParCod_Not);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove notice *****/
|
|
|
|
|
/* Copy notice to table of deleted notices */
|
2021-09-30 23:17:10 +02:00
|
|
|
|
Not_DB_CopyNoticeToDeleted (NotCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Remove notice */
|
2021-09-30 23:17:10 +02:00
|
|
|
|
Not_DB_RemoveNotice (NotCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark possible notifications as removed *****/
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_NOTICE,NotCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-01-03 19:30:59 +01:00
|
|
|
|
/***** Mark possible social note as unavailable *****/
|
2022-05-30 19:03:56 +02:00
|
|
|
|
Tml_DB_MarkNoteAsUnavailable (TmlNot_NOTICE,NotCod);
|
2016-01-03 19:30:59 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Update RSS of current course *****/
|
2023-09-22 14:47:56 +02:00
|
|
|
|
RSS_UpdateRSSFileForACrs (&Gbl.Hierarchy.Node[Hie_CRS]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Show the notices ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-03-24 23:17:32 +01:00
|
|
|
|
void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-09-26 17:20:01 +02:00
|
|
|
|
extern const char *Hlp_COMMUNICATION_Notices;
|
2016-03-21 15:10:00 +01:00
|
|
|
|
extern const char *Txt_Notices;
|
2015-11-01 18:54:10 +01:00
|
|
|
|
extern const char *Txt_No_notices;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
2023-11-28 09:24:29 +01:00
|
|
|
|
// char StrWidth[Cns_MAX_DECIMAL_DIGITS_UINT + 2 + 1];
|
2023-03-23 18:06:03 +01:00
|
|
|
|
struct Not_Notice Notice;
|
2021-04-17 01:08:48 +02:00
|
|
|
|
unsigned NumNot;
|
|
|
|
|
unsigned NumNotices = 0; // Initialized to avoid warning
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-03 20:57:04 +02:00
|
|
|
|
/***** Trivial check *****/
|
2023-09-22 14:47:56 +02:00
|
|
|
|
if (Gbl.Hierarchy.Level != Hie_CRS) // No course selected
|
2019-04-03 20:57:04 +02:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch (TypeNoticesListing)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Not_LIST_BRIEF_NOTICES:
|
2023-11-27 13:06:18 +01:00
|
|
|
|
/***** Get notices from database *****/
|
2023-11-28 01:44:05 +01:00
|
|
|
|
NumNotices = Not_DB_GetActiveNotices (&mysql_res,
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2019-04-03 20:57:04 +02:00
|
|
|
|
break;
|
|
|
|
|
case Not_LIST_FULL_NOTICES:
|
2023-11-27 13:06:18 +01:00
|
|
|
|
/***** Get notices from database *****/
|
2021-09-30 23:17:10 +02:00
|
|
|
|
NumNotices = Not_DB_GetAllNotices (&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-11-27 13:06:18 +01:00
|
|
|
|
/***** Begin box *****/
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (Txt_Notices,Not_PutIconsListNotices,NULL,
|
2023-11-27 13:06:18 +01:00
|
|
|
|
Hlp_COMMUNICATION_Notices,Box_NOT_CLOSABLE);
|
|
|
|
|
if (!NumNotices)
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_notices);
|
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-11-27 13:06:18 +01:00
|
|
|
|
/***** Show notices *****/
|
2019-04-03 20:57:04 +02:00
|
|
|
|
for (NumNot = 0;
|
|
|
|
|
NumNot < NumNotices;
|
|
|
|
|
NumNot++)
|
|
|
|
|
{
|
2023-11-27 13:06:18 +01:00
|
|
|
|
/* Get notice data */
|
2023-03-23 18:06:03 +01:00
|
|
|
|
Not_GetNoticeDataFromRow (mysql_res,&Notice,TypeNoticesListing);
|
2019-04-03 20:57:04 +02:00
|
|
|
|
|
2023-11-27 13:06:18 +01:00
|
|
|
|
/* Draw notice */
|
2023-03-23 18:06:03 +01:00
|
|
|
|
Not_DrawANotice (TypeNoticesListing,&Notice,
|
2023-11-27 14:41:02 +01:00
|
|
|
|
(Notice.NotCod == HighlightNotCod) ? Lay_HIGHLIGHT :
|
|
|
|
|
Lay_NO_HIGHLIGHT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-04-03 20:57:04 +02:00
|
|
|
|
|
|
|
|
|
switch (TypeNoticesListing)
|
|
|
|
|
{
|
|
|
|
|
case Not_LIST_BRIEF_NOTICES:
|
|
|
|
|
/***** Link to RSS file *****/
|
2023-11-27 13:06:18 +01:00
|
|
|
|
Not_PutLinkToRSSFile ();
|
2019-04-03 20:57:04 +02:00
|
|
|
|
break;
|
|
|
|
|
case Not_LIST_FULL_NOTICES:
|
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2019-04-03 20:57:04 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Mark possible notification as seen *****/
|
2021-11-09 12:36:32 +01:00
|
|
|
|
Ntf_DB_MarkNotifsInCrsAsSeen (Ntf_EVENT_NOTICE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-27 13:06:18 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Link to RSS file *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Not_PutLinkToRSSFile (void)
|
|
|
|
|
{
|
|
|
|
|
char PathRelRSSFile[PATH_MAX + 1];
|
2024-04-23 23:54:23 +02:00
|
|
|
|
char RSSLink[WWW_MAX_BYTES_WWW + 1];
|
2023-11-27 13:06:18 +01:00
|
|
|
|
|
|
|
|
|
/***** Create RSS file if not exists *****/
|
|
|
|
|
snprintf (PathRelRSSFile,sizeof (PathRelRSSFile),"%s/%ld/%s/%s",
|
|
|
|
|
Cfg_PATH_CRS_PUBLIC,
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,Cfg_RSS_FOLDER,Cfg_RSS_FILE);
|
|
|
|
|
if (!Fil_CheckIfPathExists (PathRelRSSFile))
|
|
|
|
|
RSS_UpdateRSSFileForACrs (&Gbl.Hierarchy.Node[Hie_CRS]);
|
|
|
|
|
|
|
|
|
|
/***** Put a link to the RSS file *****/
|
|
|
|
|
HTM_DIV_Begin ("class=\"CM\"");
|
|
|
|
|
RSS_BuildRSSLink (RSSLink,Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
|
|
|
|
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",RSSLink);
|
|
|
|
|
Ico_PutIcon ("rss-square.svg",Ico_BLACK,"RSS","ICO16x16");
|
|
|
|
|
HTM_A_End ();
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-06 23:46:29 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Check if I can edit notices *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-04-19 12:00:30 +02:00
|
|
|
|
static Usr_Can_t Not_CheckIfICanEditNotices (void)
|
2016-11-06 23:46:29 +01:00
|
|
|
|
{
|
2024-04-01 17:59:51 +02:00
|
|
|
|
return (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
2024-04-19 12:00:30 +02:00
|
|
|
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Usr_CAN :
|
|
|
|
|
Usr_CAN_NOT;
|
2016-11-06 23:46:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-06 15:47:37 +01:00
|
|
|
|
/*****************************************************************************/
|
2016-11-06 21:19:25 +01:00
|
|
|
|
/****************** Put contextual icons in list of notices ******************/
|
2016-11-06 15:47:37 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 19:42:03 +02:00
|
|
|
|
static void Not_PutIconsListNotices (__attribute__((unused)) void *Args)
|
2016-11-06 15:47:37 +01:00
|
|
|
|
{
|
2020-04-08 19:42:03 +02:00
|
|
|
|
/***** Put icon to add a new notice *****/
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (Not_CheckIfICanEditNotices () == Usr_CAN)
|
2020-04-08 19:42:03 +02:00
|
|
|
|
Not_PutIconToAddNewNotice ();
|
2016-11-06 15:47:37 +01:00
|
|
|
|
|
2020-04-08 19:42:03 +02:00
|
|
|
|
/***** Put icon to show a figure *****/
|
|
|
|
|
Fig_PutIconToShowFigure (Fig_NOTICES);
|
2016-11-06 15:47:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-21 15:10:00 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Put icon to add a new notice ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Not_PutIconToAddNewNotice (void)
|
|
|
|
|
{
|
2022-06-29 18:04:45 +02:00
|
|
|
|
Ico_PutContextualIconToAdd (ActWriNot,NULL,NULL,NULL);
|
2016-03-21 15:10:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-21 16:49:44 +01:00
|
|
|
|
/*****************************************************************************/
|
2015-11-03 21:58:51 +01:00
|
|
|
|
/******************** Get data of a notice and show it ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-06 22:37:12 +01:00
|
|
|
|
static void Not_GetDataAndShowNotice (long NotCod)
|
2015-11-03 21:58:51 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
2023-03-23 18:06:03 +01:00
|
|
|
|
struct Not_Notice Notice;
|
2015-11-03 21:58:51 +01:00
|
|
|
|
|
|
|
|
|
/***** Get notice data from database *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
if (Not_DB_GetNoticeData (&mysql_res,NotCod))
|
2015-11-03 21:58:51 +01:00
|
|
|
|
{
|
2023-03-23 18:06:03 +01:00
|
|
|
|
Not_GetNoticeDataFromRow (mysql_res,&Notice,Not_LIST_FULL_NOTICES);
|
2015-11-03 21:58:51 +01:00
|
|
|
|
|
2023-03-23 18:06:03 +01:00
|
|
|
|
/***** Draw the notice *****/
|
2023-11-27 14:41:02 +01:00
|
|
|
|
Not_DrawANotice (Not_LIST_FULL_NOTICES,&Notice,Lay_NO_HIGHLIGHT);
|
2023-03-23 18:06:03 +01:00
|
|
|
|
}
|
2015-11-03 21:58:51 +01:00
|
|
|
|
|
2023-03-23 18:06:03 +01:00
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
2015-11-03 21:58:51 +01:00
|
|
|
|
|
2023-03-23 18:06:03 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get notice data from database row ***********************/
|
|
|
|
|
/*****************************************************************************/
|
2015-11-03 21:58:51 +01:00
|
|
|
|
|
2023-03-23 18:06:03 +01:00
|
|
|
|
static void Not_GetNoticeDataFromRow (MYSQL_RES *mysql_res,
|
|
|
|
|
struct Not_Notice *Notice,
|
|
|
|
|
Not_Listing_t TypeNoticesListing)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned UnsignedNum;
|
2015-11-03 21:58:51 +01:00
|
|
|
|
|
2023-03-23 19:56:18 +01:00
|
|
|
|
/***** Get next row from result *****/
|
2023-03-23 18:06:03 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Get notice code (row[0]) *****/
|
|
|
|
|
if (sscanf (row[0],"%ld",&Notice->NotCod) != 1)
|
|
|
|
|
Err_WrongNoticeExit ();
|
|
|
|
|
|
|
|
|
|
/***** Get creation time (row[1] holds the UTC date-time) *****/
|
|
|
|
|
Notice->CreatTime = Dat_GetUNIXTimeFromStr (row[1]);
|
|
|
|
|
|
|
|
|
|
/***** Get user code (row[2]) *****/
|
|
|
|
|
Notice->UsrCod = Str_ConvertStrCodToLongCod (row[2]);
|
|
|
|
|
|
|
|
|
|
/***** Get the content (row[3]) and insert links *****/
|
|
|
|
|
Str_Copy (Notice->Content,row[3],sizeof (Notice->Content) - 1);
|
|
|
|
|
|
|
|
|
|
/* Inserting links is incompatible with limiting the length
|
|
|
|
|
==> don't insert links when limiting length */
|
|
|
|
|
switch (TypeNoticesListing)
|
|
|
|
|
{
|
|
|
|
|
case Not_LIST_BRIEF_NOTICES:
|
|
|
|
|
Str_LimitLengthHTMLStr (Notice->Content,Not_MAX_CHARS_ON_NOTICE);
|
|
|
|
|
break;
|
|
|
|
|
case Not_LIST_FULL_NOTICES:
|
|
|
|
|
ALn_InsertLinks (Notice->Content,Cns_MAX_BYTES_TEXT,
|
|
|
|
|
Not_MaxCharsURLOnScreen[Not_LIST_FULL_NOTICES]);
|
|
|
|
|
break;
|
2015-11-03 21:58:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 18:06:03 +01:00
|
|
|
|
/***** Get status of the notice (row[4]) *****/
|
|
|
|
|
Notice->Status = Not_OBSOLETE_NOTICE;
|
|
|
|
|
if (sscanf (row[4],"%u",&UnsignedNum) == 1)
|
|
|
|
|
if (UnsignedNum < Not_NUM_STATUS)
|
|
|
|
|
Notice->Status = (Not_Status_t) UnsignedNum;
|
2015-11-03 21:58:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Draw a notice as a yellow note ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Not_DrawANotice (Not_Listing_t TypeNoticesListing,
|
2023-03-23 18:06:03 +01:00
|
|
|
|
struct Not_Notice *Notice,
|
2023-11-27 14:41:02 +01:00
|
|
|
|
Lay_Highlight_t Highlight)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_See_full_notice;
|
2024-03-20 09:39:04 +01:00
|
|
|
|
static Act_Action_t ActionHideUnhide[HidVis_NUM_HIDDEN_VISIBLE] =
|
2022-07-21 19:30:03 +02:00
|
|
|
|
{
|
2023-06-06 22:18:31 +02:00
|
|
|
|
[HidVis_HIDDEN ] = ActUnhNot, // Hidden ==> action to unhide
|
|
|
|
|
[HidVis_VISIBLE] = ActHidNot, // Visible ==> action to hide
|
2022-07-21 19:30:03 +02:00
|
|
|
|
};
|
2015-11-01 14:11:46 +01:00
|
|
|
|
static const char *ContainerClass[Not_NUM_STATUS] =
|
|
|
|
|
{
|
2021-12-27 12:58:20 +01:00
|
|
|
|
[Not_ACTIVE_NOTICE ] = "NOTICE_BOX",
|
|
|
|
|
[Not_OBSOLETE_NOTICE] = "NOTICE_BOX LIGHT",
|
2015-11-01 14:11:46 +01:00
|
|
|
|
};
|
2019-11-18 17:59:02 +01:00
|
|
|
|
static const char *ContainerWidthClass[Not_NUM_TYPES_LISTING] =
|
2019-10-15 15:23:38 +02:00
|
|
|
|
{
|
2021-12-27 12:58:20 +01:00
|
|
|
|
[Not_LIST_BRIEF_NOTICES] = "NOTICE_BOX_NARROW",
|
|
|
|
|
[Not_LIST_FULL_NOTICES ] = "NOTICE_BOX_WIDE",
|
2015-11-01 14:11:46 +01:00
|
|
|
|
};
|
2023-11-27 14:41:02 +01:00
|
|
|
|
static const char *ContainerHighLightClass[Lay_NUM_HIGHLIGHT] =
|
|
|
|
|
{
|
|
|
|
|
[Lay_NO_HIGHLIGHT] = "",
|
|
|
|
|
[Lay_HIGHLIGHT ] = " NOTICE_HIGHLIGHT",
|
|
|
|
|
};
|
2015-10-26 14:49:42 +01:00
|
|
|
|
static unsigned UniqueId = 0;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
char *Id;
|
2022-09-24 18:30:26 +02:00
|
|
|
|
struct Usr_Data UsrDat;
|
2019-03-25 19:05:10 +01:00
|
|
|
|
char *Anchor = NULL;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-03-24 23:17:32 +01:00
|
|
|
|
/***** Build anchor string *****/
|
2023-03-23 18:06:03 +01:00
|
|
|
|
Frm_SetAnchorStr (Notice->NotCod,&Anchor);
|
2019-03-24 23:17:32 +01:00
|
|
|
|
|
2019-10-26 01:56:36 +02:00
|
|
|
|
/***** Begin article for this notice *****/
|
2019-03-24 23:17:32 +01:00
|
|
|
|
if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
|
|
|
|
|
{
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_ARTICLE_Begin (Anchor);
|
2021-12-29 20:43:07 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"NOTICE_CONT%s\"",
|
2023-11-27 14:41:02 +01:00
|
|
|
|
ContainerHighLightClass[Highlight]);
|
2019-03-24 23:17:32 +01:00
|
|
|
|
}
|
2016-12-11 20:28:58 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin yellow note *****/
|
2019-10-24 00:04:40 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"%s %s\"",
|
2023-03-23 18:06:03 +01:00
|
|
|
|
ContainerClass[Notice->Status],ContainerWidthClass[TypeNoticesListing]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-29 15:25:42 +02:00
|
|
|
|
/***** Write the date in the top part of the yellow note *****/
|
|
|
|
|
/* Write symbol to indicate if notice is obsolete or active */
|
|
|
|
|
if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (Not_CheckIfICanEditNotices () == Usr_CAN)
|
2021-06-29 15:25:42 +02:00
|
|
|
|
{
|
2022-07-21 19:30:03 +02:00
|
|
|
|
/***** Icon to remove announcement *****/
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Ico_PutContextualIconToRemove (ActReqRemNot,NULL,
|
2023-03-23 18:06:03 +01:00
|
|
|
|
Not_PutParNotCod,&Notice->NotCod);
|
2021-06-29 15:25:42 +02:00
|
|
|
|
|
2022-07-21 19:30:03 +02:00
|
|
|
|
/***** Icon to change the status of the notice *****/
|
|
|
|
|
Ico_PutContextualIconToHideUnhide (ActionHideUnhide,NULL, // TODO: Put anchor
|
2023-03-23 18:06:03 +01:00
|
|
|
|
Not_PutParNotCod,&Notice->NotCod,
|
2023-09-10 15:20:25 +02:00
|
|
|
|
Notice->Status == Not_OBSOLETE_NOTICE ? HidVis_HIDDEN :
|
|
|
|
|
HidVis_VISIBLE);
|
2021-06-29 15:25:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write the date */
|
|
|
|
|
UniqueId++;
|
2021-12-27 12:58:20 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"NOTICE_DATE NOTICE_DATE_%s RT\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-06-29 15:25:42 +02:00
|
|
|
|
if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES)
|
|
|
|
|
{
|
|
|
|
|
/* Form to view full notice */
|
|
|
|
|
Frm_BeginFormAnchor (ActSeeOneNot,Anchor);
|
2023-03-23 18:06:03 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Not,Notice->NotCod);
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Txt_See_full_notice,
|
|
|
|
|
"class=\"RT BT_LINK\"");
|
2021-06-29 15:25:42 +02:00
|
|
|
|
}
|
|
|
|
|
if (asprintf (&Id,"not_date_%u",UniqueId) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
HTM_SPAN_Begin ("id=\"%s\"",Id);
|
|
|
|
|
HTM_SPAN_End ();
|
|
|
|
|
if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES)
|
|
|
|
|
{
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
2023-03-23 18:06:03 +01:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Notice->CreatTime,
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
2024-04-24 13:47:19 +02:00
|
|
|
|
Dat_WRITE_TODAY |
|
|
|
|
|
Dat_WRITE_DATE_ON_SAME_DAY |
|
|
|
|
|
Dat_WRITE_HOUR |
|
|
|
|
|
Dat_WRITE_MINUTE);
|
2021-06-29 15:25:42 +02:00
|
|
|
|
free (Id);
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2015-11-01 21:19:33 +01:00
|
|
|
|
|
2021-06-29 15:25:42 +02:00
|
|
|
|
/***** Write the content of the notice *****/
|
|
|
|
|
if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES)
|
|
|
|
|
{
|
2021-12-27 12:58:20 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"NOTICE_TEXT_BRIEF NOTICE_TEXT_%s\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2023-03-23 18:06:03 +01:00
|
|
|
|
HTM_Txt (Notice->Content);
|
2021-06-29 15:25:42 +02:00
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-29 15:25:42 +02:00
|
|
|
|
/* Put form to view full notice */
|
|
|
|
|
HTM_DIV_Begin ("class=\"CM\"");
|
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActSeeOneNot,Anchor,
|
2023-03-23 18:06:03 +01:00
|
|
|
|
Not_PutParNotCod,&Notice->NotCod,
|
2022-06-29 18:34:15 +02:00
|
|
|
|
"ellipsis-h.svg",Ico_BLACK);
|
2021-06-29 15:25:42 +02:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
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-23 18:06:03 +01:00
|
|
|
|
HTM_Txt (Notice->Content);
|
2021-06-29 15:25:42 +02:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Write the author *****/
|
2021-12-27 12:58:20 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"NOTICE_AUTHOR NOTICE_AUTHOR_%s\"", // Limited width
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
2023-03-23 18:06:03 +01:00
|
|
|
|
UsrDat.UsrCod = Notice->UsrCod;
|
2021-06-29 15:25:42 +02:00
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat, // Get author's data from database
|
|
|
|
|
Usr_DONT_GET_PREFS,
|
2023-10-27 13:54:14 +02:00
|
|
|
|
Usr_DONT_GET_ROLE_IN_CRS))
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Usr_WriteFirstNameBRSurnames (&UsrDat);
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-12-30 12:40:13 +01:00
|
|
|
|
/***** End yellow note *****/
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2019-03-24 23:17:32 +01:00
|
|
|
|
|
|
|
|
|
/***** End article for this notice *****/
|
|
|
|
|
if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
|
|
|
|
|
{
|
2021-12-27 12:58:20 +01:00
|
|
|
|
HTM_DIV_End ();
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_ARTICLE_End ();
|
2019-03-24 23:17:32 +01:00
|
|
|
|
}
|
2019-03-25 19:05:10 +01:00
|
|
|
|
|
|
|
|
|
/***** Free anchor string *****/
|
2023-04-06 19:59:33 +02:00
|
|
|
|
Frm_FreeAnchorStr (&Anchor);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2015-12-29 01:28:17 +01:00
|
|
|
|
/******************* Get summary and content for a notice ********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
2017-03-06 13:01:16 +01:00
|
|
|
|
char **ContentStr,
|
2023-11-05 19:44:03 +01:00
|
|
|
|
long NotCod,Ntf_GetContent_t GetContent)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2017-01-15 22:58:26 +01:00
|
|
|
|
size_t Length;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
SummaryStr[0] = '\0'; // Return nothing on error
|
|
|
|
|
|
2021-09-30 23:17:10 +02:00
|
|
|
|
/***** Get content of message from database *****/
|
|
|
|
|
if (Not_DB_ContentNotice (&mysql_res,NotCod) == 1) // Result should have a unique row
|
2018-10-24 00:18:36 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Get sumary / content *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Copy summary *****/
|
|
|
|
|
// TODO: Do only direct copy when a Subject of type VARCHAR(255) is available
|
|
|
|
|
if (strlen (row[0]) > Ntf_MAX_BYTES_SUMMARY)
|
|
|
|
|
{
|
2020-05-25 17:53:13 +02:00
|
|
|
|
/* Inserting links is incompatible with limiting the length
|
|
|
|
|
==> don't insert links */
|
2018-10-24 00:18:36 +02:00
|
|
|
|
strncpy (SummaryStr,row[0],
|
|
|
|
|
Ntf_MAX_BYTES_SUMMARY);
|
|
|
|
|
SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0';
|
|
|
|
|
}
|
|
|
|
|
else
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
|
2018-10-24 00:18:36 +02:00
|
|
|
|
|
|
|
|
|
/***** Copy content *****/
|
2023-11-05 19:44:03 +01:00
|
|
|
|
if (GetContent == Ntf_GET_CONTENT)
|
2018-10-24 00:18:36 +02:00
|
|
|
|
{
|
|
|
|
|
Length = strlen (row[0]);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (*ContentStr,row[0],Length);
|
2018-10-24 00:18:36 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Get number of notices ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns the number of (active or obsolete) notices
|
|
|
|
|
// sent from this location (all the platform, current degree or current course)
|
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
unsigned Not_GetNumNotices (Hie_Level_t Level,Not_Status_t Status,unsigned *NumNotif)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumNotices;
|
|
|
|
|
|
|
|
|
|
/***** Get number of notices from database *****/
|
2023-07-11 19:12:24 +02:00
|
|
|
|
if (Not_DB_GetNumNotices (&mysql_res,Level,Status) == 1)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-09-30 23:17:10 +02:00
|
|
|
|
/***** Get number of notices *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if (sscanf (row[0],"%u",&NumNotices) != 1)
|
|
|
|
|
Err_ShowErrorAndExit ("Error when getting number of notices.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-30 23:17:10 +02:00
|
|
|
|
/***** Get number of notifications by email *****/
|
|
|
|
|
if (row[1])
|
|
|
|
|
{
|
|
|
|
|
if (sscanf (row[1],"%u",NumNotif) != 1)
|
|
|
|
|
Err_ShowErrorAndExit ("Error when getting number of notifications of notices.");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
*NumNotif = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2021-09-30 23:17:10 +02:00
|
|
|
|
{
|
|
|
|
|
NumNotices = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
*NumNotif = 0;
|
2021-09-30 23:17:10 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumNotices;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Get number of deleted notices **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns the number of deleted notices
|
|
|
|
|
// sent from this location (all the platform, current degree or current course)
|
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
unsigned Not_GetNumNoticesDeleted (Hie_Level_t Level,unsigned *NumNotif)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumNotices;
|
|
|
|
|
|
|
|
|
|
/***** Get number of notices from database *****/
|
2023-07-11 19:12:24 +02:00
|
|
|
|
if (Not_DB_GetNumNoticesDeleted (&mysql_res,Level) == 1)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-09-30 23:17:10 +02:00
|
|
|
|
/***** Get number of notices *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if (sscanf (row[0],"%u",&NumNotices) != 1)
|
|
|
|
|
Err_ShowErrorAndExit ("Error when getting number of deleted notices.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-30 23:17:10 +02:00
|
|
|
|
/***** Get number of notifications by email *****/
|
|
|
|
|
if (row[1])
|
|
|
|
|
{
|
|
|
|
|
if (sscanf (row[1],"%u",NumNotif) != 1)
|
|
|
|
|
Err_ShowErrorAndExit ("Error when getting number of notifications of deleted notices.");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
*NumNotif = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2021-09-30 23:17:10 +02:00
|
|
|
|
{
|
|
|
|
|
NumNotices = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
*NumNotif = 0;
|
2021-09-30 23:17:10 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumNotices;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Put parameter with the code of a notice *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Not_PutParNotCod (void *NotCod)
|
2016-12-11 20:28:58 +01:00
|
|
|
|
{
|
2020-04-08 19:42:03 +02:00
|
|
|
|
if (NotCod)
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Not,*((long *) NotCod));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2022-01-03 02:47:16 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Show figures about notices ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Not_GetAndShowNoticesStats (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ANALYTICS_Figures_notices;
|
|
|
|
|
extern const char *Txt_FIGURE_TYPES[Fig_NUM_FIGURES];
|
|
|
|
|
extern const char *Txt_NOTICE_Active_BR_notices;
|
|
|
|
|
extern const char *Txt_NOTICE_Obsolete_BR_notices;
|
|
|
|
|
extern const char *Txt_NOTICE_Deleted_BR_notices;
|
|
|
|
|
extern const char *Txt_Total;
|
|
|
|
|
extern const char *Txt_Number_of_BR_notifications;
|
|
|
|
|
Not_Status_t NoticeStatus;
|
|
|
|
|
unsigned NumNotices[Not_NUM_STATUS];
|
|
|
|
|
unsigned NumNoticesDeleted;
|
|
|
|
|
unsigned NumTotalNotices = 0;
|
|
|
|
|
unsigned NumNotif;
|
|
|
|
|
unsigned NumTotalNotifications = 0;
|
|
|
|
|
|
|
|
|
|
/***** Get the number of notices active and obsolete *****/
|
|
|
|
|
for (NoticeStatus = (Not_Status_t) 0;
|
|
|
|
|
NoticeStatus <= (Not_Status_t) (Not_NUM_STATUS - 1);
|
|
|
|
|
NoticeStatus++)
|
|
|
|
|
{
|
|
|
|
|
NumNotices[NoticeStatus] = Not_GetNumNotices (Gbl.Scope.Current,NoticeStatus,&NumNotif);
|
|
|
|
|
NumTotalNotices += NumNotices[NoticeStatus];
|
|
|
|
|
NumTotalNotifications += NumNotif;
|
|
|
|
|
}
|
|
|
|
|
NumNoticesDeleted = Not_GetNumNoticesDeleted (Gbl.Scope.Current,&NumNotif);
|
|
|
|
|
NumTotalNotices += NumNoticesDeleted;
|
|
|
|
|
NumTotalNotifications += NumNotif;
|
|
|
|
|
|
|
|
|
|
/***** Begin box and table *****/
|
2024-01-29 08:47:21 +01:00
|
|
|
|
Box_BoxTableBegin (Txt_FIGURE_TYPES[Fig_NOTICES],NULL,NULL,
|
2022-01-03 02:47:16 +01:00
|
|
|
|
Hlp_ANALYTICS_Figures_notices,Box_NOT_CLOSABLE,2);
|
|
|
|
|
|
|
|
|
|
/***** Write table heading *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
HTM_TH (Txt_NOTICE_Active_BR_notices ,HTM_HEAD_RIGHT);
|
|
|
|
|
HTM_TH (Txt_NOTICE_Obsolete_BR_notices,HTM_HEAD_RIGHT);
|
|
|
|
|
HTM_TH (Txt_NOTICE_Deleted_BR_notices ,HTM_HEAD_RIGHT);
|
|
|
|
|
HTM_TH (Txt_Total ,HTM_HEAD_RIGHT);
|
|
|
|
|
HTM_TH (Txt_Number_of_BR_notifications,HTM_HEAD_RIGHT);
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** Write number of notices *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2023-10-14 21:36:39 +02:00
|
|
|
|
HTM_TD_Unsigned (NumNotices[Not_ACTIVE_NOTICE]);
|
|
|
|
|
HTM_TD_Unsigned (NumNotices[Not_OBSOLETE_NOTICE]);
|
|
|
|
|
HTM_TD_Unsigned (NumNoticesDeleted);
|
|
|
|
|
HTM_TD_Unsigned (NumTotalNotices);
|
|
|
|
|
HTM_TD_Unsigned (NumTotalNotifications);
|
2022-01-03 02:47:16 +01:00
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** End table and box *****/
|
|
|
|
|
Box_BoxTableEnd ();
|
|
|
|
|
}
|