diff --git a/swad_changelog.h b/swad_changelog.h index 421b860dc..039c2e11c 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.3 (2021-02-26)" +#define Log_PLATFORM_VERSION "SWAD 20.36.4 (2021-02-26)" #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.4: Feb 26, 2021 Query moved to module swad_timeline_database. (305156 lines) Version 20.36.3: Feb 26, 2021 Query moved to module swad_timeline_database. (305140 lines) Version 20.36.2: Feb 26, 2021 Query moved to module swad_timeline_database. (305126 lines) Version 20.36.1: Feb 26, 2021 Function moved to module swad_timeline_database. (305113 lines) diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index 81cb2aa72..1455701a6 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -938,27 +938,15 @@ static void TL_Com_RemoveComment (void) void TL_Com_RemoveCommentMediaAndDBEntries (long PubCod) { - MYSQL_RES *mysql_res; - MYSQL_ROW row; long MedCod; /***** Remove media associated to comment *****/ - if (DB_QuerySELECT (&mysql_res,"can not get media", - "SELECT MedCod" // row[0] - " FROM tl_comments" - " WHERE PubCod=%ld", - PubCod) == 1) // Result should have a unique row - { - /* Get media code */ - row = mysql_fetch_row (mysql_res); - MedCod = Str_ConvertStrCodToLongCod (row[0]); + /* Get media code */ + MedCod = TL_DB_GetMedCodFromComment (PubCod); - /* Remove media */ + /* Remove media */ + if (MedCod > 0) Med_RemoveMedia (MedCod); - } - - /* Free structure that stores the query result */ - DB_FreeMySQLResult (&mysql_res); /***** Mark possible notifications on this comment as removed *****/ Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_COMMENT,PubCod); diff --git a/swad_timeline_database.c b/swad_timeline_database.c index 7238c5e20..853a56f57 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -66,6 +66,7 @@ unsigned TL_DB_GetNumCommentsInNote (long NotCod) /*****************************************************************************/ /************** Get initial comments of a note from database *****************/ /*****************************************************************************/ +// Returns the number of rows got unsigned TL_DB_GetInitialComments (long NotCod, unsigned NumInitialCommentsToGet, @@ -92,6 +93,7 @@ unsigned TL_DB_GetInitialComments (long NotCod, /*****************************************************************************/ /*************** Get final comments of a note from database ******************/ /*****************************************************************************/ +// Returns the number of rows got unsigned TL_DB_GetFinalComments (long NotCod, unsigned NumFinalCommentsToGet, @@ -136,3 +138,31 @@ void TL_DB_InsertCommentContent (long PubCod, Content->Txt, Content->Media.MedCod); } + +/*****************************************************************************/ +/******************* Insert comment content in database **********************/ +/*****************************************************************************/ + +long TL_DB_GetMedCodFromComment (long PubCod) + { + MYSQL_RES *mysql_res; + MYSQL_ROW row; + long MedCod = -1L; + + /***** Get code of media associated to comment *****/ + if (DB_QuerySELECT (&mysql_res,"can not get media code", + "SELECT MedCod" // row[0] + " FROM tl_comments" + " WHERE PubCod=%ld", + PubCod) == 1) // Result should have a unique row + { + /* Get media code */ + row = mysql_fetch_row (mysql_res); + MedCod = Str_ConvertStrCodToLongCod (row[0]); + } + + /* Free structure that stores the query result */ + DB_FreeMySQLResult (&mysql_res); + + return MedCod; + } diff --git a/swad_timeline_database.h b/swad_timeline_database.h index c990d5a8e..4ce68b5e8 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -51,5 +51,6 @@ unsigned TL_DB_GetFinalComments (long NotCod, MYSQL_RES **mysql_res); void TL_DB_InsertCommentContent (long PubCod, const struct TL_Pst_PostContent *Content); +long TL_DB_GetMedCodFromComment (long PubCod); #endif