Version 20.36.34: Mar 01, 2021 Function moved to module swad_timeline_database.

This commit is contained in:
acanas 2021-03-01 11:48:44 +01:00
parent fc4c188e68
commit 5fc917c664
6 changed files with 24 additions and 25 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.33 (2021-03-01)"
#define Log_PLATFORM_VERSION "SWAD 20.36.34 (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.34: Mar 01, 2021 Function moved to module swad_timeline_database. (305446 lines)
Version 20.36.33: Mar 01, 2021 Function moved to module swad_timeline_database. (305446 lines)
Version 20.36.32: Mar 01, 2021 Query moved to module swad_timeline_database. (305444 lines)
Version 20.36.31: Mar 01, 2021 Code refactoring in timeline favourites. (305432 lines)

View File

@ -1013,6 +1013,24 @@ bool TL_DB_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod)
(unsigned) TL_Pub_SHARED_NOTE) != 0);
}
/*****************************************************************************/
/********** Get number of times a note has been shared in timeline ***********/
/*****************************************************************************/
unsigned TL_DB_GetNumTimesANoteHasBeenShared (struct TL_Not_Note *Not)
{
/***** Get number of times (users) this note has been shared *****/
return (unsigned)
DB_QueryCOUNT ("can not get number of times a note has been shared",
"SELECT COUNT(*) FROM tl_pubs"
" WHERE NotCod=%ld"
" AND PublisherCod<>%ld"
" AND PubType=%u",
Not->NotCod,
Not->UsrCod, // Author of the note
(unsigned) TL_Pub_SHARED_NOTE);
}
/*****************************************************************************/
/****************** Remove shared publication from database ******************/
/*****************************************************************************/

View File

@ -128,6 +128,7 @@ void TL_DB_UnmarkCommAsFav (long PubCod);
/******************************** Shared *************************************/
bool TL_DB_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod);
unsigned TL_DB_GetNumTimesANoteHasBeenShared (struct TL_Not_Note *Not);
void TL_DB_RemoveSharedPub (long NotCod);
#endif

View File

@ -1291,7 +1291,7 @@ static void TL_Not_GetDataOfNoteFromRow (MYSQL_ROW row,struct TL_Not_Note *Not)
Not->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[6]);
/***** Get number of times this note has been shared *****/
TL_Sha_UpdateNumTimesANoteHasBeenShared (Not);
Not->NumShared = TL_DB_GetNumTimesANoteHasBeenShared (Not);
/***** Get number of times this note has been favourited *****/
Not->NumFavs = TL_DB_GetNumTimesANoteHasBeenFav (Not);

View File

@ -135,7 +135,7 @@ static void TL_Sha_ShaNote (struct TL_Not_Note *Not)
TL_Pub_PublishPubInTimeline (&Pub); // Set Pub.PubCod
/* Update number of times this note is shared */
TL_Sha_UpdateNumTimesANoteHasBeenShared (Not);
Not->NumShared = TL_DB_GetNumTimesANoteHasBeenShared (Not);
/**** Create notification about shared post
for the author of the post ***/
@ -189,7 +189,7 @@ static void TL_Sha_UnsNote (struct TL_Not_Note *Not)
TL_DB_RemoveSharedPub (Not->NotCod);
/***** Update number of times this note is shared *****/
TL_Sha_UpdateNumTimesANoteHasBeenShared (Not);
Not->NumShared = TL_DB_GetNumTimesANoteHasBeenShared (Not);
/***** Mark possible notifications on this note as removed *****/
OriginalPubCod = TL_DB_GetPubCodOfOriginalNote (Not->NotCod);
@ -271,25 +271,6 @@ static void TL_Sha_PutFormToShaUnsNote (long NotCod)
Gbl.Usrs.Me.UsrDat.UsrCod)]);
}
/*****************************************************************************/
/********** Get number of times a note has been shared in timeline ***********/
/*****************************************************************************/
void TL_Sha_UpdateNumTimesANoteHasBeenShared (struct TL_Not_Note *Not)
{
/***** Get number of times (users) this note has been shared *****/
Not->NumShared =
(unsigned) DB_QueryCOUNT ("can not get number of times"
" a note has been shared",
"SELECT COUNT(*) FROM tl_pubs"
" WHERE NotCod=%ld"
" AND PublisherCod<>%ld"
" AND PubType=%u",
Not->NotCod,
Not->UsrCod, // The author
(unsigned) TL_Pub_SHARED_NOTE);
}
/*****************************************************************************/
/******************* Show users who have shared this note ********************/
/*****************************************************************************/

View File

@ -50,6 +50,4 @@ void TL_Sha_UnsNoteGbl (void);
void TL_Sha_PutIconToShaUnsNote (const struct TL_Not_Note *Not,
TL_Usr_HowManyUsrs_t HowManyUsrs);
void TL_Sha_UpdateNumTimesANoteHasBeenShared (struct TL_Not_Note *Not);
#endif