2021-09-15 13:48:41 +02:00
|
|
|
|
// swad_forum_database.h: forums operations with database
|
|
|
|
|
|
|
|
|
|
#ifndef _SWAD_FOR_DB
|
|
|
|
|
#define _SWAD_FOR_DB
|
|
|
|
|
/*
|
|
|
|
|
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-09-15 13:48:41 +02: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-15 20:21:02 +02:00
|
|
|
|
#include "swad_forum.h"
|
2021-09-15 13:48:41 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Public prototypes *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-09-15 20:21:02 +02:00
|
|
|
|
//------------------------------- Forums --------------------------------------
|
|
|
|
|
unsigned For_DB_GetNumThrsInForum (const struct For_Forum *Forum);
|
2021-09-16 23:28:29 +02:00
|
|
|
|
unsigned For_DB_GetNumThrsInForumNewerThan (const struct For_Forum *Forum,
|
|
|
|
|
const char *Time);
|
|
|
|
|
unsigned For_DB_GetNumPstsOfUsrInForum (const struct For_Forum *Forum,
|
|
|
|
|
long UsrCod);
|
2023-04-06 12:39:13 +02:00
|
|
|
|
void For_DB_RemoveForums (HieLvl_Level_t Scope,long HieCod);
|
2021-09-15 20:21:02 +02:00
|
|
|
|
|
2021-09-15 13:48:41 +02:00
|
|
|
|
//------------------------------- Posts ---------------------------------------
|
|
|
|
|
long For_DB_InsertForumPst (long ThrCod,long UsrCod,
|
|
|
|
|
const char *Subject,const char *Content,
|
|
|
|
|
long MedCod);
|
2021-09-15 20:21:02 +02:00
|
|
|
|
void For_DB_UpdateNumUsrsNotifiedByEMailAboutPost (long PstCod,
|
|
|
|
|
unsigned NumUsrsToBeNotifiedByEMail);
|
2021-11-05 23:41:26 +01:00
|
|
|
|
bool For_DB_CheckIfForumPstExists (long PstCod);
|
2021-09-16 17:10:32 +02:00
|
|
|
|
unsigned For_DB_GetPstData (MYSQL_RES **mysql_res,long PstCod);
|
|
|
|
|
unsigned For_DB_GetPstSubjectAndContent (MYSQL_RES **mysql_res,long PstCod);
|
2023-04-06 12:39:13 +02:00
|
|
|
|
unsigned For_DB_GetThreadForumTypeAndHieCodOfAPost (MYSQL_RES **mysql_res,long PstCod);
|
|
|
|
|
unsigned For_DB_GetForumTypeAndHieCodOfAThread (MYSQL_RES **mysql_res,long ThrCod);
|
2021-09-15 20:21:02 +02:00
|
|
|
|
unsigned For_DB_GetNumPostsUsr (long UsrCod);
|
2021-09-16 17:10:32 +02:00
|
|
|
|
unsigned For_DB_GetPostsOfAThread (MYSQL_RES **mysql_res,long ThrCod);
|
2021-09-15 13:48:41 +02:00
|
|
|
|
unsigned For_DB_GetThreadAndNumPostsGivenPstCod (MYSQL_RES **mysql_res,long PstCod);
|
2021-10-04 14:36:35 +02:00
|
|
|
|
unsigned For_DB_GetPublishersInThreadExceptMe (MYSQL_RES **mysql_res,long PstCod);
|
2021-09-15 13:48:41 +02:00
|
|
|
|
void For_DB_RemovePst (long PstCod);
|
|
|
|
|
void For_DB_RemoveThreadPsts (long ThrCod);
|
|
|
|
|
|
|
|
|
|
//------------------------------ Threads --------------------------------------
|
|
|
|
|
long For_DB_InsertForumThread (const struct For_Forums *Forums,
|
|
|
|
|
long FirstPstCod);
|
2021-09-15 20:21:02 +02:00
|
|
|
|
void For_DB_UpdateThrFirstAndLastPst (long ThrCod,long FirstPstCod,long LastPstCod);
|
|
|
|
|
void For_DB_UpdateThrLastPst (long ThrCod,long LastPstCod);
|
2021-09-16 17:10:32 +02:00
|
|
|
|
unsigned For_DB_GetForumThreads (MYSQL_RES **mysql_res,
|
|
|
|
|
const struct For_Forums *Forums);
|
2021-09-15 20:21:02 +02:00
|
|
|
|
unsigned For_DB_GetThreadData (MYSQL_RES **mysql_res,long ThrCod);
|
2023-04-06 22:39:26 +02:00
|
|
|
|
void For_DB_GetThreadTitle (long ThrCod,char *Subject,size_t TitleSize);
|
2021-09-15 20:21:02 +02:00
|
|
|
|
bool For_DB_CheckIfThrBelongsToForum (long ThrCod,const struct For_Forum *Forum);
|
|
|
|
|
long For_DB_GetThrLastPst (long ThrCod);
|
2021-09-15 13:48:41 +02:00
|
|
|
|
void For_DB_GetThrSubject (long ThrCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1]);
|
2021-09-15 20:21:02 +02:00
|
|
|
|
unsigned For_DB_GetNumOfWritersInThr (long ThrCod);
|
|
|
|
|
unsigned For_DB_GetNumPstsInThr (long ThrCod);
|
|
|
|
|
unsigned For_DB_GetNumMyPstsInThr (long ThrCod);
|
|
|
|
|
unsigned For_DB_GetNumPstsInThrNewerThan (long ThrCod,const char *Time);
|
2021-09-15 13:48:41 +02:00
|
|
|
|
void For_DB_RemoveThread (long ThrCod);
|
|
|
|
|
|
2021-09-15 20:21:02 +02:00
|
|
|
|
//----------------------------- Thread read -----------------------------------
|
|
|
|
|
void For_DB_UpdateThrReadTime (long ThrCod,
|
|
|
|
|
time_t CreatTimeUTCOfTheMostRecentPostRead);
|
|
|
|
|
unsigned For_DB_GetNumReadersOfThr (long ThrCod);
|
2021-09-16 17:10:32 +02:00
|
|
|
|
unsigned For_DB_GetThrReadTime (MYSQL_RES **mysql_res,long ThrCod);
|
2021-09-16 23:28:29 +02:00
|
|
|
|
unsigned For_DB_GetLastTimeIReadForum (MYSQL_RES **mysql_res,
|
|
|
|
|
const struct For_Forum *Forum);
|
|
|
|
|
unsigned For_DB_GetLastTimeIReadThread (MYSQL_RES **mysql_res,long ThrCod);
|
2021-09-15 20:21:02 +02:00
|
|
|
|
void For_DB_RemoveThrFromReadThrs (long ThrCod);
|
|
|
|
|
void For_DB_RemoveUsrFromReadThrs (long UsrCod);
|
|
|
|
|
|
|
|
|
|
//-------------------------- Thread clipboard ---------------------------------
|
|
|
|
|
void For_DB_InsertThrInMyClipboard (long ThrCod);
|
|
|
|
|
void For_DB_MoveThrToCurrentForum (const struct For_Forums *Forums);
|
|
|
|
|
long For_DB_GetThrInMyClipboard (void);
|
|
|
|
|
void For_DB_RemoveThrFromClipboard (long ThrCod);
|
|
|
|
|
void For_DB_RemoveUsrFromClipboard (long UsrCod);
|
|
|
|
|
void For_DB_RemoveExpiredClipboards (void);
|
|
|
|
|
|
2021-09-15 13:48:41 +02:00
|
|
|
|
//--------------------------- Disabled posts ----------------------------------
|
|
|
|
|
void For_DB_InsertPstIntoDisabled (long PstCod);
|
2023-05-31 09:29:23 +02:00
|
|
|
|
Cns_DisabledOrEnabled_t For_DB_GetIfPstIsDisabledOrEnabled (long PstCod);
|
2021-09-15 13:48:41 +02:00
|
|
|
|
void For_DB_RemovePstFromDisabled (long PstCod);
|
|
|
|
|
void For_DB_RemoveDisabledPstsInThread (long ThrCod);
|
|
|
|
|
|
2021-09-15 20:21:02 +02:00
|
|
|
|
//----------------------------- Statistics ------------------------------------
|
|
|
|
|
unsigned For_DB_GetNumTotalForumsOfType (For_ForumType_t ForumType,
|
|
|
|
|
long CtyCod,
|
|
|
|
|
long InsCod,
|
|
|
|
|
long CtrCod,
|
|
|
|
|
long DegCod,
|
|
|
|
|
long CrsCod);
|
|
|
|
|
unsigned For_DB_GetNumTotalThrsInForumsOfType (For_ForumType_t ForumType,
|
|
|
|
|
long CtyCod,
|
|
|
|
|
long InsCod,
|
|
|
|
|
long CtrCod,
|
|
|
|
|
long DegCod,
|
|
|
|
|
long CrsCod);
|
|
|
|
|
unsigned For_DB_GetNumTotalPstsInForumsOfType (For_ForumType_t ForumType,
|
|
|
|
|
long CtyCod,
|
|
|
|
|
long InsCod,
|
|
|
|
|
long CtrCod,
|
|
|
|
|
long DegCod,
|
|
|
|
|
long CrsCod,
|
|
|
|
|
unsigned *NumUsrsToBeNotifiedByEMail);
|
|
|
|
|
|
2021-09-15 13:48:41 +02:00
|
|
|
|
#endif
|