From e85c2105c797d90988731803cad1b3897ecc3241 Mon Sep 17 00:00:00 2001 From: acanas Date: Wed, 11 Nov 2020 01:14:53 +0100 Subject: [PATCH] Version20.6 --- swad_changelog.h | 3 +- swad_forum.c | 69 ++++++++++++++++++++++++--------------------- swad_forum.h | 8 ++++-- swad_notification.c | 2 +- swad_timeline.c | 2 +- 5 files changed, 47 insertions(+), 37 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 01e2131cf..27022a212 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -555,7 +555,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 20.5.1 (2020-11-10)" +#define Log_PLATFORM_VERSION "SWAD 20.6 (2020-11-11)" #define CSS_FILE "swad20.1.1.css" #define JS_FILE "swad19.254.js" /* @@ -602,6 +602,7 @@ Juan Miguel. TODO: DNI de un estudiante sale erróneamente como ******* en lugar de mostrarse al ver los accesos de un estudiante a la asignatura. TODO: Poder editar las partidas, al menos el título, y si es posible, también los grupos. + Version 20.6: Nov 11, 2020 Fixed bug and code refactoring in forums. (304516 lines) Version 20.5.1: Nov 10, 2020 Fixed bug in file browser, reportedby Luis Javier Herrera Maldonado. (? lines) Version 20.5: Oct 14, 2020 Code refactoring in remove icon. (304491 lines) Version 20.4: Oct 13, 2020 Code refactoring in remove icon. diff --git a/swad_forum.c b/swad_forum.c index dc65dea2c..496ada9ec 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -425,11 +425,12 @@ void For_ResetForums (struct For_Forums *Forums) Forums->Forum.Type = For_FORUM_UNKNOWN; Forums->Forum.Location = -1L; - Forums->ThrCod = -1L; + Forums->Thread.Selected = + Forums->Thread.Current = + Forums->Thread.ToMove = -1L; Forums->PstCod = -1L; - Forums->ThreadToMove = -1L; } /*****************************************************************************/ @@ -1009,12 +1010,14 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums, bool ICanModerateForum = false; /***** Get data of the thread *****/ - Thread.ThrCod = Forums->ThrCod; + Thread.ThrCod = + Forums->Thread.Current = + Forums->Thread.Selected; For_GetThreadData (&Thread); /***** Get if there is a thread ready to be moved *****/ if (For_CheckIfICanMoveThreads ()) - Forums->ThreadToMove = For_GetThrInMyClipboard (); + Forums->Thread.ToMove = For_GetThrInMyClipboard (); /***** Get thread read time for the current user *****/ ReadTimeUTC = For_GetThrReadTime (Thread.ThrCod); @@ -1182,7 +1185,7 @@ static void For_PutAllHiddenParamsNewPost (void *Forums) ((struct For_Forums *) Forums)->ForumSet, ((struct For_Forums *) Forums)->ThreadsOrder, ((struct For_Forums *) Forums)->Forum.Location, - ((struct For_Forums *) Forums)->ThrCod, + ((struct For_Forums *) Forums)->Thread.Current, -1L); } @@ -1485,7 +1488,7 @@ static void For_PutParamsForum (void *Forums) ((struct For_Forums *) Forums)->ForumSet, ((struct For_Forums *) Forums)->ThreadsOrder, ((struct For_Forums *) Forums)->Forum.Location, - ((struct For_Forums *) Forums)->ThrCod, + ((struct For_Forums *) Forums)->Thread.Current, ((struct For_Forums *) Forums)->PstCod); } @@ -1578,7 +1581,7 @@ static void For_ShowForumList (struct For_Forums *Forums) /***** Get if there is a thread ready to be moved *****/ if (For_CheckIfICanMoveThreads ()) - Forums->ThreadToMove = For_GetThrInMyClipboard (); + Forums->Thread.ToMove = For_GetThrInMyClipboard (); /***** Fill the list with the institutions I belong to *****/ Usr_GetMyInstits (); @@ -2071,10 +2074,10 @@ static void For_WriteLinkToForum (const struct For_Forums *Forums, Lay_IndentDependingOnLevel (Level,IsLastItemInLevel); /***** Write paste button used to move a thread in clipboard to this forum *****/ - if (Forums->ThreadToMove >= 0) // If I have permission to paste threads and there is a thread ready to be pasted... + if (Forums->Thread.ToMove >= 0) // If I have permission to paste threads and there is a thread ready to be pasted... { /* Check if thread to move is yet in current forum */ - if (For_CheckIfThrBelongsToForum (Forums->ThreadToMove,Forum)) + if (For_CheckIfThrBelongsToForum (Forums->Thread.ToMove,Forum)) Ico_PutIcon ("paste.svg",Txt_Copy_not_allowed,"CONTEXT_OPT ICO_HIDDEN ICO16x16"); else { @@ -2085,7 +2088,7 @@ static void For_WriteLinkToForum (const struct For_Forums *Forums, Forums->ForumSet, Forums->ThreadsOrder, Forum->Location, - Forums->ThreadToMove, + Forums->Thread.ToMove, -1L); Ico_PutIconPaste (); Frm_EndForm (); @@ -2560,7 +2563,7 @@ static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums HTM_TR_End (); /***** List the threads *****/ - For_ListForumThrs (Forums,ThrCods,Forums->ThrCod,&PaginationThrs); + For_ListForumThrs (Forums,ThrCods,Forums->Thread.Current,&PaginationThrs); /***** End table *****/ HTM_TABLE_End (); @@ -3330,7 +3333,7 @@ static void For_ListForumThrs (struct For_Forums *Forums, /***** Get the data of this thread *****/ Thr.ThrCod = ThrCods[NumThrInScreen]; For_GetThreadData (&Thr); - Forums->ThrCod = Thr.ThrCod; + Forums->Thread.Current = Thr.ThrCod; Style = (Thr.NumUnreadPosts ? "AUTHOR_TXT_NEW" : "AUTHOR_TXT"); BgColor = (Thr.ThrCod == ThreadInMyClipboard) ? "LIGHT_GREEN" : @@ -3607,7 +3610,8 @@ static void For_GetParamsForums (struct For_Forums *Forums) } /***** Get optional parameter with code of a selected thread *****/ - Forums->ThrCod = Par_GetParToLong ("ThrCod"); + Forums->Thread.Current = + Forums->Thread.Selected = Par_GetParToLong ("ThrCod"); /***** Get optional parameter with code of a selected post *****/ Forums->PstCod = Par_GetParToLong ("PstCod"); @@ -3973,23 +3977,24 @@ void For_ReceiveForumPost (void) // Forums.ThrCod has been received from form /***** Create last message of the thread *****/ - PstCod = For_InsertForumPst (Forums.ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod, + PstCod = For_InsertForumPst (Forums.Thread.Current,Gbl.Usrs.Me.UsrDat.UsrCod, Subject,Content,&Media); /***** Modify last message of the thread *****/ - For_UpdateThrLastPst (Forums.ThrCod,PstCod); + For_UpdateThrLastPst (Forums.Thread.Current,PstCod); } else // This post is the first of a new thread { /***** Create new thread with unknown first and last message codes *****/ - Forums.ThrCod = For_InsertForumThread (&Forums,-1L); + Forums.Thread.Current = + Forums.Thread.Selected = For_InsertForumThread (&Forums,-1L); /***** Create first (and last) message of the thread *****/ - PstCod = For_InsertForumPst (Forums.ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod, + PstCod = For_InsertForumPst (Forums.Thread.Current,Gbl.Usrs.Me.UsrDat.UsrCod, Subject,Content,&Media); /***** Update first and last posts of new thread *****/ - For_UpdateThrFirstAndLastPst (Forums.ThrCod,PstCod,PstCod); + For_UpdateThrFirstAndLastPst (Forums.Thread.Current,PstCod,PstCod); } /***** Free media *****/ @@ -4090,7 +4095,7 @@ void For_RemovePost (void) Lay_NoPermissionExit (); /* Check if the message is the last message in the thread */ - if (Forums.PstCod != For_GetLastPstCod (Forums.ThrCod)) + if (Forums.PstCod != For_GetLastPstCod (Forums.Thread.Current)) Lay_NoPermissionExit (); /***** Remove the post *****/ @@ -4148,7 +4153,7 @@ void For_RequestRemoveThread (void) For_GetParamsForums (&Forums); /***** Get subject of the thread to delete *****/ - For_GetThrSubject (Forums.ThrCod,Subject); + For_GetThrSubject (Forums.Thread.Current,Subject); /***** Show forum list again *****/ For_ShowForumList (&Forums); @@ -4182,7 +4187,7 @@ static void For_PutAllHiddenParamsRemThread (void *Forums) ((struct For_Forums *) Forums)->ForumSet, ((struct For_Forums *) Forums)->ThreadsOrder, ((struct For_Forums *) Forums)->Forum.Location, - ((struct For_Forums *) Forums)->ThrCod, + ((struct For_Forums *) Forums)->Thread.Current, -1L); } @@ -4208,10 +4213,10 @@ void For_RemoveThread (void) (1 << Gbl.Usrs.Me.Role.Logged)) // If I have permission to remove thread in this forum... { /***** Get subject of thread to delete *****/ - For_GetThrSubject (Forums.ThrCod,Subject); + For_GetThrSubject (Forums.Thread.Current,Subject); /***** Remove the thread and all its posts *****/ - For_RemoveThreadAndItsPsts (Forums.ThrCod); + For_RemoveThreadAndItsPsts (Forums.Thread.Current); /***** Show forum list again *****/ For_ShowForumList (&Forums); @@ -4249,10 +4254,10 @@ void For_CutThread (void) For_GetParamsForums (&Forums); /***** Get subject of thread to cut *****/ - For_GetThrSubject (Forums.ThrCod,Subject); + For_GetThrSubject (Forums.Thread.Current,Subject); /***** Mark the thread as cut *****/ - For_InsertThrInClipboard (Forums.ThrCod); + For_InsertThrInClipboard (Forums.Thread.Current); /***** Show forum list again *****/ For_ShowForumList (&Forums); @@ -4290,10 +4295,10 @@ void For_PasteThread (void) For_GetParamsForums (&Forums); /***** Get subject of thread to paste *****/ - For_GetThrSubject (Forums.ThrCod,Subject); + For_GetThrSubject (Forums.Thread.Current,Subject); /***** Check if paste (move) the thread to current forum has sense *****/ - if (For_CheckIfThrBelongsToForum (Forums.ThrCod,&Forums.Forum)) + if (For_CheckIfThrBelongsToForum (Forums.Thread.Current,&Forums.Forum)) { /***** Show forum list again *****/ For_ShowForumList (&Forums); @@ -4408,7 +4413,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums) " SET ForumType=%u,Location=-1" " WHERE ThrCod=%ld", (unsigned) Forums->Forum.Type, - Forums->ThrCod); + Forums->Thread.Current); break; case For_FORUM_INSTIT_USRS: case For_FORUM_INSTIT_TCHS: @@ -4418,7 +4423,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums) " WHERE ThrCod=%ld", (unsigned) Forums->Forum.Type, Forums->Forum.Location, - Forums->ThrCod); + Forums->Thread.Current); break; case For_FORUM_CENTRE_USRS: case For_FORUM_CENTRE_TCHS: @@ -4428,7 +4433,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums) " WHERE ThrCod=%ld", (unsigned) Forums->Forum.Type, Forums->Forum.Location, - Forums->ThrCod); + Forums->Thread.Current); break; case For_FORUM_DEGREE_USRS: case For_FORUM_DEGREE_TCHS: @@ -4438,7 +4443,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums) " WHERE ThrCod=%ld", (unsigned) Forums->Forum.Type, Forums->Forum.Location, - Forums->ThrCod); + Forums->Thread.Current); break; case For_FORUM_COURSE_USRS: case For_FORUM_COURSE_TCHS: @@ -4448,7 +4453,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums) " WHERE ThrCod=%ld", (unsigned) Forums->Forum.Type, Forums->Forum.Location, - Forums->ThrCod); + Forums->Thread.Current); break; default: Lay_ShowErrorAndExit ("Wrong forum."); diff --git a/swad_forum.h b/swad_forum.h index 05d348654..155940c2c 100644 --- a/swad_forum.h +++ b/swad_forum.h @@ -98,9 +98,13 @@ struct For_Forums unsigned CurrentPageThrs; unsigned CurrentPagePsts; struct For_Forum Forum; // Forum selected - long ThrCod; // Thread selected + struct + { + long Selected; // Thread selected + long Current; // Current thread + long ToMove; // Thread to move + } Thread; long PstCod; // Post selected - long ThreadToMove; }; #define For_DEFAULT_ORDER Dat_END_TIME diff --git a/swad_notification.c b/swad_notification.c index bc527298e..27a5b2587 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -748,7 +748,7 @@ static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent, Forums->ForumSet, Forums->ThreadsOrder, Forums->Forum.Location, - Forums->ThrCod, + Forums->Thread.Selected, -1L); break; case Ntf_EVENT_NOTICE: diff --git a/swad_timeline.c b/swad_timeline.c index 5ff5eefd9..441a1712a 100644 --- a/swad_timeline.c +++ b/swad_timeline.c @@ -2150,7 +2150,7 @@ static void TL_PutFormGoToAction (const struct TL_Note *SocNot, Forums->ForumSet, Forums->ThreadsOrder, Forums->Forum.Location, - Forums->ThrCod, + Forums->Thread.Selected, -1L); if (SocNot->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course Crs_PutParamCrsCod (SocNot->HieCod); // Go to another course