From c28559868d556e2da43602cf8beb8a9e5a332fbd Mon Sep 17 00:00:00 2001 From: acanas Date: Sat, 27 Feb 2021 19:28:27 +0100 Subject: [PATCH] Version 20.36.17: Feb 27, 2021 Query moved to module swad_timeline_database. --- swad_changelog.h | 3 ++- swad_timeline_database.c | 18 ++++++++++++++++++ swad_timeline_database.h | 1 + swad_timeline_post.c | 9 +-------- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 278b48828..2045a3d37 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.36.16 (2021-02-27)" +#define Log_PLATFORM_VERSION "SWAD 20.36.17 (2021-02-27)" #define CSS_FILE "swad20.33.9.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.36.17: Feb 27, 2021 Query moved to module swad_timeline_database. (305328 lines) Version 20.36.16: Feb 27, 2021 Query moved to module swad_timeline_database. (305317 lines) Version 20.36.15: Feb 27, 2021 Functions moved to module swad_timeline_database. (305305 lines) Version 20.36.14: Feb 27, 2021 Query moved to module swad_timeline_database. (305300 lines) diff --git a/swad_timeline_database.c b/swad_timeline_database.c index 88b9ebff8..e3a154614 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -348,6 +348,24 @@ long TL_DB_GetMedCodFromPost (long PubCod) return TL_DB_GetMedCodFromPub (PubCod,"tl_posts"); } +/*****************************************************************************/ +/********************* Insert post content in database ***********************/ +/*****************************************************************************/ +// Returns code of just created post + +long TL_DB_CreateNewPost (const struct TL_Pst_PostContent *Content) + { + /***** Insert post content in the database *****/ + return + DB_QueryINSERTandReturnCode ("can not create post", + "INSERT INTO tl_posts" + " (Txt,MedCod)" + " VALUES" + " ('%s',%ld)", + Content->Txt, + Content->Media.MedCod); + } + /*****************************************************************************/ /************************* Remove post from database *************************/ /*****************************************************************************/ diff --git a/swad_timeline_database.h b/swad_timeline_database.h index 4bde0d955..945075976 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -70,6 +70,7 @@ void TL_DB_RemoveNote (long NotCod,long PublisherCod); /* Posts */ unsigned TL_DB_GetPostByCod (long PstCod,MYSQL_RES **mysql_res); long TL_DB_GetMedCodFromPost (long PubCod); +long TL_DB_CreateNewPost (const struct TL_Pst_PostContent *Content); void TL_DB_RemovePost (long PstCod); /* Comments */ diff --git a/swad_timeline_post.c b/swad_timeline_post.c index 0623d1a6b..670d8a73d 100644 --- a/swad_timeline_post.c +++ b/swad_timeline_post.c @@ -270,14 +270,7 @@ static long TL_Pst_ReceivePost (void) /***** Publish *****/ /* Insert post content in the database */ - PstCod = - DB_QueryINSERTandReturnCode ("can not create post", - "INSERT INTO tl_posts" - " (Txt,MedCod)" - " VALUES" - " ('%s',%ld)", - Content.Txt, - Content.Media.MedCod); + PstCod = TL_DB_CreateNewPost (&Content); /* Insert post in notes */ TL_Not_StoreAndPublishNoteInternal (TL_NOTE_POST,PstCod,&Pub);