Version 20.51.10: Mar 18, 2021 Forum posts database tables renamed.

This commit is contained in:
acanas 2021-03-18 15:49:38 +01:00
parent 0de0a89903
commit a30d54d189
5 changed files with 291 additions and 239 deletions

View File

@ -656,17 +656,17 @@ CREATE TABLE IF NOT EXISTS fir_log (
INDEX(ClickTime), INDEX(ClickTime),
INDEX(IP)); INDEX(IP));
-- --
-- Table forum_disabled_post: stores the forum post that have been disabled -- Table for_disabled_posts: stores the forum post that have been disabled
-- --
CREATE TABLE IF NOT EXISTS forum_disabled_post ( CREATE TABLE IF NOT EXISTS for_disabled_posts (
PstCod INT NOT NULL, PstCod INT NOT NULL,
UsrCod INT NOT NULL, UsrCod INT NOT NULL,
DisableTime DATETIME NOT NULL, DisableTime DATETIME NOT NULL,
UNIQUE INDEX(PstCod)); UNIQUE INDEX(PstCod));
-- --
-- Table forum_post: stores the forum posts -- Table for_posts: stores the forum posts
-- --
CREATE TABLE IF NOT EXISTS forum_post ( CREATE TABLE IF NOT EXISTS ffor_posts(
PstCod INT NOT NULL AUTO_INCREMENT, PstCod INT NOT NULL AUTO_INCREMENT,
ThrCod INT NOT NULL, ThrCod INT NOT NULL,
UsrCod INT NOT NULL, UsrCod INT NOT NULL,

View File

@ -600,13 +600,18 @@ TODO: Salvador Romero Cort
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria. TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
*/ */
#define Log_PLATFORM_VERSION "SWAD 20.51.9 (2021-03-18)" #define Log_PLATFORM_VERSION "SWAD 20.51.10 (2021-03-18)"
#define CSS_FILE "swad20.45.css" #define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.6.2.js" #define JS_FILE "swad20.6.2.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 20.51.10: Mar 18, 2021 Forum posts database tables renamed. (307775 lines)
1 change necessary in database:
RENAME TABLE forum_disabled_post TO for_disabled_posts;
RENAME TABLE forum_post TO for_posts;
Version 20.51.9: Mar 18, 2021 Firewall database tables renamed. (307724 lines) Version 20.51.9: Mar 18, 2021 Firewall database tables renamed. (307724 lines)
2 changes necessary in database: 2 changes necessary in database:
RENAME TABLE firewall_banned TO fir_banned; RENAME TABLE firewall_banned TO fir_banned;

View File

@ -1435,9 +1435,9 @@ mysql> DESCRIBE fir_log;
"INDEX(ClickTime)," "INDEX(ClickTime),"
"INDEX(IP))"); "INDEX(IP))");
/***** Table forum_disabled_post *****/ /***** Table for_disabled_posts *****/
/* /*
mysql> DESCRIBE forum_disabled_post; mysql> DESCRIBE for_disabled_posts;
+-------------+----------+------+-----+---------+-------+ +-------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+ +-------------+----------+------+-----+---------+-------+
@ -1447,15 +1447,15 @@ mysql> DESCRIBE forum_disabled_post;
+-------------+----------+------+-----+---------+-------+ +-------------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec) 3 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS forum_disabled_post (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS for_disabled_posts ("
"PstCod INT NOT NULL," "PstCod INT NOT NULL,"
"UsrCod INT NOT NULL," "UsrCod INT NOT NULL,"
"DisableTime DATETIME NOT NULL," "DisableTime DATETIME NOT NULL,"
"UNIQUE INDEX(PstCod))"); "UNIQUE INDEX(PstCod))");
/***** Table forum_post *****/ /***** Table for_posts *****/
/* /*
mysql> DESCRIBE forum_post; mysql> DESCRIBE for_posts;
+-----------+----------+------+-----+---------+----------------+ +-----------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+----------------+ +-----------+----------+------+-----+---------+----------------+
@ -1471,7 +1471,7 @@ mysql> DESCRIBE forum_post;
+-----------+----------+------+-----+---------+----------------+ +-----------+----------+------+-----+---------+----------------+
9 rows in set (0.00 sec) 9 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS forum_post (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS for_posts ("
"PstCod INT NOT NULL AUTO_INCREMENT," "PstCod INT NOT NULL AUTO_INCREMENT,"
"ThrCod INT NOT NULL," "ThrCod INT NOT NULL,"
"UsrCod INT NOT NULL," "UsrCod INT NOT NULL,"

View File

@ -501,7 +501,9 @@ static bool For_GetIfForumPstExists (long PstCod)
{ {
/***** Get if a forum post exists from database *****/ /***** Get if a forum post exists from database *****/
return (DB_QueryCOUNT ("can not check if a post of a forum already existed", return (DB_QueryCOUNT ("can not check if a post of a forum already existed",
"SELECT COUNT(*) FROM forum_post WHERE PstCod=%ld", "SELECT COUNT(*)"
" FROM for_posts"
" WHERE PstCod=%ld",
PstCod) != 0); // Post exists if it appears in table of forum posts PstCod) != 0); // Post exists if it appears in table of forum posts
} }
@ -514,7 +516,8 @@ static bool For_GetIfPstIsEnabled (long PstCod)
if (PstCod > 0) if (PstCod > 0)
/***** Get if post is disabled from database *****/ /***** Get if post is disabled from database *****/
return (DB_QueryCOUNT ("can not check if a post of a forum is disabled", return (DB_QueryCOUNT ("can not check if a post of a forum is disabled",
"SELECT COUNT(*) FROM forum_disabled_post" "SELECT COUNT(*)"
" FROM for_disabled_posts"
" WHERE PstCod=%ld", " WHERE PstCod=%ld",
PstCod) == 0); // Post is enabled if it does not appear in table of disabled posts PstCod) == 0); // Post is enabled if it does not appear in table of disabled posts
else else
@ -529,7 +532,8 @@ static void For_DeletePstFromDisabledPstTable (long PstCod)
{ {
/***** Remove post from disabled posts table *****/ /***** Remove post from disabled posts table *****/
DB_QueryDELETE ("can not unban a post of a forum", DB_QueryDELETE ("can not unban a post of a forum",
"DELETE FROM forum_disabled_post WHERE PstCod=%ld", "DELETE FROM for_disabled_posts"
" WHERE PstCod=%ld",
PstCod); PstCod);
} }
@ -541,7 +545,7 @@ static void For_InsertPstIntoBannedPstTable (long PstCod)
{ {
/***** Remove post from banned posts table *****/ /***** Remove post from banned posts table *****/
DB_QueryREPLACE ("can not ban a post of a forum", DB_QueryREPLACE ("can not ban a post of a forum",
"REPLACE INTO forum_disabled_post" "REPLACE INTO for_disabled_posts"
" (PstCod,UsrCod,DisableTime)" " (PstCod,UsrCod,DisableTime)"
" VALUES" " VALUES"
" (%ld,%ld,NOW())", " (%ld,%ld,NOW())",
@ -564,7 +568,7 @@ static long For_InsertForumPst (long ThrCod,long UsrCod,
/***** Insert forum post in the database *****/ /***** Insert forum post in the database *****/
PstCod = PstCod =
DB_QueryINSERTandReturnCode ("can not create a new post in a forum", DB_QueryINSERTandReturnCode ("can not create a new post in a forum",
"INSERT INTO forum_post" "INSERT INTO for_posts"
" (ThrCod,UsrCod,CreatTime,ModifTime,NumNotif," " (ThrCod,UsrCod,CreatTime,ModifTime,NumNotif,"
"Subject,Content,MedCod)" "Subject,Content,MedCod)"
" VALUES" " VALUES"
@ -598,7 +602,8 @@ static bool For_RemoveForumPst (long PstCod,long MedCod)
/***** Delete post from forum post table *****/ /***** Delete post from forum post table *****/
DB_QueryDELETE ("can not remove a post from a forum", DB_QueryDELETE ("can not remove a post from a forum",
"DELETE FROM forum_post WHERE PstCod=%ld", "DELETE FROM for_posts"
" WHERE PstCod=%ld",
PstCod); PstCod);
/***** Delete the post from the table of disabled forum posts *****/ /***** Delete the post from the table of disabled forum posts *****/
@ -633,9 +638,11 @@ static unsigned For_NumPstsInThrWithPstCod (long PstCod,long *ThrCod)
if (DB_QuerySELECT (&mysql_res,"can not get number of posts in a thread", if (DB_QuerySELECT (&mysql_res,"can not get number of posts in a thread",
"SELECT COUNT(PstCod)," // row[0] "SELECT COUNT(PstCod)," // row[0]
"ThrCod" // row[1] "ThrCod" // row[1]
" FROM forum_post" " FROM for_posts"
" WHERE ThrCod IN" " WHERE ThrCod IN"
" (SELECT ThrCod FROM forum_post WHERE PstCod=%ld)" " (SELECT ThrCod"
" FROM for_posts"
" WHERE PstCod=%ld)"
" GROUP BY ThrCod;", " GROUP BY ThrCod;",
PstCod) == 1) // Result should have one row PstCod) == 1) // Result should have one row
{ {
@ -696,15 +703,17 @@ static void For_RemoveThreadAndItsPsts (long ThrCod)
{ {
/***** Delete banned posts in thread *****/ /***** Delete banned posts in thread *****/
DB_QueryDELETE ("can not unban the posts of a thread of a forum", DB_QueryDELETE ("can not unban the posts of a thread of a forum",
"DELETE forum_disabled_post" "DELETE FROM for_disabled_posts"
" FROM forum_post,forum_disabled_post" "USING for_posts,"
" WHERE forum_post.ThrCod=%ld" "for_disabled_posts"
" AND forum_post.PstCod=forum_disabled_post.PstCod", " WHERE for_posts.ThrCod=%ld"
" AND for_posts.PstCod=for_disabled_posts.PstCod",
ThrCod); ThrCod);
/***** Delete thread posts *****/ /***** Delete thread posts *****/
DB_QueryDELETE ("can not remove the posts of a thread of a forum", DB_QueryDELETE ("can not remove the posts of a thread of a forum",
"DELETE FROM forum_post WHERE ThrCod=%ld", "DELETE FROM for_posts"
" WHERE ThrCod=%ld",
ThrCod); ThrCod);
/***** Delete thread from forum thread table *****/ /***** Delete thread from forum thread table *****/
@ -723,9 +732,11 @@ static void For_GetThrSubject (long ThrCod,char Subject[Cns_MAX_BYTES_SUBJECT +
/***** Get subject of a thread from database *****/ /***** Get subject of a thread from database *****/
DB_QuerySELECT (&mysql_res,"can not get the subject" DB_QuerySELECT (&mysql_res,"can not get the subject"
" of a thread of a forum", " of a thread of a forum",
"SELECT forum_post.Subject FROM forum_thread,forum_post" "SELECT for_posts.Subject"
" FROM forum_thread,"
"for_posts"
" WHERE forum_thread.ThrCod=%ld" " WHERE forum_thread.ThrCod=%ld"
" AND forum_thread.FirstPstCod=forum_post.PstCod", " AND forum_thread.FirstPstCod=for_posts.PstCod",
ThrCod); ThrCod);
/***** Write the subject of the thread *****/ /***** Write the subject of the thread *****/
@ -753,10 +764,12 @@ void For_GetForumTypeAndLocationOfAPost (long PstCod,struct For_Forum *Forum)
/***** Check if there is a row with forum type *****/ /***** Check if there is a row with forum type *****/
if (DB_QuerySELECT (&mysql_res,"can not get forum type and location", if (DB_QuerySELECT (&mysql_res,"can not get forum type and location",
"SELECT forum_thread.ForumType,forum_thread.Location" "SELECT forum_thread.ForumType," // row[0]
" FROM forum_post,forum_thread" "forum_thread.Location" // row[1]
" WHERE forum_post.PstCod=%ld" " FROM for_posts,"
" AND forum_post.ThrCod=forum_thread.ThrCod", "forum_thread"
" WHERE for_posts.PstCod=%ld"
" AND for_posts.ThrCod=forum_thread.ThrCod",
PstCod)) PstCod))
{ {
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
@ -814,8 +827,11 @@ static long For_GetLastPstCod (long ThrCod)
/***** Get the code of the last post of a thread from database *****/ /***** Get the code of the last post of a thread from database *****/
DB_QuerySELECT (&mysql_res,"can not get the most recent post" DB_QuerySELECT (&mysql_res,"can not get the most recent post"
" of a thread of a forum", " of a thread of a forum",
"SELECT PstCod FROM forum_post" "SELECT PstCod"
" WHERE ThrCod=%ld ORDER BY CreatTime DESC LIMIT 1", " FROM for_posts"
" WHERE ThrCod=%ld"
" ORDER BY CreatTime DESC"
" LIMIT 1",
ThrCod); ThrCod);
/***** Write the subject of the thread *****/ /***** Write the subject of the thread *****/
@ -877,7 +893,8 @@ static unsigned For_GetNumOfWritersInThr (long ThrCod)
/***** Get number of distinct writers in a thread from database *****/ /***** Get number of distinct writers in a thread from database *****/
DB_QuerySELECT (&mysql_res,"can not get the number of writers" DB_QuerySELECT (&mysql_res,"can not get the number of writers"
" in a thread of a forum", " in a thread of a forum",
"SELECT COUNT(DISTINCT UsrCod) FROM forum_post" "SELECT COUNT(DISTINCT UsrCod)"
" FROM for_posts"
" WHERE ThrCod=%ld", " WHERE ThrCod=%ld",
ThrCod); ThrCod);
@ -904,7 +921,8 @@ static unsigned For_GetNumPstsInThr (long ThrCod)
return return
(unsigned) DB_QueryCOUNT ("can not get the number of posts" (unsigned) DB_QueryCOUNT ("can not get the number of posts"
" in a thread of a forum", " in a thread of a forum",
"SELECT COUNT(*) FROM forum_post" "SELECT COUNT(*)"
" FROM for_posts"
" WHERE ThrCod=%ld", " WHERE ThrCod=%ld",
ThrCod); ThrCod);
} }
@ -919,8 +937,10 @@ static unsigned For_GetNumMyPstInThr (long ThrCod)
return return
(unsigned) DB_QueryCOUNT ("can not check if you have written" (unsigned) DB_QueryCOUNT ("can not check if you have written"
" posts in a thead of a forum", " posts in a thead of a forum",
"SELECT COUNT(*) FROM forum_post" "SELECT COUNT(*)"
" WHERE ThrCod=%ld AND UsrCod=%ld", " FROM for_posts"
" WHERE ThrCod=%ld"
" AND UsrCod=%ld",
ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod); ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod);
} }
@ -932,7 +952,8 @@ unsigned long For_GetNumPostsUsr (long UsrCod)
{ {
/***** Get number of posts from a user from database *****/ /***** Get number of posts from a user from database *****/
return DB_QueryCOUNT ("can not get number of forum posts from a user", return DB_QueryCOUNT ("can not get number of forum posts from a user",
"SELECT COUNT(*) FROM forum_post" "SELECT COUNT(*)"
" FROM for_posts"
" WHERE UsrCod=%ld", " WHERE UsrCod=%ld",
UsrCod); UsrCod);
} }
@ -1048,9 +1069,11 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
/***** Get posts of a thread from database *****/ /***** Get posts of a thread from database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get posts of a thread", NumRows = DB_QuerySELECT (&mysql_res,"can not get posts of a thread",
"SELECT PstCod,UNIX_TIMESTAMP(CreatTime)" "SELECT PstCod," // row[0]
" FROM forum_post" "UNIX_TIMESTAMP(CreatTime)" // row[1]
" WHERE ThrCod=%ld ORDER BY PstCod", " FROM for_posts"
" WHERE ThrCod=%ld"
" ORDER BY PstCod",
Thread.ThrCod); Thread.ThrCod);
NumPsts = (unsigned) NumRows; NumPsts = (unsigned) NumRows;
@ -1365,7 +1388,8 @@ static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
"Subject," // row[2] "Subject," // row[2]
"Content," // row[3] "Content," // row[3]
"MedCod" // row[4] "MedCod" // row[4]
" FROM forum_post WHERE PstCod=%ld", " FROM for_posts"
" WHERE PstCod=%ld",
PstCod); PstCod);
/***** Result should have a unique row *****/ /***** Result should have a unique row *****/
@ -1411,8 +1435,9 @@ void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1
if (DB_QuerySELECT (&mysql_res,"can not get subject and content", if (DB_QuerySELECT (&mysql_res,"can not get subject and content",
"SELECT Subject," // row[0] "SELECT Subject," // row[0]
"Content" // row[1] "Content" // row[1]
" FROM forum_post" " FROM for_posts"
" WHERE PstCod=%ld",PstCod) == 1) " WHERE PstCod=%ld",
PstCod) == 1)
{ {
/***** Get subject and content of the post *****/ /***** Get subject and content of the post *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
@ -1462,10 +1487,12 @@ static void For_WriteNumberOfPosts (const struct For_Forums *Forums,long UsrCod)
NumPsts = NumPsts =
(unsigned) DB_QueryCOUNT ("can not get the number of posts of a user" (unsigned) DB_QueryCOUNT ("can not get the number of posts of a user"
" in a forum", " in a forum",
"SELECT COUNT(*) FROM forum_post,forum_thread" "SELECT COUNT(*)"
" WHERE forum_post.UsrCod=%ld" " FROM for_posts,"
" AND forum_post.ThrCod=forum_thread.ThrCod" "forum_thread"
" AND forum_thread.ForumType=%u%s", " WHERE for_posts.UsrCod=%ld"
" AND for_posts.ThrCod=forum_thread.ThrCod"
" AND forum_thread.ForumType=%u%s",
UsrCod, UsrCod,
(unsigned) Forums->Forum.Type,SubQuery); (unsigned) Forums->Forum.Type,SubQuery);
@ -2313,13 +2340,18 @@ static unsigned For_GetNumOfThreadsInForumNewerThan (const struct For_Forum *For
sprintf (SubQuery," AND forum_thread.Location=%ld",Forum->Location); sprintf (SubQuery," AND forum_thread.Location=%ld",Forum->Location);
else else
SubQuery[0] = '\0'; SubQuery[0] = '\0';
return return (unsigned)
(unsigned) DB_QueryCOUNT ("can not check if there are new posts in a forum", DB_QueryCOUNT ("can not check if there are new posts in a forum",
"SELECT COUNT(*) FROM forum_thread,forum_post" "SELECT COUNT(*)"
" WHERE forum_thread.ForumType=%u%s" " FROM forum_thread,"
" AND forum_thread.LastPstCod=forum_post.PstCod" "for_posts"
" AND forum_post.ModifTime>'%s'", " WHERE forum_thread.ForumType=%u"
(unsigned) Forum->Type,SubQuery,Time); "%s"
" AND forum_thread.LastPstCod=for_posts.PstCod"
" AND for_posts.ModifTime>'%s'",
(unsigned) Forum->Type,
SubQuery,
Time);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2364,8 +2396,10 @@ static unsigned For_GetNumOfPostsInThrNewerThan (long ThrCod,const char *Time)
return return
(unsigned) DB_QueryCOUNT ("can not check if there are new posts" (unsigned) DB_QueryCOUNT ("can not check if there are new posts"
" in a thread of a forum", " in a thread of a forum",
"SELECT COUNT(*) FROM forum_post" "SELECT COUNT(*)"
" WHERE ThrCod=%ld AND ModifTime>'%s'", " FROM for_posts"
" WHERE ThrCod=%ld"
" AND ModifTime>'%s'",
ThrCod,Time); ThrCod,Time);
} }
@ -2446,20 +2480,22 @@ static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums
{ {
case Dat_START_TIME: // First post time case Dat_START_TIME: // First post time
NumThrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get thread of a forum", NumThrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get thread of a forum",
"SELECT forum_thread.ThrCod" "SELECT forum_thread.ThrCod" // row[0]
" FROM forum_thread,forum_post" " FROM forum_thread,"
"for_posts"
" WHERE forum_thread.ForumType=%u%s" " WHERE forum_thread.ForumType=%u%s"
" AND forum_thread.FirstPstCod=forum_post.PstCod" " AND forum_thread.FirstPstCod=for_posts.PstCod"
" ORDER BY forum_post.CreatTime DESC", " ORDER BY for_posts.CreatTime DESC",
(unsigned) Forums->Forum.Type,SubQuery); (unsigned) Forums->Forum.Type,SubQuery);
break; break;
case Dat_END_TIME: // Last post time case Dat_END_TIME: // Last post time
NumThrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get thread of a forum", NumThrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get thread of a forum",
"SELECT forum_thread.ThrCod" "SELECT forum_thread.ThrCod" // row[0]
" FROM forum_thread,forum_post" " FROM forum_thread,"
"for_posts"
" WHERE forum_thread.ForumType=%u%s" " WHERE forum_thread.ForumType=%u%s"
" AND forum_thread.LastPstCod=forum_post.PstCod" " AND forum_thread.LastPstCod=for_posts.PstCod"
" ORDER BY forum_post.CreatTime DESC", " ORDER BY for_posts.CreatTime DESC",
(unsigned) Forums->Forum.Type,SubQuery); (unsigned) Forums->Forum.Type,SubQuery);
break; break;
default: // Impossible default: // Impossible
@ -3117,48 +3153,48 @@ unsigned For_GetNumTotalPstsInForumsOfType (For_ForumType_t ForumType,
// Total number of posts in forums of this type // Total number of posts in forums of this type
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"forum_post " "for_posts "
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType); (unsigned) ForumType);
break; break;
case For_FORUM_INSTIT_USRS: case For_FORUM_INSTIT_TCHS: case For_FORUM_INSTIT_USRS: case For_FORUM_INSTIT_TCHS:
if (InsCod > 0) // InsCod > 0 ==> Number of posts in institutions forums for an institution if (InsCod > 0) // InsCod > 0 ==> Number of posts in institutions forums for an institution
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"forum_post" "for_posts"
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=%ld" " AND forum_thread.Location=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,InsCod); (unsigned) ForumType,InsCod);
else if (CtyCod > 0) // InsCod <= 0 && CtyCod > 0 ==> Number of posts in institutions forums for a country else if (CtyCod > 0) // InsCod <= 0 && CtyCod > 0 ==> Number of posts in institutions forums for a country
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"ins_instits," "ins_instits,"
"forum_post" "for_posts"
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=ins_instits.InsCod" " AND forum_thread.Location=ins_instits.InsCod"
" AND ins_instits.CtyCod=%ld" " AND ins_instits.CtyCod=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,CtyCod); (unsigned) ForumType,CtyCod);
else // InsCod <= 0 ==> Number of posts in institution forums for the whole platform else // InsCod <= 0 ==> Number of posts in institution forums for the whole platform
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"forum_post " "for_posts "
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType); (unsigned) ForumType);
break; break;
case For_FORUM_CENTER_USRS: case For_FORUM_CENTER_USRS:
@ -3166,51 +3202,51 @@ unsigned For_GetNumTotalPstsInForumsOfType (For_ForumType_t ForumType,
if (CtrCod > 0) // CtrCod > 0 ==> Number of posts in center forums for a center if (CtrCod > 0) // CtrCod > 0 ==> Number of posts in center forums for a center
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"forum_post" "for_posts"
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=%ld" " AND forum_thread.Location=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,CtrCod); (unsigned) ForumType,CtrCod);
else if (InsCod > 0) // CtrCod <= 0 && InsCod > 0 ==> Number of posts in center forums for an institution else if (InsCod > 0) // CtrCod <= 0 && InsCod > 0 ==> Number of posts in center forums for an institution
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"ctr_centers," "ctr_centers,"
"forum_post" "for_posts"
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=ctr_centers.CtrCod" " AND forum_thread.Location=ctr_centers.CtrCod"
" AND ctr_centers.InsCod=%ld" " AND ctr_centers.InsCod=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,InsCod); (unsigned) ForumType,InsCod);
else if (CtyCod > 0) // InsCod <= 0 && CtyCod > 0 ==> Number of posts in center forums for a country else if (CtyCod > 0) // InsCod <= 0 && CtyCod > 0 ==> Number of posts in center forums for a country
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"ctr_centers," "ctr_centers,"
"ins_instits," "ins_instits,"
"forum_post" "for_posts"
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=ctr_centers.CtrCod" " AND forum_thread.Location=ctr_centers.CtrCod"
" AND ctr_centers.InsCod=ins_instits.InsCod" " AND ctr_centers.InsCod=ins_instits.InsCod"
" AND ins_instits.CtyCod=%ld" " AND ins_instits.CtyCod=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,CtyCod); (unsigned) ForumType,CtyCod);
else // InsCod <= 0 ==> Number of posts in center forums for the whole platform else // InsCod <= 0 ==> Number of posts in center forums for the whole platform
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"forum_post" "for_posts"
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType); (unsigned) ForumType);
break; break;
case For_FORUM_DEGREE_USRS: case For_FORUM_DEGREE_USRS:
@ -3218,68 +3254,68 @@ unsigned For_GetNumTotalPstsInForumsOfType (For_ForumType_t ForumType,
if (DegCod > 0) // DegCod > 0 ==> Number of posts in degree forums for a degree if (DegCod > 0) // DegCod > 0 ==> Number of posts in degree forums for a degree
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"forum_post" "for_posts"
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=%ld" " AND forum_thread.Location=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,DegCod); (unsigned) ForumType,DegCod);
else if (CtrCod > 0) // DegCod <= 0 && CtrCod > 0 ==> Number of posts in degree forums for a center else if (CtrCod > 0) // DegCod <= 0 && CtrCod > 0 ==> Number of posts in degree forums for a center
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"deg_degrees," "deg_degrees,"
"forum_post" "for_posts"
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=deg_degrees.DegCod" " AND forum_thread.Location=deg_degrees.DegCod"
" AND deg_degrees.CtrCod=%ld" " AND deg_degrees.CtrCod=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,CtrCod); (unsigned) ForumType,CtrCod);
else if (InsCod > 0) // CtrCod <= 0 && InsCod > 0 ==> Number of posts in degree forums for an institution else if (InsCod > 0) // CtrCod <= 0 && InsCod > 0 ==> Number of posts in degree forums for an institution
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"deg_degrees," "deg_degrees,"
"ctr_centers," "ctr_centers,"
"forum_post" "for_posts"
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=deg_degrees.DegCod" " AND forum_thread.Location=deg_degrees.DegCod"
" AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod"
" AND ctr_centers.InsCod=%ld" " AND ctr_centers.InsCod=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,InsCod); (unsigned) ForumType,InsCod);
else if (CtyCod > 0) // InsCod <= 0 && CtyCod > 0 ==> Number of posts in degree forums for a country else if (CtyCod > 0) // InsCod <= 0 && CtyCod > 0 ==> Number of posts in degree forums for a country
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"deg_degrees," "deg_degrees,"
"ctr_centers," "ctr_centers,"
"ins_instits," "ins_instits,"
"forum_post" "for_posts"
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=deg_degrees.DegCod" " AND forum_thread.Location=deg_degrees.DegCod"
" AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod"
" AND ctr_centers.InsCod=ins_instits.InsCod" " AND ctr_centers.InsCod=ins_instits.InsCod"
" AND ins_instits.CtyCod=%ld" " AND ins_instits.CtyCod=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,CtyCod); (unsigned) ForumType,CtyCod);
else // InsCod <= 0 ==> Number of posts in degree forums for the whole platform else // InsCod <= 0 ==> Number of posts in degree forums for the whole platform
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"forum_post " "for_posts "
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType); (unsigned) ForumType);
break; break;
case For_FORUM_COURSE_USRS: case For_FORUM_COURSE_USRS:
@ -3287,87 +3323,87 @@ unsigned For_GetNumTotalPstsInForumsOfType (For_ForumType_t ForumType,
if (CrsCod > 0) // CrsCod > 0 ==> 0 <= number of posts in course forums for a course if (CrsCod > 0) // CrsCod > 0 ==> 0 <= number of posts in course forums for a course
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"forum_post " "for_posts "
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=%ld" " AND forum_thread.Location=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,CrsCod); (unsigned) ForumType,CrsCod);
else if (DegCod > 0) // CrsCod <= 0 && DegCod > 0 ==> Number of posts in course forums for a degree else if (DegCod > 0) // CrsCod <= 0 && DegCod > 0 ==> Number of posts in course forums for a degree
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"crs_courses," "crs_courses,"
"forum_post " "for_posts "
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=crs_courses.CrsCod" " AND forum_thread.Location=crs_courses.CrsCod"
" AND crs_courses.DegCod=%ld" " AND crs_courses.DegCod=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,DegCod); (unsigned) ForumType,DegCod);
else if (CtrCod > 0) // DegCod <= 0 && CtrCod > 0 ==> Number of posts in course forums for a center else if (CtrCod > 0) // DegCod <= 0 && CtrCod > 0 ==> Number of posts in course forums for a center
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"crs_courses," "crs_courses,"
"deg_degrees," "deg_degrees,"
"forum_post " "for_posts "
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=crs_courses.CrsCod" " AND forum_thread.Location=crs_courses.CrsCod"
" AND crs_courses.DegCod=deg_degrees.DegCod" " AND crs_courses.DegCod=deg_degrees.DegCod"
" AND deg_degrees.CtrCod=%ld" " AND deg_degrees.CtrCod=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,CtrCod); (unsigned) ForumType,CtrCod);
else if (InsCod > 0) // CtrCod <= 0 && InsCod > 0 ==> Number of posts in course forums for an institution else if (InsCod > 0) // CtrCod <= 0 && InsCod > 0 ==> Number of posts in course forums for an institution
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"crs_courses," "crs_courses,"
"deg_degrees," "deg_degrees,"
"ctr_centers," "ctr_centers,"
"forum_post" "for_posts"
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=crs_courses.CrsCod" " AND forum_thread.Location=crs_courses.CrsCod"
" AND crs_courses.DegCod=deg_degrees.DegCod" " AND crs_courses.DegCod=deg_degrees.DegCod"
" AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod"
" AND ctr_centers.InsCod=%ld" " AND ctr_centers.InsCod=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,InsCod); (unsigned) ForumType,InsCod);
else if (CtyCod > 0) // InsCod <= 0 && CtyCod > 0 ==> Number of posts in course forums for a country else if (CtyCod > 0) // InsCod <= 0 && CtyCod > 0 ==> Number of posts in course forums for a country
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"crs_courses," "crs_courses,"
"deg_degrees," "deg_degrees,"
"ctr_centers," "ctr_centers,"
"ins_instits," "ins_instits,"
"forum_post" "for_posts"
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.Location=crs_courses.CrsCod" " AND forum_thread.Location=crs_courses.CrsCod"
" AND crs_courses.DegCod=deg_degrees.DegCod" " AND crs_courses.DegCod=deg_degrees.DegCod"
" AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod"
" AND ctr_centers.InsCod=ins_instits.InsCod" " AND ctr_centers.InsCod=ins_instits.InsCod"
" AND ins_instits.CtyCod=%ld" " AND ins_instits.CtyCod=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType,CtyCod); (unsigned) ForumType,CtyCod);
else // CrsCod <= 0 && DegCod <= 0 && CtrCod <= 0 ==> Number of posts in course forums for the whole platform else // CrsCod <= 0 && DegCod <= 0 && CtrCod <= 0 ==> Number of posts in course forums for the whole platform
DB_QuerySELECT (&mysql_res,"can not get the total number" DB_QuerySELECT (&mysql_res,"can not get the total number"
" of forums of a type", " of forums of a type",
"SELECT COUNT(*)," "SELECT COUNT(*)," // row[0]
"SUM(forum_post.NumNotif)" "SUM(for_posts.NumNotif)" // row[1]
" FROM forum_thread," " FROM forum_thread,"
"forum_post " "for_posts "
" WHERE forum_thread.ForumType=%u" " WHERE forum_thread.ForumType=%u"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
(unsigned) ForumType); (unsigned) ForumType);
break; break;
default: default:
@ -3590,14 +3626,19 @@ static void For_GetThreadData (struct For_Thread *Thr)
/***** Get data of a thread from database *****/ /***** Get data of a thread from database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get data" NumRows = DB_QuerySELECT (&mysql_res,"can not get data"
" of a thread of a forum", " of a thread of a forum",
"SELECT m0.PstCod,m1.PstCod,m0.UsrCod,m1.UsrCod," "SELECT m0.PstCod,"
"UNIX_TIMESTAMP(m0.CreatTime)," "m1.PstCod,"
"UNIX_TIMESTAMP(m1.CreatTime)," "m0.UsrCod,"
"m0.Subject" "m1.UsrCod,"
" FROM forum_thread,forum_post AS m0,forum_post AS m1" "UNIX_TIMESTAMP(m0.CreatTime),"
"UNIX_TIMESTAMP(m1.CreatTime),"
"m0.Subject"
" FROM forum_thread,"
"for_posts AS m0,"
"for_posts AS m1"
" WHERE forum_thread.ThrCod=%ld" " WHERE forum_thread.ThrCod=%ld"
" AND forum_thread.FirstPstCod=m0.PstCod" " AND forum_thread.FirstPstCod=m0.PstCod"
" AND forum_thread.LastPstCod=m1.PstCod", " AND forum_thread.LastPstCod=m1.PstCod",
Thr->ThrCod); Thr->ThrCod);
/***** The result of the query should have one row *****/ /***** The result of the query should have one row *****/
@ -4152,7 +4193,8 @@ static void For_UpdateNumUsrsNotifiedByEMailAboutPost (long PstCod,unsigned NumU
{ {
/***** Update number of users notified *****/ /***** Update number of users notified *****/
DB_QueryUPDATE ("can not update the number of notifications of a post", DB_QueryUPDATE ("can not update the number of notifications of a post",
"UPDATE forum_post SET NumNotif=NumNotif+%u" "UPDATE for_posts"
" SET NumNotif=NumNotif+%u"
" WHERE PstCod=%ld", " WHERE PstCod=%ld",
NumUsrsToBeNotifiedByEMail,PstCod); NumUsrsToBeNotifiedByEMail,PstCod);
} }
@ -4640,29 +4682,32 @@ void For_RemoveForums (Hie_Lvl_Level_t Scope,long ForumLocation)
/***** Remove disabled posts *****/ /***** Remove disabled posts *****/
DB_QueryDELETE ("can not remove the disabled posts in forums", DB_QueryDELETE ("can not remove the disabled posts in forums",
"DELETE FROM forum_disabled_post" "DELETE FROM for_disabled_posts"
" USING forum_thread,forum_post,forum_disabled_post" " USING forum_thread,"
"for_posts,"
"for_disabled_posts"
" WHERE" " WHERE"
" (forum_thread.ForumType=%u" " (forum_thread.ForumType=%u"
" OR" " OR"
" forum_thread.ForumType=%u)" " forum_thread.ForumType=%u)"
" AND forum_thread.Location=%ld" " AND forum_thread.Location=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod" " AND forum_thread.ThrCod=for_posts.ThrCod"
" AND forum_post.PstCod=forum_disabled_post.PstCod", " AND for_posts.PstCod=for_disabled_posts.PstCod",
ForumType[Scope].Usrs, ForumType[Scope].Usrs,
ForumType[Scope].Tchs, ForumType[Scope].Tchs,
ForumLocation); ForumLocation);
/***** Remove posts *****/ /***** Remove posts *****/
DB_QueryDELETE ("can not remove posts in forums", DB_QueryDELETE ("can not remove posts in forums",
"DELETE FROM forum_post" "DELETE FROM for_posts"
" USING forum_thread,forum_post" " USING forum_thread,"
"for_posts"
" WHERE" " WHERE"
" (forum_thread.ForumType=%u" " (forum_thread.ForumType=%u"
" OR" " OR"
" forum_thread.ForumType=%u)" " forum_thread.ForumType=%u)"
" AND forum_thread.Location=%ld" " AND forum_thread.Location=%ld"
" AND forum_thread.ThrCod=forum_post.ThrCod", " AND forum_thread.ThrCod=for_posts.ThrCod",
ForumType[Scope].Usrs, ForumType[Scope].Usrs,
ForumType[Scope].Tchs, ForumType[Scope].Tchs,
ForumLocation); ForumLocation);

View File

@ -1350,9 +1350,11 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
case Ntf_EVENT_FORUM_REPLY: case Ntf_EVENT_FORUM_REPLY:
NumRows = DB_QuerySELECT (&mysql_res,"can not get users" NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified", " to be notified",
"SELECT DISTINCT(UsrCod) FROM forum_post" "SELECT DISTINCT(UsrCod)"
" WHERE ThrCod = (SELECT ThrCod FROM forum_post" " FROM for_posts"
" WHERE PstCod=%ld)" " WHERE ThrCod = (SELECT ThrCod"
" FROM for_posts"
" WHERE PstCod=%ld)"
" AND UsrCod<>%ld", " AND UsrCod<>%ld",
Cod,Gbl.Usrs.Me.UsrDat.UsrCod); Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
break; break;