Version 20.36.5: Feb 26, 2021 Queries moved to module swad_timeline_database.

This commit is contained in:
acanas 2021-02-26 23:58:36 +01:00
parent 05c85c9734
commit fd781508a2
4 changed files with 53 additions and 26 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.4 (2021-02-26)"
#define Log_PLATFORM_VERSION "SWAD 20.36.5 (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.5: Feb 26, 2021 Queries moved to module swad_timeline_database. (305179 lines)
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)

View File

@ -938,15 +938,8 @@ static void TL_Com_RemoveComment (void)
void TL_Com_RemoveCommentMediaAndDBEntries (long PubCod)
{
long MedCod;
/***** Remove media associated to comment *****/
/* Get media code */
MedCod = TL_DB_GetMedCodFromComment (PubCod);
/* Remove media */
if (MedCod > 0)
Med_RemoveMedia (MedCod);
Med_RemoveMedia (TL_DB_GetMedCodFromComment (PubCod));
/***** Mark possible notifications on this comment as removed *****/
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_COMMENT,PubCod);
@ -954,26 +947,13 @@ void TL_Com_RemoveCommentMediaAndDBEntries (long PubCod)
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,PubCod);
/***** Remove favs for this comment *****/
DB_QueryDELETE ("can not remove favs for comment",
"DELETE FROM tl_comments_fav"
" WHERE PubCod=%ld",
PubCod);
TL_DB_RemoveCommentFavs (PubCod);
/***** Remove content of this comment *****/
DB_QueryDELETE ("can not remove a comment",
"DELETE FROM tl_comments"
" WHERE PubCod=%ld",
PubCod);
TL_DB_RemoveCommentContent (PubCod);
/***** Remove this comment *****/
DB_QueryDELETE ("can not remove a comment",
"DELETE FROM tl_pubs"
" WHERE PubCod=%ld"
" AND PublisherCod=%ld" // Extra check: I am the author
" AND PubType=%u", // Extra check: it's a comment
PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) TL_Pub_COMMENT_TO_NOTE);
TL_DB_RemoveCommentPub (PubCod,Gbl.Usrs.Me.UsrDat.UsrCod);
}
/*****************************************************************************/

View File

@ -147,7 +147,7 @@ long TL_DB_GetMedCodFromComment (long PubCod)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long MedCod = -1L;
long MedCod = -1L; // Default value
/***** Get code of media associated to comment *****/
if (DB_QuerySELECT (&mysql_res,"can not get media code",
@ -166,3 +166,46 @@ long TL_DB_GetMedCodFromComment (long PubCod)
return MedCod;
}
/*****************************************************************************/
/****************** Remove favs for comment from database ********************/
/*****************************************************************************/
void TL_DB_RemoveCommentFavs (long PubCod)
{
/***** Remove favs for comment *****/
DB_QueryDELETE ("can not remove favs for comment",
"DELETE FROM tl_comments_fav"
" WHERE PubCod=%ld",
PubCod);
}
/*****************************************************************************/
/***************** Remove content of comment from database *******************/
/*****************************************************************************/
void TL_DB_RemoveCommentContent (long PubCod)
{
/***** Remove content of comment *****/
DB_QueryDELETE ("can not remove a comment",
"DELETE FROM tl_comments"
" WHERE PubCod=%ld",
PubCod);
}
/*****************************************************************************/
/***************** Remove comment publication from database ******************/
/*****************************************************************************/
void TL_DB_RemoveCommentPub (long PubCod,long PublisherCod)
{
/***** Remove comment publication *****/
DB_QueryDELETE ("can not remove a comment",
"DELETE FROM tl_pubs"
" WHERE PubCod=%ld"
" AND PublisherCod=%ld" // Extra check: I am the author
" AND PubType=%u", // Extra check: it's a comment
PubCod,
PublisherCod,
(unsigned) TL_Pub_COMMENT_TO_NOTE);
}

View File

@ -52,5 +52,8 @@ unsigned TL_DB_GetFinalComments (long NotCod,
void TL_DB_InsertCommentContent (long PubCod,
const struct TL_Pst_PostContent *Content);
long TL_DB_GetMedCodFromComment (long PubCod);
void TL_DB_RemoveCommentFavs (long PubCod);
void TL_DB_RemoveCommentContent (long PubCod);
void TL_DB_RemoveCommentPub (long PubCod,long PublisherCod);
#endif