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

This commit is contained in:
acanas 2021-02-27 15:09:23 +01:00
parent c2a05d146d
commit 70bd31cf91
4 changed files with 46 additions and 39 deletions

View File

@ -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.10 (2021-02-07)" #define Log_PLATFORM_VERSION "SWAD 20.36.11 (2021-02-07)"
#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,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: 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.11: Feb 27, 2021 Query moved to module swad_timeline_database. (305246 lines)
Version 20.36.10: Feb 27, 2021 Query moved to module swad_timeline_database. (305243 lines) Version 20.36.10: Feb 27, 2021 Query moved to module swad_timeline_database. (305243 lines)
Version 20.36.9: Feb 27, 2021 Query moved to module swad_timeline_database. (305233 lines) Version 20.36.9: Feb 27, 2021 Query moved to module swad_timeline_database. (305233 lines)
Version 20.36.8: Feb 27, 2021 Function moved to module swad_timeline_database. (305215 lines) Version 20.36.8: Feb 27, 2021 Function moved to module swad_timeline_database. (305215 lines)

View File

@ -50,6 +50,8 @@
/***************************** Private prototypes ****************************/ /***************************** Private prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
static long TL_DB_GetMedCodFromPub (long PubCod,const char *DBTable);
/*****************************************************************************/ /*****************************************************************************/
/***************************** Create a new note *****************************/ /***************************** Create a new note *****************************/
/*****************************************************************************/ /*****************************************************************************/
@ -128,6 +130,15 @@ void TL_DB_InsertNoteInVisibleTimeline (long NotCod)
NotCod); NotCod);
} }
/*****************************************************************************/
/***************** Get code of media associated to post **********************/
/*****************************************************************************/
long TL_DB_GetMedCodFromPost (long PubCod)
{
return TL_DB_GetMedCodFromPub (PubCod,"tl_posts");
}
/*****************************************************************************/ /*****************************************************************************/
/********************* Get number of comments in a note **********************/ /********************* Get number of comments in a note **********************/
/*****************************************************************************/ /*****************************************************************************/
@ -265,26 +276,7 @@ void TL_DB_InsertCommentContent (long PubCod,
long TL_DB_GetMedCodFromComment (long PubCod) long TL_DB_GetMedCodFromComment (long PubCod)
{ {
MYSQL_RES *mysql_res; return TL_DB_GetMedCodFromPub (PubCod,"tl_comments");
MYSQL_ROW row;
long MedCod = -1L; // Default value
/***** 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;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -329,3 +321,31 @@ void TL_DB_RemoveCommentPub (long PubCod,long PublisherCod)
PublisherCod, PublisherCod,
(unsigned) TL_Pub_COMMENT_TO_NOTE); (unsigned) TL_Pub_COMMENT_TO_NOTE);
} }
/*****************************************************************************/
/*************** Get code of media associated to post/comment ****************/
/*****************************************************************************/
static long TL_DB_GetMedCodFromPub (long PubCod,const char *DBTable)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long MedCod = -1L; // Default value
/***** Get code of media associated to comment *****/
if (DB_QuerySELECT (&mysql_res,"can not get media code",
"SELECT MedCod" // row[0]
" FROM %s"
" WHERE PubCod=%ld",
DBTable,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;
}

View File

@ -55,6 +55,9 @@ void TL_DB_MarkNotesChildrenOfFolderAsUnavailable (TL_Not_NoteType_t NoteType,
void TL_DB_InsertNoteInJustRetrievedNotes (long NotCod); void TL_DB_InsertNoteInJustRetrievedNotes (long NotCod);
void TL_DB_InsertNoteInVisibleTimeline (long NotCod); void TL_DB_InsertNoteInVisibleTimeline (long NotCod);
/* Posts */
long TL_DB_GetMedCodFromPost (long PubCod);
/* Comments */ /* Comments */
unsigned TL_DB_GetNumCommentsInNote (long NotCod); unsigned TL_DB_GetNumCommentsInNote (long NotCod);
unsigned TL_DB_GetComments (long NotCod,MYSQL_RES **mysql_res); unsigned TL_DB_GetComments (long NotCod,MYSQL_RES **mysql_res);

View File

@ -1228,25 +1228,8 @@ static void TL_Not_RemoveNoteMediaAndDBEntries (struct TL_Not_Note *Not)
/***** Remove media associated to post *****/ /***** Remove media associated to post *****/
if (Not->NoteType == TL_NOTE_POST) if (Not->NoteType == TL_NOTE_POST)
{ if ((MedCod = TL_DB_GetMedCodFromPost (Not->Cod)) > 0)
/* Remove media associated to a post from database */
if (DB_QuerySELECT (&mysql_res,"can not get media",
"SELECT MedCod" // row[0]
" FROM tl_posts"
" WHERE PstCod=%ld",
Not->Cod) == 1) // Result should have a unique row
{
/* Get media code */
row = mysql_fetch_row (mysql_res);
MedCod = Str_ConvertStrCodToLongCod (row[0]);
/* Remove media */
Med_RemoveMedia (MedCod); Med_RemoveMedia (MedCod);
}
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
}
/***** Mark possible notifications on the publications /***** Mark possible notifications on the publications
of this note as removed *****/ of this note as removed *****/