From a90f967243e941c4241eef4b912b43af91b33bb1 Mon Sep 17 00:00:00 2001 From: acanas Date: Sun, 28 Feb 2021 19:55:04 +0100 Subject: [PATCH] Version 20.36.22: Feb 27, 2021 Function moved to module swad_timeline_database. --- swad_changelog.h | 3 ++- swad_timeline_database.c | 19 +++++++++++++++++++ swad_timeline_database.h | 1 + swad_timeline_publication.c | 10 +--------- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 10f0bf64e..261e36df4 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.21 (2021-02-27)" +#define Log_PLATFORM_VERSION "SWAD 20.36.22 (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.22: Feb 27, 2021 Function moved to module swad_timeline_database. (305387 lines) Version 20.36.21: Feb 27, 2021 Function moved to module swad_timeline_database. (305376 lines) Version 20.36.20: Feb 27, 2021 Query moved to module swad_timeline_database. (305374 lines) Version 20.36.19: Feb 27, 2021 Queries moved to module swad_timeline_database. (305363 lines) diff --git a/swad_timeline_database.c b/swad_timeline_database.c index 31da1463e..d0db7d220 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -675,6 +675,25 @@ long TL_DB_GetPubCodFromSession (const char *FieldName, return PubCod; } +/*****************************************************************************/ +/********************* Insert new publication in database ********************/ +/*****************************************************************************/ +// Return just created publication code + +long TL_DB_CreateNewPub (const struct TL_Pub_Publication *Pub) + { + /***** Insert new publication in database *****/ + return + DB_QueryINSERTandReturnCode ("can not publish note/comment", + "INSERT INTO tl_pubs" + " (NotCod,PublisherCod,PubType,TimePublish)" + " VALUES" + " (%ld,%ld,%u,NOW())", + Pub->NotCod, + Pub->PublisherCod, + (unsigned) Pub->PubType); + } + /*****************************************************************************/ /************** Update first publication code stored in session **************/ /*****************************************************************************/ diff --git a/swad_timeline_database.h b/swad_timeline_database.h index 23dd5a8a0..10ed8a632 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -97,6 +97,7 @@ unsigned TL_DB_SelectTheMostRecentPub (const struct TL_Pub_SubQueries *SubQuerie long TL_DB_GetNotCodFromPubCod (long PubCod); long TL_DB_GetPubCodFromSession (const char *FieldName, const char SessionId[Cns_BYTES_SESSION_ID + 1]); +long TL_DB_CreateNewPub (const struct TL_Pub_Publication *Pub); void TL_DB_UpdateFirstPubCodInSession (long FirstPubCod, const char SessionId[Cns_BYTES_SESSION_ID + 1]); void TL_DB_UpdateLastPubCodInSession (const char SessionId[Cns_BYTES_SESSION_ID + 1]); diff --git a/swad_timeline_publication.c b/swad_timeline_publication.c index 592694ae5..9232fb844 100644 --- a/swad_timeline_publication.c +++ b/swad_timeline_publication.c @@ -636,15 +636,7 @@ static TL_Pub_PubType_t TL_Pub_GetPubTypeFromStr (const char *Str) void TL_Pub_PublishPubInTimeline (struct TL_Pub_Publication *Pub) { /***** Publish note in timeline *****/ - Pub->PubCod = - DB_QueryINSERTandReturnCode ("can not publish note/comment", - "INSERT INTO tl_pubs" - " (NotCod,PublisherCod,PubType,TimePublish)" - " VALUES" - " (%ld,%ld,%u,NOW())", - Pub->NotCod, - Pub->PublisherCod, - (unsigned) Pub->PubType); + Pub->PubCod = TL_DB_CreateNewPub (Pub); /***** Increment number of publications in user's figures *****/ Prf_IncrementNumPubsUsr (Pub->PublisherCod);