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

This commit is contained in:
acanas 2021-03-01 14:46:57 +01:00
parent a32ed57305
commit df6dfc270b
4 changed files with 71 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.43 (2021-03-01)"
#define Log_PLATFORM_VERSION "SWAD 20.36.44 (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.44: Mar 01, 2021 Query moved to module swad_timeline_database. (305516 lines)
Version 20.36.43: Mar 01, 2021 Query moved to module swad_timeline_database. (305489 lines)
Version 20.36.42: Mar 01, 2021 Query moved to module swad_timeline_database. (305476 lines)
Version 20.36.41: Mar 01, 2021 Query moved to module swad_timeline_database. (305466 lines)

View File

@ -50,6 +50,11 @@ static const char *TL_DB_Field[TL_Fav_NUM_WHAT_TO_FAV] =
[TL_Fav_NOTE] = "NotCod",
[TL_Fav_COMM] = "PubCod",
};
static TL_Pub_PubType_t TL_DB_PubType[TL_Fav_NUM_WHAT_TO_FAV] =
{
[TL_Fav_NOTE] = TL_Pub_ORIGINAL_NOTE,
[TL_Fav_COMM] = TL_Pub_COMMENT_TO_NOTE,
};
/*****************************************************************************/
/************** External global variables from others modules ****************/
@ -914,12 +919,14 @@ void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod)
}
/*****************************************************************************/
/********** Remove all publications of any user authored by a user ***********/
/** Remove all publications published by any user & authored by a given user */
/*****************************************************************************/
void TL_DB_RemoveAllPubsOfAnyUsrAuthoredBy (long UsrCod)
void TL_DB_RemoveAllPubsPublishedByAnyUsrOfNotesAuthoredBy (long UsrCod)
{
/***** Remove all publications of any user authored by the user *****/
/***** Remove all publications (original or shared notes)
published by any user
of notes authored by this user *****/
DB_QueryDELETE ("can not remove publications",
"DELETE FROM tl_pubs"
" USING tl_notes,tl_pubs"
@ -929,12 +936,12 @@ void TL_DB_RemoveAllPubsOfAnyUsrAuthoredBy (long UsrCod)
}
/*****************************************************************************/
/********************* Remove all publications of a user *********************/
/**************** Remove all publications published by a user ****************/
/*****************************************************************************/
void TL_DB_RemoveAllPubsUsr (long UsrCod)
void TL_DB_RemoveAllPubsPublishedBy (long UsrCod)
{
/***** Remove all publications of user *****/
/***** Remove all publications published by the user *****/
DB_QueryDELETE ("can not remove publications",
"DELETE FROM tl_pubs WHERE PublisherCod=%ld",
UsrCod);
@ -1028,17 +1035,55 @@ void TL_DB_UnmarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod)
}
/*****************************************************************************/
/************* Remove all favs made by this user in any comment **************/
/********** Remove all favs made by a given user to any comment **************/
/*****************************************************************************/
void TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_WhatToFav_t WhatToFav,long UsrCod)
{
/* Remove all favs made by this user in any comment */
/* Remove all favs made by this user to any comment */
DB_QueryDELETE ("can not remove favs",
"DELETE FROM %s WHERE UsrCod=%ld",
TL_DB_Table[WhatToFav],UsrCod);
}
/*****************************************************************************/
/************ Remove all favs to notes/comments of a given user **************/
/*****************************************************************************/
void TL_DB_RemoveAllFavsToPubsBy (TL_Fav_WhatToFav_t WhatToFav,long UsrCod)
{
/***** Remove all favs to notes/comments of this user *****/
DB_QueryDELETE ("can not remove favs",
"DELETE FROM %s"
" USING tl_pubs,%s"
" WHERE tl_pubs.PublisherCod=%ld" // Author of the comment
" AND tl_pubs.PubType=%u"
" AND tl_pubs.PubCod=%s.PubCod",
TL_DB_Table[WhatToFav],
TL_DB_Table[WhatToFav],
UsrCod,
(unsigned) TL_DB_PubType[WhatToFav],
TL_DB_Table[WhatToFav]);
}
/*****************************************************************************/
/*** Remove all favs to all comments in all notes authored by a given user ***/
/*****************************************************************************/
void TL_DB_RemoveAllFavsToAllCommentsInAllNotesBy (long UsrCod)
{
/***** Remove all favs to all comments
in all notes authored by this user *****/
DB_QueryDELETE ("can not remove favs",
"DELETE FROM tl_comments_fav"
" USING tl_notes,tl_pubs,tl_comments_fav"
" WHERE tl_notes.UsrCod=%ld" // Author of the note
" AND tl_notes.NotCod=tl_pubs.NotCod"
" AND tl_pubs.PubType=%u"
" AND tl_pubs.PubCod=tl_comments_fav.PubCod",
UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE);
}
/*****************************************************************************/
/****************** Check if a user has published a note *********************/
/*****************************************************************************/

View File

@ -114,8 +114,8 @@ long TL_DB_CreateNewPub (const struct TL_Pub_Publication *Pub);
void TL_DB_UpdateFirstPubCodInSession (long FirstPubCod);
void TL_DB_UpdateLastPubCodInSession (void);
void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod);
void TL_DB_RemoveAllPubsOfAnyUsrAuthoredBy (long UsrCod);
void TL_DB_RemoveAllPubsUsr (long UsrCod);
void TL_DB_RemoveAllPubsPublishedByAnyUsrOfNotesAuthoredBy (long UsrCod);
void TL_DB_RemoveAllPubsPublishedBy (long UsrCod);
/****************************** Favourites ***********************************/
bool TL_DB_CheckIfFavedByUsr (TL_Fav_WhatToFav_t WhatToFav,
@ -129,6 +129,8 @@ unsigned TL_DB_GetListUsrsHaveFaved (TL_Fav_WhatToFav_t WhatToFav,
void TL_DB_MarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod);
void TL_DB_UnmarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod);
void TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_WhatToFav_t WhatToFav,long UsrCod);
void TL_DB_RemoveAllFavsToPubsBy (TL_Fav_WhatToFav_t WhatToFav,long UsrCod);
void TL_DB_RemoveAllFavsToAllCommentsInAllNotesBy (long UsrCod);
/******************************** Shared *************************************/
bool TL_DB_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod);

View File

@ -69,39 +69,21 @@ extern struct Globals Gbl;
void TL_Usr_RemoveUsrContent (long UsrCod)
{
/***** Remove favs for comments *****/
/* Remove all favs made by this user in any comment */
/* Remove all favs made by this user to any comment */
TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_COMM,UsrCod);
/* Remove all favs for all comments of this user */
DB_QueryDELETE ("can not remove favs",
"DELETE FROM tl_comments_fav"
" USING tl_pubs,tl_comments_fav"
" WHERE tl_pubs.PublisherCod=%ld" // Author of the comment
" AND tl_pubs.PubType=%u"
" AND tl_pubs.PubCod=tl_comments_fav.PubCod",
UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE);
/* Remove all favs to comments of this user */
TL_DB_RemoveAllFavsToPubsBy (TL_Fav_COMM,UsrCod);
/* Remove all favs for all comments in all the notes of the user */
DB_QueryDELETE ("can not remove comments",
"DELETE FROM tl_comments_fav"
" USING tl_notes,tl_pubs,tl_comments_fav"
" WHERE tl_notes.UsrCod=%ld" // Author of the note
" AND tl_notes.NotCod=tl_pubs.NotCod"
" AND tl_pubs.PubType=%u"
" AND tl_pubs.PubCod=tl_comments_fav.PubCod",
UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE);
/* Remove all favs to all comments in all notes authored by this user */
TL_DB_RemoveAllFavsToAllCommentsInAllNotesBy (UsrCod);
/***** Remove favs for notes *****/
/* Remove all favs made by this user in any note */
TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_NOTE,UsrCod);
/* Remove all favs for all notes of this user */
DB_QueryDELETE ("can not remove favs",
"DELETE FROM tl_notes_fav"
" USING tl_notes,tl_notes_fav"
" WHERE tl_notes.UsrCod=%ld" // Author of the note
" AND tl_notes.NotCod=tl_notes_fav.NotCod",
UsrCod);
/* Remove all favs to notes of this user */
TL_DB_RemoveAllFavsToPubsBy (TL_Fav_NOTE,UsrCod);
/***** Remove comments *****/
/* Remove content of all comments in all the notes of the user */
@ -137,11 +119,12 @@ void TL_Usr_RemoveUsrContent (long UsrCod)
TL_DB_RemoveAllPostsUsr (UsrCod);
/***** Remove publications *****/
/* Remove all publications of any user authored by the user */
TL_DB_RemoveAllPubsOfAnyUsrAuthoredBy (UsrCod);
/* Remove all publications (original or shared notes) published by any user
of notes authored by the user */
TL_DB_RemoveAllPubsPublishedByAnyUsrOfNotesAuthoredBy (UsrCod);
/* Remove all the publications of the user */
TL_DB_RemoveAllPubsUsr (UsrCod);
/* Remove all publications published by the user */
TL_DB_RemoveAllPubsPublishedBy (UsrCod);
/***** Remove notes *****/
/* Remove all notes of the user */