Version 20.36.37: Mar 01, 2021 Query moved to module swad_timeline_database.

This commit is contained in:
acanas 2021-03-01 13:26:59 +01:00
parent 99006c5f98
commit e556a0faa6
4 changed files with 35 additions and 11 deletions

View File

@ -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.36 (2021-03-01)"
#define Log_PLATFORM_VERSION "SWAD 20.36.37 (2021-03-01)"
#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.37: Mar 01, 2021 Query moved to module swad_timeline_database. (305449 lines)
Version 20.36.36: Mar 01, 2021 Query moved to module swad_timeline_database. (305429 lines)
Version 20.36.35: Mar 01, 2021 Code refactoring in timeline favourites. (305411 lines)
Version 20.36.34: Mar 01, 2021 Function moved to module swad_timeline_database. (305446 lines)

View File

@ -338,17 +338,22 @@ void TL_DB_RemoveNote (long NotCod)
}
/*****************************************************************************/
/************** Get publication codes of comments of a note from database *****************/
/********************* Get data of post using its code ***********************/
/*****************************************************************************/
// Returns the number of rows got
unsigned TL_DB_GetPostByCod (long PstCod,MYSQL_RES **mysql_res)
{
/***** Trivial check: post code should be > 0 *****/
if (PstCod <= 0)
return 0;
/***** Get data of post from database *****/
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get the content"
" of a post",
"SELECT Txt," // row[0]
"MedCod" // row[1]
"SELECT Txt," // row[0]
"MedCod" // row[1]
" FROM tl_posts"
" WHERE PstCod=%ld",
PstCod);
@ -721,6 +726,28 @@ unsigned TL_DB_SelectTheMostRecentPub (const struct TL_Pub_SubQueries *SubQuerie
SubQueries->AlreadyExists);
}
/*****************************************************************************/
/****************** Get data of publication using its code *******************/
/*****************************************************************************/
// Returns the number of rows got
unsigned TL_DB_GetDataOfPubByCod (long PubCod,MYSQL_RES **mysql_res)
{
/***** Trivial check: publication code should be > 0 *****/
if (PubCod <= 0)
return 0;
/***** Get data of note from database *****/
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get data of publication",
"SELECT PubCod," // row[0]
"NotCod," // row[1]
"PublisherCod," // row[2]
"PubType" // row[3]
" FROM tl_pubs WHERE PubCod=%ld",
PubCod);
}
/*****************************************************************************/
/*********************** Get code of note of a publication *******************/
/*****************************************************************************/

View File

@ -104,6 +104,7 @@ void TL_DB_CreateSubQueryRangeTop (const struct TL_Pub_RangePubsToGet *RangePubs
struct TL_Pub_SubQueries *SubQueries);
unsigned TL_DB_SelectTheMostRecentPub (const struct TL_Pub_SubQueries *SubQueries,
MYSQL_RES **mysql_res);
unsigned TL_DB_GetDataOfPubByCod (long PubCod,MYSQL_RES **mysql_res);
long TL_DB_GetNotCodFromPubCod (long PubCod);
long TL_DB_GetPubCodFromSession (const char *FieldName);
unsigned long TL_DB_GetNumPubsUsr (long UsrCod);

View File

@ -31,6 +31,7 @@
#include "swad_database.h"
#include "swad_global.h"
#include "swad_timeline.h"
#include "swad_timeline_database.h"
#include "swad_timeline_note.h"
#include "swad_timeline_notification.h"
#include "swad_timeline_post.h"
@ -119,13 +120,7 @@ void TL_Ntf_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
Content.Txt[0] = '\0';
/***** Get summary and content from post from database *****/
if (DB_QuerySELECT (&mysql_res,"can not get data of publication",
"SELECT PubCod," // row[0]
"NotCod," // row[1]
"PublisherCod," // row[2]
"PubType" // row[3]
" FROM tl_pubs WHERE PubCod=%ld",
PubCod) == 1) // Result should have a unique row
if (TL_DB_GetDataOfPubByCod (PubCod,&mysql_res) == 1) // Result should have a unique row
/* Get data of publication from row */
TL_Pub_GetDataOfPublicationFromNextRow (mysql_res,&Pub);