2021-02-08 16:24:58 +01:00
|
|
|
|
// swad_timeline_favourite.c: social timeline favourites
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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-08 16:24:58 +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 *********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "swad_database.h"
|
|
|
|
|
#include "swad_global.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-08 16:24:58 +01:00
|
|
|
|
#include "swad_timeline.h"
|
2021-02-27 16:30:41 +01:00
|
|
|
|
#include "swad_timeline_database.h"
|
2021-02-08 16:24:58 +01:00
|
|
|
|
#include "swad_timeline_favourite.h"
|
2021-02-11 17:45:16 +01:00
|
|
|
|
#include "swad_timeline_notification.h"
|
2021-02-11 13:10:08 +01:00
|
|
|
|
#include "swad_timeline_publication.h"
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlFav_FavNote (struct TmlNot_Note *Not);
|
|
|
|
|
static void TmlFav_UnfNote (struct TmlNot_Note *Not);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlFav_FavComm (struct TmlCom_Comment *Com);
|
|
|
|
|
static void TmlFav_UnfComm (struct TmlCom_Comment *Com);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-03 10:48:23 +01:00
|
|
|
|
/************************** Show all favers of a note ************************/
|
2021-02-08 16:24:58 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlFav_ShowAllFaversNoteUsr (void)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get user whom profile is displayed *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Usr_GetParOtherUsrCodEncryptedAndGetUsrData ();
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Show all favers *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFav_ShowAllFaversNoteGbl ();
|
2021-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlFav_ShowAllFaversNoteGbl (void)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct TmlNot_Note Not;
|
2021-02-08 16:24:58 +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-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Write HTML inside DIV with form to fav/unfav *****/
|
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_ALL_USRS);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-03 10:48:23 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Mark/unmark a note as favourite **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlFav_FavNoteUsr (void)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get user whom profile is displayed *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Usr_GetParOtherUsrCodEncryptedAndGetUsrData ();
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark note as favourite *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFav_FavNoteGbl ();
|
2021-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlFav_FavNoteGbl (void)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct TmlNot_Note Not;
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark note as favourite *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFav_FavNote (&Not);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Write HTML inside DIV with form to unfav *****/
|
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-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlFav_UnfNoteUsr (void)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get user whom profile is displayed *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Usr_GetParOtherUsrCodEncryptedAndGetUsrData ();
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Unfav a note previously marked as favourite *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFav_UnfNoteGbl ();
|
2021-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlFav_UnfNoteGbl (void)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct TmlNot_Note Not;
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Stop marking as favourite a previously favourited note *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFav_UnfNote (&Not);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Write HTML inside DIV with form to fav *****/
|
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-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlFav_FavNote (struct TmlNot_Note *Not)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
|
|
|
|
long OriginalPubCod;
|
|
|
|
|
|
2021-03-02 20:36:20 +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-03-02 20:36:20 +01:00
|
|
|
|
|
|
|
|
|
/***** Do some checks *****/
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (TmlUsr_CheckIfICanFavSha (Not->NotCod,Not->UsrCod) == Usr_CAN_NOT)
|
2021-03-01 22:31:56 +01:00
|
|
|
|
return;
|
|
|
|
|
|
2021-03-02 13:45:56 +01:00
|
|
|
|
/***** Trivial check: Have I faved this note? *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
if (TmlUsr_CheckIfFavedSharedByUsr (TmlUsr_FAV_UNF_NOTE,Not->NotCod,
|
2021-04-29 23:35:21 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod))
|
2021-03-01 22:31:56 +01:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/***** Mark note as favourite in database *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Tml_DB_MarkAsFav (TmlUsr_FAV_UNF_NOTE,Not->NotCod);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Update number of times this note is favourited *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Not->NumFavs = Tml_DB_GetNumFavers (TmlUsr_FAV_UNF_NOTE,
|
2021-04-29 23:35:21 +02:00
|
|
|
|
Not->NotCod,Not->UsrCod);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Create notification about favourite post
|
|
|
|
|
for the author of the post *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
if ((OriginalPubCod = Tml_DB_GetPubCodOfOriginalNote (Not->NotCod)) > 0)
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNtf_CreateNotifToAuthor (Not->UsrCod,OriginalPubCod,Ntf_EVENT_TML_FAV);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlFav_UnfNote (struct TmlNot_Note *Not)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
|
|
|
|
long OriginalPubCod;
|
|
|
|
|
|
2021-03-02 20:36:20 +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-03-02 20:36:20 +01:00
|
|
|
|
|
|
|
|
|
/***** Do some checks *****/
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (TmlUsr_CheckIfICanFavSha (Not->NotCod,Not->UsrCod) == Usr_CAN_NOT)
|
2021-03-01 22:31:56 +01:00
|
|
|
|
return;
|
|
|
|
|
|
2021-03-02 13:45:56 +01:00
|
|
|
|
/***** Trivial check: Have I faved this note? *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
if (!TmlUsr_CheckIfFavedSharedByUsr (TmlUsr_FAV_UNF_NOTE,Not->NotCod,
|
2021-04-29 23:35:21 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod))
|
2021-03-01 22:31:56 +01:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/***** Delete the mark as favourite from database *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Tml_DB_UnmarkAsFav (TmlUsr_FAV_UNF_NOTE,Not->NotCod);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Update number of times this note is favourited *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Not->NumFavs = Tml_DB_GetNumFavers (TmlUsr_FAV_UNF_NOTE,
|
2021-04-29 23:35:21 +02:00
|
|
|
|
Not->NotCod,Not->UsrCod);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark possible notifications on this note as removed *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
if ((OriginalPubCod = Tml_DB_GetPubCodOfOriginalNote (Not->NotCod)) > 0)
|
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_TML_FAV,OriginalPubCod);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-03 10:48:23 +01:00
|
|
|
|
/************************** Show all favers of a note ************************/
|
2021-02-08 16:24:58 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlFav_ShowAllFaversComUsr (void)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get user whom profile is displayed *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Usr_GetParOtherUsrCodEncryptedAndGetUsrData ();
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Show all favers *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFav_ShowAllFaversComGbl ();
|
2021-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlFav_ShowAllFaversComGbl (void)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct TmlCom_Comment Com;
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of comment *****/
|
2021-02-10 19:53:57 +01:00
|
|
|
|
Med_MediaConstructor (&Com.Content.Media);
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Com.PubCod = ParCod_GetAndCheckPar (ParCod_Pub);
|
2023-03-23 09:35:20 +01:00
|
|
|
|
TmlCom_GetCommDataByCod (&Com);
|
2021-02-10 19:53:57 +01:00
|
|
|
|
Med_MediaDestructor (&Com.Content.Media);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Write HTML inside DIV with form to fav/unfav *****/
|
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_ALL_USRS);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-03 10:48:23 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Mark/unmark a comment as favourite ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlFav_FavCommUsr (void)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get user whom profile is displayed *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Usr_GetParOtherUsrCodEncryptedAndGetUsrData ();
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark comment as favourite *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFav_FavCommGbl ();
|
2021-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlFav_FavCommGbl (void)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct TmlCom_Comment Com;
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark comment as favourite *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFav_FavComm (&Com);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Write HTML inside DIV with form to unfav *****/
|
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-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlFav_UnfCommUsr (void)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get user whom profile is displayed *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Usr_GetParOtherUsrCodEncryptedAndGetUsrData ();
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Unfav a comment previously marked as favourite *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFav_UnfCommGbl ();
|
2021-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void TmlFav_UnfCommGbl (void)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
struct TmlCom_Comment Com;
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Stop marking as favourite a previously favourited comment *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlFav_UnfComm (&Com);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Write HTML inside DIV with form to fav *****/
|
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-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlFav_FavComm (struct TmlCom_Comment *Com)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Initialize image *****/
|
2021-02-10 19:53:57 +01:00
|
|
|
|
Med_MediaConstructor (&Com->Content.Media);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
2021-03-02 20:36:20 +01:00
|
|
|
|
/***** Get data of comment *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Com->PubCod = ParCod_GetAndCheckPar (ParCod_Pub);
|
2023-03-23 09:35:20 +01:00
|
|
|
|
TmlCom_GetCommDataByCod (Com);
|
2021-03-02 20:36:20 +01:00
|
|
|
|
|
|
|
|
|
/***** Do some checks *****/
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (TmlUsr_CheckIfICanFavSha (Com->PubCod,Com->UsrCod) == Usr_CAN_NOT)
|
2021-03-01 22:31:56 +01:00
|
|
|
|
{
|
|
|
|
|
Med_MediaDestructor (&Com->Content.Media);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 13:52:11 +01:00
|
|
|
|
/***** Trivial check: Have I faved this comment? *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
if (TmlUsr_CheckIfFavedSharedByUsr (TmlUsr_FAV_UNF_COMM,Com->PubCod,
|
2021-04-29 23:35:21 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod))
|
2021-03-01 22:31:56 +01:00
|
|
|
|
{
|
|
|
|
|
Med_MediaDestructor (&Com->Content.Media);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Mark comment as favourite in database *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Tml_DB_MarkAsFav (TmlUsr_FAV_UNF_COMM,Com->PubCod);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
2021-03-01 22:31:56 +01:00
|
|
|
|
/***** Update number of times this comment is favourited *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Com->NumFavs = Tml_DB_GetNumFavers (TmlUsr_FAV_UNF_COMM,
|
2021-04-29 23:35:21 +02:00
|
|
|
|
Com->PubCod,Com->UsrCod);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
2021-03-01 22:31:56 +01:00
|
|
|
|
/***** Create notification about favourite post
|
|
|
|
|
for the author of the post *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNtf_CreateNotifToAuthor (Com->UsrCod,Com->PubCod,Ntf_EVENT_TML_FAV);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Free image *****/
|
2021-02-10 19:53:57 +01:00
|
|
|
|
Med_MediaDestructor (&Com->Content.Media);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static void TmlFav_UnfComm (struct TmlCom_Comment *Com)
|
2021-02-08 16:24:58 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Initialize image *****/
|
2021-02-10 19:53:57 +01:00
|
|
|
|
Med_MediaConstructor (&Com->Content.Media);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
2021-03-02 20:36:20 +01:00
|
|
|
|
/***** Get data of comment *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Com->PubCod = ParCod_GetAndCheckPar (ParCod_Pub);
|
2023-03-23 09:35:20 +01:00
|
|
|
|
TmlCom_GetCommDataByCod (Com);
|
2021-03-02 20:36:20 +01:00
|
|
|
|
|
|
|
|
|
/***** Do some checks *****/
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (TmlUsr_CheckIfICanFavSha (Com->PubCod,Com->UsrCod) == Usr_CAN_NOT)
|
2021-03-01 22:31:56 +01:00
|
|
|
|
{
|
|
|
|
|
Med_MediaDestructor (&Com->Content.Media);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-03 02:15:32 +01:00
|
|
|
|
/***** Trivial check: Have I faved this comment? *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
if (!TmlUsr_CheckIfFavedSharedByUsr (TmlUsr_FAV_UNF_COMM,Com->PubCod,
|
2023-03-09 00:23:54 +01:00
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod))
|
2021-03-01 22:31:56 +01:00
|
|
|
|
{
|
|
|
|
|
Med_MediaDestructor (&Com->Content.Media);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Delete the mark as favourite from database *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Tml_DB_UnmarkAsFav (TmlUsr_FAV_UNF_COMM,Com->PubCod);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Update number of times this comment is favourited *****/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Com->NumFavs = Tml_DB_GetNumFavers (TmlUsr_FAV_UNF_COMM,
|
2021-04-29 23:35:21 +02:00
|
|
|
|
Com->PubCod,Com->UsrCod);
|
2021-03-01 22:31:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark possible notifications on this comment as removed *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_TML_FAV,Com->PubCod);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Free image *****/
|
2021-02-10 19:53:57 +01:00
|
|
|
|
Med_MediaDestructor (&Com->Content.Media);
|
2021-02-08 16:24:58 +01:00
|
|
|
|
}
|