From bf6f4616b4bfc7d883296453667ea39324864c2a Mon Sep 17 00:00:00 2001 From: acanas Date: Sat, 27 Feb 2021 19:14:11 +0100 Subject: [PATCH] Version 20.36.16: Feb 27, 2021 Query moved to module swad_timeline_database. --- swad_changelog.h | 3 ++- swad_timeline_comment.c | 1 - swad_timeline_database.c | 17 +++++++++++++++++ swad_timeline_database.h | 1 + swad_timeline_note.c | 1 - swad_timeline_post.c | 23 +++++++++-------------- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index d25fa1d5..278b4882 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.15 (2021-02-27)" +#define Log_PLATFORM_VERSION "SWAD 20.36.16 (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.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) Version 20.36.13: Feb 27, 2021 Functions moved to module swad_timeline_database. (305285 lines) diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index 89f81d33..cc432f1c 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -29,7 +29,6 @@ #include // For PATH_MAX #include // For asprintf -#include "swad_database.h" #include "swad_forum.h" #include "swad_global.h" #include "swad_message.h" diff --git a/swad_timeline_database.c b/swad_timeline_database.c index 846b6309..88b9ebff 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -322,6 +322,23 @@ void TL_DB_RemoveNote (long NotCod,long PublisherCod) PublisherCod); } +/*****************************************************************************/ +/************** Get publication codes of comments of a note from database *****************/ +/*****************************************************************************/ +// Returns the number of rows got + +unsigned TL_DB_GetPostByCod (long PstCod,MYSQL_RES **mysql_res) + { + return (unsigned) + DB_QuerySELECT (mysql_res,"can not get the content" + " of a post", + "SELECT Txt," // row[0] + "MedCod" // row[1] + " FROM tl_posts" + " WHERE PstCod=%ld", + PstCod); + } + /*****************************************************************************/ /***************** Get code of media associated to post **********************/ /*****************************************************************************/ diff --git a/swad_timeline_database.h b/swad_timeline_database.h index 1e7bcdf2..4bde0d95 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -68,6 +68,7 @@ void TL_DB_RemoveNotePubs (long NotCod); 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); void TL_DB_RemovePost (long PstCod); diff --git a/swad_timeline_note.c b/swad_timeline_note.c index 9f200957..186c6b38 100644 --- a/swad_timeline_note.c +++ b/swad_timeline_note.c @@ -32,7 +32,6 @@ #include "swad_alert.h" #include "swad_box.h" #include "swad_course.h" -#include "swad_database.h" #include "swad_exam_announcement.h" #include "swad_forum.h" #include "swad_global.h" diff --git a/swad_timeline_post.c b/swad_timeline_post.c index fc922f18..0623d1a6 100644 --- a/swad_timeline_post.c +++ b/swad_timeline_post.c @@ -32,6 +32,7 @@ #include "swad_message.h" #include "swad_profile.h" #include "swad_timeline.h" +#include "swad_timeline_database.h" #include "swad_timeline_form.h" #include "swad_timeline_note.h" #include "swad_timeline_post.h" @@ -71,30 +72,24 @@ void TL_Pst_GetAndWritePost (long PstCod) { MYSQL_RES *mysql_res; MYSQL_ROW row; - unsigned long NumRows; struct TL_Pst_PostContent Content; /***** Initialize image *****/ Med_MediaConstructor (&Content.Media); /***** Get post from database *****/ - NumRows = DB_QuerySELECT (&mysql_res,"can not get the content" - " of a post", - "SELECT Txt," // row[0] - "MedCod" // row[1] - " FROM tl_posts" - " WHERE PstCod=%ld", - PstCod); - - /***** Result should have a unique row *****/ - if (NumRows == 1) + if (TL_DB_GetPostByCod (PstCod,&mysql_res) == 1) { + /* Get row */ row = mysql_fetch_row (mysql_res); - - /****** Get content (row[0]) *****/ + /* + row[0] Txt + row[1] MedCod + */ + /* Get content (row[0]) */ Str_Copy (Content.Txt,row[0],sizeof (Content.Txt) - 1); - /***** Get media (row[1]) *****/ + /* Get media (row[1]) */ Content.Media.MedCod = Str_ConvertStrCodToLongCod (row[1]); Med_GetMediaDataByCod (&Content.Media); }