2021-02-11 17:20:38 +01:00
|
|
|
|
// swad_timeline_user.c: social timeline users
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
|
|
|
|
Copyright (C) 1999-2021 Antonio Ca<EFBFBD>as Vargas
|
|
|
|
|
|
|
|
|
|
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-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2021-02-11 17:20:38 +01:00
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_photo.h"
|
|
|
|
|
#include "swad_timeline.h"
|
2021-03-01 13:52:24 +01:00
|
|
|
|
#include "swad_timeline_database.h"
|
|
|
|
|
#include "swad_timeline_favourite.h"
|
2021-03-03 02:15:32 +01:00
|
|
|
|
#include "swad_timeline_form.h"
|
2021-03-03 09:40:01 +01:00
|
|
|
|
#include "swad_timeline_share.h"
|
2021-02-11 17:20:38 +01:00
|
|
|
|
#include "swad_timeline_user.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Public constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Private constants and types ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Private global variables **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
static void Tml_Usr_GetAndShowSharersOrFavers (Tml_Usr_FavSha_t FavSha,
|
|
|
|
|
long Cod,long UsrCod,unsigned NumUsrs,
|
|
|
|
|
Tml_Usr_HowManyUsrs_t HowManyUsrs);
|
|
|
|
|
static void Tml_Usr_ShowNumSharersOrFavers (unsigned NumUsrs);
|
|
|
|
|
static void Tml_Usr_ListSharersOrFavers (MYSQL_RES **mysql_res,
|
|
|
|
|
unsigned NumUsrs,unsigned NumFirstUsrs);
|
|
|
|
|
static unsigned Tml_Usr_GetListFaversOrSharers (Tml_Usr_FavSha_t FavSha,
|
|
|
|
|
long Cod,long UsrCod,unsigned MaxUsrs,
|
|
|
|
|
MYSQL_RES **mysql_res);
|
|
|
|
|
|
|
|
|
|
static void Tml_Usr_PutDisabledIconFavSha (Tml_Usr_FavSha_t FavSha,
|
|
|
|
|
unsigned NumUsrs);
|
2021-03-03 10:48:23 +01:00
|
|
|
|
|
2021-02-11 17:20:38 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Remove all the content of a user from database ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
void Tml_Usr_RemoveUsrContent (long UsrCod)
|
2021-02-11 17:20:38 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Remove favs for comments *****/
|
2021-03-01 14:46:57 +01:00
|
|
|
|
/* Remove all favs made by this user to any comment */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveAllFavsMadeByUsr (Tml_Usr_FAV_UNF_COMM,UsrCod);
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
2021-03-01 14:46:57 +01:00
|
|
|
|
/* Remove all favs to comments of this user */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveAllFavsToPubsBy (Tml_Usr_FAV_UNF_COMM,UsrCod);
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
2021-03-01 14:46:57 +01:00
|
|
|
|
/* Remove all favs to all comments in all notes authored by this user */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveAllFavsToAllCommsInAllNotesBy (UsrCod);
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove favs for notes *****/
|
2021-03-01 15:23:18 +01:00
|
|
|
|
/* Remove all favs made by this user to any note */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveAllFavsMadeByUsr (Tml_Usr_FAV_UNF_NOTE,UsrCod);
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
2021-03-01 14:46:57 +01:00
|
|
|
|
/* Remove all favs to notes of this user */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveAllFavsToPubsBy (Tml_Usr_FAV_UNF_NOTE,UsrCod);
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove comments *****/
|
2021-03-01 15:23:18 +01:00
|
|
|
|
/* Remove all comments in all the notes of this user */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveAllCommsInAllNotesOf (UsrCod);
|
2021-03-01 15:23:18 +01:00
|
|
|
|
|
|
|
|
|
/* Remove all comments made by this user in any note */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveAllCommsMadeBy (UsrCod);
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
2021-03-01 14:12:18 +01:00
|
|
|
|
/***** Remove posts *****/
|
|
|
|
|
/* Remove all posts of the user */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveAllPostsUsr (UsrCod);
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
2021-03-01 14:12:18 +01:00
|
|
|
|
/***** Remove publications *****/
|
2021-03-01 15:23:18 +01:00
|
|
|
|
/* Remove all publications (original, shared notes, comments)
|
|
|
|
|
published by any user
|
|
|
|
|
and related to notes authored by the user */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveAllPubsPublishedByAnyUsrOfNotesAuthoredBy (UsrCod);
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
2021-03-01 14:46:57 +01:00
|
|
|
|
/* Remove all publications published by the user */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveAllPubsPublishedBy (UsrCod);
|
2021-02-11 17:20:38 +01:00
|
|
|
|
|
2021-03-01 14:12:18 +01:00
|
|
|
|
/***** Remove notes *****/
|
|
|
|
|
/* Remove all notes of the user */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_DB_RemoveAllNotesUsr (UsrCod);
|
2021-02-11 17:20:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-03 02:15:32 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Show users who have faved/shared a note/comment **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
static void Tml_Usr_GetAndShowSharersOrFavers (Tml_Usr_FavSha_t FavSha,
|
|
|
|
|
long Cod,long UsrCod,unsigned NumUsrs,
|
|
|
|
|
Tml_Usr_HowManyUsrs_t HowManyUsrs)
|
2021-03-03 02:15:32 +01:00
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
static const Tml_Frm_Action_t Action[Tml_Usr_NUM_FAV_SHA] =
|
2021-03-03 02:15:32 +01:00
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
[Tml_Usr_FAV_UNF_NOTE] = Tml_Frm_ALL_FAV_NOTE,
|
|
|
|
|
[Tml_Usr_FAV_UNF_COMM] = Tml_Frm_ALL_FAV_COMM,
|
|
|
|
|
[Tml_Usr_SHA_UNS_NOTE] = Tml_Frm_ALL_SHA_NOTE,
|
2021-03-03 02:15:32 +01:00
|
|
|
|
};
|
2021-03-04 17:47:08 +01:00
|
|
|
|
static const char *ParamFormat[Tml_Usr_NUM_FAV_SHA] =
|
2021-03-03 02:15:32 +01:00
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
[Tml_Usr_FAV_UNF_NOTE] = "NotCod=%ld",
|
|
|
|
|
[Tml_Usr_FAV_UNF_COMM] = "PubCod=%ld",
|
|
|
|
|
[Tml_Usr_SHA_UNS_NOTE] = "NotCod=%ld",
|
2021-03-03 02:15:32 +01:00
|
|
|
|
};
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumFirstUsrs;
|
|
|
|
|
|
|
|
|
|
/***** Get users who have faved/shared *****/
|
|
|
|
|
if (NumUsrs)
|
|
|
|
|
NumFirstUsrs =
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_Usr_GetListFaversOrSharers (FavSha,Cod,UsrCod,
|
2021-04-05 23:45:24 +02:00
|
|
|
|
HowManyUsrs == Tml_Usr_SHOW_FEW_USRS ? Tml_Usr_DEF_USRS_SHOWN :
|
|
|
|
|
Tml_Usr_MAX_USRS_SHOWN,
|
|
|
|
|
&mysql_res);
|
2021-03-03 02:15:32 +01:00
|
|
|
|
else
|
|
|
|
|
NumFirstUsrs = 0;
|
|
|
|
|
|
|
|
|
|
/***** Show users *****/
|
|
|
|
|
/* Number of users */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"Tml_NUM_USRS\"");
|
|
|
|
|
Tml_Usr_ShowNumSharersOrFavers (NumUsrs);
|
2021-03-03 02:15:32 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
|
|
|
|
|
/* List users one by one */
|
|
|
|
|
HTM_DIV_Begin ("class=\"TL_USRS\"");
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_Usr_ListSharersOrFavers (&mysql_res,NumUsrs,NumFirstUsrs);
|
2021-03-03 02:15:32 +01:00
|
|
|
|
if (NumFirstUsrs < NumUsrs) // Not all are shown
|
|
|
|
|
/* Clickable ellipsis to show all users */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_Frm_PutFormToSeeAllFaversSharers (Action[FavSha],
|
2021-04-05 23:45:24 +02:00
|
|
|
|
ParamFormat[FavSha],Cod,
|
|
|
|
|
HowManyUsrs);
|
2021-03-03 02:15:32 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
if (NumUsrs)
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 17:20:38 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Show sharers or favouriters ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
static void Tml_Usr_ShowNumSharersOrFavers (unsigned NumUsrs)
|
2021-02-11 17:20:38 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Show number of sharers or favers
|
|
|
|
|
(users who have shared or marked this note as favourite) *****/
|
|
|
|
|
HTM_TxtF (" %u",NumUsrs);
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
static void Tml_Usr_ListSharersOrFavers (MYSQL_RES **mysql_res,
|
|
|
|
|
unsigned NumUsrs,unsigned NumFirstUsrs)
|
2021-02-11 17:20:38 +01:00
|
|
|
|
{
|
|
|
|
|
unsigned NumUsr;
|
|
|
|
|
struct UsrData UsrDat;
|
|
|
|
|
|
2021-03-02 16:47:58 +01:00
|
|
|
|
/***** Trivial check 1: are there favers or sharers? *****/
|
|
|
|
|
if (!NumUsrs)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/***** Trivial check 1: number of favers or sharers to show *****/
|
|
|
|
|
if (!NumFirstUsrs)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
|
|
|
|
|
/***** List users *****/
|
|
|
|
|
for (NumUsr = 0;
|
|
|
|
|
NumUsr < NumFirstUsrs;
|
|
|
|
|
NumUsr++)
|
2021-02-11 17:20:38 +01:00
|
|
|
|
{
|
2021-03-02 16:47:58 +01:00
|
|
|
|
/***** Get user's code *****/
|
2021-04-05 23:45:24 +02:00
|
|
|
|
UsrDat.UsrCod = DB_GetNextCode (*mysql_res);
|
2021-03-02 16:47:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Get user's data and show user's photo *****/
|
2021-04-24 15:10:07 +02:00
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,
|
|
|
|
|
Usr_DONT_GET_PREFS,
|
|
|
|
|
Usr_DONT_GET_ROLE_IN_CURRENT_CRS))
|
2021-02-11 17:20:38 +01:00
|
|
|
|
{
|
2021-03-02 16:47:58 +01:00
|
|
|
|
/* Begin container */
|
|
|
|
|
HTM_DIV_Begin ("class=\"TL_SHARER\"");
|
|
|
|
|
|
|
|
|
|
/* User's photo */
|
|
|
|
|
Pho_ShowUsrPhotoIfAllowed (&UsrDat,"PHOTO12x16",Pho_ZOOM,true); // Use unique id
|
|
|
|
|
|
|
|
|
|
/* End container */
|
|
|
|
|
HTM_DIV_End ();
|
2021-02-11 17:20:38 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-02 16:47:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
2021-02-11 17:20:38 +01:00
|
|
|
|
}
|
2021-03-02 20:36:20 +01:00
|
|
|
|
|
2021-03-03 02:15:32 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Check if a user has faved/shared a note/comment ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
bool Tml_Usr_CheckIfFavedSharedByUsr (Tml_Usr_FavSha_t FavSha,long Cod,long UsrCod)
|
2021-03-03 02:15:32 +01:00
|
|
|
|
{
|
|
|
|
|
switch (FavSha)
|
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
case Tml_Usr_FAV_UNF_NOTE:
|
|
|
|
|
case Tml_Usr_FAV_UNF_COMM:
|
|
|
|
|
return Tml_DB_CheckIfFavedByUsr (FavSha,Cod,UsrCod);
|
|
|
|
|
case Tml_Usr_SHA_UNS_NOTE:
|
|
|
|
|
return Tml_DB_CheckIfSharedByUsr (Cod,UsrCod);
|
2021-03-03 02:15:32 +01:00
|
|
|
|
default:
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Wrong fav/share action.");
|
2021-03-03 02:15:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false; // Not reached
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******* Get list of users who have marked a note/comment as favourite *******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
static unsigned Tml_Usr_GetListFaversOrSharers (Tml_Usr_FavSha_t FavSha,
|
|
|
|
|
long Cod,long UsrCod,unsigned MaxUsrs,
|
|
|
|
|
MYSQL_RES **mysql_res)
|
2021-03-03 02:15:32 +01:00
|
|
|
|
{
|
|
|
|
|
switch (FavSha)
|
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
case Tml_Usr_FAV_UNF_NOTE:
|
|
|
|
|
case Tml_Usr_FAV_UNF_COMM:
|
|
|
|
|
return Tml_DB_GetFavers (FavSha,Cod,UsrCod,MaxUsrs,mysql_res);
|
|
|
|
|
case Tml_Usr_SHA_UNS_NOTE:
|
|
|
|
|
return Tml_DB_GetSharers (Cod,UsrCod,MaxUsrs,mysql_res);
|
2021-03-03 02:15:32 +01:00
|
|
|
|
default:
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Wrong fav/share action.");
|
2021-03-03 02:15:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0; // Not reached
|
|
|
|
|
}
|
2021-03-03 09:40:01 +01:00
|
|
|
|
|
2021-03-03 10:02:42 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Put icon to fav/unfav and list of favers *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
void Tml_Usr_PutIconFavSha (Tml_Usr_FavSha_t FavSha,
|
|
|
|
|
long Cod,long UsrCod,unsigned NumUsrs,
|
|
|
|
|
Tml_Usr_HowManyUsrs_t HowManyUsrs)
|
2021-03-03 10:02:42 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Put form to fav/unfav or share/unshare this note/comment *****/
|
|
|
|
|
/* Begin container */
|
|
|
|
|
HTM_DIV_Begin ("class=\"TL_ICO\"");
|
|
|
|
|
|
|
|
|
|
/* Icon to fav/unfav or share/unshare this note/comment */
|
|
|
|
|
if (Usr_ItsMe (UsrCod)) // I am the author ==> I can not fav/unfav or share/unshare
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_Usr_PutDisabledIconFavSha (FavSha,NumUsrs);
|
2021-03-03 10:02:42 +01:00
|
|
|
|
else // I am not the author
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_Frm_PutFormToFavUnfShaUns (FavSha,Cod);
|
2021-03-03 10:02:42 +01:00
|
|
|
|
|
|
|
|
|
/* End container */
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
|
|
|
|
|
/***** Show who have faved/shared this note/comment *****/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_Usr_GetAndShowSharersOrFavers (FavSha,Cod,UsrCod,NumUsrs,HowManyUsrs);
|
2021-03-03 10:02:42 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-03 09:40:01 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Put disabled icon to mark as favourite *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
static void Tml_Usr_PutDisabledIconFavSha (Tml_Usr_FavSha_t FavSha,
|
|
|
|
|
unsigned NumUsrs)
|
2021-03-03 09:40:01 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_TIMELINE_Favourited_by_X_USERS;
|
|
|
|
|
extern const char *Txt_TIMELINE_Not_favourited_by_anyone;
|
|
|
|
|
extern const char *Txt_TIMELINE_Shared_by_X_USERS;
|
|
|
|
|
extern const char *Txt_TIMELINE_Not_shared_by_anyone;
|
2021-03-04 17:47:08 +01:00
|
|
|
|
static const char *Icon[Tml_Usr_NUM_FAV_SHA] =
|
2021-03-03 09:40:01 +01:00
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
[Tml_Usr_FAV_UNF_NOTE] = Tml_Fav_ICON_FAV,
|
|
|
|
|
[Tml_Usr_FAV_UNF_COMM] = Tml_Fav_ICON_FAV,
|
|
|
|
|
[Tml_Usr_SHA_UNS_NOTE] = Tml_Sha_ICON_SHARE,
|
2021-03-03 09:40:01 +01:00
|
|
|
|
};
|
2021-03-04 17:47:08 +01:00
|
|
|
|
const char *TitleWithUsrs[Tml_Usr_NUM_FAV_SHA] =
|
2021-03-03 09:40:01 +01:00
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
[Tml_Usr_FAV_UNF_NOTE] = Txt_TIMELINE_Favourited_by_X_USERS,
|
|
|
|
|
[Tml_Usr_FAV_UNF_COMM] = Txt_TIMELINE_Favourited_by_X_USERS,
|
|
|
|
|
[Tml_Usr_SHA_UNS_NOTE] = Txt_TIMELINE_Shared_by_X_USERS,
|
2021-03-03 09:40:01 +01:00
|
|
|
|
};
|
2021-03-04 17:47:08 +01:00
|
|
|
|
const char *TitleWithoutUsrs[Tml_Usr_NUM_FAV_SHA] =
|
2021-03-03 09:40:01 +01:00
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
[Tml_Usr_FAV_UNF_NOTE] = Txt_TIMELINE_Not_favourited_by_anyone,
|
|
|
|
|
[Tml_Usr_FAV_UNF_COMM] = Txt_TIMELINE_Not_favourited_by_anyone,
|
|
|
|
|
[Tml_Usr_SHA_UNS_NOTE] = Txt_TIMELINE_Not_shared_by_anyone,
|
2021-03-03 09:40:01 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/***** Disabled icon to fav/share *****/
|
|
|
|
|
if (NumUsrs)
|
|
|
|
|
{
|
|
|
|
|
Ico_PutDivIcon ("TL_ICO_DISABLED",Icon[FavSha],
|
|
|
|
|
Str_BuildStringLong (TitleWithUsrs[FavSha],(long) NumUsrs));
|
|
|
|
|
Str_FreeString ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Ico_PutDivIcon ("TL_ICO_DISABLED",Icon[FavSha],TitleWithoutUsrs[FavSha]);
|
|
|
|
|
}
|
2021-03-03 21:53:43 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Check if I can fav/share a note/comment *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
bool Tml_Usr_CheckIfICanFavSha (long Cod,long UsrCod)
|
2021-03-03 21:53:43 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_post_no_longer_exists;
|
|
|
|
|
|
|
|
|
|
/***** Trivial check 1: note/comment code should be > 0 *****/
|
|
|
|
|
if (Cod <= 0)
|
|
|
|
|
{
|
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_The_post_no_longer_exists);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Trivial check 2: I must be logged
|
|
|
|
|
I can not fav/share my own notes/comments *****/
|
|
|
|
|
if (!Gbl.Usrs.Me.Logged || Usr_ItsMe (UsrCod))
|
|
|
|
|
{
|
2021-09-25 11:43:52 +02:00
|
|
|
|
Err_NoPermission ();
|
2021-04-30 00:12:54 +02:00
|
|
|
|
return false;
|
2021-03-03 21:53:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Check if I can fav/share a note/comment *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
bool Tml_Usr_CheckIfICanRemove (long Cod,long UsrCod)
|
2021-03-03 21:53:43 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_post_no_longer_exists;
|
|
|
|
|
|
|
|
|
|
/***** Trivial check 1: note/comment code should be > 0 *****/
|
|
|
|
|
if (Cod <= 0)
|
|
|
|
|
{
|
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_The_post_no_longer_exists);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Trivial check 2: I must be logged
|
|
|
|
|
I can only remove my own notes/comments *****/
|
|
|
|
|
if (!Gbl.Usrs.Me.Logged || !Usr_ItsMe (UsrCod))
|
|
|
|
|
{
|
2021-09-25 11:43:52 +02:00
|
|
|
|
Err_NoPermission ();
|
2021-04-30 00:12:54 +02:00
|
|
|
|
return false;
|
2021-03-03 21:53:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|