mirror of https://github.com/acanas/swad-core.git
Version 20.36.21: Feb 27, 2021 Function moved to module swad_timeline_database.
This commit is contained in:
parent
77ac719879
commit
bb8957e584
|
@ -553,7 +553,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
||||||
En OpenSWAD:
|
En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 20.36.19 (2021-02-27)"
|
#define Log_PLATFORM_VERSION "SWAD 20.36.21 (2021-02-27)"
|
||||||
#define CSS_FILE "swad20.33.9.css"
|
#define CSS_FILE "swad20.33.9.css"
|
||||||
#define JS_FILE "swad20.6.2.js"
|
#define JS_FILE "swad20.6.2.js"
|
||||||
/*
|
/*
|
||||||
|
@ -601,6 +601,8 @@ 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: 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
|
TODO: Salvador Romero Cortés: @acanas opción para editar posts
|
||||||
|
|
||||||
|
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)
|
Version 20.36.19: Feb 27, 2021 Queries moved to module swad_timeline_database. (305363 lines)
|
||||||
Version 20.36.18: Feb 27, 2021 Function moved to module swad_timeline_database. (305334 lines)
|
Version 20.36.18: Feb 27, 2021 Function moved to module swad_timeline_database. (305334 lines)
|
||||||
Version 20.36.17: Feb 27, 2021 Query moved to module swad_timeline_database. (305328 lines)
|
Version 20.36.17: Feb 27, 2021 Query moved to module swad_timeline_database. (305328 lines)
|
||||||
|
|
|
@ -135,6 +135,7 @@ mysql> SHOW TABLES LIKE 'tl_%';
|
||||||
#include "swad_photo.h"
|
#include "swad_photo.h"
|
||||||
#include "swad_profile.h"
|
#include "swad_profile.h"
|
||||||
#include "swad_timeline.h"
|
#include "swad_timeline.h"
|
||||||
|
#include "swad_timeline_database.h"
|
||||||
#include "swad_timeline_favourite.h"
|
#include "swad_timeline_favourite.h"
|
||||||
#include "swad_timeline_note.h"
|
#include "swad_timeline_note.h"
|
||||||
#include "swad_timeline_notification.h"
|
#include "swad_timeline_notification.h"
|
||||||
|
@ -238,7 +239,7 @@ void TL_ShowNoteAndTimelineGbl (struct TL_Timeline *Timeline)
|
||||||
|
|
||||||
/***** If a note should be highlighted ==> get code of note from database *****/
|
/***** If a note should be highlighted ==> get code of note from database *****/
|
||||||
if (PubCod > 0)
|
if (PubCod > 0)
|
||||||
Not.NotCod = TL_Pub_GetNotCodFromPubCod (PubCod);
|
Not.NotCod = TL_DB_GetNotCodFromPubCod (PubCod);
|
||||||
|
|
||||||
/***** If a note should be highlighted ==> show it above the timeline *****/
|
/***** If a note should be highlighted ==> show it above the timeline *****/
|
||||||
if (Not.NotCod > 0)
|
if (Not.NotCod > 0)
|
||||||
|
|
|
@ -590,6 +590,57 @@ static long TL_DB_GetMedCodFromPub (long PubCod,const char *DBTable)
|
||||||
return MedCod;
|
return MedCod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************** Select the most recent publication *********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
// Returns the number of rows got
|
||||||
|
|
||||||
|
unsigned TL_DB_SelectTheMostRecentPub (const struct TL_Pub_SubQueries *SubQueries,
|
||||||
|
MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get publication",
|
||||||
|
"SELECT tl_pubs.PubCod," // row[0]
|
||||||
|
"tl_pubs.NotCod," // row[1]
|
||||||
|
"tl_pubs.PublisherCod," // row[2]
|
||||||
|
"tl_pubs.PubType" // row[3]
|
||||||
|
" FROM tl_pubs%s"
|
||||||
|
" WHERE %s%s%s%s"
|
||||||
|
" ORDER BY tl_pubs.PubCod DESC LIMIT 1",
|
||||||
|
SubQueries->TablePublishers,
|
||||||
|
SubQueries->RangeBottom,
|
||||||
|
SubQueries->RangeTop,
|
||||||
|
SubQueries->Publishers,
|
||||||
|
SubQueries->AlreadyExists);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*********************** Get code of note of a publication *******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
long TL_DB_GetNotCodFromPubCod (long PubCod)
|
||||||
|
{
|
||||||
|
MYSQL_RES *mysql_res;
|
||||||
|
MYSQL_ROW row;
|
||||||
|
long NotCod = -1L; // Default value
|
||||||
|
|
||||||
|
/***** Get code of note from database *****/
|
||||||
|
if (DB_QuerySELECT (&mysql_res,"can not get code of note",
|
||||||
|
"SELECT NotCod FROM tl_pubs"
|
||||||
|
" WHERE PubCod=%ld",
|
||||||
|
PubCod) == 1) // Result should have a unique row
|
||||||
|
{
|
||||||
|
/* Get code of note */
|
||||||
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
NotCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Free structure that stores the query result *****/
|
||||||
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
|
return NotCod;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************* Get last/first publication code stored in session *************/
|
/************* Get last/first publication code stored in session *************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "swad_file_browser.h"
|
#include "swad_file_browser.h"
|
||||||
#include "swad_timeline_note.h"
|
#include "swad_timeline_note.h"
|
||||||
#include "swad_timeline_post.h"
|
#include "swad_timeline_post.h"
|
||||||
|
#include "swad_timeline_publication.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
|
@ -91,6 +92,9 @@ void TL_DB_RemoveCommentContent (long PubCod);
|
||||||
void TL_DB_RemoveCommentPub (long PubCod,long PublisherCod);
|
void TL_DB_RemoveCommentPub (long PubCod,long PublisherCod);
|
||||||
|
|
||||||
/* Publications */
|
/* Publications */
|
||||||
|
unsigned TL_DB_SelectTheMostRecentPub (const struct TL_Pub_SubQueries *SubQueries,
|
||||||
|
MYSQL_RES **mysql_res);
|
||||||
|
long TL_DB_GetNotCodFromPubCod (long PubCod);
|
||||||
long TL_DB_GetPubCodFromSession (const char *FieldName,
|
long TL_DB_GetPubCodFromSession (const char *FieldName,
|
||||||
const char SessionId[Cns_BYTES_SESSION_ID + 1]);
|
const char SessionId[Cns_BYTES_SESSION_ID + 1]);
|
||||||
void TL_DB_UpdateFirstPubCodInSession (long FirstPubCod,
|
void TL_DB_UpdateFirstPubCodInSession (long FirstPubCod,
|
||||||
|
|
|
@ -47,16 +47,6 @@
|
||||||
/************************* Private constants and types ***********************/
|
/************************* Private constants and types ***********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define TL_Pub_MAX_BYTES_SUBQUERY (128 - 1)
|
|
||||||
struct TL_Pub_SubQueries
|
|
||||||
{
|
|
||||||
char *TablePublishers;
|
|
||||||
char Publishers [TL_Pub_MAX_BYTES_SUBQUERY + 1];
|
|
||||||
char RangeBottom [TL_Pub_MAX_BYTES_SUBQUERY + 1];
|
|
||||||
char RangeTop [TL_Pub_MAX_BYTES_SUBQUERY + 1];
|
|
||||||
char AlreadyExists[TL_Pub_MAX_BYTES_SUBQUERY + 1];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TL_Pub_RangePubsToGet
|
struct TL_Pub_RangePubsToGet
|
||||||
{
|
{
|
||||||
long Top;
|
long Top;
|
||||||
|
@ -424,25 +414,9 @@ void TL_Pub_FreeListPubs (struct TL_Timeline *Timeline)
|
||||||
static struct TL_Pub_Publication *TL_Pub_SelectTheMostRecentPub (const struct TL_Pub_SubQueries *SubQueries)
|
static struct TL_Pub_Publication *TL_Pub_SelectTheMostRecentPub (const struct TL_Pub_SubQueries *SubQueries)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned NumPubs = 0; // Initialized to avoid warning
|
|
||||||
struct TL_Pub_Publication *Pub;
|
struct TL_Pub_Publication *Pub;
|
||||||
|
|
||||||
NumPubs =
|
if (TL_DB_SelectTheMostRecentPub (SubQueries,&mysql_res) == 1)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get publication",
|
|
||||||
"SELECT tl_pubs.PubCod," // row[0]
|
|
||||||
"tl_pubs.NotCod," // row[1]
|
|
||||||
"tl_pubs.PublisherCod," // row[2]
|
|
||||||
"tl_pubs.PubType" // row[3]
|
|
||||||
" FROM tl_pubs%s"
|
|
||||||
" WHERE %s%s%s%s"
|
|
||||||
" ORDER BY tl_pubs.PubCod DESC LIMIT 1",
|
|
||||||
SubQueries->TablePublishers,
|
|
||||||
SubQueries->RangeBottom,
|
|
||||||
SubQueries->RangeTop,
|
|
||||||
SubQueries->Publishers,
|
|
||||||
SubQueries->AlreadyExists);
|
|
||||||
|
|
||||||
if (NumPubs == 1)
|
|
||||||
{
|
{
|
||||||
/* Allocate space for publication */
|
/* Allocate space for publication */
|
||||||
if ((Pub = malloc (sizeof (*Pub))) == NULL)
|
if ((Pub = malloc (sizeof (*Pub))) == NULL)
|
||||||
|
@ -608,33 +582,6 @@ long TL_Pub_GetParamPubCod (void)
|
||||||
return Par_GetParToLong ("PubCod");
|
return Par_GetParToLong ("PubCod");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*********************** Get code of note of a publication *******************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
long TL_Pub_GetNotCodFromPubCod (long PubCod)
|
|
||||||
{
|
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
long NotCod = -1L;
|
|
||||||
|
|
||||||
/***** Get code of note from database *****/
|
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get code of note",
|
|
||||||
"SELECT NotCod FROM tl_pubs"
|
|
||||||
" WHERE PubCod=%ld",
|
|
||||||
PubCod) == 1) // Result should have a unique row
|
|
||||||
{
|
|
||||||
/* Get code of note */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
NotCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return NotCod;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************** Get data of publication using its code ********************/
|
/***************** Get data of publication using its code ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -65,6 +65,16 @@ struct TL_Pub_Publication
|
||||||
struct TL_Pub_Publication *Next; // Used for chained list
|
struct TL_Pub_Publication *Next; // Used for chained list
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define TL_Pub_MAX_BYTES_SUBQUERY (128 - 1)
|
||||||
|
struct TL_Pub_SubQueries
|
||||||
|
{
|
||||||
|
char *TablePublishers;
|
||||||
|
char Publishers [TL_Pub_MAX_BYTES_SUBQUERY + 1];
|
||||||
|
char RangeBottom [TL_Pub_MAX_BYTES_SUBQUERY + 1];
|
||||||
|
char RangeTop [TL_Pub_MAX_BYTES_SUBQUERY + 1];
|
||||||
|
char AlreadyExists[TL_Pub_MAX_BYTES_SUBQUERY + 1];
|
||||||
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************************** Public prototypes ****************************/
|
/****************************** Public prototypes ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -83,8 +93,6 @@ void TL_Pub_PutLinkToViewOldPublications (void);
|
||||||
void TL_Pub_PutHiddenParamPubCod (long PubCod);
|
void TL_Pub_PutHiddenParamPubCod (long PubCod);
|
||||||
long TL_Pub_GetParamPubCod (void);
|
long TL_Pub_GetParamPubCod (void);
|
||||||
|
|
||||||
long TL_Pub_GetNotCodFromPubCod (long PubCod);
|
|
||||||
|
|
||||||
void TL_Pub_GetDataOfPublicationFromNextRow (MYSQL_RES *mysql_res,
|
void TL_Pub_GetDataOfPublicationFromNextRow (MYSQL_RES *mysql_res,
|
||||||
struct TL_Pub_Publication *Pub);
|
struct TL_Pub_Publication *Pub);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue