Version 20.36.27: Feb 28, 2021 Functions moved to module swad_timeline_database.

This commit is contained in:
acanas 2021-02-28 21:47:18 +01:00
parent 9bbd553491
commit d388d5552e
4 changed files with 37 additions and 36 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.26 (2021-02-28)" #define Log_PLATFORM_VERSION "SWAD 20.36.27 (2021-02-28)"
#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.27: Feb 28, 2021 Functions moved to module swad_timeline_database. (305424 lines)
Version 20.36.26: Feb 28, 2021 Queries moved to module swad_timeline_database. (305423 lines) Version 20.36.26: Feb 28, 2021 Queries moved to module swad_timeline_database. (305423 lines)
Version 20.36.25: Feb 28, 2021 Queries moved to module swad_timeline_database. (305405 lines) Version 20.36.25: Feb 28, 2021 Queries moved to module swad_timeline_database. (305405 lines)
Version 20.36.24: Feb 28, 2021 Functions moved to module swad_timeline_database. (305385 lines) Version 20.36.24: Feb 28, 2021 Functions moved to module swad_timeline_database. (305385 lines)

View File

@ -848,6 +848,33 @@ void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod)
Gbl.Session.Id); Gbl.Session.Id);
} }
/*****************************************************************************/
/****************** Check if a user has favourited a note ********************/
/*****************************************************************************/
bool TL_DB_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod)
{
return (DB_QueryCOUNT ("can not check if a user"
" has favourited a note",
"SELECT COUNT(*) FROM tl_notes_fav"
" WHERE NotCod=%ld AND UsrCod=%ld",
NotCod,UsrCod) != 0);
}
/*****************************************************************************/
/**************** Check if a user has favourited a comment *******************/
/*****************************************************************************/
bool TL_DB_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod)
{
return (DB_QueryCOUNT ("can not check if a user"
" has favourited a comment",
"SELECT COUNT(*) FROM tl_comments_fav"
" WHERE PubCod=%ld AND UsrCod=%ld",
PubCod,UsrCod) != 0);
}
/*****************************************************************************/ /*****************************************************************************/
/********************** Mark note as favourite in database *******************/ /********************** Mark note as favourite in database *******************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -111,6 +111,8 @@ void TL_DB_UpdateLastPubCodInSession (void);
void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod); void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod);
/****************************** Favourites ***********************************/ /****************************** Favourites ***********************************/
bool TL_DB_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod);
bool TL_DB_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod);
void TL_DB_MarkNoteAsFav (long NotCod); void TL_DB_MarkNoteAsFav (long NotCod);
void TL_DB_MarkCommAsFav (long PubCod); void TL_DB_MarkCommAsFav (long PubCod);
void TL_DB_UnmarkNoteAsFav (long NotCod); void TL_DB_UnmarkNoteAsFav (long NotCod);

View File

@ -69,9 +69,6 @@ static void TL_Fav_PutDisabledIconFav (unsigned NumFavs);
static void TL_Fav_PutFormToFavUnfNote (long NotCod); static void TL_Fav_PutFormToFavUnfNote (long NotCod);
static void TL_Fav_PutFormToFavUnfComm (long PubCod); static void TL_Fav_PutFormToFavUnfComm (long PubCod);
static bool TL_Fav_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod);
static bool TL_Fav_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod);
static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Not_Note *Not, static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Not_Note *Not,
TL_Usr_HowManyUsrs_t HowManyUsrs); TL_Usr_HowManyUsrs_t HowManyUsrs);
static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Com_Comment *Com, static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Com_Comment *Com,
@ -171,7 +168,7 @@ static void TL_Fav_FavNote (struct TL_Not_Note *Not)
{ {
if (Gbl.Usrs.Me.Logged && // I am logged... if (Gbl.Usrs.Me.Logged && // I am logged...
!Usr_ItsMe (Not->UsrCod)) // ...but I am not the author !Usr_ItsMe (Not->UsrCod)) // ...but I am not the author
if (!TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod, if (!TL_DB_CheckIfNoteIsFavedByUsr (Not->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the note Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the note
{ {
/***** Mark note as favourite in database *****/ /***** Mark note as favourite in database *****/
@ -202,7 +199,7 @@ static void TL_Fav_UnfNote (struct TL_Not_Note *Not)
if (Not->NumFavs && if (Not->NumFavs &&
Gbl.Usrs.Me.Logged && // I am logged... Gbl.Usrs.Me.Logged && // I am logged...
!Usr_ItsMe (Not->UsrCod)) // ...but I am not the author !Usr_ItsMe (Not->UsrCod)) // ...but I am not the author
if (TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod, if (TL_DB_CheckIfNoteIsFavedByUsr (Not->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the note Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the note
{ {
/***** Delete the mark as favourite from database *****/ /***** Delete the mark as favourite from database *****/
@ -312,7 +309,7 @@ static void TL_Fav_FavComment (struct TL_Com_Comment *Com)
if (Com->PubCod > 0) if (Com->PubCod > 0)
if (!Usr_ItsMe (Com->UsrCod)) // I am not the author if (!Usr_ItsMe (Com->UsrCod)) // I am not the author
if (!TL_Fav_CheckIfCommIsFavedByUsr (Com->PubCod, if (!TL_DB_CheckIfCommIsFavedByUsr (Com->PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the comment Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the comment
{ {
/***** Mark comment as favourite in database *****/ /***** Mark comment as favourite in database *****/
@ -343,7 +340,7 @@ static void TL_Fav_UnfComment (struct TL_Com_Comment *Com)
if (Com->PubCod > 0) if (Com->PubCod > 0)
if (Com->NumFavs && if (Com->NumFavs &&
!Usr_ItsMe (Com->UsrCod)) // I am not the author !Usr_ItsMe (Com->UsrCod)) // I am not the author
if (TL_Fav_CheckIfCommIsFavedByUsr (Com->PubCod, if (TL_DB_CheckIfCommIsFavedByUsr (Com->PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the comment Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the comment
{ {
/***** Delete the mark as favourite from database *****/ /***** Delete the mark as favourite from database *****/
@ -412,7 +409,7 @@ static void TL_Fav_PutFormToFavUnfNote (long NotCod)
}; };
/***** Form and icon to fav/unfav note *****/ /***** Form and icon to fav/unfav note *****/
TL_Frm_FormFavSha (&Form[TL_Fav_CheckIfNoteIsFavedByUsr (NotCod,Gbl.Usrs.Me.UsrDat.UsrCod)]); TL_Frm_FormFavSha (&Form[TL_DB_CheckIfNoteIsFavedByUsr (NotCod,Gbl.Usrs.Me.UsrDat.UsrCod)]);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -444,33 +441,7 @@ static void TL_Fav_PutFormToFavUnfComm (long PubCod)
}; };
/***** Form and icon to fav/unfav *****/ /***** Form and icon to fav/unfav *****/
TL_Frm_FormFavSha (&Form[TL_Fav_CheckIfNoteIsFavedByUsr (PubCod,Gbl.Usrs.Me.UsrDat.UsrCod)]); TL_Frm_FormFavSha (&Form[TL_DB_CheckIfNoteIsFavedByUsr (PubCod,Gbl.Usrs.Me.UsrDat.UsrCod)]);
}
/*****************************************************************************/
/****************** Check if a user has favourited a note ********************/
/*****************************************************************************/
static bool TL_Fav_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod)
{
return (DB_QueryCOUNT ("can not check if a user"
" has favourited a note",
"SELECT COUNT(*) FROM tl_notes_fav"
" WHERE NotCod=%ld AND UsrCod=%ld",
NotCod,UsrCod) != 0);
}
/*****************************************************************************/
/**************** Check if a user has favourited a comment *******************/
/*****************************************************************************/
static bool TL_Fav_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod)
{
return (DB_QueryCOUNT ("can not check if a user"
" has favourited a comment",
"SELECT COUNT(*) FROM tl_comments_fav"
" WHERE PubCod=%ld AND UsrCod=%ld",
PubCod,UsrCod) != 0);
} }
/*****************************************************************************/ /*****************************************************************************/