Version19.183.1

This commit is contained in:
acanas 2020-04-14 00:11:28 +02:00
parent a03e10b543
commit ce307b0d6b
5 changed files with 90 additions and 103 deletions

View File

@ -497,7 +497,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD: En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 19.183 (2020-04-13)" #define Log_PLATFORM_VERSION "SWAD 19.183.1 (2020-04-14)"
#define CSS_FILE "swad19.146.css" #define CSS_FILE "swad19.146.css"
#define JS_FILE "swad19.172.1.js" #define JS_FILE "swad19.172.1.js"
/* /*
@ -548,6 +548,7 @@ Funci
// TODO: Oresti Baños: cambiar ojos por candados en descriptores para prohibir/permitir y dejar los ojos para poder elegir descriptores // TODO: Oresti Baños: cambiar ojos por candados en descriptores para prohibir/permitir y dejar los ojos para poder elegir descriptores
// TODO: Integrar pull requests con traducciones del alemán del usuario eruedin en GitHub // TODO: Integrar pull requests con traducciones del alemán del usuario eruedin en GitHub
Version 19.183.1: Apr 14, 2020 Fixed bug in forums, reported by Javier Fernández Baldomero. (285677 lines)
Version 19.183: Apr 13, 2020 Code refactoring in holidays. (285689 lines) Version 19.183: Apr 13, 2020 Code refactoring in holidays. (285689 lines)
Version 19.182: Apr 13, 2020 Code refactoring in places. (285685 lines) Version 19.182: Apr 13, 2020 Code refactoring in places. (285685 lines)
Version 19.181: Apr 13, 2020 Code refactoring in departments. (285667 lines) Version 19.181: Apr 13, 2020 Code refactoring in departments. (285667 lines)

View File

@ -413,36 +413,19 @@ static void For_RemoveThrCodFromThrClipboard (long ThrCod);
void For_ResetForums (struct For_Forums *Forums) void For_ResetForums (struct For_Forums *Forums)
{ {
Dat_StartEndTime_t StartEndTime; Forums->ForumSet = For_DEFAULT_FORUM_SET;
Forums->ThreadsOrder = For_DEFAULT_ORDER;
Forums->CurrentPageThrs = 0;
Forums->CurrentPagePsts = 0;
Forums->ForumSet = For_DEFAULT_FORUM_SET; Forums->Forum.Type = For_FORUM_UNKNOWN;
Forums->ThreadsOrder = For_DEFAULT_ORDER; Forums->Forum.Location = -1L;
Forums->CurrentPageThrs = 0;
Forums->CurrentPagePsts = 0;
Forums->Forum.Type = For_FORUM_UNKNOWN; Forums->ThrCod = -1L;
Forums->Forum.Location = -1L;
Forums->Thread.ThrCod = -1L; Forums->PstCod = -1L;
for (StartEndTime = (Dat_StartEndTime_t) 0;
StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
StartEndTime++)
{
Forums->Thread.PstCod[StartEndTime] = -1L;
Forums->Thread.UsrCod[StartEndTime] = -1L;
Forums->Thread.WriteTime[StartEndTime] = (time_t) 0;
Forums->Thread.Enabled[StartEndTime] = false;
}
Forums->Thread.Subject[0] = '\0';
Forums->Thread.NumPosts =
Forums->Thread.NumUnreadPosts =
Forums->Thread.NumMyPosts =
Forums->Thread.NumWriters =
Forums->Thread.NumReaders = 0;
Forums->Post.PstCod = -1L; Forums->ThreadToMove = -1L;
Forums->ThreadToMove = -1L;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -461,7 +444,7 @@ void For_EnablePost (void)
For_GetParamsForums (&Forums); For_GetParamsForums (&Forums);
/***** Delete post from table of disabled posts *****/ /***** Delete post from table of disabled posts *****/
For_DeletePstFromDisabledPstTable (Forums.Post.PstCod); For_DeletePstFromDisabledPstTable (Forums.PstCod);
/***** Show forum list again *****/ /***** Show forum list again *****/
For_ShowForumList (&Forums); For_ShowForumList (&Forums);
@ -486,10 +469,10 @@ void For_DisablePost (void)
For_GetParamsForums (&Forums); For_GetParamsForums (&Forums);
/***** Check if post really exists, if it has not been removed *****/ /***** Check if post really exists, if it has not been removed *****/
if (For_GetIfForumPstExists (Forums.Post.PstCod)) if (For_GetIfForumPstExists (Forums.PstCod))
{ {
/***** Insert post into table of banned posts *****/ /***** Insert post into table of banned posts *****/
For_InsertPstIntoBannedPstTable (Forums.Post.PstCod); For_InsertPstIntoBannedPstTable (Forums.PstCod);
/***** Show forum list again *****/ /***** Show forum list again *****/
For_ShowForumList (&Forums); For_ShowForumList (&Forums);
@ -1006,6 +989,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
{ {
extern const char *Hlp_MESSAGES_Forums_posts; extern const char *Hlp_MESSAGES_Forums_posts;
extern const char *Txt_Thread; extern const char *Txt_Thread;
struct For_Thread Thread;
char LastSubject[Cns_MAX_BYTES_SUBJECT + 1]; char LastSubject[Cns_MAX_BYTES_SUBJECT + 1];
char FrameTitle[128 + Cns_MAX_BYTES_SUBJECT]; char FrameTitle[128 + Cns_MAX_BYTES_SUBJECT];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -1022,14 +1006,15 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
bool ICanModerateForum = false; bool ICanModerateForum = false;
/***** Get data of the thread *****/ /***** Get data of the thread *****/
For_GetThreadData (&Forums->Thread); Thread.ThrCod = Forums->ThrCod;
For_GetThreadData (&Thread);
/***** Get if there is a thread ready to be moved *****/ /***** Get if there is a thread ready to be moved *****/
if (For_CheckIfICanMoveThreads ()) if (For_CheckIfICanMoveThreads ())
Forums->ThreadToMove = For_GetThrInMyClipboard (); Forums->ThreadToMove = For_GetThrInMyClipboard ();
/***** Get thread read time for the current user *****/ /***** Get thread read time for the current user *****/
ReadTimeUTC = For_GetThrReadTime (Forums->Thread.ThrCod); ReadTimeUTC = For_GetThrReadTime (Thread.ThrCod);
/***** Show alert after action *****/ /***** Show alert after action *****/
HTM_SECTION_Begin (For_FORUM_POSTS_SECTION_ID); HTM_SECTION_Begin (For_FORUM_POSTS_SECTION_ID);
@ -1041,7 +1026,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
/***** Begin box *****/ /***** Begin box *****/
snprintf (FrameTitle,sizeof (FrameTitle), snprintf (FrameTitle,sizeof (FrameTitle),
"%s: %s", "%s: %s",
Txt_Thread,Forums->Thread.Subject); Txt_Thread,Thread.Subject);
Box_BoxBegin (NULL,FrameTitle, Box_BoxBegin (NULL,FrameTitle,
For_PutIconNewPost,Forums, For_PutIconNewPost,Forums,
Hlp_MESSAGES_Forums_posts,Box_NOT_CLOSABLE); Hlp_MESSAGES_Forums_posts,Box_NOT_CLOSABLE);
@ -1051,7 +1036,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
"SELECT PstCod,UNIX_TIMESTAMP(CreatTime)" "SELECT PstCod,UNIX_TIMESTAMP(CreatTime)"
" FROM forum_post" " FROM forum_post"
" WHERE ThrCod=%ld ORDER BY PstCod", " WHERE ThrCod=%ld ORDER BY PstCod",
Forums->Thread.ThrCod); Thread.ThrCod);
NumPsts = (unsigned) NumRows; NumPsts = (unsigned) NumRows;
LastSubject[0] = '\0'; LastSubject[0] = '\0';
@ -1096,7 +1081,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
/***** Write links to pages *****/ /***** Write links to pages *****/
Pag_WriteLinksToPagesCentered (Pag_POSTS_FORUM,&PaginationPsts, Pag_WriteLinksToPagesCentered (Pag_POSTS_FORUM,&PaginationPsts,
Forums,Forums->Thread.ThrCod); Forums,Thread.ThrCod);
/***** Begin table *****/ /***** Begin table *****/
HTM_TABLE_BeginWidePadding (2); HTM_TABLE_BeginWidePadding (2);
@ -1124,7 +1109,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
Note that database is not updated with the current time, Note that database is not updated with the current time,
but with the creation time of the most recent post but with the creation time of the most recent post
in this page of threads. */ in this page of threads. */
For_UpdateThrReadTime (Forums->Thread.ThrCod, For_UpdateThrReadTime (Thread.ThrCod,
CreatTimeUTC); CreatTimeUTC);
/* Show post */ /* Show post */
@ -1144,7 +1129,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
default: default:
break; break;
} }
if (Forums->Thread.NumMyPosts) if (Thread.NumMyPosts)
Ntf_MarkNotifAsSeen (Ntf_EVENT_FORUM_REPLY, Ntf_MarkNotifAsSeen (Ntf_EVENT_FORUM_REPLY,
PstCod,-1L, PstCod,-1L,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod);
@ -1155,7 +1140,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
/***** Write again links to pages *****/ /***** Write again links to pages *****/
Pag_WriteLinksToPagesCentered (Pag_POSTS_FORUM,&PaginationPsts, Pag_WriteLinksToPagesCentered (Pag_POSTS_FORUM,&PaginationPsts,
Forums,Forums->Thread.ThrCod); Forums,Thread.ThrCod);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -1194,7 +1179,7 @@ static void For_PutAllHiddenParamsNewPost (void *Forums)
((struct For_Forums *) Forums)->ForumSet, ((struct For_Forums *) Forums)->ForumSet,
((struct For_Forums *) Forums)->ThreadsOrder, ((struct For_Forums *) Forums)->ThreadsOrder,
((struct For_Forums *) Forums)->Forum.Location, ((struct For_Forums *) Forums)->Forum.Location,
((struct For_Forums *) Forums)->Thread.ThrCod, ((struct For_Forums *) Forums)->ThrCod,
-1L); -1L);
} }
@ -1291,7 +1276,7 @@ static void For_ShowAForumPost (const struct For_Forums *Forums,
Forums->ForumSet, Forums->ForumSet,
Forums->ThreadsOrder, Forums->ThreadsOrder,
Forums->Forum.Location, Forums->Forum.Location,
Forums->Thread.ThrCod, Forums->ThrCod,
PstCod); PstCod);
Ico_PutIconLink (Enabled ? "eye-green.svg" : Ico_PutIconLink (Enabled ? "eye-green.svg" :
"eye-slash-red.svg", "eye-slash-red.svg",
@ -1330,7 +1315,7 @@ static void For_ShowAForumPost (const struct For_Forums *Forums,
Forums->ForumSet, Forums->ForumSet,
Forums->ThreadsOrder, Forums->ThreadsOrder,
Forums->Forum.Location, Forums->Forum.Location,
Forums->Thread.ThrCod, Forums->ThrCod,
PstCod); PstCod);
Ico_PutIconRemove (); Ico_PutIconRemove ();
Frm_EndForm (); Frm_EndForm ();
@ -2583,7 +2568,7 @@ static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums
HTM_TR_End (); HTM_TR_End ();
/***** List the threads *****/ /***** List the threads *****/
For_ListForumThrs (Forums,ThrCods,Forums->Thread.ThrCod,&PaginationThrs); For_ListForumThrs (Forums,ThrCods,Forums->ThrCod,&PaginationThrs);
/***** End table *****/ /***** End table *****/
HTM_TABLE_End (); HTM_TABLE_End ();
@ -3322,6 +3307,7 @@ static void For_ListForumThrs (struct For_Forums *Forums,
extern const char *Txt_No_new_posts; extern const char *Txt_No_new_posts;
unsigned NumThr; unsigned NumThr;
unsigned NumThrInScreen; // From 0 to Pag_ITEMS_PER_PAGE-1 unsigned NumThrInScreen; // From 0 to Pag_ITEMS_PER_PAGE-1
struct For_Thread Thr;
unsigned UniqueId; unsigned UniqueId;
char *Id; char *Id;
struct UsrData UsrDat; struct UsrData UsrDat;
@ -3341,24 +3327,24 @@ static void For_ListForumThrs (struct For_Forums *Forums,
/***** Initialize structure with user's data *****/ /***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat); Usr_UsrDataConstructor (&UsrDat);
for (NumThr = PaginationThrs->FirstItemVisible, NumThrInScreen = 0, UniqueId = 0, Gbl.RowEvenOdd = 0; for (NumThr = PaginationThrs->FirstItemVisible, NumThrInScreen = 0, UniqueId = 0, Gbl.RowEvenOdd = 0;
NumThr <= PaginationThrs->LastItemVisible; NumThr <= PaginationThrs->LastItemVisible;
NumThr++, NumThrInScreen++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd) NumThr++, NumThrInScreen++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd)
{ {
/***** Get the data of this thread *****/ /***** Get the data of this thread *****/
Forums->Thread.ThrCod = ThrCods[NumThrInScreen]; Thr.ThrCod = ThrCods[NumThrInScreen];
For_GetThreadData (&Forums->Thread); For_GetThreadData (&Thr);
Style = (Forums->Thread.NumUnreadPosts ? "AUTHOR_TXT_NEW" : Style = (Thr.NumUnreadPosts ? "AUTHOR_TXT_NEW" :
"AUTHOR_TXT"); "AUTHOR_TXT");
BgColor = (Forums->Thread.ThrCod == ThreadInMyClipboard) ? "LIGHT_GREEN" : BgColor = (Thr.ThrCod == ThreadInMyClipboard) ? "LIGHT_GREEN" :
((Forums->Thread.ThrCod == ThrCodHighlighted) ? "LIGHT_BLUE" : ((Thr.ThrCod == ThrCodHighlighted) ? "LIGHT_BLUE" :
Gbl.ColorRows[Gbl.RowEvenOdd]); Gbl.ColorRows[Gbl.RowEvenOdd]);
/***** Show my photo if I have any posts in this thread *****/ /***** Show my photo if I have any posts in this thread *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
HTM_TD_Begin ("class=\"BT %s\"",BgColor); HTM_TD_Begin ("class=\"BT %s\"",BgColor);
if (Forums->Thread.NumMyPosts) if (Thr.NumMyPosts)
HTM_IMG (Gbl.Usrs.Me.PhotoURL[0] ? Gbl.Usrs.Me.PhotoURL : HTM_IMG (Gbl.Usrs.Me.PhotoURL[0] ? Gbl.Usrs.Me.PhotoURL :
Cfg_URL_ICON_PUBLIC, Cfg_URL_ICON_PUBLIC,
Gbl.Usrs.Me.PhotoURL[0] ? NULL : Gbl.Usrs.Me.PhotoURL[0] ? NULL :
@ -3369,10 +3355,10 @@ static void For_ListForumThrs (struct For_Forums *Forums,
/***** Put an icon with thread status *****/ /***** Put an icon with thread status *****/
HTM_TD_Begin ("class=\"CONTEXT_COL %s\"",BgColor); HTM_TD_Begin ("class=\"CONTEXT_COL %s\"",BgColor);
Ico_PutIcon (Forums->Thread.NumUnreadPosts ? "envelope.svg" : Ico_PutIcon (Thr.NumUnreadPosts ? "envelope.svg" :
"envelope-open-text.svg", "envelope-open-text.svg",
Forums->Thread.NumUnreadPosts ? Txt_There_are_new_posts : Thr.NumUnreadPosts ? Txt_There_are_new_posts :
Txt_No_new_posts, Txt_No_new_posts,
"ICO16x16"); "ICO16x16");
/***** Put button to remove the thread *****/ /***** Put button to remove the thread *****/
@ -3387,7 +3373,7 @@ static void For_ListForumThrs (struct For_Forums *Forums,
Forums->ForumSet, Forums->ForumSet,
Forums->ThreadsOrder, Forums->ThreadsOrder,
Forums->Forum.Location, Forums->Forum.Location,
Forums->Thread.ThrCod, Thr.ThrCod,
-1L); -1L);
Ico_PutIconRemove (); Ico_PutIconRemove ();
Frm_EndForm (); Frm_EndForm ();
@ -3404,7 +3390,7 @@ static void For_ListForumThrs (struct For_Forums *Forums,
Forums->ForumSet, Forums->ForumSet,
Forums->ThreadsOrder, Forums->ThreadsOrder,
Forums->Forum.Location, Forums->Forum.Location,
Forums->Thread.ThrCod, Thr.ThrCod,
-1L); -1L);
Ico_PutIconCut (); Ico_PutIconCut ();
Frm_EndForm (); Frm_EndForm ();
@ -3414,17 +3400,17 @@ static void For_ListForumThrs (struct For_Forums *Forums,
/***** Write subject and links to thread pages *****/ /***** Write subject and links to thread pages *****/
HTM_TD_Begin ("class=\"LT %s\"",BgColor); HTM_TD_Begin ("class=\"LT %s\"",BgColor);
PaginationPsts.NumItems = Forums->Thread.NumPosts; PaginationPsts.NumItems = Thr.NumPosts;
PaginationPsts.CurrentPage = 1; // First page PaginationPsts.CurrentPage = 1; // First page
Pag_CalculatePagination (&PaginationPsts); Pag_CalculatePagination (&PaginationPsts);
PaginationPsts.Anchor = For_FORUM_POSTS_SECTION_ID; PaginationPsts.Anchor = For_FORUM_POSTS_SECTION_ID;
Pag_WriteLinksToPages (Pag_POSTS_FORUM, Pag_WriteLinksToPages (Pag_POSTS_FORUM,
&PaginationPsts, &PaginationPsts,
Forums,Forums->Thread.ThrCod, Forums,Thr.ThrCod,
Forums->Thread.Enabled[Dat_START_TIME], Thr.Enabled[Dat_START_TIME],
Forums->Thread.Subject, Thr.Subject,
Forums->Thread.NumUnreadPosts ? The_ClassFormInBoxBold[Gbl.Prefs.Theme] : Thr.NumUnreadPosts ? The_ClassFormInBoxBold[Gbl.Prefs.Theme] :
The_ClassFormInBox[Gbl.Prefs.Theme], The_ClassFormInBox[Gbl.Prefs.Theme],
true); true);
HTM_TD_End (); HTM_TD_End ();
@ -3433,17 +3419,17 @@ static void For_ListForumThrs (struct For_Forums *Forums,
Order <= Dat_END_TIME; Order <= Dat_END_TIME;
Order++) Order++)
{ {
if (Order == Dat_START_TIME || Forums->Thread.NumPosts > 1) // Don't write twice the same author when thread has only one thread if (Order == Dat_START_TIME || Thr.NumPosts > 1) // Don't write twice the same author when thread has only one thread
{ {
/* Write the author of first or last message */ /* Write the author of first or last message */
UsrDat.UsrCod = Forums->Thread.UsrCod[Order]; UsrDat.UsrCod = Thr.UsrCod[Order];
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS); Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS);
HTM_TD_Begin ("class=\"%s LT %s\"",Style,BgColor); HTM_TD_Begin ("class=\"%s LT %s\"",Style,BgColor);
Msg_WriteMsgAuthor (&UsrDat,Forums->Thread.Enabled[Order],BgColor); Msg_WriteMsgAuthor (&UsrDat,Thr.Enabled[Order],BgColor);
HTM_TD_End (); HTM_TD_End ();
/* Write the date of first or last message (it's in YYYYMMDDHHMMSS format) */ /* Write the date of first or last message (it's in YYYYMMDDHHMMSS format) */
TimeUTC = Forums->Thread.WriteTime[Order]; TimeUTC = Thr.WriteTime[Order];
UniqueId++; UniqueId++;
if (asprintf (&Id,"thr_date_%u",UniqueId) < 0) if (asprintf (&Id,"thr_date_%u",UniqueId) < 0)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
@ -3466,22 +3452,22 @@ static void For_ListForumThrs (struct For_Forums *Forums,
/***** Write number of posts in this thread *****/ /***** Write number of posts in this thread *****/
HTM_TD_Begin ("class=\"%s RT %s\"",Style,BgColor); HTM_TD_Begin ("class=\"%s RT %s\"",Style,BgColor);
HTM_TxtF ("%u&nbsp;",Forums->Thread.NumPosts); HTM_TxtF ("%u&nbsp;",Thr.NumPosts);
HTM_TD_End (); HTM_TD_End ();
/***** Write number of new posts in this thread *****/ /***** Write number of new posts in this thread *****/
HTM_TD_Begin ("class=\"%s RT %s\"",Style,BgColor); HTM_TD_Begin ("class=\"%s RT %s\"",Style,BgColor);
HTM_TxtF ("%u&nbsp;",Forums->Thread.NumUnreadPosts); HTM_TxtF ("%u&nbsp;",Thr.NumUnreadPosts);
HTM_TD_End (); HTM_TD_End ();
/***** Write number of users who have write posts in this thread *****/ /***** Write number of users who have write posts in this thread *****/
HTM_TD_Begin ("class=\"%s RT %s\"",Style,BgColor); HTM_TD_Begin ("class=\"%s RT %s\"",Style,BgColor);
HTM_TxtF ("%u&nbsp;",Forums->Thread.NumWriters); HTM_TxtF ("%u&nbsp;",Thr.NumWriters);
HTM_TD_End (); HTM_TD_End ();
/***** Write number of users who have read this thread *****/ /***** Write number of users who have read this thread *****/
HTM_TD_Begin ("class=\"%s RT %s\"",Style,BgColor); HTM_TD_Begin ("class=\"%s RT %s\"",Style,BgColor);
HTM_TxtF ("%u&nbsp;",Forums->Thread.NumReaders); HTM_TxtF ("%u&nbsp;",Thr.NumReaders);
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
@ -3633,10 +3619,10 @@ static void For_GetParamsForums (struct For_Forums *Forums)
} }
/***** Get optional parameter with code of a selected thread *****/ /***** Get optional parameter with code of a selected thread *****/
Forums->Thread.ThrCod = Par_GetParToLong ("ThrCod"); Forums->ThrCod = Par_GetParToLong ("ThrCod");
/***** Get optional parameter with code of a selected post *****/ /***** Get optional parameter with code of a selected post *****/
Forums->Post.PstCod = Par_GetParToLong ("PstCod"); Forums->PstCod = Par_GetParToLong ("PstCod");
/***** Get which forums I want to see *****/ /***** Get which forums I want to see *****/
Forums->ForumSet = (For_ForumSet_t) Forums->ForumSet = (For_ForumSet_t)
@ -3995,26 +3981,26 @@ void For_ReceiveForumPost (void)
/***** Create a new message *****/ /***** Create a new message *****/
if (IsReply) // This post is a reply to another posts in the thread if (IsReply) // This post is a reply to another posts in the thread
{ {
// Forums.Thread.ThrCod has been received from form // Forums.ThrCod has been received from form
/***** Create last message of the thread *****/ /***** Create last message of the thread *****/
PstCod = For_InsertForumPst (Forums.Thread.ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod, PstCod = For_InsertForumPst (Forums.ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod,
Subject,Content,&Media); Subject,Content,&Media);
/***** Modify last message of the thread *****/ /***** Modify last message of the thread *****/
For_UpdateThrLastPst (Forums.Thread.ThrCod,PstCod); For_UpdateThrLastPst (Forums.ThrCod,PstCod);
} }
else // This post is the first of a new thread else // This post is the first of a new thread
{ {
/***** Create new thread with unknown first and last message codes *****/ /***** Create new thread with unknown first and last message codes *****/
Forums.Thread.ThrCod = For_InsertForumThread (&Forums,-1L); Forums.ThrCod = For_InsertForumThread (&Forums,-1L);
/***** Create first (and last) message of the thread *****/ /***** Create first (and last) message of the thread *****/
PstCod = For_InsertForumPst (Forums.Thread.ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod, PstCod = For_InsertForumPst (Forums.ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod,
Subject,Content,&Media); Subject,Content,&Media);
/***** Update first and last posts of new thread *****/ /***** Update first and last posts of new thread *****/
For_UpdateThrFirstAndLastPst (Forums.Thread.ThrCod,PstCod,PstCod); For_UpdateThrFirstAndLastPst (Forums.ThrCod,PstCod,PstCod);
} }
/***** Free media *****/ /***** Free media *****/
@ -4101,12 +4087,12 @@ void For_RemovePost (void)
Med_MediaConstructor (&Media); Med_MediaConstructor (&Media);
/***** Get forum post data *****/ /***** Get forum post data *****/
For_GetPstData (Forums.Post.PstCod,&UsrDat.UsrCod,&CreatTimeUTC, For_GetPstData (Forums.PstCod,&UsrDat.UsrCod,&CreatTimeUTC,
Subject,OriginalContent,&Media); Subject,OriginalContent,&Media);
/***** Check if I can remove the post *****/ /***** Check if I can remove the post *****/
/* Check if the message really exists, if it has not been removed */ /* Check if the message really exists, if it has not been removed */
if (!For_GetIfForumPstExists (Forums.Post.PstCod)) if (!For_GetIfForumPstExists (Forums.PstCod))
Lay_ShowErrorAndExit ("The post to remove no longer exists."); Lay_ShowErrorAndExit ("The post to remove no longer exists.");
/* Check if I am the author of the message */ /* Check if I am the author of the message */
@ -4115,25 +4101,25 @@ void For_RemovePost (void)
Lay_NoPermissionExit (); Lay_NoPermissionExit ();
/* Check if the message is the last message in the thread */ /* Check if the message is the last message in the thread */
if (Forums.Post.PstCod != For_GetLastPstCod (Forums.Thread.ThrCod)) if (Forums.PstCod != For_GetLastPstCod (Forums.ThrCod))
Lay_NoPermissionExit (); Lay_NoPermissionExit ();
/***** Remove the post *****/ /***** Remove the post *****/
ThreadDeleted = For_RemoveForumPst (Forums.Post.PstCod,Media.MedCod); ThreadDeleted = For_RemoveForumPst (Forums.PstCod,Media.MedCod);
/***** Free image *****/ /***** Free image *****/
Med_MediaDestructor (&Media); Med_MediaDestructor (&Media);
/***** Mark possible notifications as removed *****/ /***** Mark possible notifications as removed *****/
Ntf_MarkNotifAsRemoved (Ntf_EVENT_FORUM_POST_COURSE,Forums.Post.PstCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_FORUM_POST_COURSE,Forums.PstCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_FORUM_REPLY,Forums.Post.PstCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_FORUM_REPLY ,Forums.PstCod);
/***** Mark possible social note as unavailable *****/ /***** Mark possible social note as unavailable *****/
switch (Forums.Forum.Type) // Only if forum is public for any logged user switch (Forums.Forum.Type) // Only if forum is public for any logged user
{ {
case For_FORUM_GLOBAL_USRS: case For_FORUM_GLOBAL_USRS:
case For_FORUM__SWAD__USRS: case For_FORUM__SWAD__USRS:
TL_MarkNoteAsUnavailableUsingNoteTypeAndCod (TL_NOTE_FORUM_POST,Forums.Post.PstCod); TL_MarkNoteAsUnavailableUsingNoteTypeAndCod (TL_NOTE_FORUM_POST,Forums.PstCod);
break; break;
default: default:
break; break;
@ -4173,7 +4159,7 @@ void For_RequestRemoveThread (void)
For_GetParamsForums (&Forums); For_GetParamsForums (&Forums);
/***** Get subject of the thread to delete *****/ /***** Get subject of the thread to delete *****/
For_GetThrSubject (Forums.Thread.ThrCod,Subject); For_GetThrSubject (Forums.ThrCod,Subject);
/***** Show forum list again *****/ /***** Show forum list again *****/
For_ShowForumList (&Forums); For_ShowForumList (&Forums);
@ -4207,7 +4193,7 @@ static void For_PutAllHiddenParamsRemThread (void *Forums)
((struct For_Forums *) Forums)->ForumSet, ((struct For_Forums *) Forums)->ForumSet,
((struct For_Forums *) Forums)->ThreadsOrder, ((struct For_Forums *) Forums)->ThreadsOrder,
((struct For_Forums *) Forums)->Forum.Location, ((struct For_Forums *) Forums)->Forum.Location,
((struct For_Forums *) Forums)->Thread.ThrCod, ((struct For_Forums *) Forums)->ThrCod,
-1L); -1L);
} }
@ -4233,10 +4219,10 @@ void For_RemoveThread (void)
(1 << Gbl.Usrs.Me.Role.Logged)) // If I have permission to remove thread in this forum... (1 << Gbl.Usrs.Me.Role.Logged)) // If I have permission to remove thread in this forum...
{ {
/***** Get subject of thread to delete *****/ /***** Get subject of thread to delete *****/
For_GetThrSubject (Forums.Thread.ThrCod,Subject); For_GetThrSubject (Forums.ThrCod,Subject);
/***** Remove the thread and all its posts *****/ /***** Remove the thread and all its posts *****/
For_RemoveThreadAndItsPsts (Forums.Thread.ThrCod); For_RemoveThreadAndItsPsts (Forums.ThrCod);
/***** Show forum list again *****/ /***** Show forum list again *****/
For_ShowForumList (&Forums); For_ShowForumList (&Forums);
@ -4274,10 +4260,10 @@ void For_CutThread (void)
For_GetParamsForums (&Forums); For_GetParamsForums (&Forums);
/***** Get subject of thread to cut *****/ /***** Get subject of thread to cut *****/
For_GetThrSubject (Forums.Thread.ThrCod,Subject); For_GetThrSubject (Forums.ThrCod,Subject);
/***** Mark the thread as cut *****/ /***** Mark the thread as cut *****/
For_InsertThrInClipboard (Forums.Thread.ThrCod); For_InsertThrInClipboard (Forums.ThrCod);
/***** Show forum list again *****/ /***** Show forum list again *****/
For_ShowForumList (&Forums); For_ShowForumList (&Forums);
@ -4315,10 +4301,10 @@ void For_PasteThread (void)
For_GetParamsForums (&Forums); For_GetParamsForums (&Forums);
/***** Get subject of thread to paste *****/ /***** Get subject of thread to paste *****/
For_GetThrSubject (Forums.Thread.ThrCod,Subject); For_GetThrSubject (Forums.ThrCod,Subject);
/***** Check if paste (move) the thread to current forum has sense *****/ /***** Check if paste (move) the thread to current forum has sense *****/
if (For_CheckIfThrBelongsToForum (Forums.Thread.ThrCod,&Forums.Forum)) if (For_CheckIfThrBelongsToForum (Forums.ThrCod,&Forums.Forum))
{ {
/***** Show forum list again *****/ /***** Show forum list again *****/
For_ShowForumList (&Forums); For_ShowForumList (&Forums);
@ -4433,7 +4419,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums)
" SET ForumType=%u,Location=-1" " SET ForumType=%u,Location=-1"
" WHERE ThrCod=%ld", " WHERE ThrCod=%ld",
(unsigned) Forums->Forum.Type, (unsigned) Forums->Forum.Type,
Forums->Thread.ThrCod); Forums->ThrCod);
break; break;
case For_FORUM_INSTIT_USRS: case For_FORUM_INSTIT_USRS:
case For_FORUM_INSTIT_TCHS: case For_FORUM_INSTIT_TCHS:
@ -4443,7 +4429,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums)
" WHERE ThrCod=%ld", " WHERE ThrCod=%ld",
(unsigned) Forums->Forum.Type, (unsigned) Forums->Forum.Type,
Forums->Forum.Location, Forums->Forum.Location,
Forums->Thread.ThrCod); Forums->ThrCod);
break; break;
case For_FORUM_CENTRE_USRS: case For_FORUM_CENTRE_USRS:
case For_FORUM_CENTRE_TCHS: case For_FORUM_CENTRE_TCHS:
@ -4453,7 +4439,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums)
" WHERE ThrCod=%ld", " WHERE ThrCod=%ld",
(unsigned) Forums->Forum.Type, (unsigned) Forums->Forum.Type,
Forums->Forum.Location, Forums->Forum.Location,
Forums->Thread.ThrCod); Forums->ThrCod);
break; break;
case For_FORUM_DEGREE_USRS: case For_FORUM_DEGREE_USRS:
case For_FORUM_DEGREE_TCHS: case For_FORUM_DEGREE_TCHS:
@ -4463,7 +4449,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums)
" WHERE ThrCod=%ld", " WHERE ThrCod=%ld",
(unsigned) Forums->Forum.Type, (unsigned) Forums->Forum.Type,
Forums->Forum.Location, Forums->Forum.Location,
Forums->Thread.ThrCod); Forums->ThrCod);
break; break;
case For_FORUM_COURSE_USRS: case For_FORUM_COURSE_USRS:
case For_FORUM_COURSE_TCHS: case For_FORUM_COURSE_TCHS:
@ -4473,7 +4459,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums)
" WHERE ThrCod=%ld", " WHERE ThrCod=%ld",
(unsigned) Forums->Forum.Type, (unsigned) Forums->Forum.Type,
Forums->Forum.Location, Forums->Forum.Location,
Forums->Thread.ThrCod); Forums->ThrCod);
break; break;
default: default:
Lay_ShowErrorAndExit ("Wrong forum."); Lay_ShowErrorAndExit ("Wrong forum.");

View File

@ -98,8 +98,8 @@ struct For_Forums
unsigned CurrentPageThrs; unsigned CurrentPageThrs;
unsigned CurrentPagePsts; unsigned CurrentPagePsts;
struct For_Forum Forum; // Forum selected struct For_Forum Forum; // Forum selected
struct For_Thread Thread; // Thread selected long ThrCod; // Thread selected
struct For_Post Post; // Post selected long PstCod; // Post selected
long ThreadToMove; long ThreadToMove;
}; };

View File

@ -745,7 +745,7 @@ static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
Forums->ForumSet, Forums->ForumSet,
Forums->ThreadsOrder, Forums->ThreadsOrder,
Forums->Forum.Location, Forums->Forum.Location,
Forums->Thread.ThrCod, Forums->ThrCod,
-1L); -1L);
break; break;
case Ntf_EVENT_NOTICE: case Ntf_EVENT_NOTICE:

View File

@ -2147,7 +2147,7 @@ static void TL_PutFormGoToAction (const struct TL_Note *SocNot,
Forums->ForumSet, Forums->ForumSet,
Forums->ThreadsOrder, Forums->ThreadsOrder,
Forums->Forum.Location, Forums->Forum.Location,
Forums->Thread.ThrCod, Forums->ThrCod,
-1L); -1L);
if (SocNot->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course if (SocNot->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course
Crs_PutParamCrsCod (SocNot->HieCod); // Go to another course Crs_PutParamCrsCod (SocNot->HieCod); // Go to another course