Version 20.36.14: Feb 27, 2021 Query moved to module swad_timeline_database.

This commit is contained in:
acanas 2021-02-27 16:45:29 +01:00
parent d5428a11c9
commit f346dfc4f1
4 changed files with 58 additions and 40 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.13 (2021-02-27)"
#define Log_PLATFORM_VERSION "SWAD 20.36.14 (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.14: Feb 27, 2021 Query moved to module swad_timeline_database. (? lines)
Version 20.36.13: Feb 27, 2021 Functions moved to module swad_timeline_database. (305285 lines)
Version 20.36.12: Feb 27, 2021 Queries moved to module swad_timeline_database. (305282 lines)
Version 20.36.11: Feb 27, 2021 Query moved to module swad_timeline_database. (305246 lines)

View File

@ -52,6 +52,59 @@
static long TL_DB_GetMedCodFromPub (long PubCod,const char *DBTable);
/*****************************************************************************/
/********************* Get data of note using its code ***********************/
/*****************************************************************************/
// Returns the number of rows got
unsigned TL_DB_GetDataOfNoteByCod (long NotCod,MYSQL_RES **mysql_res)
{
/***** Trivial check: note code should be > 0 *****/
if (NotCod <= 0)
return 0;
/***** Get data of note from database *****/
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get data of note",
"SELECT NotCod," // row[0]
"NoteType," // row[1]
"Cod," // row[2]
"UsrCod," // row[3]
"HieCod," // row[4]
"Unavailable," // row[5]
"UNIX_TIMESTAMP(TimeNote)" // row[6]
" FROM tl_notes"
" WHERE NotCod=%ld",
NotCod);
}
/*****************************************************************************/
/*************** Get code of publication of the original note ****************/
/*****************************************************************************/
long TL_DB_GetPubCodOfOriginalNote (long NotCod)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long OriginalPubCod = -1L; // Default value
/***** Get code of publication of the original note *****/
if (DB_QuerySELECT (&mysql_res,"can not get code of publication",
"SELECT PubCod FROM tl_pubs"
" WHERE NotCod=%ld AND PubType=%u",
NotCod,(unsigned) TL_Pub_ORIGINAL_NOTE) == 1) // Result should have a unique row
{
/* Get code of publication (row[0]) */
row = mysql_fetch_row (mysql_res);
OriginalPubCod = Str_ConvertStrCodToLongCod (row[0]);
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return OriginalPubCod;
}
/*****************************************************************************/
/***************************** Create a new note *****************************/
/*****************************************************************************/
@ -161,33 +214,6 @@ mysql> SELECT SessionId,COUNT(*) FROM tl_timelines GROUP BY SessionId;
SessionId);
}
/*****************************************************************************/
/*************** Get code of publication of the original note ****************/
/*****************************************************************************/
long TL_DB_GetPubCodOfOriginalNote (long NotCod)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long OriginalPubCod = -1L; // Default value
/***** Get code of publication of the original note *****/
if (DB_QuerySELECT (&mysql_res,"can not get code of publication",
"SELECT PubCod FROM tl_pubs"
" WHERE NotCod=%ld AND PubType=%u",
NotCod,(unsigned) TL_Pub_ORIGINAL_NOTE) == 1) // Result should have a unique row
{
/* Get code of publication (row[0]) */
row = mysql_fetch_row (mysql_res);
OriginalPubCod = Str_ConvertStrCodToLongCod (row[0]);
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return OriginalPubCod;
}
/*****************************************************************************/
/*************************** Remove favs for a note **************************/
/*****************************************************************************/

View File

@ -45,6 +45,8 @@
/*****************************************************************************/
/* Notes */
unsigned TL_DB_GetDataOfNoteByCod (long NotCod,MYSQL_RES **mysql_res);
long TL_DB_GetPubCodOfOriginalNote (long NotCod);
long TL_DB_CreateNewNote (TL_Not_NoteType_t NoteType,long Cod,
long PublisherCod,long HieCod);
void TL_DB_MarkNoteAsUnavailable (TL_Not_NoteType_t NoteType,long Cod);
@ -55,7 +57,6 @@ void TL_DB_MarkNotesChildrenOfFolderAsUnavailable (TL_Not_NoteType_t NoteType,
void TL_DB_InsertNoteInJustRetrievedNotes (long NotCod);
void TL_DB_InsertNoteInVisibleTimeline (long NotCod);
void TL_DB_AddNotesJustRetrievedToVisibleTimelineOfSession (char SessionId[Cns_BYTES_SESSION_ID + 1]);
long TL_DB_GetPubCodOfOriginalNote (long NotCod);
void TL_DB_RemoveNoteFavs (long NotCod);
void TL_DB_RemoveNotePubs (long NotCod);
void TL_DB_RemoveNote (long NotCod,long PublisherCod);

View File

@ -1341,17 +1341,7 @@ void TL_Not_GetDataOfNoteByCod (struct TL_Not_Note *Not)
if (Not->NotCod > 0)
{
/***** Get data of note from database *****/
if (DB_QuerySELECT (&mysql_res,"can not get data of note",
"SELECT NotCod," // row[0]
"NoteType," // row[1]
"Cod," // row[2]
"UsrCod," // row[3]
"HieCod," // row[4]
"Unavailable," // row[5]
"UNIX_TIMESTAMP(TimeNote)" // row[6]
" FROM tl_notes"
" WHERE NotCod=%ld",
Not->NotCod))
if (TL_DB_GetDataOfNoteByCod (Not->NotCod,&mysql_res))
{
/***** Get data of note *****/
row = mysql_fetch_row (mysql_res);