2021-02-11 00:58:53 +01:00
|
|
|
|
// swad_timeline_comment.c: social timeline comments
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2022-09-21 10:46:14 +02:00
|
|
|
|
Copyright (C) 1999-2022 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
|
2021-04-23 22:57:57 +02:00
|
|
|
|
#include <stdlib.h> // For free
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2021-02-11 00:58:53 +01:00
|
|
|
|
#include "swad_forum.h"
|
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_message.h"
|
2021-10-01 09:11:58 +02:00
|
|
|
|
#include "swad_notification_database.h"
|
2021-02-11 00:58:53 +01:00
|
|
|
|
#include "swad_photo.h"
|
|
|
|
|
#include "swad_profile.h"
|
|
|
|
|
#include "swad_timeline.h"
|
2021-02-26 22:20:03 +01:00
|
|
|
|
#include "swad_timeline_database.h"
|
2021-02-21 21:30:06 +01:00
|
|
|
|
#include "swad_timeline_form.h"
|
2021-02-11 00:58:53 +01:00
|
|
|
|
#include "swad_timeline_note.h"
|
2021-02-11 13:10:08 +01:00
|
|
|
|
#include "swad_timeline_publication.h"
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Private constants and types ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
#define TmlCom_NUM_VISIBLE_COMMENTS 3 // Maximum number of comments visible before expanding them
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
#define TmlCom_NUM_CONTRACT_EXPAND 2
|
2021-03-03 20:30:49 +01:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_CONTRACT = 0,
|
|
|
|
|
TmlCom_EXPAND = 1,
|
|
|
|
|
} TmlCom_ContractExpand_t;
|
2021-03-03 20:30:49 +01:00
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
static void TmlCom_ShowAuthorPhoto (struct Usr_Data *UsrDat);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_PutFormToWriteNewComm (const struct Tml_Timeline *Timeline,
|
|
|
|
|
long NotCod);
|
|
|
|
|
|
|
|
|
|
static unsigned TmlCom_WriteHiddenComms (struct Tml_Timeline *Timeline,
|
|
|
|
|
long NotCod,
|
|
|
|
|
char IdComms[Frm_MAX_BYTES_ID + 1],
|
|
|
|
|
unsigned NumInitialCommsToGet);
|
|
|
|
|
static void TmlCom_ListComms (const struct Tml_Timeline *Timeline,
|
|
|
|
|
unsigned NumComms,MYSQL_RES *mysql_res);
|
|
|
|
|
static void TmlCom_WriteOneCommInList (const struct Tml_Timeline *Timeline,
|
|
|
|
|
MYSQL_RES *mysql_res);
|
|
|
|
|
static void TmlCom_LinkToShowComms (TmlCom_ContractExpand_t ConExp,
|
|
|
|
|
const char IdComms[Frm_MAX_BYTES_ID + 1],
|
|
|
|
|
unsigned NumComms);
|
|
|
|
|
static void TmlCom_PutIconToToggleComms (const char *UniqueId,
|
|
|
|
|
const char *Icon,const char *Text);
|
|
|
|
|
static void TmlCom_CheckAndWriteComm (const struct Tml_Timeline *Timeline,
|
|
|
|
|
struct TmlCom_Comment *Com);
|
|
|
|
|
static void TmlCom_WriteComm (const struct Tml_Timeline *Timeline,
|
|
|
|
|
struct TmlCom_Comment *Com);
|
|
|
|
|
static void TmlCom_WriteAuthorTimeAndContent (struct TmlCom_Comment *Com,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
const struct Usr_Data *UsrDat);
|
|
|
|
|
static void TmlCom_WriteAuthorName (const struct Usr_Data *UsrDat);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_WriteContent (struct TmlCom_Comment *Com);
|
|
|
|
|
static void TmlCom_WriteButtons (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlCom_Comment *Com,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
const struct Usr_Data *UsrDat);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
|
|
|
|
|
static void TmlCom_PutFormToRemoveComm (const struct Tml_Timeline *Timeline,
|
|
|
|
|
long PubCod);
|
|
|
|
|
|
|
|
|
|
static long TmlCom_ReceiveComm (void);
|
|
|
|
|
|
|
|
|
|
static void TmlCom_RequestRemovalComm (struct Tml_Timeline *Timeline);
|
|
|
|
|
static void TmlCom_PutParamsRemoveComm (void *Timeline);
|
|
|
|
|
static void TmlCom_RemoveComm (void);
|
|
|
|
|
|
|
|
|
|
static void TmlCom_GetDataOfCommFromRow (MYSQL_ROW row,
|
|
|
|
|
struct TmlCom_Comment *Com);
|
|
|
|
|
|
|
|
|
|
static void TmlCom_ResetComm (struct TmlCom_Comment *Com);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Put an icon to toggle on/off the form to comment a note ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-06-30 11:53:24 +02:00
|
|
|
|
void TmlCom_PutIconToToggleComm (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const char UniqueId[Frm_MAX_BYTES_ID + 1])
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2022-06-30 11:53:24 +02:00
|
|
|
|
/***** Begin container *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("id=\"%s_ico\" class=\"Tml_ICO_COM_OFF\"",UniqueId);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/* Begin anchor */
|
|
|
|
|
HTM_A_Begin ("href=\"\" onclick=\"toggleNewComment ('%s');"
|
|
|
|
|
"return false;\"",
|
|
|
|
|
UniqueId);
|
|
|
|
|
|
|
|
|
|
/* Icon to toggle comment */
|
2021-12-22 00:20:06 +01:00
|
|
|
|
Ico_PutIcon ("comment-regular.svg",Ico_BLACK,
|
2022-06-30 11:53:24 +02:00
|
|
|
|
Act_GetActionText (Timeline->UsrOrGbl == TmlUsr_TIMELINE_GBL ? ActRcvComGblTL :
|
|
|
|
|
ActRcvComUsrTL),
|
|
|
|
|
"CONTEXT_ICO16x16");
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/* End anchor */
|
|
|
|
|
HTM_A_End ();
|
|
|
|
|
|
2022-06-30 11:53:24 +02:00
|
|
|
|
/***** End container *****/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Put an icon to toggle on/off the form to comment a note **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlCom_PutIconCommDisabled (void)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2022-06-30 11:53:24 +02:00
|
|
|
|
extern const char *Txt_not_available;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Disabled icon to comment a note *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/* Begin container */
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_ICO_COM_OFF Tml_ICO_DISABLED\"");
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/* Disabled icon */
|
2022-06-30 11:53:24 +02:00
|
|
|
|
Ico_PutIcon ("comment-regular.svg",Ico_BLACK,Txt_not_available,"ICO16x16");
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/* End container */
|
2021-02-11 00:58:53 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Form to comment a note ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlCom_PutPhotoAndFormToWriteNewComm (const struct Tml_Timeline *Timeline,
|
|
|
|
|
long NotCod,
|
|
|
|
|
const char IdNewComm[Frm_MAX_BYTES_ID + 1])
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Begin container *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("id=\"%s\" class=\"Tml_FORM_NEW_COM Tml_RIGHT_WIDTH\""
|
2021-02-11 00:58:53 +01:00
|
|
|
|
" style=\"display:none;\"",
|
2021-03-02 00:54:26 +01:00
|
|
|
|
IdNewComm);
|
|
|
|
|
|
|
|
|
|
/***** Left: write author's photo (my photo) *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_ShowAuthorPhoto (&Gbl.Usrs.Me.UsrDat);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Right: form to write the comment *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_PutFormToWriteNewComm (Timeline,NotCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 09:36:22 +01:00
|
|
|
|
/***** End container *****/
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 09:36:22 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Show photo of author of a comment *********************/
|
|
|
|
|
/*****************************************************************************/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
static void TmlCom_ShowAuthorPhoto (struct Usr_Data *UsrDat)
|
2021-03-02 09:36:22 +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 ] = "PHOTOC30x40",
|
|
|
|
|
[PhoSha_SHAPE_ELLIPSE ] = "PHOTOE30x40",
|
|
|
|
|
[PhoSha_SHAPE_OVAL ] = "PHOTOO30x40",
|
|
|
|
|
[PhoSha_SHAPE_RECTANGLE] = "PHOTOR30x40",
|
2021-12-01 01:43:13 +01:00
|
|
|
|
};
|
|
|
|
|
|
2021-03-02 09:36:22 +01:00
|
|
|
|
/***** Show author's photo *****/
|
|
|
|
|
/* Begin container */
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_COM_PHOTO\"");
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 09:36:22 +01:00
|
|
|
|
/* Author's photo */
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Pho_ShowUsrPhotoIfAllowed (UsrDat,
|
2021-12-02 08:39:18 +01:00
|
|
|
|
ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM,
|
2021-12-01 01:43:13 +01:00
|
|
|
|
true); // Use unique id
|
2021-03-02 09:36:22 +01:00
|
|
|
|
|
|
|
|
|
/* End container */
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-02 13:10:09 +01:00
|
|
|
|
/**************************** Form with textarea *****************************/
|
2021-03-02 09:36:22 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_PutFormToWriteNewComm (const struct Tml_Timeline *Timeline,
|
|
|
|
|
long NotCod)
|
2021-03-02 09:36:22 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_TIMELINE_comment;
|
2021-12-30 11:50:29 +01:00
|
|
|
|
char *ClassTextArea;
|
2021-03-02 09:36:22 +01:00
|
|
|
|
|
2021-03-02 13:10:09 +01:00
|
|
|
|
/***** Begin container *****/
|
2022-03-10 00:32:53 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_COM_CONT Tml_COM_WIDTH\"");
|
2021-03-02 09:36:22 +01:00
|
|
|
|
|
2021-03-02 13:10:09 +01:00
|
|
|
|
/***** Begin form to write the post *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFrm_BeginForm (Timeline,TmlFrm_RECEIVE_COMM);
|
|
|
|
|
TmlNot_PutHiddenParamNotCod (NotCod);
|
2021-03-02 09:36:22 +01:00
|
|
|
|
|
2021-03-02 13:10:09 +01:00
|
|
|
|
/***** Textarea and button *****/
|
2022-03-30 00:46:18 +02:00
|
|
|
|
if (asprintf (&ClassTextArea,"Tml_COM_TEXTAREA Tml_COM_WIDTH INPUT_%s",
|
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
|
|
|
|
TmlPst_PutTextarea (Txt_New_TIMELINE_comment,ClassTextArea);
|
2021-12-30 11:50:29 +01:00
|
|
|
|
free (ClassTextArea);
|
2021-03-02 09:36:22 +01:00
|
|
|
|
|
2021-03-02 13:10:09 +01:00
|
|
|
|
/***** End form *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFrm_EndForm ();
|
2021-03-02 09:36:22 +01:00
|
|
|
|
|
2021-03-02 13:10:09 +01:00
|
|
|
|
/***** End container *****/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Write comments in a note ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlCom_WriteCommsInNote (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlNot_Note *Not)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
2021-03-02 00:54:26 +01:00
|
|
|
|
unsigned NumComms;
|
|
|
|
|
unsigned NumInitialComms;
|
|
|
|
|
unsigned NumFinalCommsToGet;
|
2021-03-03 20:30:49 +01:00
|
|
|
|
unsigned NumFinalComms;
|
2021-03-02 00:54:26 +01:00
|
|
|
|
char IdComms[Frm_MAX_BYTES_ID + 1];
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-02-22 13:40:31 +01:00
|
|
|
|
/***** Get number of comments in note *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
NumComms = Tml_DB_GetNumCommsInNote (Not->NotCod);
|
2021-02-22 13:40:31 +01:00
|
|
|
|
|
|
|
|
|
/***** Trivial check: if no comments ==> nothing to do *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
if (!NumComms)
|
2021-02-22 13:40:31 +01:00
|
|
|
|
return;
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/***** Compute how many initial comments will be hidden
|
|
|
|
|
and how many final comments will be visible *****/
|
|
|
|
|
// Never hide only one comment
|
|
|
|
|
// So, the number of comments initially hidden must be 0 or >= 2
|
2021-12-31 14:51:44 +01:00
|
|
|
|
if (NumComms <= TmlCom_NUM_VISIBLE_COMMENTS + 1)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
NumInitialComms = 0;
|
|
|
|
|
NumFinalCommsToGet = NumComms;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
NumInitialComms = NumComms - TmlCom_NUM_VISIBLE_COMMENTS;
|
|
|
|
|
NumFinalCommsToGet = TmlCom_NUM_VISIBLE_COMMENTS;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-26 22:20:03 +01:00
|
|
|
|
/***** Get final comments of this note from database *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
NumFinalComms = Tml_DB_GetFinalComms (Not->NotCod,NumFinalCommsToGet,&mysql_res);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*
|
|
|
|
|
Before clicking "See prev..." --> After clicking "See prev..."
|
|
|
|
|
_________________________________ _________________________________
|
|
|
|
|
| div con_<id> | | div con_<id> |
|
|
|
|
|
| (hidden) | | (visible) |
|
|
|
|
|
| _____________________________ | | _____________________________ |
|
|
|
|
|
| | v See only the latest | | | | v See only the latest | |
|
2021-03-03 20:30:49 +01:00
|
|
|
|
| |_________(contract)__________| | | |_________(contract)__________| |
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|_________________________________| |_________________________________|
|
|
|
|
|
_________________________________ _________________________________
|
|
|
|
|
| div <id> | | div <id> updated |
|
|
|
|
|
| which content | | _____________________________ |
|
|
|
|
|
| will be updated via AJAX | | | ul com_<id> | |
|
|
|
|
|
| (parent of parent of form) | | | _________________________ | |
|
|
|
|
|
| | | | | li (comment 1) | | |
|
|
|
|
|
| | | | |_________________________| | |
|
|
|
|
|
| | | | | ... | | |
|
|
|
|
|
| | | | |_________________________| | |
|
|
|
|
|
| | | | | li (comment n) | | |
|
|
|
|
|
| | --> | | |_________________________| | |
|
|
|
|
|
| | | |_____________________________| |
|
|
|
|
|
| _____________________________ | | _____________________________ |
|
|
|
|
|
| | div exp_<id> | | | | div exp_<id> | |
|
2021-11-12 01:12:15 +01:00
|
|
|
|
| | (visible) | | | | (hidden) | |
|
|
|
|
|
| | _________________________ | | | | | |
|
2021-02-11 00:58:53 +01:00
|
|
|
|
| | | form | | | | | | |
|
|
|
|
|
| | | _____________________ | | | | | _____________________ | |
|
|
|
|
|
| | | | ^ See prev.comments | | | | | | | ^ See prev.comments | | |
|
2021-03-03 20:30:49 +01:00
|
|
|
|
| | | |_______(expand)______| | | | | | |_______(expand)______| | |
|
2021-02-11 00:58:53 +01:00
|
|
|
|
| | |_________________________| | | | | | |
|
|
|
|
|
| |_____________________________| | | |_____________________________| |
|
|
|
|
|
|_________________________________| |_________________________________|
|
|
|
|
|
_________________________________ _________________________________
|
2021-03-03 20:30:49 +01:00
|
|
|
|
| ul | | ul |
|
2021-02-11 00:58:53 +01:00
|
|
|
|
| _________________________ | | _________________________ |
|
2021-03-03 20:30:49 +01:00
|
|
|
|
| | li (comment n+1) | | | | li (comment n+1) | |
|
2021-02-11 00:58:53 +01:00
|
|
|
|
| |_________________________| | | |_________________________| |
|
|
|
|
|
| | ... | | | | ... | |
|
|
|
|
|
| |_________________________| | | |_________________________| |
|
2021-03-03 20:30:49 +01:00
|
|
|
|
| | li (comment m) | | | | li (comment m) | |
|
2021-02-11 00:58:53 +01:00
|
|
|
|
| |_________________________| | | |_________________________| |
|
|
|
|
|
|_________________________________| |_________________________________|
|
|
|
|
|
*/
|
|
|
|
|
/***** Link to show initial hidden comments *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
if (NumInitialComms)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Create unique id for list of hidden comments *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_SetUniqueId (IdComms);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Link (initially hidden) to show only the latest comments *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_LinkToShowComms (TmlCom_CONTRACT,IdComms,NumFinalComms);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-03 20:30:49 +01:00
|
|
|
|
/***** Div with form to show hidden coments,
|
|
|
|
|
which content will be updated via AJAX *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFrm_FormToShowHiddenComms (Not->NotCod,IdComms,NumInitialComms);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** List final visible comments *****/
|
2021-03-03 20:30:49 +01:00
|
|
|
|
if (NumFinalComms)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_UL_Begin ("class=\"Tml_LIST\""); // Never hidden, always visible
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_ListComms (Timeline,NumFinalComms,mysql_res);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
HTM_UL_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Write hidden comments via AJAX ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlCom_ShowHiddenCommsUsr (void)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get user whom profile is displayed *****/
|
|
|
|
|
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
|
|
|
|
|
|
|
|
|
/***** Show hidden comments *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_ShowHiddenCommsGbl ();
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlCom_ShowHiddenCommsGbl (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
|
|
|
|
long NotCod;
|
2021-03-02 00:54:26 +01:00
|
|
|
|
char IdComms[Frm_MAX_BYTES_ID + 1];
|
|
|
|
|
unsigned NumInitialCommsToGet;
|
|
|
|
|
unsigned NumInitialCommsGot;
|
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 parameters *****/
|
2021-03-02 10:36:00 +01:00
|
|
|
|
/* Get note code, identifier and number of comments to get */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
NotCod = TmlNot_GetParamNotCod ();
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Par_GetParToText ("IdComments",IdComms,Frm_MAX_BYTES_ID);
|
|
|
|
|
NumInitialCommsToGet = (unsigned) Par_GetParToLong ("NumHidCom");
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Write HTML inside DIV with hidden comments *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
NumInitialCommsGot =
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_WriteHiddenComms (&Timeline,NotCod,IdComms,NumInitialCommsToGet);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Link to show the first comments *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_LinkToShowComms (TmlCom_EXPAND,IdComms,NumInitialCommsGot);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Write hidden comments **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns the number of comments got
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static unsigned TmlCom_WriteHiddenComms (struct Tml_Timeline *Timeline,
|
|
|
|
|
long NotCod,
|
|
|
|
|
char IdComms[Frm_MAX_BYTES_ID + 1],
|
|
|
|
|
unsigned NumInitialCommsToGet)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
2021-03-02 00:54:26 +01:00
|
|
|
|
unsigned long NumInitialCommsGot;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Get comments of this note from database *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
NumInitialCommsGot = Tml_DB_GetInitialComms (NotCod,
|
2021-04-29 23:35:21 +02:00
|
|
|
|
NumInitialCommsToGet,
|
|
|
|
|
&mysql_res);
|
2021-02-26 22:34:11 +01:00
|
|
|
|
|
|
|
|
|
/***** List comments *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_UL_Begin ("id=\"com_%s\" class=\"Tml_LIST\"",IdComms);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_ListComms (Timeline,NumInitialCommsGot,mysql_res);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
HTM_UL_End ();
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
return NumInitialCommsGot;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 10:36:00 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Write comments in a note ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_ListComms (const struct Tml_Timeline *Timeline,
|
|
|
|
|
unsigned NumComms,MYSQL_RES *mysql_res)
|
2021-03-02 10:36:00 +01:00
|
|
|
|
{
|
|
|
|
|
unsigned NumCom;
|
|
|
|
|
|
|
|
|
|
/***** List comments one by one *****/
|
|
|
|
|
for (NumCom = 0;
|
|
|
|
|
NumCom < NumComms;
|
|
|
|
|
NumCom++)
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_WriteOneCommInList (Timeline,mysql_res);
|
2021-03-02 10:36:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Write a comment in list ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_WriteOneCommInList (const struct Tml_Timeline *Timeline,
|
|
|
|
|
MYSQL_RES *mysql_res)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_ROW row;
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct TmlCom_Comment Com;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Initialize image *****/
|
|
|
|
|
Med_MediaConstructor (&Com.Content.Media);
|
|
|
|
|
|
|
|
|
|
/***** Get data of comment *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_GetDataOfCommFromRow (row,&Com);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Write comment *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_LI_Begin ("class=\"Tml_COM\"");
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_CheckAndWriteComm (Timeline,&Com);
|
2021-02-22 19:16:28 +01:00
|
|
|
|
HTM_LI_End ();
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Free image *****/
|
|
|
|
|
Med_MediaDestructor (&Com.Content.Media);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-03 20:30:49 +01:00
|
|
|
|
/**** Link to "show only the latest comments" / "show the first comments" ****/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_LinkToShowComms (TmlCom_ContractExpand_t ConExp,
|
|
|
|
|
const char IdComms[Frm_MAX_BYTES_ID + 1],
|
|
|
|
|
unsigned NumComms)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-03-03 20:30:49 +01:00
|
|
|
|
extern const char *Txt_See_only_the_latest_X_COMMENTS;
|
|
|
|
|
extern const char *Txt_See_the_previous_X_COMMENTS;
|
2021-11-12 01:12:15 +01:00
|
|
|
|
static const struct
|
2021-03-03 20:30:49 +01:00
|
|
|
|
{
|
2021-11-12 01:12:15 +01:00
|
|
|
|
const char *Id;
|
|
|
|
|
const char *Icon;
|
|
|
|
|
const char **Text;
|
2021-12-31 14:51:44 +01:00
|
|
|
|
} Link[TmlCom_NUM_CONTRACT_EXPAND] =
|
2021-03-03 20:30:49 +01:00
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
[TmlCom_CONTRACT] =
|
2021-11-12 01:12:15 +01:00
|
|
|
|
{
|
|
|
|
|
.Id = "con",
|
|
|
|
|
.Icon = "angle-down.svg",
|
|
|
|
|
.Text = &Txt_See_only_the_latest_X_COMMENTS,
|
|
|
|
|
},
|
2021-12-31 14:51:44 +01:00
|
|
|
|
[TmlCom_EXPAND] =
|
2021-11-12 01:12:15 +01:00
|
|
|
|
{
|
|
|
|
|
.Id = "exp",
|
|
|
|
|
.Icon = "angle-up.svg",
|
|
|
|
|
.Text = &Txt_See_the_previous_X_COMMENTS,
|
|
|
|
|
},
|
2021-03-03 20:30:49 +01:00
|
|
|
|
};
|
2021-12-30 11:50:29 +01:00
|
|
|
|
char *Text;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-11-12 01:12:15 +01:00
|
|
|
|
/***** Link (icon and text) to show comments ****/
|
2021-03-03 20:30:49 +01:00
|
|
|
|
/* Begin container */
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("id=\"%s_%s\" class=\"Tml_EXPAND_COM Tml_RIGHT_WIDTH\""
|
2021-02-11 00:58:53 +01:00
|
|
|
|
" style=\"display:none;\"", // Hidden
|
2021-11-12 01:12:15 +01:00
|
|
|
|
Link[ConExp].Id,IdComms);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-03 20:30:49 +01:00
|
|
|
|
/* Icon and text */
|
2021-12-30 11:50:29 +01:00
|
|
|
|
if (asprintf (&Text,*Link[ConExp].Text,NumComms) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_PutIconToToggleComms (IdComms,Link[ConExp].Icon,Text);
|
2021-12-30 11:50:29 +01:00
|
|
|
|
free (Text);
|
2021-03-03 20:30:49 +01:00
|
|
|
|
|
|
|
|
|
/* End container */
|
2021-02-11 00:58:53 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Put an icon to toggle on/off comments in a publication ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_PutIconToToggleComms (const char *UniqueId,
|
|
|
|
|
const char *Icon,const char *Text)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Link to toggle on/off some divs *****/
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Begin (Text,
|
|
|
|
|
"class=\"BT_LINK FORM_IN_%s\""
|
|
|
|
|
" onclick=\"toggleComments('%s');return false;\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix (),UniqueId);
|
2021-12-22 00:20:06 +01:00
|
|
|
|
Ico_PutIconTextLink (Icon,Ico_BLACK,Text);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Check and write comment **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_CheckAndWriteComm (const struct Tml_Timeline *Timeline,
|
|
|
|
|
struct TmlCom_Comment *Com)
|
2021-02-23 00:07:52 +01:00
|
|
|
|
{
|
2021-11-12 01:12:15 +01:00
|
|
|
|
/*
|
|
|
|
|
___________________________________________
|
2021-02-23 00:07:52 +01:00
|
|
|
|
| _____ | | | \ \
|
|
|
|
|
|| | | Author's name | Date-time | | |
|
|
|
|
|
||Auth.| |______________________|___________| | |
|
|
|
|
|
||photo| | | | author's |
|
|
|
|
|
||_____| | | > name, time |
|
|
|
|
|
| | Comment | | and content > comment
|
|
|
|
|
| | content | | |
|
|
|
|
|
| | | | |
|
|
|
|
|
| |__________________________________| / |
|
|
|
|
|
| | | | \ |
|
|
|
|
|
| | Favs |Remove| > buttons |
|
|
|
|
|
|________|___________________________|______| / /
|
|
|
|
|
*/
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Trivial check: codes *****/
|
|
|
|
|
if (Com->PubCod <= 0 ||
|
|
|
|
|
Com->NotCod <= 0 ||
|
|
|
|
|
Com->UsrCod <= 0)
|
|
|
|
|
{
|
2021-02-23 00:07:52 +01:00
|
|
|
|
Ale_ShowAlert (Ale_ERROR,"Error in comment.");
|
2021-03-01 22:31:56 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Write comment *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_WriteComm (Timeline,Com);
|
2021-02-23 00:07:52 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************** Write comment ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_WriteComm (const struct Tml_Timeline *Timeline,
|
|
|
|
|
struct TmlCom_Comment *Com)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2022-09-24 18:30:26 +02:00
|
|
|
|
struct Usr_Data UsrDat; // Author of the comment
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/***** Get author's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
UsrDat.UsrCod = Com->UsrCod;
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,
|
|
|
|
|
Usr_DONT_GET_PREFS,
|
|
|
|
|
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/***** Left: author's photo *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_ShowAuthorPhoto (&UsrDat);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/***** Right: author's name, time, content, and buttons *****/
|
|
|
|
|
/* Begin container */
|
2022-03-10 00:32:53 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_COM_CONT Tml_COM_WIDTH\"");
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/* Right top: author's name, time, and content */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_WriteAuthorTimeAndContent (Com,&UsrDat);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/* Right bottom: buttons */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_WriteButtons (Timeline,Com,&UsrDat);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/* End container */
|
|
|
|
|
HTM_DIV_End ();
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
}
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**** Write top right part of a note: author's name, time and note content ***/
|
|
|
|
|
/*****************************************************************************/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_WriteAuthorTimeAndContent (struct TmlCom_Comment *Com,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
const struct Usr_Data *UsrDat) // Author
|
2021-02-23 00:07:52 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Write author's full name and nickname *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_WriteAuthorName (UsrDat);
|
2021-02-23 00:07:52 +01:00
|
|
|
|
|
|
|
|
|
/***** Write date and time *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_WriteDateTime (Com->DateTimeUTC);
|
2021-02-23 00:07:52 +01:00
|
|
|
|
|
|
|
|
|
/***** Write content of the comment *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_WriteContent (Com);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-02-23 00:07:52 +01:00
|
|
|
|
/*************** Write name of author of a comment to a note *****************/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
static void TmlCom_WriteAuthorName (const struct Usr_Data *UsrDat) // Author
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_My_public_profile;
|
|
|
|
|
extern const char *Txt_Another_user_s_profile;
|
|
|
|
|
|
|
|
|
|
/***** Show user's name inside form to go to user's public profile *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/* Begin form */
|
|
|
|
|
Frm_BeginFormUnique (ActSeeOthPubPrf);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/* Author's name */
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Usr_ItsMe (UsrDat->UsrCod) ? Txt_My_public_profile :
|
|
|
|
|
Txt_Another_user_s_profile,
|
|
|
|
|
"class=\"Tml_COM_AUTHOR Tml_COM_AUTHOR_WIDTH BT_LINK DAT_%s BOLD\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
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-23 00:07:52 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Write content of comment **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_WriteContent (struct TmlCom_Comment *Com)
|
2021-02-23 00:07:52 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Write content of the comment *****/
|
|
|
|
|
if (Com->Content.Txt[0])
|
|
|
|
|
{
|
2021-12-27 12:58:20 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_TXT Tml_TXT_%s\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-11-24 01:20:08 +01:00
|
|
|
|
Msg_WriteMsgContent (Com->Content.Txt,true,false);
|
2021-02-23 00:07:52 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Show image *****/
|
2022-03-10 00:32:53 +01:00
|
|
|
|
Med_ShowMedia (&Com->Content.Media,"Tml_COM_MED_CONT Tml_COM_WIDTH",
|
|
|
|
|
"Tml_COM_MED Tml_COM_WIDTH");
|
2021-02-23 00:07:52 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Write bottom part of a comment ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_WriteButtons (const struct Tml_Timeline *Timeline,
|
|
|
|
|
const struct TmlCom_Comment *Com,
|
2022-09-24 18:30:26 +02:00
|
|
|
|
const struct Usr_Data *UsrDat) // Author
|
2021-02-23 00:07:52 +01:00
|
|
|
|
{
|
|
|
|
|
static unsigned NumDiv = 0; // Used to create unique div id for fav
|
|
|
|
|
|
|
|
|
|
NumDiv++;
|
|
|
|
|
|
|
|
|
|
/***** Begin buttons container *****/
|
2022-03-10 00:32:53 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_FOOT Tml_COM_WIDTH\"");
|
2021-02-23 00:07:52 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Foot column 1: fav zone *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("id=\"fav_com_%s_%u\" class=\"Tml_FAV_COM Tml_FAV_WIDTH\"",
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Gbl.UniqueNameEncrypted,NumDiv);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlUsr_PutIconFavSha (TmlUsr_FAV_UNF_COMM,
|
2022-06-30 11:53:24 +02:00
|
|
|
|
Com->PubCod,Com->UsrCod,Com->NumFavs,
|
|
|
|
|
TmlUsr_SHOW_FEW_USRS);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
HTM_DIV_End ();
|
2021-02-23 00:07:52 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/***** Foot column 2: icon to remove this comment *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_REM\"");
|
2021-04-29 23:35:21 +02:00
|
|
|
|
if (Usr_ItsMe (UsrDat->UsrCod)) // I am the author
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_PutFormToRemoveComm (Timeline,Com->PubCod);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
HTM_DIV_End ();
|
2021-02-23 00:07:52 +01:00
|
|
|
|
|
|
|
|
|
/***** End buttons container *****/
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Form to remove comment ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_PutFormToRemoveComm (const struct Tml_Timeline *Timeline,
|
|
|
|
|
long PubCod)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
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-11 00:58:53 +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_COMM);
|
|
|
|
|
TmlPub_PutHiddenParamPubCod (PubCod);
|
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_COMM] :
|
|
|
|
|
TmlFrm_ActionGbl[TmlFrm_REQ_REM_COMM]);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
|
|
|
|
|
/* End form */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFrm_EndForm ();
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Comment a note ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlCom_ReceiveCommUsr (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
|
|
|
|
long NotCod;
|
|
|
|
|
|
|
|
|
|
/***** 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 *****/
|
|
|
|
|
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
|
|
|
|
|
|
|
|
|
/***** Show user's profile *****/
|
|
|
|
|
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
|
|
|
|
|
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
|
|
|
|
/***** Receive comment in a note
|
|
|
|
|
and write updated timeline after commenting (user) *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
NotCod = TmlCom_ReceiveComm ();
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_ShowTimelineUsrHighlighting (&Timeline,NotCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** End section *****/
|
|
|
|
|
HTM_SECTION_End ();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlCom_ReceiveCommGbl (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
|
|
|
|
long NotCod;
|
|
|
|
|
|
|
|
|
|
/***** Initialize timeline *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_InitTimelineGbl (&Timeline);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Receive comment in a note *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
NotCod = TmlCom_ReceiveComm ();
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Write updated timeline after commenting (global) *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_ShowTimelineGblHighlighting (&Timeline,NotCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static long TmlCom_ReceiveComm (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-12-31 14:51:44 +01:00
|
|
|
|
struct TmlPst_Content Content;
|
|
|
|
|
struct TmlNot_Note Not;
|
|
|
|
|
struct TmlPub_Publication Pub;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of note *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Not.NotCod = TmlNot_GetParamNotCod ();
|
|
|
|
|
TmlNot_GetDataOfNoteByCod (&Not);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-01 22:31:56 +01:00
|
|
|
|
/***** Trivial check: note code *****/
|
|
|
|
|
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 -1L;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get the content of the comment *****/
|
|
|
|
|
Par_GetParAndChangeFormat ("Txt",Content.Txt,Cns_MAX_BYTES_LONG_TEXT,
|
|
|
|
|
Str_TO_RIGOROUS_HTML,true);
|
|
|
|
|
|
|
|
|
|
/***** Initialize image *****/
|
|
|
|
|
Med_MediaConstructor (&Content.Media);
|
|
|
|
|
|
|
|
|
|
/***** Get attached image (action, file and title) *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Content.Media.Width = Tml_IMAGE_SAVED_MAX_WIDTH;
|
|
|
|
|
Content.Media.Height = Tml_IMAGE_SAVED_MAX_HEIGHT;
|
|
|
|
|
Content.Media.Quality = Tml_IMAGE_SAVED_QUALITY;
|
2021-03-01 22:31:56 +01:00
|
|
|
|
Med_GetMediaFromForm (-1L,-1L,-1,&Content.Media,NULL,NULL);
|
|
|
|
|
Ale_ShowAlerts (NULL);
|
|
|
|
|
|
|
|
|
|
if (Content.Txt[0] || // Text not empty
|
|
|
|
|
Content.Media.Status == Med_PROCESSED) // A media is attached
|
|
|
|
|
{
|
|
|
|
|
/***** Store media in filesystem and database *****/
|
|
|
|
|
Med_RemoveKeepOrStoreMedia (-1L,&Content.Media);
|
|
|
|
|
|
|
|
|
|
/***** Publish *****/
|
|
|
|
|
/* Insert into publications */
|
|
|
|
|
Pub.NotCod = Not.NotCod;
|
|
|
|
|
Pub.PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Pub.Type = TmlPub_COMMENT_TO_NOTE;
|
|
|
|
|
TmlPub_PublishPubInTimeline (&Pub); // Set Pub.PubCod
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/* Insert comment content in the database */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_InsertCommContent (Pub.PubCod,&Content);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Store notifications about the new comment *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_TML_COMMENT,Pub.PubCod);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Analyze content and store notifications about mentions *****/
|
|
|
|
|
Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (Pub.PubCod,Content.Txt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free image *****/
|
|
|
|
|
Med_MediaDestructor (&Content.Media);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
return Not.NotCod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Request the removal of a comment in a note *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlCom_RequestRemComUsr (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 *****/
|
|
|
|
|
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
|
|
|
|
|
|
|
|
|
/***** Show user's profile *****/
|
|
|
|
|
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
|
|
|
|
|
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 comment in note *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_RequestRemovalComm (&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 ();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlCom_RequestRemComGbl (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 comment in note *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_RequestRemovalComm (&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
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_RequestRemovalComm (struct Tml_Timeline *Timeline)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_following_comment;
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct TmlCom_Comment Com;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-01 22:31:56 +01:00
|
|
|
|
/***** Initialize media *****/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
Med_MediaConstructor (&Com.Content.Media);
|
|
|
|
|
|
|
|
|
|
/***** Get data of comment *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Com.PubCod = TmlPub_GetParamPubCod ();
|
|
|
|
|
TmlCom_GetDataOfCommByCod (&Com);
|
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 (Com.PubCod,Com.UsrCod))
|
2021-03-01 22:31:56 +01:00
|
|
|
|
{
|
|
|
|
|
Med_MediaDestructor (&Com.Content.Media);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Show question and button to remove comment *****/
|
|
|
|
|
/* Begin alert */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFrm_BeginAlertRemove (Txt_Do_you_really_want_to_remove_the_following_comment);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
2021-03-02 10:36:00 +01:00
|
|
|
|
/* Begin box for the comment */
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Box_BoxBegin (NULL,NULL,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
2021-03-02 10:36:00 +01:00
|
|
|
|
/* Indent the comment */
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_LEFT_PHOTO\"");
|
2021-03-02 00:54:26 +01:00
|
|
|
|
HTM_DIV_End ();
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
2021-03-02 10:36:00 +01:00
|
|
|
|
/* Show the comment */
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_RIGHT_CONT Tml_RIGHT_WIDTH\"");
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_CheckAndWriteComm (Timeline,&Com);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
HTM_DIV_End ();
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
2021-03-02 10:36:00 +01:00
|
|
|
|
/* End box */
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Box_BoxEnd ();
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/* End alert */
|
|
|
|
|
Timeline->PubCod = Com.PubCod; // Publication to be removed
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFrm_EndAlertRemove (Timeline,TmlFrm_REM_COMM,
|
|
|
|
|
TmlCom_PutParamsRemoveComm);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Free media *****/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
Med_MediaDestructor (&Com.Content.Media);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Put parameters to remove a comment *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_PutParamsRemoveComm (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
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
2021-02-22 09:25:29 +01:00
|
|
|
|
else // Global timeline
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Usr_PutHiddenParamWho (((struct Tml_Timeline *) Timeline)->Who);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlPub_PutHiddenParamPubCod (((struct Tml_Timeline *) Timeline)->PubCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Remove a comment ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlCom_RemoveComUsr (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 *****/
|
|
|
|
|
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
|
|
|
|
|
|
|
|
|
/***** Show user's profile *****/
|
|
|
|
|
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
|
|
|
|
|
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 comment *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_RemoveComm ();
|
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 TmlCom_RemoveComGbl (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 comment *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_RemoveComm ();
|
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 TmlCom_RemoveComm (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_Comment_removed;
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct TmlCom_Comment Com;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-01 22:31:56 +01:00
|
|
|
|
/***** Initialize media *****/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
Med_MediaConstructor (&Com.Content.Media);
|
|
|
|
|
|
|
|
|
|
/***** Get data of comment *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Com.PubCod = TmlPub_GetParamPubCod ();
|
|
|
|
|
TmlCom_GetDataOfCommByCod (&Com);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-03-01 22:31:56 +01:00
|
|
|
|
/***** Trivial check 1: publication code *****/
|
|
|
|
|
if (Com.PubCod <= 0)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-03-01 22:31:56 +01:00
|
|
|
|
Med_MediaDestructor (&Com.Content.Media);
|
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
|
|
|
|
|
2021-03-01 22:31:56 +01:00
|
|
|
|
/***** Trivial check 2: only if I am the author of this comment *****/
|
|
|
|
|
if (!Usr_ItsMe (Com.UsrCod))
|
|
|
|
|
{
|
|
|
|
|
Med_MediaDestructor (&Com.Content.Media);
|
2021-09-25 11:43:52 +02:00
|
|
|
|
Err_NoPermission ();
|
2021-03-01 22:31:56 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Remove media associated to comment
|
|
|
|
|
and delete comment from database *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_RemoveCommMediaAndDBEntries (Com.PubCod);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Free media *****/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
Med_MediaDestructor (&Com.Content.Media);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Reset fields of comment *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_ResetComm (&Com);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Message of success *****/
|
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Comment_removed);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Remove comment media and database entries *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlCom_RemoveCommMediaAndDBEntries (long PubCod)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Remove media associated to comment *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Med_RemoveMedia (Tml_DB_GetMedCodFromComm (PubCod));
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark possible notifications on this comment as removed *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_TML_COMMENT,PubCod);
|
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_TML_FAV ,PubCod);
|
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_TML_MENTION,PubCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove favs for this comment *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveCommFavs (PubCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove content of this comment *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveCommContent (PubCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-02-27 13:17:15 +01:00
|
|
|
|
/***** Remove this comment publication *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveCommPub (PubCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get data of comment using its code **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlCom_GetDataOfCommByCod (struct TmlCom_Comment *Com)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
2021-03-01 22:31:56 +01:00
|
|
|
|
/***** Trivial check: publication code should be > 0 *****/
|
|
|
|
|
if (Com->PubCod <= 0)
|
|
|
|
|
{
|
|
|
|
|
/***** Reset fields of comment *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_ResetComm (Com);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get data of comment from database *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
if (Tml_DB_GetDataOfCommByCod (Com->PubCod,&mysql_res))
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/* Get data of comment */
|
2021-03-01 22:31:56 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_GetDataOfCommFromRow (row,Com);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2021-03-02 00:54:26 +01:00
|
|
|
|
/* Reset fields of comment */
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlCom_ResetComm (Com);
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Get data of comment from row *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_GetDataOfCommFromRow (MYSQL_ROW row,
|
|
|
|
|
struct TmlCom_Comment *Com)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
row[0]: PubCod
|
2021-02-27 13:17:15 +01:00
|
|
|
|
row[1]: PublisherCod]
|
2021-02-11 00:58:53 +01:00
|
|
|
|
row[2]: NotCod
|
|
|
|
|
row[3]: TimePublish
|
|
|
|
|
row[4]: Txt
|
|
|
|
|
row[5]: MedCod
|
|
|
|
|
*/
|
2021-02-27 13:17:15 +01:00
|
|
|
|
/***** Get code of comment (row[0]), publisher code (row[1])
|
|
|
|
|
and note code (row[2) *****/
|
|
|
|
|
Com->PubCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
Com->UsrCod = Str_ConvertStrCodToLongCod (row[1]);
|
|
|
|
|
Com->NotCod = Str_ConvertStrCodToLongCod (row[2]);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
2021-02-27 13:17:15 +01:00
|
|
|
|
/***** Get date-time of the note (row[3]) *****/
|
2021-02-11 00:58:53 +01:00
|
|
|
|
Com->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[3]);
|
|
|
|
|
|
2021-02-27 13:17:15 +01:00
|
|
|
|
/***** Get text content (row[4]) and media content (row[5]) *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Com->Content.Txt,row[4],sizeof (Com->Content.Txt) - 1);
|
2021-02-27 13:17:15 +01:00
|
|
|
|
Com->Content.Media.MedCod = Str_ConvertStrCodToLongCod (row[5]);
|
|
|
|
|
Med_GetMediaDataByCod (&Com->Content.Media);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
|
|
|
|
|
/***** Get number of times this comment has been favourited *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Com->NumFavs = Tml_DB_GetNumFavers (TmlUsr_FAV_UNF_COMM,
|
2021-03-03 02:15:32 +01:00
|
|
|
|
Com->PubCod,Com->UsrCod);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Reset fields of comment **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlCom_ResetComm (struct TmlCom_Comment *Com)
|
2021-02-11 00:58:53 +01:00
|
|
|
|
{
|
2021-02-27 13:17:15 +01:00
|
|
|
|
Com->PubCod =
|
|
|
|
|
Com->UsrCod =
|
|
|
|
|
Com->NotCod = -1L;
|
|
|
|
|
Com->DateTimeUTC = (time_t) 0;
|
|
|
|
|
Com->Content.Txt[0] = '\0';
|
|
|
|
|
Com->NumFavs = 0;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
}
|