diff --git a/swad_changelog.h b/swad_changelog.h index 2cd3e2c80..b91783c03 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -553,7 +553,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.32.1 (2021-02-15)" +#define Log_PLATFORM_VERSION "SWAD 20.32.2 (2021-02-21)" #define CSS_FILE "swad20.8.css" #define JS_FILE "swad20.6.2.js" /* @@ -601,6 +601,7 @@ TODO: DNI de un estudiante sale err TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede. TODO: Salvador Romero Cortés: @acanas opción para editar posts + Version 20.32.2: Feb 21, 2021 Code refactoring in timeline related to actions. (304771 lines) Version 20.32.1: Feb 15, 2021 Fixed bug in forums. (304756 lines) Version 20.32: Feb 15, 2021 Fixed bugs in copy of strings. Code refactoring in copy of strings. (304755 lines) diff --git a/swad_timeline.c b/swad_timeline.c index be3800c98..31bbc55d5 100644 --- a/swad_timeline.c +++ b/swad_timeline.c @@ -507,20 +507,33 @@ static void TL_PutIconsTimeline (__attribute__((unused)) void *Args) /***************** Start a form in global or user timeline *******************/ /*****************************************************************************/ -void TL_FormStart (const struct TL_Timeline *Timeline, - Act_Action_t ActionGbl, - Act_Action_t ActionUsr) +void TL_FormStart (const struct TL_Timeline *Timeline,TL_FormAction_t Action) { + static const Act_Action_t ActionGbl[TL_NUM_ACTIONS] = + { + [TL_RECEIVE_POST] = ActRcvTL_PstGbl, + [TL_RECEIVE_COMM] = ActRcvTL_ComGbl, + [TL_REQ_REM_NOTE] = ActReqRemTL_PubGbl, + [TL_REQ_REM_COMM] = ActReqRemTL_ComGbl, + }; + static const Act_Action_t ActionUsr[TL_NUM_ACTIONS] = + { + [TL_RECEIVE_POST] = ActRcvTL_PstUsr, + [TL_RECEIVE_COMM] = ActRcvTL_ComUsr, + [TL_REQ_REM_NOTE] = ActReqRemTL_PubUsr, + [TL_REQ_REM_COMM] = ActReqRemTL_ComUsr, + }; + if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) { /***** Start form in user timeline *****/ - Frm_StartFormAnchor (ActionUsr,"timeline"); + Frm_StartFormAnchor (ActionUsr[Action],"timeline"); Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod); } else { /***** Start form in global timeline *****/ - Frm_StartForm (ActionGbl); + Frm_StartForm (ActionGbl[Action]); Usr_PutHiddenParamWho (Timeline->Who); } } diff --git a/swad_timeline.h b/swad_timeline.h index 229ab16ac..bb0c07140 100644 --- a/swad_timeline.h +++ b/swad_timeline.h @@ -103,6 +103,15 @@ typedef enum TL_SHOW_ALONE, } TL_ShowAlone_t; +#define TL_NUM_ACTIONS 4 +typedef enum + { + TL_RECEIVE_POST, // Receive post + TL_RECEIVE_COMM, // Receive comment + TL_REQ_REM_NOTE, // Request removal note + TL_REQ_REM_COMM, // Request removal comment + } TL_FormAction_t; + /*****************************************************************************/ /****************************** Public prototypes ****************************/ /*****************************************************************************/ @@ -125,9 +134,7 @@ void TL_RefreshNewTimelineGbl (void); void TL_RefreshOldTimelineGbl (void); void TL_RefreshOldTimelineUsr (void); -void TL_FormStart (const struct TL_Timeline *Timeline, - Act_Action_t ActionGbl, - Act_Action_t ActionUsr); +void TL_FormStart (const struct TL_Timeline *Timeline,TL_FormAction_t Action); void TL_WriteDateTime (time_t TimeUTC); diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index 11588445c..8c13b6701 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -159,8 +159,7 @@ void TL_Com_PutHiddenFormToWriteNewComment (const struct TL_Timeline *Timeline, HTM_DIV_Begin ("class=\"TL_COM_CONT TL_COMM_WIDTH\""); /* Begin form to write the post */ - TL_FormStart (Timeline,ActRcvTL_ComGbl, - ActRcvTL_ComUsr); + TL_FormStart (Timeline,TL_RECEIVE_COMM); TL_Not_PutHiddenParamNotCod (NotCod); /* Textarea and button */ @@ -696,8 +695,7 @@ static void TL_Com_PutFormToRemoveComment (const struct TL_Timeline *Timeline, extern const char *Txt_Remove; /***** Form to remove publication *****/ - TL_FormStart (Timeline,ActReqRemTL_ComGbl, - ActReqRemTL_ComUsr); + TL_FormStart (Timeline,TL_REQ_REM_COMM); TL_Pub_PutHiddenParamPubCod (PubCod); Ico_PutIconLink ("trash.svg",Txt_Remove); Frm_EndForm (); diff --git a/swad_timeline_note.c b/swad_timeline_note.c index f5afa81be..6ba30650f 100644 --- a/swad_timeline_note.c +++ b/swad_timeline_note.c @@ -942,8 +942,7 @@ static void TL_Not_PutFormToRemoveNote (const struct TL_Timeline *Timeline, extern const char *Txt_Remove; /***** Form to remove publication *****/ - TL_FormStart (Timeline,ActReqRemTL_PubGbl, - ActReqRemTL_PubUsr); + TL_FormStart (Timeline,TL_REQ_REM_NOTE); TL_Not_PutHiddenParamNotCod (NotCod); Ico_PutIconLink ("trash.svg",Txt_Remove); Frm_EndForm (); diff --git a/swad_timeline_post.c b/swad_timeline_post.c index 9dd22dc17..e49613a51 100644 --- a/swad_timeline_post.c +++ b/swad_timeline_post.c @@ -149,8 +149,7 @@ void TL_Pst_PutFormToWriteNewPost (struct TL_Timeline *Timeline) /* Form to write the post */ HTM_DIV_Begin ("class=\"TL_FORM_NEW_PST TL_RIGHT_WIDTH\""); - TL_FormStart (Timeline,ActRcvTL_PstGbl, - ActRcvTL_PstUsr); + TL_FormStart (Timeline,TL_RECEIVE_POST); TL_Pst_PutTextarea (Txt_New_TIMELINE_post,"TL_PST_TEXTAREA TL_RIGHT_WIDTH"); Frm_EndForm (); HTM_DIV_End ();