2021-02-11 00:58:53 +01:00
|
|
|
|
// swad_timeline_note.c: social timeline 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
|
2021-02-11 00:58:53 +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 *********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
|
|
|
|
#include <linux/limits.h> // For PATH_MAX
|
|
|
|
|
#include <stdio.h> // For asprintf
|
2022-04-25 18:27:24 +02:00
|
|
|
|
#include <stdlib.h> // For free
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2021-02-11 00:58:53 +01:00
|
|
|
|
#include "swad_alert.h"
|
|
|
|
|
#include "swad_box.h"
|
2021-09-15 01:54:56 +02:00
|
|
|
|
#include "swad_browser_database.h"
|
2021-03-18 01:49:43 +01:00
|
|
|
|
#include "swad_call_for_exam.h"
|
2021-02-11 00:58:53 +01:00
|
|
|
|
#include "swad_course.h"
|
2021-09-25 11:43:52 +02:00
|
|
|
|
#include "swad_error.h"
|
2021-02-11 00:58:53 +01:00
|
|
|
|
#include "swad_forum.h"
|
|
|
|
|
#include "swad_global.h"
|
2021-02-11 22:57:09 +01:00
|
|
|
|
#include "swad_hierarchy.h"
|
2021-02-11 00:58:53 +01:00
|
|
|
|
#include "swad_notice.h"
|
2021-10-01 09:11:58 +02:00
|
|
|
|
#include "swad_notification_database.h"
|
2023-03-10 17:21:04 +01:00
|
|
|
|
#include "swad_parameter_code.h"
|
2021-02-11 00:58:53 +01:00
|
|
|
|
#include "swad_photo.h"
|
|
|
|
|
#include "swad_profile.h"
|
|
|
|
|
#include "swad_timeline.h"
|
2021-02-27 14:12:41 +01:00
|
|
|
|
#include "swad_timeline_database.h"
|
2021-02-21 21:30:06 +01:00
|
|
|
|
#include "swad_timeline_form.h"
|
2021-02-11 13:10:08 +01:00
|
|
|
|
#include "swad_timeline_publication.h"
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
2021-11-10 23:05:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Private constants ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static const TmlNot_Type_t TmlNot_NoteType[Brw_NUM_TYPES_FILE_BROWSER] =
|
2021-11-10 23:05:08 +01:00
|
|
|
|
{
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[Brw_ADMI_DOC_INS] = TmlNot_INS_DOC_PUB_FILE,
|
|
|
|
|
[Brw_ADMI_SHR_INS] = TmlNot_INS_SHA_PUB_FILE,
|
|
|
|
|
[Brw_ADMI_DOC_CTR] = TmlNot_CTR_DOC_PUB_FILE,
|
|
|
|
|
[Brw_ADMI_SHR_CTR] = TmlNot_CTR_SHA_PUB_FILE,
|
|
|
|
|
[Brw_ADMI_DOC_DEG] = TmlNot_DEG_DOC_PUB_FILE,
|
|
|
|
|
[Brw_ADMI_SHR_DEG] = TmlNot_DEG_SHA_PUB_FILE,
|
|
|
|
|
[Brw_ADMI_DOC_CRS] = TmlNot_CRS_DOC_PUB_FILE,
|
|
|
|
|
[Brw_ADMI_SHR_CRS] = TmlNot_CRS_SHA_PUB_FILE,
|
2021-11-10 23:05:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_WriteTopMessage (Tml_TopMessage_t TopMessage,long PublisherCod);
|
|
|
|
|
static void TmlNot_WriteNote (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlNot_Note *Not);
|
|
|
|
|
static void TmlNot_WriteAuthorTimeAndContent (const struct TmlNot_Note *Not,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
const struct Usr_Data *UsrDat);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_WriteContent (const struct TmlNot_Note *Not);
|
|
|
|
|
static void TmlNot_GetAndWriteNoPost (const struct TmlNot_Note *Not);
|
|
|
|
|
static void TmlNot_GetLocationInHierarchy (const struct TmlNot_Note *Not,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
struct Hie_Node Hie[Hie_NUM_LEVELS],
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct For_Forum *Forum,
|
|
|
|
|
char ForumName[For_MAX_BYTES_FORUM_NAME + 1]);
|
|
|
|
|
static void TmlNot_WriteLocationInHierarchy (const struct TmlNot_Note *Not,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
struct Hie_Node Hie[Hie_NUM_LEVELS],
|
2021-12-31 14:51:44 +01:00
|
|
|
|
const char ForumName[For_MAX_BYTES_FORUM_NAME + 1]);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_PutFormGoToAction (const struct TmlNot_Note *Not,
|
|
|
|
|
const struct For_Forums *Forums);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_WriteButtonsAndComms (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlNot_Note *Not,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
const struct Usr_Data *UsrDat);
|
2022-06-30 11:53:24 +02:00
|
|
|
|
static void TmlNot_WriteButtonToAddAComm (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlNot_Note *Not,
|
2021-12-31 14:51:44 +01:00
|
|
|
|
const char IdNewComm[Frm_MAX_BYTES_ID + 1]);
|
|
|
|
|
static void TmlNot_WriteFavShaRemAndComms (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlNot_Note *Not,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
const struct Usr_Data *UsrDat);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_WriteFavShaRem (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlNot_Note *Not,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
const struct Usr_Data *UsrDat);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_PutFormToRemoveNote (const struct Tml_Timeline *Timeline,
|
|
|
|
|
long NotCod);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
|
2023-03-17 12:51:11 +01:00
|
|
|
|
static void TmlNot_ReqRemNote (struct Tml_Timeline *Timeline);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void TmlNot_PutParsRemoveNote (void *Timeline);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_RemoveNote (void);
|
|
|
|
|
static void TmlNot_RemoveNoteMediaAndDBEntries (struct TmlNot_Note *Not);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
|
2023-03-22 11:34:06 +01:00
|
|
|
|
static void TmlNot_GetNoteDataFromRow (MYSQL_RES *mysql_res,
|
|
|
|
|
struct TmlNot_Note *Not);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static TmlNot_Type_t TmlNot_GetNoteTypeFromStr (const char *Str);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_ResetNote (struct TmlNot_Note *Not);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Show highlighted note above timeline *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlNot_ShowHighlightedNote (struct Tml_Timeline *Timeline,
|
2023-03-22 01:42:27 +01:00
|
|
|
|
struct TmlNot_Note *Not)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2022-09-24 18:30:26 +02:00
|
|
|
|
struct Usr_Data PublisherDat;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
Ntf_NotifyEvent_t NotifyEvent;
|
2021-03-04 17:47:08 +01:00
|
|
|
|
static const Tml_TopMessage_t TopMessages[Ntf_NUM_NOTIFY_EVENTS] =
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-11-18 01:29:48 +01:00
|
|
|
|
[Ntf_EVENT_TML_COMMENT] = Tml_TOP_MESSAGE_COMMENTED,
|
|
|
|
|
[Ntf_EVENT_TML_FAV ] = Tml_TOP_MESSAGE_FAVED,
|
|
|
|
|
[Ntf_EVENT_TML_SHARE ] = Tml_TOP_MESSAGE_SHARED,
|
|
|
|
|
[Ntf_EVENT_TML_MENTION] = Tml_TOP_MESSAGE_MENTIONED,
|
2021-02-11 00:58:53 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/***** Get other parameters *****/
|
|
|
|
|
/* Get the publisher who did the action
|
|
|
|
|
(publishing, commenting, faving, sharing, mentioning) */
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Usr_GetParOtherUsrCodEncrypted (&PublisherDat);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/* Get what he/she did */
|
2023-03-10 00:13:55 +01:00
|
|
|
|
NotifyEvent = Ntf_GetParNotifyEvent ();
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-02-22 17:59:59 +01:00
|
|
|
|
/***** Get data of the note *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
TmlNot_GetNoteDataByCod (Not);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Show the note highlighted *****/
|
2021-03-02 12:40:24 +01:00
|
|
|
|
/* Begin box */
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (NULL,NULL,NULL,NULL,Box_CLOSABLE);
|
2021-03-02 12:40:24 +01:00
|
|
|
|
|
|
|
|
|
/* Begin container */
|
2022-04-25 19:45:05 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_WIDTH Tml_NEW_PUB_%s\"",The_GetSuffix ());
|
2021-03-02 12:40:24 +01:00
|
|
|
|
|
|
|
|
|
/* Check and write note with top message */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_CheckAndWriteNoteWithTopMsg (Timeline,Not,
|
2022-05-09 21:39:00 +02:00
|
|
|
|
TopMessages[NotifyEvent],
|
|
|
|
|
PublisherDat.UsrCod);
|
2021-03-02 12:40:24 +01:00
|
|
|
|
|
|
|
|
|
/* End container */
|
2021-03-02 00:54:26 +01:00
|
|
|
|
HTM_DIV_End ();
|
2021-03-02 12:40:24 +01:00
|
|
|
|
|
|
|
|
|
/* End box */
|
2021-02-22 17:59:59 +01:00
|
|
|
|
Box_BoxEnd ();
|
2024-02-28 00:12:48 +01:00
|
|
|
|
HTM_BR ();
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/****************** Check and write note with top message ********************/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlNot_CheckAndWriteNoteWithTopMsg (const struct Tml_Timeline *Timeline,
|
2022-05-30 19:03:56 +02:00
|
|
|
|
const struct TmlNot_Note *Not,
|
|
|
|
|
Tml_TopMessage_t TopMessage,
|
|
|
|
|
long PublisherCod) // Who did the action (publication, commenting, faving, sharing, mentioning)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-11-12 01:12:15 +01:00
|
|
|
|
/*
|
|
|
|
|
___________________________________________
|
2021-02-23 00:07:52 +01:00
|
|
|
|
| | \
|
|
|
|
|
| Top message: | > top message
|
|
|
|
|
|___________________________________________| /
|
|
|
|
|
| _____ | | | \ \
|
|
|
|
|
|| | | Author's name | Date-time | | |
|
|
|
|
|
||Auth.| |______________________|___________| | |
|
|
|
|
|
||photo| | | | author's |
|
|
|
|
|
||_____| | | > name, time |
|
|
|
|
|
| | Note | | and content |
|
|
|
|
|
| | content | | |
|
|
|
|
|
| | | | |
|
|
|
|
|
| |__________________________________| / |
|
|
|
|
|
| | | | | \ |
|
|
|
|
|
| | Favs | Shared |Remove| | > note
|
|
|
|
|
| |_____________|_____________|______| | |
|
|
|
|
|
|________| | | |
|
|
|
|
|
| | List | | buttons |
|
|
|
|
|
| Comment| of | > and |
|
|
|
|
|
| icon | comments | | comments |
|
|
|
|
|
|________|__________________________________| | |
|
|
|
|
|
| | | |
|
|
|
|
|
| Form to write new comment | | |
|
|
|
|
|
|__________________________________| / /
|
|
|
|
|
*/
|
2021-03-01 22:31:56 +01:00
|
|
|
|
/***** Trivial check: codes *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
if (Not->NotCod <= 0 ||
|
|
|
|
|
Not->UsrCod <= 0 ||
|
2022-05-30 19:03:56 +02:00
|
|
|
|
Not->Type == TmlNot_UNKNOWN)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-02-22 17:59:59 +01:00
|
|
|
|
Ale_ShowAlert (Ale_ERROR,"Error in note.");
|
2021-03-01 22:31:56 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Write sharer/commenter if distinct to author *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
if (TopMessage != Tml_TOP_MESSAGE_NONE)
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_WriteTopMessage (TopMessage,PublisherCod);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Write note *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_WriteNote (Timeline,Not);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 17:20:38 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Write sharer/commenter if distinct to author ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_WriteTopMessage (Tml_TopMessage_t TopMessage,long PublisherCod)
|
2021-02-11 17:20:38 +01:00
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
extern const char *Txt_TIMELINE_NOTE_TOP_MESSAGES[Tml_NUM_TOP_MESSAGES];
|
2022-09-24 18:30:26 +02:00
|
|
|
|
struct Usr_Data PublisherDat;
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&PublisherDat);
|
|
|
|
|
|
|
|
|
|
/***** Get user's data *****/
|
|
|
|
|
PublisherDat.UsrCod = PublisherCod;
|
2021-04-24 15:10:07 +02:00
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&PublisherDat, // Really we only need EncryptedUsrCod and FullName
|
|
|
|
|
Usr_DONT_GET_PREFS,
|
2023-10-27 13:54:14 +02:00
|
|
|
|
Usr_DONT_GET_ROLE_IN_CRS))
|
2021-02-11 17:20:38 +01:00
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin container *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_TOP_CONT Tml_TOP_PUBLISHER Tml_WIDTH\"");
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
2021-03-02 12:40:24 +01:00
|
|
|
|
/***** Show publisher's name inside form to go to user's public profile *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_WriteAuthorName (&PublisherDat,"BT_LINK");
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Show action made *****/
|
|
|
|
|
HTM_TxtF (" %s:",Txt_TIMELINE_NOTE_TOP_MESSAGES[TopMessage]);
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** End container *****/
|
2021-02-11 17:20:38 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&PublisherDat);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-22 17:59:59 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Show note *********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_WriteNote (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlNot_Note *Not)
|
2021-02-22 17:59:59 +01:00
|
|
|
|
{
|
2022-09-24 18:30:26 +02:00
|
|
|
|
struct Usr_Data UsrDat; // Author of the note
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Get author data *****/
|
2021-02-23 00:07:52 +01:00
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
UsrDat.UsrCod = Not->UsrCod;
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,
|
|
|
|
|
Usr_DONT_GET_PREFS,
|
2023-10-27 13:54:14 +02:00
|
|
|
|
Usr_DONT_GET_ROLE_IN_CRS);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/***** Left top: author's photo *****/
|
2022-10-15 10:58:23 +02:00
|
|
|
|
TmlNot_ShowAuthorPhoto (&UsrDat);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/***** Right top: author's name, time, and content *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_WriteAuthorTimeAndContent (Not,&UsrDat);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Bottom: buttons and comments *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_WriteButtonsAndComms (Timeline,Not,&UsrDat);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory used for author's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-22 10:52:00 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Show photo of author of a note **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-10-15 10:58:23 +02:00
|
|
|
|
void TmlNot_ShowAuthorPhoto (struct Usr_Data *UsrDat)
|
2021-02-22 10:52:00 +01:00
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static const char *ClassPhoto[PhoSha_NUM_SHAPES] =
|
2021-12-01 01:43:13 +01:00
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
[PhoSha_SHAPE_CIRCLE ] = "PHOTOC45x60",
|
|
|
|
|
[PhoSha_SHAPE_ELLIPSE ] = "PHOTOE45x60",
|
|
|
|
|
[PhoSha_SHAPE_OVAL ] = "PHOTOO45x60",
|
|
|
|
|
[PhoSha_SHAPE_RECTANGLE] = "PHOTOR45x60",
|
2021-12-01 01:43:13 +01:00
|
|
|
|
};
|
|
|
|
|
|
2021-11-24 01:20:08 +01:00
|
|
|
|
/***** Begin container *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_LEFT_PHOTO\"");
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
2021-11-24 01:20:08 +01:00
|
|
|
|
/***** Photo *****/
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Pho_ShowUsrPhotoIfAllowed (UsrDat,
|
2022-10-15 10:58:23 +02:00
|
|
|
|
ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
2021-11-24 01:20:08 +01:00
|
|
|
|
/***** End container *****/
|
2021-02-22 10:52:00 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-22 17:59:59 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**** Write top right part of a note: author's name, time and note content ***/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_WriteAuthorTimeAndContent (const struct TmlNot_Note *Not,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
const struct Usr_Data *UsrDat)
|
2021-02-22 17:59:59 +01:00
|
|
|
|
{
|
2021-12-30 11:50:29 +01:00
|
|
|
|
char *Class;
|
2021-12-15 14:02:49 +01:00
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/***** Begin top container *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_RIGHT_CONT Tml_RIGHT_WIDTH\"");
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Write author's full name *****/
|
2022-03-26 21:08:25 +01:00
|
|
|
|
if (asprintf (&Class,"Tml_RIGHT_AUTHOR Tml_RIGHT_AUTHOR_WIDTH BT_LINK DAT_STRONG_%s BOLD",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ()) < 0)
|
2021-12-30 11:50:29 +01:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_WriteAuthorName (UsrDat,Class);
|
2021-12-30 11:50:29 +01:00
|
|
|
|
free (Class);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Write date and time *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_WriteDateTime (Not->DateTimeUTC);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Write content of the note *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_WriteContent (Not);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/***** End top container *****/
|
2021-02-22 17:59:59 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Write name and nickname of author of a note *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void TmlNot_WriteAuthorName (const struct Usr_Data *UsrDat,
|
2022-03-26 21:08:25 +01:00
|
|
|
|
const char *Class)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_My_public_profile;
|
|
|
|
|
extern const char *Txt_Another_user_s_profile;
|
2023-04-04 13:46:51 +02:00
|
|
|
|
const char *Title[Usr_NUM_ME_OR_OTHER] =
|
|
|
|
|
{
|
|
|
|
|
[Usr_ME ] = Txt_My_public_profile,
|
|
|
|
|
[Usr_OTHER] = Txt_Another_user_s_profile,
|
|
|
|
|
};
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Show user's name inside form to go to user's public profile *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/* Begin form */
|
2022-10-15 10:42:32 +02:00
|
|
|
|
Frm_BeginForm (ActSeeOthPubPrf);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Usr_PutParUsrCodEncrypted (UsrDat->EnUsrCod);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/* Author's name */
|
2023-04-04 13:46:51 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Title[Usr_ItsMe (UsrDat->UsrCod)],
|
2022-04-01 01:06:44 +02:00
|
|
|
|
"class=\"%s\"",Class);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
HTM_Txt (UsrDat->FullName);
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
|
|
|
|
|
/* End form */
|
2021-02-11 00:58:53 +01:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-22 17:59:59 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Get and write a note content ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_WriteContent (const struct TmlNot_Note *Not)
|
2021-02-22 17:59:59 +01:00
|
|
|
|
{
|
2022-05-30 19:03:56 +02:00
|
|
|
|
if (Not->Type == TmlNot_POST) // It's a post
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlPst_GetAndWritePost (Not->Cod);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
else // Not a post
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_GetAndWriteNoPost (Not);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-22 10:37:17 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Get and write a note which is not a post ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_GetAndWriteNoPost (const struct TmlNot_Note *Not)
|
2021-02-22 10:37:17 +01:00
|
|
|
|
{
|
2023-09-22 14:47:56 +02:00
|
|
|
|
struct Hie_Node Hie[Hie_NUM_LEVELS];
|
2021-02-22 10:37:17 +01:00
|
|
|
|
struct For_Forums Forums;
|
|
|
|
|
char ForumName[For_MAX_BYTES_FORUM_NAME + 1];
|
|
|
|
|
char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1];
|
|
|
|
|
|
2021-02-22 17:59:59 +01:00
|
|
|
|
/***** Reset forums *****/
|
2021-02-22 10:37:17 +01:00
|
|
|
|
For_ResetForums (&Forums);
|
|
|
|
|
|
2021-02-22 17:59:59 +01:00
|
|
|
|
/***** Get location in hierarchy *****/
|
2021-02-22 10:37:17 +01:00
|
|
|
|
if (!Not->Unavailable)
|
2023-09-19 10:28:52 +02:00
|
|
|
|
TmlNot_GetLocationInHierarchy (Not,Hie,&Forums.Forum,ForumName);
|
2021-02-22 10:37:17 +01:00
|
|
|
|
|
2021-02-22 17:59:59 +01:00
|
|
|
|
/***** Write note type *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_PutFormGoToAction (Not,&Forums);
|
2021-02-22 10:37:17 +01:00
|
|
|
|
|
2021-02-22 17:59:59 +01:00
|
|
|
|
/***** Write location in hierarchy *****/
|
2021-02-22 10:37:17 +01:00
|
|
|
|
if (!Not->Unavailable)
|
2023-09-19 10:28:52 +02:00
|
|
|
|
TmlNot_WriteLocationInHierarchy (Not,Hie,ForumName);
|
2021-02-22 10:37:17 +01:00
|
|
|
|
|
2021-02-22 17:59:59 +01:00
|
|
|
|
/***** Get and write note summary *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/* Get note summary */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_GetNoteSummary (Not,SummaryStr);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/* Write note summary */
|
2022-04-05 01:00:24 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_TXT Tml_TXT_%s\"",The_GetSuffix ());
|
2021-03-02 00:54:26 +01:00
|
|
|
|
HTM_Txt (SummaryStr);
|
2021-02-22 10:37:17 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-02-11 21:16:22 +01:00
|
|
|
|
/************************ Get location in hierarchy **************************/
|
2021-02-11 20:41:31 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_GetLocationInHierarchy (const struct TmlNot_Note *Not,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
struct Hie_Node Hie[Hie_NUM_LEVELS],
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct For_Forum *Forum,
|
|
|
|
|
char ForumName[For_MAX_BYTES_FORUM_NAME + 1])
|
2021-02-11 20:41:31 +01:00
|
|
|
|
{
|
2023-12-06 20:59:19 +01:00
|
|
|
|
extern bool (*Hie_GetDataByCod[Hie_NUM_LEVELS]) (struct Hie_Node *Node);
|
|
|
|
|
|
2021-02-22 10:37:17 +01:00
|
|
|
|
/***** Initialize location in hierarchy *****/
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Hie[Hie_CTY].HieCod =
|
|
|
|
|
Hie[Hie_INS].HieCod =
|
|
|
|
|
Hie[Hie_CTR].HieCod =
|
|
|
|
|
Hie[Hie_DEG].HieCod =
|
|
|
|
|
Hie[Hie_CRS].HieCod = -1L;
|
2021-02-22 10:37:17 +01:00
|
|
|
|
|
|
|
|
|
/***** Get location in hierarchy *****/
|
2021-11-10 00:39:09 +01:00
|
|
|
|
switch (Not->Type)
|
2021-02-11 20:41:31 +01:00
|
|
|
|
{
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_INS_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_INS_SHA_PUB_FILE:
|
2021-02-11 20:41:31 +01:00
|
|
|
|
/* Get institution data */
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Hie[Hie_INS].HieCod = Not->HieCod;
|
2023-12-06 20:59:19 +01:00
|
|
|
|
Hie_GetDataByCod[Hie_INS] (&Hie[Hie_INS]);
|
2021-02-11 20:41:31 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_CTR_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_CTR_SHA_PUB_FILE:
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Get center data */
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Hie[Hie_CTR].HieCod = Not->HieCod;
|
2023-12-06 20:59:19 +01:00
|
|
|
|
Hie_GetDataByCod[Hie_CTR] (&Hie[Hie_CTR]);
|
2021-02-11 20:41:31 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_DEG_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_DEG_SHA_PUB_FILE:
|
2021-02-11 20:41:31 +01:00
|
|
|
|
/* Get degree data */
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Hie[Hie_DEG].HieCod = Not->HieCod;
|
2023-12-06 20:59:19 +01:00
|
|
|
|
Hie_GetDataByCod[Hie_DEG] (&Hie[Hie_DEG]);
|
2021-02-11 20:41:31 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_CRS_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_CRS_SHA_PUB_FILE:
|
|
|
|
|
case TmlNot_CALL_FOR_EXAM:
|
|
|
|
|
case TmlNot_NOTICE:
|
2021-02-11 20:41:31 +01:00
|
|
|
|
/* Get course data */
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Hie[Hie_CRS].HieCod = Not->HieCod;
|
2023-12-06 20:59:19 +01:00
|
|
|
|
Hie_GetDataByCod[Hie_CRS] (&Hie[Hie_CRS]);
|
2021-02-11 20:41:31 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_FORUM_POST:
|
2021-02-11 20:41:31 +01:00
|
|
|
|
/* Get forum type of the post */
|
2023-04-06 12:39:13 +02:00
|
|
|
|
For_GetThreadForumTypeAndHieCodOfAPost (Not->Cod,Forum);
|
2021-03-02 12:40:24 +01:00
|
|
|
|
|
|
|
|
|
/* Set forum name in recipient's language */
|
|
|
|
|
For_SetForumName (Forum,ForumName,Gbl.Prefs.Language,false);
|
2021-02-11 20:41:31 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-02-11 21:16:22 +01:00
|
|
|
|
/*********************** Write location in hierarchy *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_WriteLocationInHierarchy (const struct TmlNot_Note *Not,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
struct Hie_Node Hie[Hie_NUM_LEVELS],
|
2021-12-31 14:51:44 +01:00
|
|
|
|
const char ForumName[For_MAX_BYTES_FORUM_NAME + 1])
|
2021-02-11 21:16:22 +01:00
|
|
|
|
{
|
2023-11-06 12:36:05 +01:00
|
|
|
|
extern const char *Txt_HIERARCHY_SINGUL_Abc[Hie_NUM_LEVELS];
|
2021-04-29 23:35:21 +02:00
|
|
|
|
extern const char *Txt_Forum;
|
2021-02-11 21:16:22 +01:00
|
|
|
|
|
2021-04-29 23:35:21 +02:00
|
|
|
|
/***** Begin container *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_LOC\"");
|
2021-04-29 23:35:21 +02:00
|
|
|
|
|
|
|
|
|
/***** Write location *****/
|
2021-11-10 00:39:09 +01:00
|
|
|
|
switch (Not->Type)
|
2021-04-29 23:35:21 +02:00
|
|
|
|
{
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_INS_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_INS_SHA_PUB_FILE:
|
2021-04-29 23:35:21 +02:00
|
|
|
|
/* Write location (institution) in hierarchy */
|
2024-01-26 10:26:19 +01:00
|
|
|
|
HTM_TxtF ("%s: %s",
|
2023-11-06 12:36:05 +01:00
|
|
|
|
Txt_HIERARCHY_SINGUL_Abc[Hie_INS],Hie[Hie_INS].ShrtName);
|
2021-04-29 23:35:21 +02:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_CTR_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_CTR_SHA_PUB_FILE:
|
2021-04-29 23:35:21 +02:00
|
|
|
|
/* Write location (center) in hierarchy */
|
2024-01-26 10:26:19 +01:00
|
|
|
|
HTM_TxtF ("%s: %s",
|
2023-11-06 12:36:05 +01:00
|
|
|
|
Txt_HIERARCHY_SINGUL_Abc[Hie_CTR],Hie[Hie_CTR].ShrtName);
|
2021-04-29 23:35:21 +02:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_DEG_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_DEG_SHA_PUB_FILE:
|
2021-04-29 23:35:21 +02:00
|
|
|
|
/* Write location (degree) in hierarchy */
|
2024-01-26 10:26:19 +01:00
|
|
|
|
HTM_TxtF ("%s: %s",
|
2023-11-06 12:36:05 +01:00
|
|
|
|
Txt_HIERARCHY_SINGUL_Abc[Hie_DEG],Hie[Hie_DEG].ShrtName);
|
2021-04-29 23:35:21 +02:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_CRS_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_CRS_SHA_PUB_FILE:
|
|
|
|
|
case TmlNot_CALL_FOR_EXAM:
|
|
|
|
|
case TmlNot_NOTICE:
|
2021-04-29 23:35:21 +02:00
|
|
|
|
/* Write location (course) in hierarchy */
|
2024-01-26 10:26:19 +01:00
|
|
|
|
HTM_TxtF ("%s: %s",
|
2023-11-06 12:36:05 +01:00
|
|
|
|
Txt_HIERARCHY_SINGUL_Abc[Hie_CRS],Hie[Hie_CRS].ShrtName);
|
2021-04-29 23:35:21 +02:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_FORUM_POST:
|
2021-04-29 23:35:21 +02:00
|
|
|
|
/* Write forum name */
|
2024-01-26 10:26:19 +01:00
|
|
|
|
HTM_TxtF ("%s: %s",Txt_Forum,ForumName);
|
2021-04-29 23:35:21 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** End container *****/
|
|
|
|
|
HTM_DIV_End ();
|
2021-02-11 21:16:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/************* Put form to go to an action depending on the note *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_PutFormGoToAction (const struct TmlNot_Note *Not,
|
|
|
|
|
const struct For_Forums *Forums)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
extern const Act_Action_t For_ActionsSeeFor[For_NUM_TYPES_FORUM];
|
2021-11-12 01:12:15 +01:00
|
|
|
|
extern const char *Txt_TIMELINE_NOTE[Tml_NOT_NUM_NOTE_TYPES];
|
2021-02-11 00:58:53 +01:00
|
|
|
|
extern const char *Txt_not_available;
|
|
|
|
|
char *Anchor = NULL;
|
2021-11-12 01:12:15 +01:00
|
|
|
|
static const Act_Action_t Tml_DefaultActions[Tml_NOT_NUM_NOTE_TYPES] =
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_UNKNOWN ] = ActUnk,
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Start tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_POST ] = ActUnk, // action not used
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Institution tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_INS_DOC_PUB_FILE ] = ActReqDatSeeDocIns,
|
|
|
|
|
[TmlNot_INS_SHA_PUB_FILE ] = ActReqDatShaIns,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Center tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_CTR_DOC_PUB_FILE ] = ActReqDatSeeDocCtr,
|
|
|
|
|
[TmlNot_CTR_SHA_PUB_FILE ] = ActReqDatShaCtr,
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Degree tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_DEG_DOC_PUB_FILE ] = ActReqDatSeeDocDeg,
|
|
|
|
|
[TmlNot_DEG_SHA_PUB_FILE ] = ActReqDatShaDeg,
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Course tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_CRS_DOC_PUB_FILE ] = ActReqDatSeeDocCrs,
|
|
|
|
|
[TmlNot_CRS_SHA_PUB_FILE ] = ActReqDatShaCrs,
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Assessment tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_CALL_FOR_EXAM ] = ActSeeOneCfe,
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Users tab */
|
|
|
|
|
/* Messages tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_NOTICE ] = ActSeeOneNot,
|
|
|
|
|
[TmlNot_FORUM_POST ] = ActSeeFor,
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Analytics tab */
|
|
|
|
|
/* Profile tab */
|
|
|
|
|
};
|
2021-11-12 01:12:15 +01:00
|
|
|
|
static const char *Tml_Icons[Tml_NOT_NUM_NOTE_TYPES] =
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_UNKNOWN ] = NULL,
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Start tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_POST ] = NULL, // icon not used
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Institution tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_INS_DOC_PUB_FILE ] = "file.svg",
|
|
|
|
|
[TmlNot_INS_SHA_PUB_FILE ] = "file.svg",
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Center tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_CTR_DOC_PUB_FILE ] = "file.svg",
|
|
|
|
|
[TmlNot_CTR_SHA_PUB_FILE ] = "file.svg",
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Degree tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_DEG_DOC_PUB_FILE ] = "file.svg",
|
|
|
|
|
[TmlNot_DEG_SHA_PUB_FILE ] = "file.svg",
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Course tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_CRS_DOC_PUB_FILE ] = "file.svg",
|
|
|
|
|
[TmlNot_CRS_SHA_PUB_FILE ] = "file.svg",
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Assessment tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_CALL_FOR_EXAM ] = "bullhorn.svg",
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Users tab */
|
|
|
|
|
/* Messages tab */
|
2022-05-30 19:03:56 +02:00
|
|
|
|
[TmlNot_NOTICE ] = "sticky-note.svg",
|
|
|
|
|
[TmlNot_FORUM_POST ] = "comments.svg",
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/* Analytics tab */
|
|
|
|
|
/* Profile tab */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (Not->Unavailable || // File/notice... pointed by this note is unavailable
|
2022-10-18 00:42:47 +02:00
|
|
|
|
Frm_CheckIfInside ()) // Inside another form
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Do not put form *****/
|
2021-03-02 12:40:24 +01:00
|
|
|
|
/* Begin container */
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_FORM_OFF\"");
|
2021-03-02 12:40:24 +01:00
|
|
|
|
|
|
|
|
|
/* Text ("not available") */
|
2021-11-10 00:39:09 +01:00
|
|
|
|
HTM_Txt (Txt_TIMELINE_NOTE[Not->Type]);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
if (Not->Unavailable)
|
|
|
|
|
HTM_TxtF (" (%s)",Txt_not_available);
|
2021-03-02 12:40:24 +01:00
|
|
|
|
|
|
|
|
|
/* End container */
|
2021-02-11 00:58:53 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
else // Not inside another form
|
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin container *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_FORM\"");
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin form with parameters depending on the type of note *****/
|
2021-11-10 00:39:09 +01:00
|
|
|
|
switch (Not->Type)
|
2021-03-02 00:54:26 +01:00
|
|
|
|
{
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_INS_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_INS_SHA_PUB_FILE:
|
2022-10-15 10:42:32 +02:00
|
|
|
|
Frm_BeginForm (Tml_DefaultActions[Not->Type]);
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Fil,Not->Cod);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
if (Not->HieCod != Gbl.Hierarchy.Node[Hie_INS].HieCod) // Not the current institution
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Ins,Not->HieCod); // Go to another institution
|
2021-03-02 00:54:26 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_CTR_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_CTR_SHA_PUB_FILE:
|
2022-10-15 10:42:32 +02:00
|
|
|
|
Frm_BeginForm (Tml_DefaultActions[Not->Type]);
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Fil,Not->Cod);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
if (Not->HieCod != Gbl.Hierarchy.Node[Hie_CTR].HieCod) // Not the current center
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Ctr,Not->HieCod); // Go to another center
|
2021-12-01 01:43:13 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_DEG_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_DEG_SHA_PUB_FILE:
|
2022-10-15 10:42:32 +02:00
|
|
|
|
Frm_BeginForm (Tml_DefaultActions[Not->Type]);
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Fil,Not->Cod);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
if (Not->HieCod != Gbl.Hierarchy.Node[Hie_DEG].HieCod) // Not the current degree
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Deg,Not->HieCod); // Go to another degree
|
2021-03-02 00:54:26 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_CRS_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_CRS_SHA_PUB_FILE:
|
2022-10-15 10:42:32 +02:00
|
|
|
|
Frm_BeginForm (Tml_DefaultActions[Not->Type]);
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Fil,Not->Cod);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
if (Not->HieCod != Gbl.Hierarchy.Node[Hie_CRS].HieCod) // Not the current course
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Crs,Not->HieCod); // Go to another course
|
2021-03-02 00:54:26 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_CALL_FOR_EXAM:
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_SetAnchorStr (Not->Cod,&Anchor);
|
2022-10-15 10:42:32 +02:00
|
|
|
|
Frm_BeginFormAnchor (Tml_DefaultActions[Not->Type],
|
|
|
|
|
Anchor); // Locate on this specific exam
|
2023-04-06 19:59:33 +02:00
|
|
|
|
Frm_FreeAnchorStr (&Anchor);
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Exa,Not->Cod);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
if (Not->HieCod != Gbl.Hierarchy.Node[Hie_CRS].HieCod) // Not the current course
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Crs,Not->HieCod); // Go to another course
|
2021-03-02 00:54:26 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_POST: // Not applicable
|
2021-03-02 00:54:26 +01:00
|
|
|
|
return;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_FORUM_POST:
|
2022-10-15 10:42:32 +02:00
|
|
|
|
Frm_BeginForm (For_ActionsSeeFor[Forums->Forum.Type]);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
For_PutAllParsForum (1, // Page of threads = first
|
|
|
|
|
1, // Page of posts = first
|
|
|
|
|
Forums->ForumSet,
|
|
|
|
|
Forums->ThreadsOrder,
|
2023-04-06 12:39:13 +02:00
|
|
|
|
Forums->Forum.HieCod,
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Forums->Thread.Selected,
|
|
|
|
|
-1L);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
if (Not->HieCod != Gbl.Hierarchy.Node[Hie_CRS].HieCod) // Not the current course
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Crs,Not->HieCod); // Go to another course
|
2021-03-02 00:54:26 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_NOTICE:
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_SetAnchorStr (Not->Cod,&Anchor);
|
2022-10-15 10:42:32 +02:00
|
|
|
|
Frm_BeginFormAnchor (Tml_DefaultActions[Not->Type],Anchor);
|
2023-04-06 19:59:33 +02:00
|
|
|
|
Frm_FreeAnchorStr (&Anchor);
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Not,Not->Cod);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
if (Not->HieCod != Gbl.Hierarchy.Node[Hie_CRS].HieCod) // Not the current course
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Crs,Not->HieCod); // Go to another course
|
2021-03-02 00:54:26 +01:00
|
|
|
|
break;
|
|
|
|
|
default: // Not applicable
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Icon and link to go to action *****/
|
|
|
|
|
/* Begin button */
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Txt_TIMELINE_NOTE[Not->Type],
|
2022-04-27 13:56:32 +02:00
|
|
|
|
"class=\"BT_LINK FORM_IN_%s ICO_HIGHLIGHT\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/* Icon and text */
|
2021-12-22 00:20:06 +01:00
|
|
|
|
Ico_PutIcon (Tml_Icons[Not->Type],Ico_BLACK,
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Txt_TIMELINE_NOTE[Not->Type],"CONTEXT_ICOx16");
|
2024-01-26 10:26:19 +01:00
|
|
|
|
HTM_NBSPTxt (Txt_TIMELINE_NOTE[Not->Type]);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/* End button */
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
|
|
|
|
|
/***** End container *****/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Get note summary and content *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlNot_GetNoteSummary (const struct TmlNot_Note *Not,
|
|
|
|
|
char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1])
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
SummaryStr[0] = '\0';
|
|
|
|
|
|
2021-11-10 00:39:09 +01:00
|
|
|
|
switch (Not->Type)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_UNKNOWN:
|
2021-02-11 00:58:53 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_INS_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_INS_SHA_PUB_FILE:
|
|
|
|
|
case TmlNot_CTR_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_CTR_SHA_PUB_FILE:
|
|
|
|
|
case TmlNot_DEG_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_DEG_SHA_PUB_FILE:
|
|
|
|
|
case TmlNot_CRS_DOC_PUB_FILE:
|
|
|
|
|
case TmlNot_CRS_SHA_PUB_FILE:
|
2023-11-05 19:44:03 +01:00
|
|
|
|
Brw_GetSummaryAndContentOfFile (SummaryStr,NULL,Not->Cod,
|
|
|
|
|
Ntf_DONT_GET_CONTENT);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_CALL_FOR_EXAM:
|
2023-11-05 19:44:03 +01:00
|
|
|
|
Cfe_GetSummaryAndContentCallForExam (SummaryStr,NULL,Not->Cod,
|
|
|
|
|
Ntf_DONT_GET_CONTENT);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_POST:
|
2021-02-11 00:58:53 +01:00
|
|
|
|
// Not applicable
|
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_FORUM_POST:
|
2023-11-05 19:44:03 +01:00
|
|
|
|
For_GetSummaryAndContentForumPst (SummaryStr,NULL,Not->Cod,
|
|
|
|
|
Ntf_DONT_GET_CONTENT);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
break;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
case TmlNot_NOTICE:
|
2023-11-05 19:44:03 +01:00
|
|
|
|
Not_GetSummaryAndContentNotice (SummaryStr,NULL,Not->Cod,
|
|
|
|
|
Ntf_DONT_GET_CONTENT);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-22 17:59:59 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Write bottom part of a note ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_WriteButtonsAndComms (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlNot_Note *Not,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
const struct Usr_Data *UsrDat) // Author
|
2021-02-22 17:59:59 +01:00
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
char IdNewComm[Frm_MAX_BYTES_ID + 1];
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Create unique id for new comment *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_SetUniqueId (IdNewComm);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Left: button to add a comment *****/
|
2022-06-30 11:53:24 +02:00
|
|
|
|
TmlNot_WriteButtonToAddAComm (Timeline,Not,IdNewComm);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/***** Right: write favs, shared and remove buttons, and comments *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_WriteFavShaRemAndComms (Timeline,Not,UsrDat);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Put hidden form to write a new comment *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_PutPhotoAndFormToWriteNewComm (Timeline,Not->NotCod,IdNewComm);
|
2021-02-22 17:59:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Write button to add a comment ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-06-30 11:53:24 +02:00
|
|
|
|
static void TmlNot_WriteButtonToAddAComm (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlNot_Note *Not,
|
2021-12-31 14:51:44 +01:00
|
|
|
|
const char IdNewComm[Frm_MAX_BYTES_ID + 1])
|
2021-02-22 17:59:59 +01:00
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin container *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_BOTTOM_LEFT\"");
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/***** Button to add a comment *****/
|
|
|
|
|
if (Not->Unavailable) // Unavailable notes can not be commented
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_PutIconCommDisabled ();
|
2021-03-02 00:54:26 +01:00
|
|
|
|
else
|
2022-06-30 11:53:24 +02:00
|
|
|
|
TmlCom_PutIconToToggleComm (Timeline,IdNewComm);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/***** End container *****/
|
2021-02-22 17:59:59 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-22 13:40:31 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/******* Write favs, shared and remove buttons, and comments of a note *******/
|
2021-02-22 13:40:31 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_WriteFavShaRemAndComms (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlNot_Note *Not,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
const struct Usr_Data *UsrDat) // Author
|
2021-02-22 13:40:31 +01:00
|
|
|
|
{
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/***** Begin container *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_BOTTOM_RIGHT Tml_RIGHT_WIDTH\"");
|
2021-02-22 13:40:31 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Write favs, shared and remove buttons int the foot of a note *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_WriteFavShaRem (Timeline,Not,UsrDat);
|
2021-02-22 13:40:31 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Comments *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_WriteCommsInNote (Timeline,Not);
|
2021-02-22 13:40:31 +01:00
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/***** End container *****/
|
2021-02-22 13:40:31 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/******* Write favs, shared and remove buttons in the foot of a note *********/
|
2021-02-22 13:40:31 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_WriteFavShaRem (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlNot_Note *Not,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
const struct Usr_Data *UsrDat) // Author
|
2021-02-22 13:40:31 +01:00
|
|
|
|
{
|
|
|
|
|
static unsigned NumDiv = 0; // Used to create unique div id for fav and shared
|
2022-10-21 12:11:50 +02:00
|
|
|
|
const char *UniqueNameEncrypted = Cry_GetUniqueNameEncrypted ();
|
2021-02-22 13:40:31 +01:00
|
|
|
|
|
|
|
|
|
NumDiv++;
|
|
|
|
|
|
|
|
|
|
/***** Begin foot container *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_FOOT Tml_RIGHT_WIDTH\"");
|
2021-02-22 13:40:31 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Foot column 1: fav zone *****/
|
|
|
|
|
HTM_DIV_Begin ("id=\"fav_not_%s_%u\""
|
2021-11-12 01:12:15 +01:00
|
|
|
|
" class=\"Tml_FAV_NOT Tml_FAV_NOT_WIDTH\"",
|
2022-10-21 12:11:50 +02:00
|
|
|
|
UniqueNameEncrypted,NumDiv);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlUsr_PutIconFavSha (TmlUsr_FAV_UNF_NOTE,
|
2022-06-30 11:53:24 +02:00
|
|
|
|
Not->NotCod,Not->UsrCod,Not->NumFavs,
|
|
|
|
|
TmlUsr_SHOW_FEW_USRS);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
HTM_DIV_End ();
|
2021-02-22 13:40:31 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Foot column 2: share zone *****/
|
|
|
|
|
HTM_DIV_Begin ("id=\"sha_not_%s_%u\""
|
2021-11-12 01:12:15 +01:00
|
|
|
|
" class=\"Tml_SHA_NOT Tml_SHA_NOT_WIDTH\"",
|
2022-10-21 12:11:50 +02:00
|
|
|
|
UniqueNameEncrypted,NumDiv);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlUsr_PutIconFavSha (TmlUsr_SHA_UNS_NOTE,
|
2022-06-30 11:53:24 +02:00
|
|
|
|
Not->NotCod,Not->UsrCod,Not->NumShared,
|
|
|
|
|
TmlUsr_SHOW_FEW_USRS);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
HTM_DIV_End ();
|
2021-02-22 13:40:31 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Foot column 3: icon to remove this note *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_REM\"");
|
2023-04-04 13:46:51 +02:00
|
|
|
|
if (Usr_ItsMe (UsrDat->UsrCod) == Usr_ME) // I am the author
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_PutFormToRemoveNote (Timeline,Not->NotCod);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
HTM_DIV_End ();
|
2021-02-22 13:40:31 +01:00
|
|
|
|
|
|
|
|
|
/***** End foot container *****/
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Form to remove note ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_PutFormToRemoveNote (const struct Tml_Timeline *Timeline,
|
2021-02-22 13:40:31 +01:00
|
|
|
|
long NotCod)
|
|
|
|
|
{
|
2022-06-28 18:11:31 +02:00
|
|
|
|
extern const Act_Action_t TmlFrm_ActionUsr[TmlFrm_NUM_ACTIONS];
|
|
|
|
|
extern const Act_Action_t TmlFrm_ActionGbl[TmlFrm_NUM_ACTIONS];
|
2021-02-22 13:40:31 +01:00
|
|
|
|
|
|
|
|
|
/***** Form to remove publication *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/* Begin form */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFrm_BeginForm (Timeline,TmlFrm_REQ_REM_NOTE);
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Not,NotCod);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/* Icon to remove */
|
2022-06-28 18:11:31 +02:00
|
|
|
|
Ico_PutIconLink ("trash.svg",Ico_RED,
|
2022-06-30 13:39:57 +02:00
|
|
|
|
Gbl.Usrs.Other.UsrDat.UsrCod > 0 ? TmlFrm_ActionUsr[TmlFrm_REQ_REM_NOTE] :
|
|
|
|
|
TmlFrm_ActionGbl[TmlFrm_REQ_REM_NOTE]);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/* End form */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFrm_EndForm ();
|
2021-02-22 13:40:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Store and publish a note into database ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlNot_StoreAndPublishNote (TmlNot_Type_t NoteType,long Cod)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct TmlPub_Publication Pub;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_StoreAndPublishNoteInternal (NoteType,Cod,&Pub);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlNot_StoreAndPublishNoteInternal (TmlNot_Type_t NoteType,long Cod,
|
|
|
|
|
struct TmlPub_Publication *Pub)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2023-10-05 00:12:48 +02:00
|
|
|
|
static Hie_Level_t Level[Tml_NOT_NUM_NOTE_TYPES] =
|
|
|
|
|
{
|
|
|
|
|
[TmlNot_INS_DOC_PUB_FILE] = Hie_INS,
|
|
|
|
|
[TmlNot_INS_SHA_PUB_FILE] = Hie_INS,
|
|
|
|
|
|
|
|
|
|
[TmlNot_CTR_DOC_PUB_FILE] = Hie_CTR,
|
|
|
|
|
[TmlNot_CTR_SHA_PUB_FILE] = Hie_CTR,
|
|
|
|
|
|
|
|
|
|
[TmlNot_DEG_DOC_PUB_FILE] = Hie_DEG,
|
|
|
|
|
[TmlNot_DEG_SHA_PUB_FILE] = Hie_DEG,
|
|
|
|
|
|
|
|
|
|
[TmlNot_CRS_DOC_PUB_FILE] = Hie_CRS,
|
|
|
|
|
[TmlNot_CRS_SHA_PUB_FILE] = Hie_CRS,
|
|
|
|
|
[TmlNot_CALL_FOR_EXAM ] = Hie_CRS,
|
|
|
|
|
[TmlNot_NOTICE ] = Hie_CRS,
|
|
|
|
|
};
|
2021-03-07 21:21:04 +01:00
|
|
|
|
long HieCod; // Hierarchy code (institution/center/degree/course)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2023-10-05 00:12:48 +02:00
|
|
|
|
if (Level[NoteType])
|
|
|
|
|
HieCod = Gbl.Hierarchy.Node[Level[NoteType]].HieCod;
|
|
|
|
|
else
|
|
|
|
|
HieCod = -1L;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Publish note in timeline *****/
|
|
|
|
|
Pub->PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Pub->NotCod = Tml_DB_CreateNewNote (NoteType,Cod,Pub->PublisherCod,HieCod);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Pub->Type = TmlPub_ORIGINAL_NOTE;
|
|
|
|
|
TmlPub_PublishPubInTimeline (Pub);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Mark notes of one file as unavailable ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlNot_MarkNoteOneFileAsUnavailable (const char *Path)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-09-15 02:14:42 +02:00
|
|
|
|
extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
|
|
|
|
|
Brw_FileBrowser_t FileBrowser = Brw_DB_FileBrowserForDB_files[Gbl.FileBrowser.Type];
|
2021-02-11 00:58:53 +01:00
|
|
|
|
long FilCod;
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
if (TmlNot_NoteType[FileBrowser])
|
2021-11-10 23:05:08 +01:00
|
|
|
|
/***** Get file code *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
if ((FilCod = Brw_DB_GetFilCodByPath (Path,
|
|
|
|
|
true)) > 0) // Only public files
|
2021-11-10 23:05:08 +01:00
|
|
|
|
/***** Mark possible note as unavailable *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Tml_DB_MarkNoteAsUnavailable (TmlNot_NoteType[FileBrowser],FilCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***** Mark possible notes involving children of a folder as unavailable *****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlNot_MarkNotesChildrenOfFolderAsUnavailable (const char *Path)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-09-15 02:14:42 +02:00
|
|
|
|
extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
|
|
|
|
|
Brw_FileBrowser_t FileBrowser = Brw_DB_FileBrowserForDB_files[Gbl.FileBrowser.Type];
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
if (TmlNot_NoteType[FileBrowser])
|
|
|
|
|
Tml_DB_MarkNotesChildrenOfFolderAsUnavailable (TmlNot_NoteType[FileBrowser],FileBrowser,
|
2021-11-10 23:05:08 +01:00
|
|
|
|
Brw_GetCodForFileBrowser (),
|
|
|
|
|
Path);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Request the removal of a note ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-17 12:51:11 +01:00
|
|
|
|
void TmlNot_ReqRemNoteUsr (void)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
struct Tml_Timeline Timeline;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Reset timeline context *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_ResetTimeline (&Timeline);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Get user whom profile is displayed *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Usr_GetParOtherUsrCodEncryptedAndGetUsrData ();
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Show user's profile *****/
|
2023-10-27 13:54:14 +02:00
|
|
|
|
Prf_ShowUsrProfile (&Gbl.Usrs.Other.UsrDat);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin section *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_SECTION_Begin (Tml_TIMELINE_SECTION_ID);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Request the removal of note *****/
|
2023-03-17 12:51:11 +01:00
|
|
|
|
TmlNot_ReqRemNote (&Timeline);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Write timeline again (user) *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_ShowTimelineUsr (&Timeline);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** End section *****/
|
|
|
|
|
HTM_SECTION_End ();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-17 12:51:11 +01:00
|
|
|
|
void TmlNot_ReqRemNoteGbl (void)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
struct Tml_Timeline Timeline;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Initialize timeline *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_InitTimelineGbl (&Timeline);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Request the removal of note *****/
|
2023-03-17 12:51:11 +01:00
|
|
|
|
TmlNot_ReqRemNote (&Timeline);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Write timeline again (global) *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_ShowNoteAndTimelineGbl (&Timeline);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-17 12:51:11 +01:00
|
|
|
|
static void TmlNot_ReqRemNote (struct Tml_Timeline *Timeline)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_following_post;
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct TmlNot_Note Not;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of note *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Not.NotCod = ParCod_GetAndCheckPar (ParCod_Not);
|
2023-03-23 09:35:20 +01:00
|
|
|
|
TmlNot_GetNoteDataByCod (&Not);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-03 21:53:43 +01:00
|
|
|
|
/***** Do some checks *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
if (!TmlUsr_CheckIfICanRemove (Not.NotCod,Not.UsrCod))
|
2021-03-01 22:31:56 +01:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/***** Show question and button to remove note *****/
|
|
|
|
|
/* Begin alert */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFrm_BeginAlertRemove (Txt_Do_you_really_want_to_remove_the_following_post);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/* Show note */
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (NULL,NULL,NULL,NULL,Box_CLOSABLE);
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_WIDTH\"");
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_CheckAndWriteNoteWithTopMsg (Timeline,&Not,
|
2023-11-05 19:44:03 +01:00
|
|
|
|
Tml_TOP_MESSAGE_NONE,
|
|
|
|
|
-1L);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
HTM_DIV_End ();
|
2021-03-01 22:31:56 +01:00
|
|
|
|
Box_BoxEnd ();
|
2024-02-28 00:12:48 +01:00
|
|
|
|
HTM_BR ();
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/* End alert */
|
|
|
|
|
Timeline->NotCod = Not.NotCod; // Note to be removed
|
2023-11-05 19:44:03 +01:00
|
|
|
|
TmlFrm_EndAlertRemove (Timeline,TmlFrm_REM_NOTE,TmlNot_PutParsRemoveNote);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Put parameters to remove a note ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void TmlNot_PutParsRemoveNote (void *Timeline)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
if (Timeline)
|
|
|
|
|
{
|
2021-02-22 09:25:29 +01:00
|
|
|
|
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) // User's timeline
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Usr_PutParOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
2021-02-22 09:25:29 +01:00
|
|
|
|
else // Global timeline
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Usr_PutParWho (((struct Tml_Timeline *) Timeline)->Who);
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Not,((struct Tml_Timeline *) Timeline)->NotCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Remove a note *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlNot_RemoveNoteUsr (void)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
struct Tml_Timeline Timeline;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Reset timeline context *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_ResetTimeline (&Timeline);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Get user whom profile is displayed *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Usr_GetParOtherUsrCodEncryptedAndGetUsrData ();
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Show user's profile *****/
|
2023-10-27 13:54:14 +02:00
|
|
|
|
Prf_ShowUsrProfile (&Gbl.Usrs.Other.UsrDat);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin section *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_SECTION_Begin (Tml_TIMELINE_SECTION_ID);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Remove a note *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_RemoveNote ();
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Write updated timeline after removing (user) *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_ShowTimelineUsr (&Timeline);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** End section *****/
|
|
|
|
|
HTM_SECTION_End ();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlNot_RemoveNoteGbl (void)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
struct Tml_Timeline Timeline;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Initialize timeline *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_InitTimelineGbl (&Timeline);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove a note *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_RemoveNote ();
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Write updated timeline after removing (global) *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_ShowNoteAndTimelineGbl (&Timeline);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_RemoveNote (void)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-03-02 20:36:20 +01:00
|
|
|
|
extern const char *Txt_The_post_no_longer_exists;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
extern const char *Txt_TIMELINE_Post_removed;
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct TmlNot_Note Not;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of note *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Not.NotCod = ParCod_GetAndCheckPar (ParCod_Not);
|
2023-03-23 09:35:20 +01:00
|
|
|
|
TmlNot_GetNoteDataByCod (&Not);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-01 22:31:56 +01:00
|
|
|
|
/***** Trivial check 1: note code should be > 0 *****/
|
|
|
|
|
if (Not.NotCod <= 0)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-03-02 20:36:20 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_The_post_no_longer_exists);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2023-04-04 13:46:51 +02:00
|
|
|
|
/***** Trivial check 2: Am I the author of this note? *****/
|
|
|
|
|
if (Usr_ItsMe (Not.UsrCod) == Usr_OTHER)
|
2021-03-01 22:31:56 +01:00
|
|
|
|
{
|
2021-09-25 11:43:52 +02:00
|
|
|
|
Err_NoPermission ();
|
2021-03-01 22:31:56 +01:00
|
|
|
|
return;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Delete note from database *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_RemoveNoteMediaAndDBEntries (&Not);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Reset note *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_ResetNote (&Not);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Message of success *****/
|
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_TIMELINE_Post_removed);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Remove a note from database *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_RemoveNoteMediaAndDBEntries (struct TmlNot_Note *Not)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
long PubCod;
|
2021-03-02 00:54:26 +01:00
|
|
|
|
unsigned long NumComms;
|
|
|
|
|
unsigned long NumComm;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
long MedCod;
|
|
|
|
|
|
|
|
|
|
/***** Remove comments associated to this note *****/
|
|
|
|
|
/* Get comments of this note */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
NumComms = Tml_DB_GetComms (Not->NotCod,&mysql_res);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/* For each comment... */
|
2021-03-02 00:54:26 +01:00
|
|
|
|
for (NumComm = 0;
|
|
|
|
|
NumComm < NumComms;
|
|
|
|
|
NumComm++)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get code of comment **/
|
2021-04-05 23:45:24 +02:00
|
|
|
|
PubCod = DB_GetNextCode (mysql_res);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/* Remove media associated to comment
|
|
|
|
|
and delete comment from database */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_RemoveCommMediaAndDBEntries (PubCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Remove media associated to post *****/
|
2022-05-30 19:03:56 +02:00
|
|
|
|
if (Not->Type == TmlNot_POST)
|
2021-03-04 17:47:08 +01:00
|
|
|
|
if ((MedCod = Tml_DB_GetMedCodFromPost (Not->Cod)) > 0)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
Med_RemoveMedia (MedCod);
|
|
|
|
|
|
|
|
|
|
/***** Mark possible notifications on the publications
|
|
|
|
|
of this note as removed *****/
|
2021-11-21 01:22:59 +01:00
|
|
|
|
if ((PubCod = Tml_DB_GetPubCodOfOriginalNote (Not->NotCod)) > 0)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-11-12 01:12:15 +01:00
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_TML_FAV ,PubCod);
|
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_TML_SHARE ,PubCod);
|
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_TML_MENTION,PubCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Remove favs for this note *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveNoteFavs (Not->NotCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-02-27 16:16:46 +01:00
|
|
|
|
/***** Remove all publications of this note *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveNotePubs (Not->NotCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove note *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveNote (Not->NotCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2022-05-30 19:03:56 +02:00
|
|
|
|
if (Not->Type == TmlNot_POST)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/***** Remove post *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemovePost (Not->Cod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Get data of note from row **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-22 11:34:06 +01:00
|
|
|
|
static void TmlNot_GetNoteDataFromRow (MYSQL_RES *mysql_res,
|
|
|
|
|
struct TmlNot_Note *Not)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2023-03-22 01:42:27 +01:00
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
2023-03-23 19:56:18 +01:00
|
|
|
|
/***** Get next row from result *****/
|
2023-03-22 01:42:27 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*
|
|
|
|
|
row[0]: NotCod
|
|
|
|
|
row[1]: NoteType
|
|
|
|
|
row[2]: Cod
|
|
|
|
|
row[3]: UsrCod
|
|
|
|
|
row[4]: HieCod
|
|
|
|
|
row[5]: Unavailable
|
2021-04-30 00:12:54 +02:00
|
|
|
|
row[6]: UNIX_TIMESTAMP(TimeNote)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
*/
|
|
|
|
|
/***** Get code (row[0]) *****/
|
|
|
|
|
Not->NotCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
|
|
|
|
/***** Get note type (row[1]) *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Not->Type = TmlNot_GetNoteTypeFromStr (row[1]);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-11-12 01:12:15 +01:00
|
|
|
|
/***** Get file/post... code (row[2]),
|
|
|
|
|
(from) user code (row[3])
|
|
|
|
|
and hierarchy code (row[4]) *****/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
Not->Cod = Str_ConvertStrCodToLongCod (row[2]);
|
|
|
|
|
Not->UsrCod = Str_ConvertStrCodToLongCod (row[3]);
|
|
|
|
|
Not->HieCod = Str_ConvertStrCodToLongCod (row[4]);
|
|
|
|
|
|
|
|
|
|
/***** File/post... unavailable (row[5]) *****/
|
|
|
|
|
Not->Unavailable = (row[5][0] == 'Y');
|
|
|
|
|
|
|
|
|
|
/***** Get time of the note (row[6]) *****/
|
|
|
|
|
Not->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[6]);
|
|
|
|
|
|
2021-11-12 01:12:15 +01:00
|
|
|
|
/***** Get number of times this note has been shared and favourited *****/
|
2021-04-30 00:12:54 +02:00
|
|
|
|
Not->NumShared = Tml_DB_GetNumSharers (Not->NotCod,Not->UsrCod);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Not->NumFavs = Tml_DB_GetNumFavers (TmlUsr_FAV_UNF_NOTE,
|
2021-04-30 00:12:54 +02:00
|
|
|
|
Not->NotCod,Not->UsrCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Get note type from string number coming from database *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static TmlNot_Type_t TmlNot_GetNoteTypeFromStr (const char *Str)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
unsigned UnsignedNum;
|
|
|
|
|
|
|
|
|
|
if (sscanf (Str,"%u",&UnsignedNum) == 1)
|
2021-11-12 01:12:15 +01:00
|
|
|
|
if (UnsignedNum < Tml_NOT_NUM_NOTE_TYPES)
|
2021-12-31 14:51:44 +01:00
|
|
|
|
return (TmlNot_Type_t) UnsignedNum;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2022-05-30 19:03:56 +02:00
|
|
|
|
return TmlNot_UNKNOWN;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Reset fields of note ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlNot_ResetNote (struct TmlNot_Note *Not)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
Not->NotCod = -1L;
|
2022-05-30 19:03:56 +02:00
|
|
|
|
Not->Type = TmlNot_UNKNOWN;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
Not->UsrCod = -1L;
|
|
|
|
|
Not->HieCod = -1L;
|
|
|
|
|
Not->Cod = -1L;
|
|
|
|
|
Not->Unavailable = false;
|
|
|
|
|
Not->DateTimeUTC = (time_t) 0;
|
|
|
|
|
Not->NumShared = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Get data of note using its code ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-23 09:35:20 +01:00
|
|
|
|
void TmlNot_GetNoteDataByCod (struct TmlNot_Note *Not)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
|
2021-03-01 22:31:56 +01:00
|
|
|
|
/***** Trivial check: note code should be > 0 *****/
|
|
|
|
|
if (Not->NotCod <= 0)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-11-18 01:29:48 +01:00
|
|
|
|
/* Reset fields of note */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_ResetNote (Not);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-01 22:31:56 +01:00
|
|
|
|
/***** Get data of note from database *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
if (Tml_DB_GetNoteDataByCod (Not->NotCod,&mysql_res))
|
2023-03-22 11:34:06 +01:00
|
|
|
|
TmlNot_GetNoteDataFromRow (mysql_res,Not);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
else
|
2021-11-18 01:29:48 +01:00
|
|
|
|
/* Reset fields of note */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_ResetNote (Not);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|