2021-02-26 22:20:03 +01:00
|
|
|
|
// swad_timeline_database.h: social timeline operations with database
|
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
#ifndef _SWAD_TML_DB
|
|
|
|
|
#define _SWAD_TML_DB
|
2021-02-26 22:20:03 +01:00
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance in Spanish),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Copyright (C) 1999-2023 Antonio Ca<EFBFBD>as Vargas
|
2021-02-26 22:20:03 +01:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************** Headers **********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-09-13 23:55:28 +02:00
|
|
|
|
#include "swad_browser.h"
|
2021-02-26 22:20:03 +01:00
|
|
|
|
#include "swad_database.h"
|
2021-02-28 21:55:33 +01:00
|
|
|
|
#include "swad_timeline_comment.h"
|
2021-03-01 10:42:59 +01:00
|
|
|
|
#include "swad_timeline_favourite.h"
|
2021-02-27 14:12:41 +01:00
|
|
|
|
#include "swad_timeline_note.h"
|
2021-02-26 23:13:06 +01:00
|
|
|
|
#include "swad_timeline_post.h"
|
2021-02-27 22:13:05 +01:00
|
|
|
|
#include "swad_timeline_publication.h"
|
2021-02-26 22:20:03 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Public prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-01 16:54:18 +01:00
|
|
|
|
/****************************** Timeline from who ****************************/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
unsigned Tml_DB_GetWho (MYSQL_RES **mysql_res);
|
|
|
|
|
void Tml_DB_UpdateWho (Usr_Who_t Who);
|
2021-03-01 16:54:18 +01:00
|
|
|
|
|
2021-02-28 21:24:49 +01:00
|
|
|
|
/*********************************** Notes ***********************************/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
unsigned Tml_DB_GetNoteDataByCod (long NotCod,MYSQL_RES **mysql_res);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
long Tml_DB_GetPubCodOfOriginalNote (long NotCod);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
long Tml_DB_CreateNewNote (TmlNot_Type_t NoteType,long Cod,
|
2021-03-04 17:47:08 +01:00
|
|
|
|
long PublisherCod,long HieCod);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void Tml_DB_MarkNoteAsUnavailable (TmlNot_Type_t NoteType,long Cod);
|
|
|
|
|
void Tml_DB_MarkNotesChildrenOfFolderAsUnavailable (TmlNot_Type_t NoteType,
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Brw_FileBrowser_t FileBrowser,
|
|
|
|
|
long Cod,const char *Path);
|
2021-09-11 17:44:00 +02:00
|
|
|
|
|
|
|
|
|
unsigned Tml_DB_GetNumNotesAndUsrsByType (MYSQL_RES **mysql_res,
|
2021-12-31 14:51:44 +01:00
|
|
|
|
TmlNot_Type_t NoteType);
|
2021-09-11 17:44:00 +02:00
|
|
|
|
unsigned Tml_DB_GetNumNotesAndUsrsTotal (MYSQL_RES **mysql_res);
|
|
|
|
|
|
2021-11-21 01:22:59 +01:00
|
|
|
|
void Tml_DB_CreateTmpTableTimeline (Tml_WhatToGet_t WhatToGet);
|
|
|
|
|
void Tml_DB_InsertNoteInTimeline (long NotCod);
|
|
|
|
|
void Tml_DB_DropTmpTableTimeline (void);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
void Tml_DB_ClearOldTimelinesNotesFromDB (void);
|
|
|
|
|
void Tml_DB_ClearTimelineNotesOfSessionFromDB (void);
|
2021-09-11 17:44:00 +02:00
|
|
|
|
|
2021-03-04 17:47:08 +01:00
|
|
|
|
void Tml_DB_RemoveNoteFavs (long NotCod);
|
|
|
|
|
void Tml_DB_RemoveNotePubs (long NotCod);
|
|
|
|
|
void Tml_DB_RemoveNote (long NotCod);
|
|
|
|
|
void Tml_DB_RemoveAllNotesUsr (long UsrCod);
|
2021-02-27 14:12:41 +01:00
|
|
|
|
|
2021-03-01 16:54:18 +01:00
|
|
|
|
/********************************* Posts *************************************/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
unsigned Tml_DB_GetPostByCod (long PstCod,MYSQL_RES **mysql_res);
|
|
|
|
|
long Tml_DB_GetMedCodFromPost (long PubCod);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
long Tml_DB_CreateNewPost (const struct TmlPst_Content *Content);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
void Tml_DB_RemovePost (long PstCod);
|
|
|
|
|
void Tml_DB_RemoveAllPostsUsr (long UsrCod);
|
2021-02-27 15:09:23 +01:00
|
|
|
|
|
2021-02-28 21:24:49 +01:00
|
|
|
|
/******************************** Comments ***********************************/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
unsigned Tml_DB_GetNumCommsInNote (long NotCod);
|
|
|
|
|
unsigned Tml_DB_GetComms (long NotCod,MYSQL_RES **mysql_res);
|
|
|
|
|
unsigned Tml_DB_GetInitialComms (long NotCod,unsigned NumInitialCommsToGet,
|
|
|
|
|
MYSQL_RES **mysql_res);
|
|
|
|
|
unsigned Tml_DB_GetFinalComms (long NotCod,unsigned NumFinalCommsToGet,
|
|
|
|
|
MYSQL_RES **mysql_res);
|
2023-03-23 09:35:20 +01:00
|
|
|
|
unsigned Tml_DB_GetCommDataByCod (long PubCod,MYSQL_RES **mysql_res);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
void Tml_DB_InsertCommContent (long PubCod,
|
2021-12-31 14:51:44 +01:00
|
|
|
|
const struct TmlPst_Content *Content);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
long Tml_DB_GetMedCodFromComm (long PubCod);
|
|
|
|
|
void Tml_DB_RemoveCommFavs (long PubCod);
|
|
|
|
|
void Tml_DB_RemoveCommContent (long PubCod);
|
|
|
|
|
void Tml_DB_RemoveCommPub (long PubCod);
|
|
|
|
|
void Tml_DB_RemoveAllCommsInAllNotesOf (long UsrCod);
|
|
|
|
|
void Tml_DB_RemoveAllCommsMadeBy (long UsrCod);
|
2021-02-26 22:20:03 +01:00
|
|
|
|
|
2021-02-28 21:24:49 +01:00
|
|
|
|
/****************************** Publications *********************************/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void Tml_DB_CreateSubQueryPublishers (TmlUsr_UsrOrGbl_t UsrOrGbl,Usr_Who_t Who,
|
2021-11-18 01:29:48 +01:00
|
|
|
|
char **Table,
|
2021-12-31 14:51:44 +01:00
|
|
|
|
char SubQuery[TmlPub_MAX_BYTES_SUBQUERY + 1]);
|
|
|
|
|
void Tml_DB_CreateSubQueryRange (TmlPub_Range_t Range,long PubCod,
|
|
|
|
|
char SubQuery[TmlPub_MAX_BYTES_SUBQUERY + 1]);
|
2021-11-18 01:29:48 +01:00
|
|
|
|
unsigned Tml_DB_SelectTheMostRecentPub (MYSQL_RES **mysql_res,
|
2021-12-31 14:51:44 +01:00
|
|
|
|
const struct TmlPub_SubQueries *SubQueries);
|
2023-03-23 09:35:20 +01:00
|
|
|
|
unsigned Tml_DB_GetPubDataByCod (long PubCod,MYSQL_RES **mysql_res);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
long Tml_DB_GetNotCodFromPubCod (long PubCod);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
long Tml_DB_GetPubCodFromSession (TmlPub_FirstLast_t FirstLast);
|
2021-04-17 01:57:19 +02:00
|
|
|
|
unsigned Tml_DB_GetNumPubsUsr (long UsrCod);
|
2021-10-04 14:36:35 +02:00
|
|
|
|
unsigned Tml_DB_GetPublishersInNoteExceptMe (MYSQL_RES **mysql_res,long PubCod);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
long Tml_DB_CreateNewPub (const struct TmlPub_Publication *Pub);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
void Tml_DB_UpdateFirstPubCodInSession (long FirstPubCod);
|
|
|
|
|
void Tml_DB_UpdateLastPubCodInSession (void);
|
|
|
|
|
void Tml_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod);
|
|
|
|
|
void Tml_DB_RemoveAllPubsPublishedByAnyUsrOfNotesAuthoredBy (long UsrCod);
|
|
|
|
|
void Tml_DB_RemoveAllPubsPublishedBy (long UsrCod);
|
2021-02-27 21:23:14 +01:00
|
|
|
|
|
2021-02-28 21:24:49 +01:00
|
|
|
|
/****************************** Favourites ***********************************/
|
2021-12-31 14:51:44 +01:00
|
|
|
|
bool Tml_DB_CheckIfFavedByUsr (TmlUsr_FavSha_t FavSha,long Cod,long UsrCod);
|
|
|
|
|
unsigned Tml_DB_GetNumFavers (TmlUsr_FavSha_t FavSha,long Cod,long UsrCod);
|
|
|
|
|
unsigned Tml_DB_GetFavers (TmlUsr_FavSha_t FavSha,
|
2021-03-04 17:47:08 +01:00
|
|
|
|
long Cod,long UsrCod,unsigned MaxUsrs,
|
|
|
|
|
MYSQL_RES **mysql_res);
|
2021-12-31 14:51:44 +01:00
|
|
|
|
void Tml_DB_MarkAsFav (TmlUsr_FavSha_t FavSha,long Cod);
|
|
|
|
|
void Tml_DB_UnmarkAsFav (TmlUsr_FavSha_t FavSha,long Cod);
|
|
|
|
|
void Tml_DB_RemoveAllFavsMadeByUsr (TmlUsr_FavSha_t FavSha,long UsrCod);
|
|
|
|
|
void Tml_DB_RemoveAllFavsToPubsBy (TmlUsr_FavSha_t FavSha,long UsrCod);
|
2021-03-04 17:47:08 +01:00
|
|
|
|
void Tml_DB_RemoveAllFavsToAllCommsInAllNotesBy (long UsrCod);
|
2021-02-28 21:24:49 +01:00
|
|
|
|
|
2021-03-01 11:40:03 +01:00
|
|
|
|
/******************************** Shared *************************************/
|
2021-03-04 17:47:08 +01:00
|
|
|
|
bool Tml_DB_CheckIfSharedByUsr (long NotCod,long UsrCod);
|
|
|
|
|
unsigned Tml_DB_GetNumSharers (long NotCod,long UsrCod);
|
|
|
|
|
unsigned Tml_DB_GetSharers (long NotCod,long UsrCod,unsigned MaxUsrs,
|
|
|
|
|
MYSQL_RES **mysql_res);
|
|
|
|
|
void Tml_DB_RemoveSharedPub (long NotCod);
|
2021-03-01 11:40:03 +01:00
|
|
|
|
|
2021-02-26 22:20:03 +01:00
|
|
|
|
#endif
|