Version 21.5.1: Sep 15, 2021 Queries moved to module swad_forum_database.

This commit is contained in:
acanas 2021-09-15 20:21:02 +02:00
parent 9bb2eafff3
commit 93a33d4148
15 changed files with 1455 additions and 1455 deletions

View File

@ -44,7 +44,7 @@
#include "swad_exam_database.h"
#include "swad_follow.h"
#include "swad_form.h"
#include "swad_forum.h"
#include "swad_forum_database.h"
#include "swad_global.h"
#include "swad_HTML.h"
#include "swad_ID.h"
@ -1005,7 +1005,7 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
UsrDat->FullName);
/***** Remove user's clipboard in forums *****/
For_DB_RemoveUsrFromThrClipboard (UsrDat->UsrCod);
For_DB_RemoveUsrFromClipboard (UsrDat->UsrCod);
/***** Remove some files of the user's from database *****/
Brw_DB_RemoveUsrFiles (UsrDat->UsrCod);

View File

@ -41,7 +41,7 @@
#include "swad_figure.h"
#include "swad_figure_cache.h"
#include "swad_form.h"
#include "swad_forum.h"
#include "swad_forum_database.h"
#include "swad_global.h"
#include "swad_hierarchy.h"
#include "swad_hierarchy_level.h"
@ -1080,7 +1080,7 @@ void Ctr_RemoveCenter (void)
else // Center has no degrees or users ==> remove it
{
/***** Remove all the threads and posts in forums of the center *****/
For_RemoveForums (HieLvl_CTR,Ctr_EditingCtr->CtrCod);
For_DB_RemoveForums (HieLvl_CTR,Ctr_EditingCtr->CtrCod);
/***** Remove surveys of the center *****/
Svy_RemoveSurveys (HieLvl_CTR,Ctr_EditingCtr->CtrCod);

View File

@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
*/
#define Log_PLATFORM_VERSION "SWAD 21.5 (2021-09-15)"
#define Log_PLATFORM_VERSION "SWAD 21.5.1 (2021-09-15)"
#define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js"
/*
TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 21.5.1: Sep 15, 2021 Queries moved to module swad_forum_database. (315348 lines)
Version 21.5: Sep 15, 2021 New module swad_forum_database for database queries related to forums. (315354 lines)
Version 21.4: Sep 15, 2021 New module swad_firewall_database for database queries related to firewall. (315286 lines)
Version 21.3.1: Sep 15, 2021 Queries moved to module swad_browser_database. (315201 lines)

View File

@ -43,7 +43,7 @@
#include "swad_figure.h"
#include "swad_figure_cache.h"
#include "swad_form.h"
#include "swad_forum.h"
#include "swad_forum_database.h"
#include "swad_game.h"
#include "swad_global.h"
#include "swad_help.h"
@ -1823,7 +1823,7 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
Not_DB_RemoveCrsNotices (CrsCod);
/***** Remove all the threads and posts in forums of the course *****/
For_RemoveForums (HieLvl_CRS,CrsCod);
For_DB_RemoveForums (HieLvl_CRS,CrsCod);
/***** Remove all surveys in the course *****/
Svy_RemoveSurveys (HieLvl_CRS,CrsCod);

View File

@ -42,7 +42,7 @@
#include "swad_figure.h"
#include "swad_figure_cache.h"
#include "swad_form.h"
#include "swad_forum.h"
#include "swad_forum_database.h"
#include "swad_global.h"
#include "swad_hierarchy.h"
#include "swad_HTML.h"
@ -1350,7 +1350,7 @@ void Deg_RemoveDegreeCompletely (long DegCod)
DB_FreeMySQLResult (&mysql_res);
/***** Remove all the threads and posts in forums of the degree *****/
For_RemoveForums (HieLvl_DEG,DegCod);
For_DB_RemoveForums (HieLvl_DEG,DegCod);
/***** Remove surveys of the degree *****/
Svy_RemoveSurveys (HieLvl_DEG,DegCod);

View File

@ -468,6 +468,11 @@ void Err_WrongForumExit (void)
Err_ShowErrorAndExit ("Wrong forum.");
}
void Err_WrongThreadExit (void)
{
Err_ShowErrorAndExit ("Wrong thread.");
}
void Err_WrongPostExit (void)
{
Err_ShowErrorAndExit ("Wrong post.");

View File

@ -90,6 +90,7 @@ void Err_WrongEventExit (void);
void Err_WrongAnnouncementExit (void);
void Err_WrongNoticeExit (void);
void Err_WrongForumExit (void);
void Err_WrongThreadExit (void);
void Err_WrongPostExit (void);
void Err_WrongMessageExit (void);
void Err_WrongMailDomainExit (void);

View File

@ -44,6 +44,7 @@
#include "swad_follow_database.h"
#include "swad_form.h"
#include "swad_forum.h"
#include "swad_forum_database.h"
#include "swad_global.h"
#include "swad_hierarchy.h"
#include "swad_hierarchy_level.h"
@ -2670,7 +2671,7 @@ static void Fig_WriteForumTitleAndStats (For_ForumType_t ForumType,
/***** Compute number of forums, number of threads and number of posts *****/
NumForums = For_DB_GetNumTotalForumsOfType (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod);
NumThreads = For_DB_GetNumTotalThrsInForumsOfType (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod);
NumPosts = For_GetNumTotalPstsInForumsOfType (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,&NumUsrsToBeNotifiedByEMail);
NumPosts = For_DB_GetNumTotalPstsInForumsOfType (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,&NumUsrsToBeNotifiedByEMail);
/***** Compute number of threads per forum, number of posts per forum and number of posts per thread *****/
NumThrsPerForum = (NumForums ? (double) NumThreads / (double) NumForums :

File diff suppressed because it is too large Load Diff

View File

@ -121,9 +121,6 @@ void For_DisablePost (void);
void For_GetForumTypeAndLocationOfAPost (long PstCod,struct For_Forum *Forum);
unsigned For_DB_GetNumPostsUsr (long UsrCod);
void For_DB_RemoveUsrFromReadThrs (long UsrCod);
void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
char **ContentStr,
long PstCod,bool GetContent);
@ -141,25 +138,6 @@ void For_SetForumName (const struct For_Forum *Forum,
Lan_Language_t Language,bool UseHTMLEntities);
void For_ShowForumTheads (void);
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_GetNumTotalPstsInForumsOfType (For_ForumType_t ForumType,
long CtyCod,
long InsCod,
long CtrCod,
long DegCod,
long CrsCod,
unsigned *NumUsrsToBeNotifiedByEMail);
void For_ShowThreadPosts (void);
void For_ReceiveForumPost (void);
@ -168,8 +146,5 @@ void For_RequestRemoveThread (void);
void For_RemoveThread (void);
void For_CutThread (void);
void For_PasteThread (void);
void For_DB_RemoveUsrFromThrClipboard (long UsrCod);
void For_RemoveForums (HieLvl_Level_t Scope,long ForumLocation);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -27,13 +27,7 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
// #include "swad_center.h"
// #include "swad_degree.h"
// #include "swad_institution.h"
// #include "swad_notification.h"
// #include "swad_pagination.h"
// #include "swad_scope.h"
// #include "swad_string.h"
#include "swad_forum.h"
/*****************************************************************************/
/************************ Public constants and types *************************/
@ -43,11 +37,20 @@
/***************************** Public prototypes *****************************/
/*****************************************************************************/
//------------------------------- Forums --------------------------------------
unsigned For_DB_GetNumThrsInForum (const struct For_Forum *Forum);
unsigned For_DB_GetNumOfThreadsInForumNewerThan (const struct For_Forum *Forum,
const char *Time);
void For_DB_RemoveForums (HieLvl_Level_t Scope,long ForumLocation);
//------------------------------- Posts ---------------------------------------
long For_DB_InsertForumPst (long ThrCod,long UsrCod,
const char *Subject,const char *Content,
long MedCod);
void For_DB_UpdateNumUsrsNotifiedByEMailAboutPost (long PstCod,
unsigned NumUsrsToBeNotifiedByEMail);
bool For_DB_GetIfForumPstExists (long PstCod);
unsigned For_DB_GetNumPostsUsr (long UsrCod);
unsigned For_DB_GetThreadAndNumPostsGivenPstCod (MYSQL_RES **mysql_res,long PstCod);
void For_DB_RemovePst (long PstCod);
void For_DB_RemoveThreadPsts (long ThrCod);
@ -55,13 +58,58 @@ void For_DB_RemoveThreadPsts (long ThrCod);
//------------------------------ Threads --------------------------------------
long For_DB_InsertForumThread (const struct For_Forums *Forums,
long FirstPstCod);
void For_DB_UpdateThrFirstAndLastPst (long ThrCod,long FirstPstCod,long LastPstCod);
void For_DB_UpdateThrLastPst (long ThrCod,long LastPstCod);
unsigned For_DB_GetThreadData (MYSQL_RES **mysql_res,long ThrCod);
bool For_DB_CheckIfThrBelongsToForum (long ThrCod,const struct For_Forum *Forum);
long For_DB_GetThrLastPst (long ThrCod);
void For_DB_GetThrSubject (long ThrCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1]);
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);
void For_DB_RemoveThread (long ThrCod);
//----------------------------- Thread read -----------------------------------
void For_DB_UpdateThrReadTime (long ThrCod,
time_t CreatTimeUTCOfTheMostRecentPostRead);
unsigned For_DB_GetNumReadersOfThr (long ThrCod);
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);
//--------------------------- Disabled posts ----------------------------------
void For_DB_InsertPstIntoDisabled (long PstCod);
bool For_DB_GetIfPstIsEnabled (long PstCod);
void For_DB_RemovePstFromDisabled (long PstCod);
void For_DB_RemoveDisabledPstsInThread (long ThrCod);
//----------------------------- 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);
#endif

View File

@ -35,7 +35,7 @@
#include "swad_department.h"
#include "swad_error.h"
#include "swad_form.h"
#include "swad_forum.h"
#include "swad_forum_database.h"
#include "swad_global.h"
#include "swad_hierarchy_level.h"
#include "swad_HTML.h"
@ -1452,7 +1452,7 @@ void Ind_ComputeAndStoreIndicatorsCrs (long CrsCod,int NumIndicatorsFromDB,
/***** Indicator #3: information about online tutoring *****/
IndicatorsCrs->NumThreads = For_DB_GetNumTotalThrsInForumsOfType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,CrsCod);
IndicatorsCrs->NumPosts = For_GetNumTotalPstsInForumsOfType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,CrsCod,&(IndicatorsCrs->NumUsrsToBeNotifiedByEMail));
IndicatorsCrs->NumPosts = For_DB_GetNumTotalPstsInForumsOfType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,CrsCod,&(IndicatorsCrs->NumUsrsToBeNotifiedByEMail));
IndicatorsCrs->NumMsgsSentByTchs = Msg_DB_GetNumMsgsSentByTchsCrs (CrsCod);
IndicatorsCrs->ThereIsOnlineTutoring = (IndicatorsCrs->NumThreads != 0) ||
(IndicatorsCrs->NumPosts != 0) ||

View File

@ -39,7 +39,7 @@
#include "swad_figure.h"
#include "swad_figure_cache.h"
#include "swad_form.h"
#include "swad_forum.h"
#include "swad_forum_database.h"
#include "swad_global.h"
#include "swad_hierarchy.h"
#include "swad_hierarchy_level.h"
@ -1243,7 +1243,7 @@ void Ins_RemoveInstitution (void)
else // Institution has no users ==> remove it
{
/***** Remove all the threads and posts in forums of the institution *****/
For_RemoveForums (HieLvl_INS,Ins_EditingIns->InsCod);
For_DB_RemoveForums (HieLvl_INS,Ins_EditingIns->InsCod);
/***** Remove surveys of the institution *****/
Svy_RemoveSurveys (HieLvl_INS,Ins_EditingIns->InsCod);

View File

@ -39,7 +39,7 @@
#include "swad_figure.h"
#include "swad_follow_database.h"
#include "swad_form.h"
#include "swad_forum.h"
#include "swad_forum_database.h"
#include "swad_global.h"
#include "swad_hierarchy_level.h"
#include "swad_HTML.h"