mirror of https://github.com/acanas/swad-core.git
Version 20.40: Mar 03, 2021 Code refactoring in fav/share timeline.
This commit is contained in:
parent
a83e87d750
commit
e3865dc32c
|
@ -598,10 +598,11 @@ 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
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 20.39.11 (2021-03-02)"
|
#define Log_PLATFORM_VERSION "SWAD 20.40 (2021-03-03)"
|
||||||
#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"
|
||||||
/*
|
/*
|
||||||
|
Version 20.40: Mar 03, 2021 Code refactoring in fav/share timeline. (305532 lines)
|
||||||
Version 20.39.11: Mar 02, 2021 Code refactoring in fav/share timeline. (305525 lines)
|
Version 20.39.11: Mar 02, 2021 Code refactoring in fav/share timeline. (305525 lines)
|
||||||
Version 20.39.10: Mar 02, 2021 Code refactoring in timeline. (305576 lines)
|
Version 20.39.10: Mar 02, 2021 Code refactoring in timeline. (305576 lines)
|
||||||
Version 20.39.9: Mar 02, 2021 Code refactoring in timeline. (305580 lines)
|
Version 20.39.9: Mar 02, 2021 Code refactoring in timeline. (305580 lines)
|
||||||
|
|
|
@ -644,7 +644,8 @@ static void TL_Com_WriteButtons (const struct TL_Timeline *Timeline,
|
||||||
/***** Foot column 1: fav zone *****/
|
/***** Foot column 1: fav zone *****/
|
||||||
HTM_DIV_Begin ("id=\"fav_com_%s_%u\" class=\"TL_FAV_COM TL_FAV_WIDTH\"",
|
HTM_DIV_Begin ("id=\"fav_com_%s_%u\" class=\"TL_FAV_COM TL_FAV_WIDTH\"",
|
||||||
Gbl.UniqueNameEncrypted,NumDiv);
|
Gbl.UniqueNameEncrypted,NumDiv);
|
||||||
TL_Fav_PutIconToFavUnf (TL_Fav_COMM,Com->PubCod,Com->UsrCod,Com->NumFavs,
|
TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_COMM,
|
||||||
|
Com->PubCod,Com->UsrCod,Com->NumFavs,
|
||||||
TL_Usr_SHOW_FEW_USRS);
|
TL_Usr_SHOW_FEW_USRS);
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
|
||||||
|
@ -1077,8 +1078,8 @@ static void TL_Com_GetDataOfCommFromRow (MYSQL_ROW row,
|
||||||
Med_GetMediaDataByCod (&Com->Content.Media);
|
Med_GetMediaDataByCod (&Com->Content.Media);
|
||||||
|
|
||||||
/***** Get number of times this comment has been favourited *****/
|
/***** Get number of times this comment has been favourited *****/
|
||||||
Com->NumFavs = TL_DB_GetNumTimesHasBeenFav (TL_Fav_COMM,
|
Com->NumFavs = TL_DB_GetNumFavers (TL_Usr_FAV_UNF_COMM,
|
||||||
Com->PubCod,Com->UsrCod);
|
Com->PubCod,Com->UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -40,20 +40,23 @@
|
||||||
/************************* Private constants and types ***********************/
|
/************************* Private constants and types ***********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static const char *TL_DB_Table[TL_Fav_NUM_WHAT_TO_FAV] =
|
static const char *TL_DB_TableFav[TL_Usr_NUM_FAV_SHA] =
|
||||||
{
|
{
|
||||||
[TL_Fav_NOTE] = "tl_notes_fav",
|
[TL_Usr_FAV_UNF_NOTE] = "tl_notes_fav",
|
||||||
[TL_Fav_COMM] = "tl_comments_fav",
|
[TL_Usr_FAV_UNF_COMM] = "tl_comments_fav",
|
||||||
|
[TL_Usr_SHA_UNS_NOTE] = NULL, // Not used
|
||||||
};
|
};
|
||||||
static const char *TL_DB_Field[TL_Fav_NUM_WHAT_TO_FAV] =
|
static const char *TL_DB_FieldFav[TL_Usr_NUM_FAV_SHA] =
|
||||||
{
|
{
|
||||||
[TL_Fav_NOTE] = "NotCod",
|
[TL_Usr_FAV_UNF_NOTE] = "NotCod",
|
||||||
[TL_Fav_COMM] = "PubCod",
|
[TL_Usr_FAV_UNF_COMM] = "PubCod",
|
||||||
|
[TL_Usr_SHA_UNS_NOTE] = NULL, // Not used
|
||||||
};
|
};
|
||||||
static TL_Pub_PubType_t TL_DB_PubType[TL_Fav_NUM_WHAT_TO_FAV] =
|
static TL_Pub_PubType_t TL_DB_PubTypeFav[TL_Usr_NUM_FAV_SHA] =
|
||||||
{
|
{
|
||||||
[TL_Fav_NOTE] = TL_Pub_ORIGINAL_NOTE,
|
[TL_Usr_FAV_UNF_NOTE] = TL_Pub_ORIGINAL_NOTE,
|
||||||
[TL_Fav_COMM] = TL_Pub_COMMENT_TO_NOTE,
|
[TL_Usr_FAV_UNF_COMM] = TL_Pub_COMMENT_TO_NOTE,
|
||||||
|
[TL_Usr_SHA_UNS_NOTE] = TL_Pub_UNKNOWN, // Not used
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -881,7 +884,7 @@ long TL_DB_GetPubCodFromSession (const char *FieldName)
|
||||||
" WHERE SessionId='%s'",
|
" WHERE SessionId='%s'",
|
||||||
FieldName,Gbl.Session.Id) == 1)
|
FieldName,Gbl.Session.Id) == 1)
|
||||||
{
|
{
|
||||||
/***** Get last publication code *****/
|
/* Get last publication code */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
if (sscanf (row[0],"%ld",&PubCod) != 1)
|
if (sscanf (row[0],"%ld",&PubCod) != 1)
|
||||||
PubCod = 0;
|
PubCod = 0;
|
||||||
|
@ -1007,23 +1010,21 @@ void TL_DB_RemoveAllPubsPublishedBy (long UsrCod)
|
||||||
/****************** Check if a user has favourited a note ********************/
|
/****************** Check if a user has favourited a note ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
bool TL_DB_CheckIfFavedByUsr (TL_Fav_WhatToFav_t WhatToFav,
|
bool TL_DB_CheckIfFavedByUsr (TL_Usr_FavSha_t FavSha,long Cod,long UsrCod)
|
||||||
long Cod,long UsrCod)
|
|
||||||
{
|
{
|
||||||
/***** Check if a user has favourited a note/comment from database *****/
|
/***** Check if a user has favourited a note/comment from database *****/
|
||||||
return (DB_QueryCOUNT ("can not check if a user has favourited",
|
return (DB_QueryCOUNT ("can not check if a user has favourited",
|
||||||
"SELECT COUNT(*) FROM %s"
|
"SELECT COUNT(*) FROM %s"
|
||||||
" WHERE %s=%ld AND UsrCod=%ld",
|
" WHERE %s=%ld AND UsrCod=%ld",
|
||||||
TL_DB_Table[WhatToFav],
|
TL_DB_TableFav[FavSha],
|
||||||
TL_DB_Field[WhatToFav],Cod,UsrCod) != 0);
|
TL_DB_FieldFav[FavSha],Cod,UsrCod) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********* Get number of times a note/comment has been favourited ************/
|
/********* Get number of times a note/comment has been favourited ************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned TL_DB_GetNumTimesHasBeenFav (TL_Fav_WhatToFav_t WhatToFav,
|
unsigned TL_DB_GetNumFavers (TL_Usr_FavSha_t FavSha,long Cod,long UsrCod)
|
||||||
long Cod,long UsrCod)
|
|
||||||
{
|
{
|
||||||
/***** Get number of times (users) a note/comment has been favourited *****/
|
/***** Get number of times (users) a note/comment has been favourited *****/
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
|
@ -1031,8 +1032,8 @@ unsigned TL_DB_GetNumTimesHasBeenFav (TL_Fav_WhatToFav_t WhatToFav,
|
||||||
"SELECT COUNT(*) FROM %s"
|
"SELECT COUNT(*) FROM %s"
|
||||||
" WHERE %s=%ld"
|
" WHERE %s=%ld"
|
||||||
" AND UsrCod<>%ld", // Extra check
|
" AND UsrCod<>%ld", // Extra check
|
||||||
TL_DB_Table[WhatToFav],
|
TL_DB_TableFav[FavSha],
|
||||||
TL_DB_Field[WhatToFav],Cod,
|
TL_DB_FieldFav[FavSha],Cod,
|
||||||
UsrCod); // The author
|
UsrCod); // The author
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,10 +1041,9 @@ unsigned TL_DB_GetNumTimesHasBeenFav (TL_Fav_WhatToFav_t WhatToFav,
|
||||||
/******* Get list of users who have marked a note/comment as favourite *******/
|
/******* Get list of users who have marked a note/comment as favourite *******/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned TL_DB_GetListUsrsHaveFaved (TL_Fav_WhatToFav_t WhatToFav,
|
unsigned TL_DB_GetFavers (TL_Usr_FavSha_t FavSha,
|
||||||
long Cod,long UsrCod,
|
long Cod,long UsrCod,unsigned MaxUsrs,
|
||||||
unsigned MaxUsrs,
|
MYSQL_RES **mysql_res)
|
||||||
MYSQL_RES **mysql_res)
|
|
||||||
{
|
{
|
||||||
/***** Get list of users who have marked a note/comment as favourite from database *****/
|
/***** Get list of users who have marked a note/comment as favourite from database *****/
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
|
@ -1053,8 +1053,8 @@ unsigned TL_DB_GetListUsrsHaveFaved (TL_Fav_WhatToFav_t WhatToFav,
|
||||||
" WHERE %s=%ld"
|
" WHERE %s=%ld"
|
||||||
" AND UsrCod<>%ld" // Extra check
|
" AND UsrCod<>%ld" // Extra check
|
||||||
" ORDER BY FavCod LIMIT %u",
|
" ORDER BY FavCod LIMIT %u",
|
||||||
TL_DB_Table[WhatToFav],
|
TL_DB_TableFav[FavSha],
|
||||||
TL_DB_Field[WhatToFav],Cod,
|
TL_DB_FieldFav[FavSha],Cod,
|
||||||
UsrCod,
|
UsrCod,
|
||||||
MaxUsrs);
|
MaxUsrs);
|
||||||
}
|
}
|
||||||
|
@ -1063,7 +1063,7 @@ unsigned TL_DB_GetListUsrsHaveFaved (TL_Fav_WhatToFav_t WhatToFav,
|
||||||
/**************** Mark note/comment as favourite in database *****************/
|
/**************** Mark note/comment as favourite in database *****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void TL_DB_MarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod)
|
void TL_DB_MarkAsFav (TL_Usr_FavSha_t FavSha,long Cod)
|
||||||
{
|
{
|
||||||
/***** Insert in favourited in database *****/
|
/***** Insert in favourited in database *****/
|
||||||
DB_QueryINSERT ("can not favourite comment",
|
DB_QueryINSERT ("can not favourite comment",
|
||||||
|
@ -1071,8 +1071,8 @@ void TL_DB_MarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod)
|
||||||
" (%s,UsrCod,TimeFav)"
|
" (%s,UsrCod,TimeFav)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld,NOW())",
|
" (%ld,%ld,NOW())",
|
||||||
TL_DB_Table[WhatToFav],
|
TL_DB_TableFav[FavSha],
|
||||||
TL_DB_Field[WhatToFav],
|
TL_DB_FieldFav[FavSha],
|
||||||
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1080,33 +1080,33 @@ void TL_DB_MarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod)
|
||||||
/*************** Unmark note/comment as favourite in database ****************/
|
/*************** Unmark note/comment as favourite in database ****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void TL_DB_UnmarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod)
|
void TL_DB_UnmarkAsFav (TL_Usr_FavSha_t FavSha,long Cod)
|
||||||
{
|
{
|
||||||
/***** Delete the mark as favourite from database *****/
|
/***** Delete the mark as favourite from database *****/
|
||||||
DB_QueryDELETE ("can not unfavourite",
|
DB_QueryDELETE ("can not unfavourite",
|
||||||
"DELETE FROM %s"
|
"DELETE FROM %s"
|
||||||
" WHERE %s=%ld AND UsrCod=%ld",
|
" WHERE %s=%ld AND UsrCod=%ld",
|
||||||
TL_DB_Table[WhatToFav],
|
TL_DB_TableFav[FavSha],
|
||||||
TL_DB_Field[WhatToFav],Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
TL_DB_FieldFav[FavSha],Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********** Remove all favs made by a given user to any comment **************/
|
/********** Remove all favs made by a given user to any comment **************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_WhatToFav_t WhatToFav,long UsrCod)
|
void TL_DB_RemoveAllFavsMadeByUsr (TL_Usr_FavSha_t FavSha,long UsrCod)
|
||||||
{
|
{
|
||||||
/* Remove all favs made by this user to any note/comment */
|
/* Remove all favs made by this user to any note/comment */
|
||||||
DB_QueryDELETE ("can not remove favs",
|
DB_QueryDELETE ("can not remove favs",
|
||||||
"DELETE FROM %s WHERE UsrCod=%ld",
|
"DELETE FROM %s WHERE UsrCod=%ld",
|
||||||
TL_DB_Table[WhatToFav],UsrCod);
|
TL_DB_TableFav[FavSha],UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************ Remove all favs to notes/comments of a given user **************/
|
/************ Remove all favs to notes/comments of a given user **************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void TL_DB_RemoveAllFavsToPubsBy (TL_Fav_WhatToFav_t WhatToFav,long UsrCod)
|
void TL_DB_RemoveAllFavsToPubsBy (TL_Usr_FavSha_t FavSha,long UsrCod)
|
||||||
{
|
{
|
||||||
/***** Remove all favs to notes/comments of this user *****/
|
/***** Remove all favs to notes/comments of this user *****/
|
||||||
DB_QueryDELETE ("can not remove favs",
|
DB_QueryDELETE ("can not remove favs",
|
||||||
|
@ -1115,11 +1115,11 @@ void TL_DB_RemoveAllFavsToPubsBy (TL_Fav_WhatToFav_t WhatToFav,long UsrCod)
|
||||||
" WHERE tl_pubs.PublisherCod=%ld" // Author of the comment
|
" WHERE tl_pubs.PublisherCod=%ld" // Author of the comment
|
||||||
" AND tl_pubs.PubType=%u"
|
" AND tl_pubs.PubType=%u"
|
||||||
" AND tl_pubs.PubCod=%s.PubCod",
|
" AND tl_pubs.PubCod=%s.PubCod",
|
||||||
TL_DB_Table[WhatToFav],
|
TL_DB_TableFav[FavSha],
|
||||||
TL_DB_Table[WhatToFav],
|
TL_DB_TableFav[FavSha],
|
||||||
UsrCod,
|
UsrCod,
|
||||||
(unsigned) TL_DB_PubType[WhatToFav],
|
(unsigned) TL_DB_PubTypeFav[FavSha],
|
||||||
TL_DB_Table[WhatToFav]);
|
TL_DB_TableFav[FavSha]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1144,7 +1144,7 @@ void TL_DB_RemoveAllFavsToAllCommsInAllNotesBy (long UsrCod)
|
||||||
/****************** Check if a user has published a note *********************/
|
/****************** Check if a user has published a note *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
bool TL_DB_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod)
|
bool TL_DB_CheckIfSharedByUsr (long NotCod,long UsrCod)
|
||||||
{
|
{
|
||||||
return (DB_QueryCOUNT ("can not check if a user has shared a note",
|
return (DB_QueryCOUNT ("can not check if a user has shared a note",
|
||||||
"SELECT COUNT(*) FROM tl_pubs"
|
"SELECT COUNT(*) FROM tl_pubs"
|
||||||
|
@ -1160,7 +1160,7 @@ bool TL_DB_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod)
|
||||||
/********** Get number of times a note has been shared in timeline ***********/
|
/********** Get number of times a note has been shared in timeline ***********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned TL_DB_GetNumTimesANoteHasBeenShared (struct TL_Not_Note *Not)
|
unsigned TL_DB_GetNumSharers (long NotCod,long UsrCod)
|
||||||
{
|
{
|
||||||
/***** Get number of times (users) this note has been shared *****/
|
/***** Get number of times (users) this note has been shared *****/
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
|
@ -1169,8 +1169,8 @@ unsigned TL_DB_GetNumTimesANoteHasBeenShared (struct TL_Not_Note *Not)
|
||||||
" WHERE NotCod=%ld"
|
" WHERE NotCod=%ld"
|
||||||
" AND PublisherCod<>%ld"
|
" AND PublisherCod<>%ld"
|
||||||
" AND PubType=%u",
|
" AND PubType=%u",
|
||||||
Not->NotCod,
|
NotCod,
|
||||||
Not->UsrCod, // Author of the note
|
UsrCod, // Author of the note
|
||||||
(unsigned) TL_Pub_SHARED_NOTE);
|
(unsigned) TL_Pub_SHARED_NOTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1178,9 +1178,8 @@ unsigned TL_DB_GetNumTimesANoteHasBeenShared (struct TL_Not_Note *Not)
|
||||||
/***************** Get list of users who have shared a note ******************/
|
/***************** Get list of users who have shared a note ******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned TL_DB_GetListUsrsHaveShared (long NotCod,long UsrCod,
|
unsigned TL_DB_GetSharers (long NotCod,long UsrCod,unsigned MaxUsrs,
|
||||||
unsigned MaxUsrs,
|
MYSQL_RES **mysql_res)
|
||||||
MYSQL_RES **mysql_res)
|
|
||||||
{
|
{
|
||||||
/***** Get list of users who have shared a note from database *****/
|
/***** Get list of users who have shared a note from database *****/
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
|
|
|
@ -123,26 +123,22 @@ void TL_DB_RemoveAllPubsPublishedByAnyUsrOfNotesAuthoredBy (long UsrCod);
|
||||||
void TL_DB_RemoveAllPubsPublishedBy (long UsrCod);
|
void TL_DB_RemoveAllPubsPublishedBy (long UsrCod);
|
||||||
|
|
||||||
/****************************** Favourites ***********************************/
|
/****************************** Favourites ***********************************/
|
||||||
bool TL_DB_CheckIfFavedByUsr (TL_Fav_WhatToFav_t WhatToFav,
|
bool TL_DB_CheckIfFavedByUsr (TL_Usr_FavSha_t FavSha,long Cod,long UsrCod);
|
||||||
long Cod,long UsrCod);
|
unsigned TL_DB_GetNumFavers (TL_Usr_FavSha_t FavSha,long Cod,long UsrCod);
|
||||||
unsigned TL_DB_GetNumTimesHasBeenFav (TL_Fav_WhatToFav_t WhatToFav,
|
unsigned TL_DB_GetFavers (TL_Usr_FavSha_t FavSha,
|
||||||
long Cod,long UsrCod);
|
long Cod,long UsrCod,unsigned MaxUsrs,
|
||||||
unsigned TL_DB_GetListUsrsHaveFaved (TL_Fav_WhatToFav_t WhatToFav,
|
MYSQL_RES **mysql_res);
|
||||||
long Cod,long UsrCod,
|
void TL_DB_MarkAsFav (TL_Usr_FavSha_t FavSha,long Cod);
|
||||||
unsigned MaxUsrs,
|
void TL_DB_UnmarkAsFav (TL_Usr_FavSha_t FavSha,long Cod);
|
||||||
MYSQL_RES **mysql_res);
|
void TL_DB_RemoveAllFavsMadeByUsr (TL_Usr_FavSha_t FavSha,long UsrCod);
|
||||||
void TL_DB_MarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod);
|
void TL_DB_RemoveAllFavsToPubsBy (TL_Usr_FavSha_t FavSha,long UsrCod);
|
||||||
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_RemoveAllFavsToAllCommsInAllNotesBy (long UsrCod);
|
void TL_DB_RemoveAllFavsToAllCommsInAllNotesBy (long UsrCod);
|
||||||
|
|
||||||
/******************************** Shared *************************************/
|
/******************************** Shared *************************************/
|
||||||
bool TL_DB_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod);
|
bool TL_DB_CheckIfSharedByUsr (long NotCod,long UsrCod);
|
||||||
unsigned TL_DB_GetNumTimesANoteHasBeenShared (struct TL_Not_Note *Not);
|
unsigned TL_DB_GetNumSharers (long NotCod,long UsrCod);
|
||||||
unsigned TL_DB_GetListUsrsHaveShared (long NotCod,long UsrCod,
|
unsigned TL_DB_GetSharers (long NotCod,long UsrCod,unsigned MaxUsrs,
|
||||||
unsigned MaxUsrs,
|
MYSQL_RES **mysql_res);
|
||||||
MYSQL_RES **mysql_res);
|
|
||||||
void TL_DB_RemoveSharedPub (long NotCod);
|
void TL_DB_RemoveSharedPub (long NotCod);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,9 +42,6 @@
|
||||||
/************************* Private constants and types ***********************/
|
/************************* Private constants and types ***********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define TL_Fav_ICON_FAV "heart.svg"
|
|
||||||
#define TL_Fav_ICON_FAVED "heart-red.svg"
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************** External global variables from others modules ****************/
|
/************** External global variables from others modules ****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -65,13 +62,7 @@ static void TL_Fav_UnfNote (struct TL_Not_Note *Not);
|
||||||
static void TL_Fav_FavComm (struct TL_Com_Comment *Com);
|
static void TL_Fav_FavComm (struct TL_Com_Comment *Com);
|
||||||
static void TL_Fav_UnfComm (struct TL_Com_Comment *Com);
|
static void TL_Fav_UnfComm (struct TL_Com_Comment *Com);
|
||||||
|
|
||||||
static void TL_Fav_PutDisabledIconFav (unsigned NumFavs);
|
static void TL_Fav_PutDisabledIconFav (unsigned NumUsrs);
|
||||||
static void TL_Fav_PutFormToFavUnf (TL_Fav_WhatToFav_t WhatToFav,long Cod);
|
|
||||||
|
|
||||||
static void TL_Fav_ShowUsrsWhoHaveMarkedAsFav (TL_Fav_WhatToFav_t WhatToFav,
|
|
||||||
long Cod,long UsrCod,
|
|
||||||
unsigned NumFavs,
|
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********************** Mark/unmark a note as favourite **********************/
|
/********************** Mark/unmark a note as favourite **********************/
|
||||||
|
@ -95,7 +86,8 @@ void TL_Fav_ShowAllFaversNoteGbl (void)
|
||||||
TL_Not_GetDataOfNoteByCod (&Not);
|
TL_Not_GetDataOfNoteByCod (&Not);
|
||||||
|
|
||||||
/***** Write HTML inside DIV with form to fav/unfav *****/
|
/***** Write HTML inside DIV with form to fav/unfav *****/
|
||||||
TL_Fav_PutIconToFavUnf (TL_Fav_NOTE,Not.NotCod,Not.UsrCod,Not.NumFavs,
|
TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_NOTE,
|
||||||
|
Not.NotCod,Not.UsrCod,Not.NumFavs,
|
||||||
TL_Usr_SHOW_ALL_USRS);
|
TL_Usr_SHOW_ALL_USRS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +108,8 @@ void TL_Fav_FavNoteGbl (void)
|
||||||
TL_Fav_FavNote (&Not);
|
TL_Fav_FavNote (&Not);
|
||||||
|
|
||||||
/***** Write HTML inside DIV with form to unfav *****/
|
/***** Write HTML inside DIV with form to unfav *****/
|
||||||
TL_Fav_PutIconToFavUnf (TL_Fav_NOTE,Not.NotCod,Not.UsrCod,Not.NumFavs,
|
TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_NOTE,
|
||||||
|
Not.NotCod,Not.UsrCod,Not.NumFavs,
|
||||||
TL_Usr_SHOW_FEW_USRS);
|
TL_Usr_SHOW_FEW_USRS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +130,8 @@ void TL_Fav_UnfNoteGbl (void)
|
||||||
TL_Fav_UnfNote (&Not);
|
TL_Fav_UnfNote (&Not);
|
||||||
|
|
||||||
/***** Write HTML inside DIV with form to fav *****/
|
/***** Write HTML inside DIV with form to fav *****/
|
||||||
TL_Fav_PutIconToFavUnf (TL_Fav_NOTE,Not.NotCod,Not.UsrCod,Not.NumFavs,
|
TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_NOTE,
|
||||||
|
Not.NotCod,Not.UsrCod,Not.NumFavs,
|
||||||
TL_Usr_SHOW_FEW_USRS);
|
TL_Usr_SHOW_FEW_USRS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,15 +148,16 @@ static void TL_Fav_FavNote (struct TL_Not_Note *Not)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Trivial check: Have I faved this note? *****/
|
/***** Trivial check: Have I faved this note? *****/
|
||||||
if (TL_DB_CheckIfFavedByUsr (TL_Fav_NOTE,Not->NotCod,Gbl.Usrs.Me.UsrDat.UsrCod))
|
if (TL_Usr_CheckIfFavedSharedByUsr (TL_Usr_FAV_UNF_NOTE,Not->NotCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Mark note as favourite in database *****/
|
/***** Mark note as favourite in database *****/
|
||||||
TL_DB_MarkAsFav (TL_Fav_NOTE,Not->NotCod);
|
TL_DB_MarkAsFav (TL_Usr_FAV_UNF_NOTE,Not->NotCod);
|
||||||
|
|
||||||
/***** Update number of times this note is favourited *****/
|
/***** Update number of times this note is favourited *****/
|
||||||
Not->NumFavs = TL_DB_GetNumTimesHasBeenFav (TL_Fav_NOTE,
|
Not->NumFavs = TL_DB_GetNumFavers (TL_Usr_FAV_UNF_NOTE,
|
||||||
Not->NotCod,Not->UsrCod);
|
Not->NotCod,Not->UsrCod);
|
||||||
|
|
||||||
/***** Create notification about favourite post
|
/***** Create notification about favourite post
|
||||||
for the author of the post *****/
|
for the author of the post *****/
|
||||||
|
@ -185,15 +180,16 @@ static void TL_Fav_UnfNote (struct TL_Not_Note *Not)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Trivial check: Have I faved this note? *****/
|
/***** Trivial check: Have I faved this note? *****/
|
||||||
if (!TL_DB_CheckIfFavedByUsr (TL_Fav_NOTE,Not->NotCod,Gbl.Usrs.Me.UsrDat.UsrCod))
|
if (!TL_Usr_CheckIfFavedSharedByUsr (TL_Usr_FAV_UNF_NOTE,Not->NotCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Delete the mark as favourite from database *****/
|
/***** Delete the mark as favourite from database *****/
|
||||||
TL_DB_UnmarkAsFav (TL_Fav_NOTE,Not->NotCod);
|
TL_DB_UnmarkAsFav (TL_Usr_FAV_UNF_NOTE,Not->NotCod);
|
||||||
|
|
||||||
/***** Update number of times this note is favourited *****/
|
/***** Update number of times this note is favourited *****/
|
||||||
Not->NumFavs = TL_DB_GetNumTimesHasBeenFav (TL_Fav_NOTE,
|
Not->NumFavs = TL_DB_GetNumFavers (TL_Usr_FAV_UNF_NOTE,
|
||||||
Not->NotCod,Not->UsrCod);
|
Not->NotCod,Not->UsrCod);
|
||||||
|
|
||||||
/***** Mark possible notifications on this note as removed *****/
|
/***** Mark possible notifications on this note as removed *****/
|
||||||
OriginalPubCod = TL_DB_GetPubCodOfOriginalNote (Not->NotCod);
|
OriginalPubCod = TL_DB_GetPubCodOfOriginalNote (Not->NotCod);
|
||||||
|
@ -225,7 +221,8 @@ void TL_Fav_ShowAllFaversComGbl (void)
|
||||||
Med_MediaDestructor (&Com.Content.Media);
|
Med_MediaDestructor (&Com.Content.Media);
|
||||||
|
|
||||||
/***** Write HTML inside DIV with form to fav/unfav *****/
|
/***** Write HTML inside DIV with form to fav/unfav *****/
|
||||||
TL_Fav_PutIconToFavUnf (TL_Fav_COMM,Com.PubCod,Com.UsrCod,Com.NumFavs,
|
TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_COMM,
|
||||||
|
Com.PubCod,Com.UsrCod,Com.NumFavs,
|
||||||
TL_Usr_SHOW_ALL_USRS);
|
TL_Usr_SHOW_ALL_USRS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +243,8 @@ void TL_Fav_FavCommGbl (void)
|
||||||
TL_Fav_FavComm (&Com);
|
TL_Fav_FavComm (&Com);
|
||||||
|
|
||||||
/***** Write HTML inside DIV with form to unfav *****/
|
/***** Write HTML inside DIV with form to unfav *****/
|
||||||
TL_Fav_PutIconToFavUnf (TL_Fav_COMM,Com.PubCod,Com.UsrCod,Com.NumFavs,
|
TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_COMM,
|
||||||
|
Com.PubCod,Com.UsrCod,Com.NumFavs,
|
||||||
TL_Usr_SHOW_FEW_USRS);
|
TL_Usr_SHOW_FEW_USRS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +265,8 @@ void TL_Fav_UnfCommGbl (void)
|
||||||
TL_Fav_UnfComm (&Com);
|
TL_Fav_UnfComm (&Com);
|
||||||
|
|
||||||
/***** Write HTML inside DIV with form to fav *****/
|
/***** Write HTML inside DIV with form to fav *****/
|
||||||
TL_Fav_PutIconToFavUnf (TL_Fav_COMM,Com.PubCod,Com.UsrCod,Com.NumFavs,
|
TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_COMM,
|
||||||
|
Com.PubCod,Com.UsrCod,Com.NumFavs,
|
||||||
TL_Usr_SHOW_FEW_USRS);
|
TL_Usr_SHOW_FEW_USRS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,19 +287,19 @@ static void TL_Fav_FavComm (struct TL_Com_Comment *Com)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Trivial check: Have I faved this comment? *****/
|
/***** Trivial check: Have I faved this comment? *****/
|
||||||
if (TL_DB_CheckIfFavedByUsr (TL_Fav_COMM,Com->PubCod,
|
if (TL_Usr_CheckIfFavedSharedByUsr (TL_Usr_FAV_UNF_COMM,Com->PubCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod))
|
Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||||
{
|
{
|
||||||
Med_MediaDestructor (&Com->Content.Media);
|
Med_MediaDestructor (&Com->Content.Media);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Mark comment as favourite in database *****/
|
/***** Mark comment as favourite in database *****/
|
||||||
TL_DB_MarkAsFav (TL_Fav_COMM,Com->PubCod);
|
TL_DB_MarkAsFav (TL_Usr_FAV_UNF_COMM,Com->PubCod);
|
||||||
|
|
||||||
/***** Update number of times this comment is favourited *****/
|
/***** Update number of times this comment is favourited *****/
|
||||||
Com->NumFavs = TL_DB_GetNumTimesHasBeenFav (TL_Fav_COMM,
|
Com->NumFavs = TL_DB_GetNumFavers (TL_Usr_FAV_UNF_COMM,
|
||||||
Com->PubCod,Com->UsrCod);
|
Com->PubCod,Com->UsrCod);
|
||||||
|
|
||||||
/***** Create notification about favourite post
|
/***** Create notification about favourite post
|
||||||
for the author of the post *****/
|
for the author of the post *****/
|
||||||
|
@ -327,20 +326,20 @@ static void TL_Fav_UnfComm (struct TL_Com_Comment *Com)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Trivial check 4: Have I faved this comment? *****/
|
/***** Trivial check: Have I faved this comment? *****/
|
||||||
if (!TL_DB_CheckIfFavedByUsr (TL_Fav_COMM,Com->PubCod,
|
if (!TL_Usr_CheckIfFavedSharedByUsr (TL_Usr_FAV_UNF_COMM,Com->PubCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod))
|
Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||||
{
|
{
|
||||||
Med_MediaDestructor (&Com->Content.Media);
|
Med_MediaDestructor (&Com->Content.Media);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Delete the mark as favourite from database *****/
|
/***** Delete the mark as favourite from database *****/
|
||||||
TL_DB_UnmarkAsFav (TL_Fav_COMM,Com->PubCod);
|
TL_DB_UnmarkAsFav (TL_Usr_FAV_UNF_COMM,Com->PubCod);
|
||||||
|
|
||||||
/***** Update number of times this comment is favourited *****/
|
/***** Update number of times this comment is favourited *****/
|
||||||
Com->NumFavs = TL_DB_GetNumTimesHasBeenFav (TL_Fav_COMM,
|
Com->NumFavs = TL_DB_GetNumFavers (TL_Usr_FAV_UNF_COMM,
|
||||||
Com->PubCod,Com->UsrCod);
|
Com->PubCod,Com->UsrCod);
|
||||||
|
|
||||||
/***** Mark possible notifications on this comment as removed *****/
|
/***** Mark possible notifications on this comment as removed *****/
|
||||||
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV,Com->PubCod);
|
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV,Com->PubCod);
|
||||||
|
@ -353,8 +352,8 @@ static void TL_Fav_UnfComm (struct TL_Com_Comment *Com)
|
||||||
/**************** Put icon to fav/unfav and list of favers *******************/
|
/**************** Put icon to fav/unfav and list of favers *******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void TL_Fav_PutIconToFavUnf (TL_Fav_WhatToFav_t WhatToFav,
|
void TL_Fav_PutIconToFavUnf (TL_Usr_FavSha_t FavSha,
|
||||||
long Cod,long UsrCod,unsigned NumFavs,
|
long Cod,long UsrCod,unsigned NumUsrs,
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
||||||
{
|
{
|
||||||
/***** Put form to fav/unfav this comment *****/
|
/***** Put form to fav/unfav this comment *****/
|
||||||
|
@ -363,143 +362,35 @@ void TL_Fav_PutIconToFavUnf (TL_Fav_WhatToFav_t WhatToFav,
|
||||||
|
|
||||||
/* Icon to fav/unfav */
|
/* Icon to fav/unfav */
|
||||||
if (Usr_ItsMe (UsrCod)) // I am the author ==> I can not fav/unfav
|
if (Usr_ItsMe (UsrCod)) // I am the author ==> I can not fav/unfav
|
||||||
TL_Fav_PutDisabledIconFav (NumFavs);
|
TL_Fav_PutDisabledIconFav (NumUsrs);
|
||||||
else // I am not the author
|
else // I am not the author
|
||||||
TL_Fav_PutFormToFavUnf (WhatToFav,Cod);
|
TL_Frm_PutFormToFavUnfShaUns (FavSha,Cod);
|
||||||
|
|
||||||
/* End container */
|
/* End container */
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
|
||||||
/***** Show who have marked this comment as favourite *****/
|
/***** Show who have faved this note/comment *****/
|
||||||
TL_Fav_ShowUsrsWhoHaveMarkedAsFav (WhatToFav,Cod,UsrCod,NumFavs,HowManyUsrs);
|
TL_Usr_GetAndShowSharersOrFavers (FavSha,Cod,UsrCod,NumUsrs,HowManyUsrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************** Put disabled icon to mark as favourite *******************/
|
/****************** Put disabled icon to mark as favourite *******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void TL_Fav_PutDisabledIconFav (unsigned NumFavs)
|
static void TL_Fav_PutDisabledIconFav (unsigned NumUsrs)
|
||||||
{
|
{
|
||||||
extern const char *Txt_TIMELINE_Favourited_by_X_USERS;
|
extern const char *Txt_TIMELINE_Favourited_by_X_USERS;
|
||||||
extern const char *Txt_TIMELINE_Not_favourited_by_anyone;
|
extern const char *Txt_TIMELINE_Not_favourited_by_anyone;
|
||||||
|
|
||||||
/***** Disabled icon to mark as favourite *****/
|
/***** Disabled icon to mark as favourite *****/
|
||||||
if (NumFavs)
|
if (NumUsrs)
|
||||||
{
|
{
|
||||||
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Fav_ICON_FAV,
|
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Fav_ICON_FAV,
|
||||||
Str_BuildStringLong (Txt_TIMELINE_Favourited_by_X_USERS,
|
Str_BuildStringLong (Txt_TIMELINE_Favourited_by_X_USERS,
|
||||||
(long) NumFavs));
|
(long) NumUsrs));
|
||||||
Str_FreeString ();
|
Str_FreeString ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Fav_ICON_FAV,
|
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Fav_ICON_FAV,
|
||||||
Txt_TIMELINE_Not_favourited_by_anyone);
|
Txt_TIMELINE_Not_favourited_by_anyone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/************************** Form to fav/unfav note ***************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static void TL_Fav_PutFormToFavUnf (TL_Fav_WhatToFav_t WhatToFav,long Cod)
|
|
||||||
{
|
|
||||||
extern const char *Txt_TIMELINE_Favourite;
|
|
||||||
extern const char *Txt_TIMELINE_Mark_as_favourite;
|
|
||||||
struct TL_Form Form[TL_Fav_NUM_WHAT_TO_FAV][2] =
|
|
||||||
{
|
|
||||||
[TL_Fav_NOTE] =
|
|
||||||
{
|
|
||||||
[false] = // I have not faved ==> fav
|
|
||||||
{
|
|
||||||
.Action = TL_Frm_FAV_NOTE,
|
|
||||||
.ParamFormat = "NotCod=%ld",
|
|
||||||
.ParamCod = Cod,
|
|
||||||
.Icon = TL_Fav_ICON_FAV,
|
|
||||||
.Title = Txt_TIMELINE_Mark_as_favourite,
|
|
||||||
},
|
|
||||||
[true] = // I have faved ==> unfav
|
|
||||||
{
|
|
||||||
.Action = TL_Frm_UNF_NOTE,
|
|
||||||
.ParamFormat = "NotCod=%ld",
|
|
||||||
.ParamCod = Cod,
|
|
||||||
.Icon = TL_Fav_ICON_FAVED,
|
|
||||||
.Title = Txt_TIMELINE_Favourite,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[TL_Fav_COMM] =
|
|
||||||
{
|
|
||||||
[false] = // I have not faved ==> fav
|
|
||||||
{
|
|
||||||
.Action = TL_Frm_FAV_COMM,
|
|
||||||
.ParamFormat = "PubCod=%ld",
|
|
||||||
.ParamCod = Cod,
|
|
||||||
.Icon = TL_Fav_ICON_FAV,
|
|
||||||
.Title = Txt_TIMELINE_Mark_as_favourite,
|
|
||||||
},
|
|
||||||
[true] = // I have faved ==> unfav
|
|
||||||
{
|
|
||||||
.Action = TL_Frm_UNF_COMM,
|
|
||||||
.ParamFormat = "PubCod=%ld",
|
|
||||||
.ParamCod = Cod,
|
|
||||||
.Icon = TL_Fav_ICON_FAVED,
|
|
||||||
.Title = Txt_TIMELINE_Favourite,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
/***** Form and icon to fav/unfav note *****/
|
|
||||||
TL_Frm_FormFavSha (&Form[WhatToFav][TL_DB_CheckIfFavedByUsr (WhatToFav,Cod,Gbl.Usrs.Me.UsrDat.UsrCod)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/********** Show users who have marked a note/comment as favourite ***********/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static void TL_Fav_ShowUsrsWhoHaveMarkedAsFav (TL_Fav_WhatToFav_t WhatToFav,
|
|
||||||
long Cod,long UsrCod,
|
|
||||||
unsigned NumFavs,
|
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
|
||||||
{
|
|
||||||
static const TL_Frm_Action_t Action[TL_Fav_NUM_WHAT_TO_FAV] =
|
|
||||||
{
|
|
||||||
[TL_Fav_NOTE] = TL_Frm_ALL_FAV_NOTE,
|
|
||||||
[TL_Fav_COMM] = TL_Frm_ALL_FAV_COMM,
|
|
||||||
};
|
|
||||||
static const char *ParamFormat[TL_Fav_NUM_WHAT_TO_FAV] =
|
|
||||||
{
|
|
||||||
[TL_Fav_NOTE] = "NotCod=%ld",
|
|
||||||
[TL_Fav_COMM] = "PubCod=%ld",
|
|
||||||
};
|
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
unsigned NumFirstUsrs;
|
|
||||||
|
|
||||||
/***** Get users who have marked this note as favourite *****/
|
|
||||||
if (NumFavs)
|
|
||||||
/***** Get list of users from database *****/
|
|
||||||
NumFirstUsrs =
|
|
||||||
TL_DB_GetListUsrsHaveFaved (WhatToFav,Cod,UsrCod,
|
|
||||||
HowManyUsrs == TL_Usr_SHOW_FEW_USRS ? TL_Usr_DEF_USRS_SHOWN :
|
|
||||||
TL_Usr_MAX_USRS_SHOWN,
|
|
||||||
&mysql_res);
|
|
||||||
else
|
|
||||||
NumFirstUsrs = 0;
|
|
||||||
|
|
||||||
/***** Show users *****/
|
|
||||||
/* Number of users */
|
|
||||||
HTM_DIV_Begin ("class=\"TL_NUM_USRS\"");
|
|
||||||
TL_Usr_ShowNumSharersOrFavers (NumFavs);
|
|
||||||
HTM_DIV_End ();
|
|
||||||
|
|
||||||
/* List users one by one */
|
|
||||||
HTM_DIV_Begin ("class=\"TL_USRS\"");
|
|
||||||
TL_Usr_ShowSharersOrFavers (&mysql_res,NumFavs,NumFirstUsrs);
|
|
||||||
if (NumFirstUsrs < NumFavs) // Not all are shown
|
|
||||||
/* Clickable ellipsis to show all users */
|
|
||||||
TL_Frm_PutFormToSeeAllFaversSharers (Action[WhatToFav],
|
|
||||||
ParamFormat[WhatToFav],Cod,
|
|
||||||
HowManyUsrs);
|
|
||||||
HTM_DIV_End ();
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
if (NumFavs)
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
}
|
|
||||||
|
|
|
@ -34,12 +34,8 @@
|
||||||
/************************ Public constants and types *************************/
|
/************************ Public constants and types *************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define TL_Fav_NUM_WHAT_TO_FAV 2
|
#define TL_Fav_ICON_FAV "heart.svg"
|
||||||
typedef enum
|
#define TL_Fav_ICON_FAVED "heart-red.svg"
|
||||||
{
|
|
||||||
TL_Fav_NOTE = 0,
|
|
||||||
TL_Fav_COMM = 1,
|
|
||||||
} TL_Fav_WhatToFav_t;
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Public prototypes *****************************/
|
/***************************** Public prototypes *****************************/
|
||||||
|
@ -59,8 +55,8 @@ void TL_Fav_FavCommGbl (void);
|
||||||
void TL_Fav_UnfCommUsr (void);
|
void TL_Fav_UnfCommUsr (void);
|
||||||
void TL_Fav_UnfCommGbl (void);
|
void TL_Fav_UnfCommGbl (void);
|
||||||
|
|
||||||
void TL_Fav_PutIconToFavUnf (TL_Fav_WhatToFav_t WhatToFav,
|
void TL_Fav_PutIconToFavUnf (TL_Usr_FavSha_t FavSha,
|
||||||
long Cod,long UsrCod,unsigned NumFavs,
|
long Cod,long UsrCod,unsigned NumUsrs,
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs);
|
TL_Usr_HowManyUsrs_t HowManyUsrs);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,7 +32,10 @@
|
||||||
#include "swad_action.h"
|
#include "swad_action.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
#include "swad_timeline.h"
|
#include "swad_timeline.h"
|
||||||
|
#include "swad_timeline_database.h"
|
||||||
|
#include "swad_timeline_favourite.h"
|
||||||
#include "swad_timeline_form.h"
|
#include "swad_timeline_form.h"
|
||||||
|
#include "swad_timeline_share.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
|
@ -97,6 +100,83 @@ extern struct Globals Gbl;
|
||||||
/***************************** Private prototypes ****************************/
|
/***************************** Private prototypes ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************** Form to fav/unfav or share/unshare *********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void TL_Frm_PutFormToFavUnfShaUns (TL_Usr_FavSha_t FavSha,long Cod)
|
||||||
|
{
|
||||||
|
extern const char *Txt_TIMELINE_Mark_as_favourite;
|
||||||
|
extern const char *Txt_TIMELINE_Favourite;
|
||||||
|
extern const char *Txt_TIMELINE_Share;
|
||||||
|
extern const char *Txt_TIMELINE_Shared;
|
||||||
|
struct TL_Form Form[TL_Usr_NUM_FAV_SHA][2] =
|
||||||
|
{
|
||||||
|
[TL_Usr_FAV_UNF_NOTE] =
|
||||||
|
{
|
||||||
|
[false] = // I have not faved ==> fav
|
||||||
|
{
|
||||||
|
.Action = TL_Frm_FAV_NOTE,
|
||||||
|
.ParamFormat = "NotCod=%ld",
|
||||||
|
.ParamCod = Cod,
|
||||||
|
.Icon = TL_Fav_ICON_FAV,
|
||||||
|
.Title = Txt_TIMELINE_Mark_as_favourite,
|
||||||
|
},
|
||||||
|
[true] = // I have faved ==> unfav
|
||||||
|
{
|
||||||
|
.Action = TL_Frm_UNF_NOTE,
|
||||||
|
.ParamFormat = "NotCod=%ld",
|
||||||
|
.ParamCod = Cod,
|
||||||
|
.Icon = TL_Fav_ICON_FAVED,
|
||||||
|
.Title = Txt_TIMELINE_Favourite,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[TL_Usr_FAV_UNF_COMM] =
|
||||||
|
{
|
||||||
|
[false] = // I have not faved ==> fav
|
||||||
|
{
|
||||||
|
.Action = TL_Frm_FAV_COMM,
|
||||||
|
.ParamFormat = "PubCod=%ld",
|
||||||
|
.ParamCod = Cod,
|
||||||
|
.Icon = TL_Fav_ICON_FAV,
|
||||||
|
.Title = Txt_TIMELINE_Mark_as_favourite,
|
||||||
|
},
|
||||||
|
[true] = // I have faved ==> unfav
|
||||||
|
{
|
||||||
|
.Action = TL_Frm_UNF_COMM,
|
||||||
|
.ParamFormat = "PubCod=%ld",
|
||||||
|
.ParamCod = Cod,
|
||||||
|
.Icon = TL_Fav_ICON_FAVED,
|
||||||
|
.Title = Txt_TIMELINE_Favourite,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[TL_Usr_SHA_UNS_NOTE] =
|
||||||
|
{
|
||||||
|
[false] = // I have not shared ==> share
|
||||||
|
{
|
||||||
|
.Action = TL_Frm_SHA_NOTE,
|
||||||
|
.ParamFormat = "NotCod=%ld",
|
||||||
|
.ParamCod = Cod,
|
||||||
|
.Icon = TL_Sha_ICON_SHARE,
|
||||||
|
.Title = Txt_TIMELINE_Share,
|
||||||
|
},
|
||||||
|
[true] = // I have shared ==> unshare
|
||||||
|
{
|
||||||
|
.Action = TL_Frm_UNS_NOTE,
|
||||||
|
.ParamFormat = "NotCod=%ld",
|
||||||
|
.ParamCod = Cod,
|
||||||
|
.Icon = TL_Sha_ICON_SHARED,
|
||||||
|
.Title = Txt_TIMELINE_Shared,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
bool FavedShared;
|
||||||
|
|
||||||
|
/***** Form and icon to fav/unfav note *****/
|
||||||
|
FavedShared = TL_Usr_CheckIfFavedSharedByUsr (FavSha,Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
TL_Frm_FormFavSha (&Form[FavSha][FavedShared]);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************** Begin a form in global or user timeline *******************/
|
/***************** Begin a form in global or user timeline *******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -77,6 +77,8 @@ struct TL_Form
|
||||||
/****************************** Public prototypes ****************************/
|
/****************************** Public prototypes ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void TL_Frm_PutFormToFavUnfShaUns (TL_Usr_FavSha_t FavSha,long Cod);
|
||||||
|
|
||||||
void TL_Frm_BeginForm (const struct TL_Timeline *Timeline,TL_Frm_Action_t Action);
|
void TL_Frm_BeginForm (const struct TL_Timeline *Timeline,TL_Frm_Action_t Action);
|
||||||
void TL_Frm_EndForm (void);
|
void TL_Frm_EndForm (void);
|
||||||
|
|
||||||
|
@ -86,8 +88,8 @@ void TL_Frm_PutFormToSeeAllFaversSharers (TL_Frm_Action_t Action,
|
||||||
void TL_Frm_FormFavSha (const struct TL_Form *Form);
|
void TL_Frm_FormFavSha (const struct TL_Form *Form);
|
||||||
|
|
||||||
void TL_Frm_FormToShowHiddenComms (long NotCod,
|
void TL_Frm_FormToShowHiddenComms (long NotCod,
|
||||||
char IdComments[Frm_MAX_BYTES_ID + 1],
|
char IdComms[Frm_MAX_BYTES_ID + 1],
|
||||||
unsigned NumInitialComments);
|
unsigned NumInitialComms);
|
||||||
|
|
||||||
void TL_Frm_BeginAlertRemove (const char *QuestionTxt);
|
void TL_Frm_BeginAlertRemove (const char *QuestionTxt);
|
||||||
void TL_Frm_EndAlertRemove (struct TL_Timeline *Timeline,TL_Frm_Action_t Action,
|
void TL_Frm_EndAlertRemove (struct TL_Timeline *Timeline,TL_Frm_Action_t Action,
|
||||||
|
|
|
@ -841,7 +841,8 @@ static void TL_Not_WriteFavShaRem (const struct TL_Timeline *Timeline,
|
||||||
HTM_DIV_Begin ("id=\"fav_not_%s_%u\""
|
HTM_DIV_Begin ("id=\"fav_not_%s_%u\""
|
||||||
" class=\"TL_FAV_NOT TL_FAV_NOT_WIDTH\"",
|
" class=\"TL_FAV_NOT TL_FAV_NOT_WIDTH\"",
|
||||||
Gbl.UniqueNameEncrypted,NumDiv);
|
Gbl.UniqueNameEncrypted,NumDiv);
|
||||||
TL_Fav_PutIconToFavUnf (TL_Fav_NOTE,Not->NotCod,Not->UsrCod,Not->NumFavs,
|
TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_NOTE,
|
||||||
|
Not->NotCod,Not->UsrCod,Not->NumFavs,
|
||||||
TL_Usr_SHOW_FEW_USRS);
|
TL_Usr_SHOW_FEW_USRS);
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
|
||||||
|
@ -1355,11 +1356,11 @@ static void TL_Not_GetDataOfNoteFromRow (MYSQL_ROW row,struct TL_Not_Note *Not)
|
||||||
Not->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[6]);
|
Not->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[6]);
|
||||||
|
|
||||||
/***** Get number of times this note has been shared *****/
|
/***** Get number of times this note has been shared *****/
|
||||||
Not->NumShared = TL_DB_GetNumTimesANoteHasBeenShared (Not);
|
Not->NumShared = TL_DB_GetNumSharers (Not->NotCod,Not->UsrCod);
|
||||||
|
|
||||||
/***** Get number of times this note has been favourited *****/
|
/***** Get number of times this note has been favourited *****/
|
||||||
Not->NumFavs = TL_DB_GetNumTimesHasBeenFav (TL_Fav_NOTE,
|
Not->NumFavs = TL_DB_GetNumFavers (TL_Usr_FAV_UNF_NOTE,
|
||||||
Not->NotCod,Not->UsrCod);
|
Not->NotCod,Not->UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -278,8 +278,8 @@ static long TL_Pst_ReceivePost (void)
|
||||||
Med_GetMediaFromForm (-1L,-1L,-1,&Content.Media,NULL,NULL);
|
Med_GetMediaFromForm (-1L,-1L,-1,&Content.Media,NULL,NULL);
|
||||||
Ale_ShowAlerts (NULL);
|
Ale_ShowAlerts (NULL);
|
||||||
|
|
||||||
if (Content.Txt[0] || // Text not empty
|
if (Content.Txt[0] || // Text not empty
|
||||||
Content.Media.Status == Med_PROCESSED) // A media is attached
|
Content.Media.Status == Med_PROCESSED) // A media is attached
|
||||||
{
|
{
|
||||||
/***** Store media in filesystem and database *****/
|
/***** Store media in filesystem and database *****/
|
||||||
Med_RemoveKeepOrStoreMedia (-1L,&Content.Media);
|
Med_RemoveKeepOrStoreMedia (-1L,&Content.Media);
|
||||||
|
|
|
@ -42,9 +42,6 @@
|
||||||
/************************* Private constants and types ***********************/
|
/************************* Private constants and types ***********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define TL_Sha_ICON_SHARE "share-alt.svg"
|
|
||||||
#define TL_Sha_ICON_SHARED "share-alt-green.svg"
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************** External global variables from others modules ****************/
|
/************** External global variables from others modules ****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -63,10 +60,6 @@ static void TL_Sha_ShaNote (struct TL_Not_Note *Not);
|
||||||
static void TL_Sha_UnsNote (struct TL_Not_Note *Not);
|
static void TL_Sha_UnsNote (struct TL_Not_Note *Not);
|
||||||
|
|
||||||
static void TL_Sha_PutDisabledIconShare (unsigned NumShared);
|
static void TL_Sha_PutDisabledIconShare (unsigned NumShared);
|
||||||
static void TL_Sha_PutFormToShaUnsNote (long NotCod);
|
|
||||||
|
|
||||||
static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Not_Note *Not,
|
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************************** Share a note *******************************/
|
/******************************** Share a note *******************************/
|
||||||
|
@ -127,7 +120,8 @@ static void TL_Sha_ShaNote (struct TL_Not_Note *Not)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Trivial check: Is note already shared by me? *****/
|
/***** Trivial check: Is note already shared by me? *****/
|
||||||
if (TL_DB_CheckIfNoteIsSharedByUsr (Not->NotCod,Gbl.Usrs.Me.UsrDat.UsrCod))
|
if (TL_Usr_CheckIfFavedSharedByUsr (TL_Usr_SHA_UNS_NOTE,Not->NotCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Share (publish note in timeline) *****/
|
/***** Share (publish note in timeline) *****/
|
||||||
|
@ -137,7 +131,7 @@ static void TL_Sha_ShaNote (struct TL_Not_Note *Not)
|
||||||
TL_Pub_PublishPubInTimeline (&Pub); // Set Pub.PubCod
|
TL_Pub_PublishPubInTimeline (&Pub); // Set Pub.PubCod
|
||||||
|
|
||||||
/***** Update number of times this note is shared *****/
|
/***** Update number of times this note is shared *****/
|
||||||
Not->NumShared = TL_DB_GetNumTimesANoteHasBeenShared (Not);
|
Not->NumShared = TL_DB_GetNumSharers (Not->NotCod,Not->UsrCod);
|
||||||
|
|
||||||
/***** Create notification about shared post
|
/***** Create notification about shared post
|
||||||
for the author of the post *****/
|
for the author of the post *****/
|
||||||
|
@ -187,7 +181,7 @@ static void TL_Sha_UnsNote (struct TL_Not_Note *Not)
|
||||||
TL_DB_RemoveSharedPub (Not->NotCod);
|
TL_DB_RemoveSharedPub (Not->NotCod);
|
||||||
|
|
||||||
/***** Update number of times this note is shared *****/
|
/***** Update number of times this note is shared *****/
|
||||||
Not->NumShared = TL_DB_GetNumTimesANoteHasBeenShared (Not);
|
Not->NumShared = TL_DB_GetNumSharers (Not->NotCod,Not->UsrCod);
|
||||||
|
|
||||||
/***** Mark possible notifications on this note as removed *****/
|
/***** Mark possible notifications on this note as removed *****/
|
||||||
OriginalPubCod = TL_DB_GetPubCodOfOriginalNote (Not->NotCod);
|
OriginalPubCod = TL_DB_GetPubCodOfOriginalNote (Not->NotCod);
|
||||||
|
@ -204,18 +198,20 @@ void TL_Sha_PutIconToShaUnsNote (const struct TL_Not_Note *Not,
|
||||||
|
|
||||||
/* Icon to share */
|
/* Icon to share */
|
||||||
if (Not->Unavailable || // Unavailable notes can not be shared
|
if (Not->Unavailable || // Unavailable notes can not be shared
|
||||||
Usr_ItsMe (Not->UsrCod)) // I am the author
|
Usr_ItsMe (Not->UsrCod)) // I am the author
|
||||||
/* Put disabled icon */
|
/* Put disabled icon */
|
||||||
TL_Sha_PutDisabledIconShare (Not->NumShared);
|
TL_Sha_PutDisabledIconShare (Not->NumShared);
|
||||||
else // Available and I am not the author
|
else // Available and I am not the author
|
||||||
/* Put icon to share/unshare */
|
/* Put icon to share/unshare */
|
||||||
TL_Sha_PutFormToShaUnsNote (Not->NotCod);
|
TL_Frm_PutFormToFavUnfShaUns (TL_Usr_SHA_UNS_NOTE,Not->NotCod);
|
||||||
|
|
||||||
|
|
||||||
/* End container */
|
/* End container */
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
|
||||||
/***** Show who have shared this note *****/
|
/***** Show who have shared this note *****/
|
||||||
TL_Sha_ShowUsrsWhoHaveSharedNote (Not,HowManyUsrs);
|
TL_Usr_GetAndShowSharersOrFavers (TL_Usr_SHA_UNS_NOTE,
|
||||||
|
Not->NotCod,Not->UsrCod,Not->NumShared,HowManyUsrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -239,77 +235,3 @@ static void TL_Sha_PutDisabledIconShare (unsigned NumShared)
|
||||||
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Sha_ICON_SHARE,
|
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Sha_ICON_SHARE,
|
||||||
Txt_TIMELINE_Not_shared_by_anyone);
|
Txt_TIMELINE_Not_shared_by_anyone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*********************** Form to share/unshare note **************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static void TL_Sha_PutFormToShaUnsNote (long NotCod)
|
|
||||||
{
|
|
||||||
extern const char *Txt_TIMELINE_Shared;
|
|
||||||
extern const char *Txt_TIMELINE_Share;
|
|
||||||
struct TL_Form Form[2] =
|
|
||||||
{
|
|
||||||
[false] = // I have not shared ==> share
|
|
||||||
{
|
|
||||||
.Action = TL_Frm_SHA_NOTE,
|
|
||||||
.ParamFormat = "NotCod=%ld",
|
|
||||||
.ParamCod = NotCod,
|
|
||||||
.Icon = TL_Sha_ICON_SHARE,
|
|
||||||
.Title = Txt_TIMELINE_Share,
|
|
||||||
},
|
|
||||||
[true] = // I have shared ==> unshare
|
|
||||||
{
|
|
||||||
.Action = TL_Frm_UNS_NOTE,
|
|
||||||
.ParamFormat = "NotCod=%ld",
|
|
||||||
.ParamCod = NotCod,
|
|
||||||
.Icon = TL_Sha_ICON_SHARED,
|
|
||||||
.Title = Txt_TIMELINE_Shared,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
/***** Form and icon to share/unshare note *****/
|
|
||||||
TL_Frm_FormFavSha (&Form[TL_DB_CheckIfNoteIsSharedByUsr (NotCod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/******************* Show users who have shared this note ********************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Not_Note *Not,
|
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
|
||||||
{
|
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
unsigned NumFirstUsrs;
|
|
||||||
|
|
||||||
/***** Get users who have shared this note *****/
|
|
||||||
if (Not->NumShared)
|
|
||||||
NumFirstUsrs =
|
|
||||||
TL_DB_GetListUsrsHaveShared (Not->NotCod,Not->UsrCod,
|
|
||||||
HowManyUsrs == TL_Usr_SHOW_FEW_USRS ? TL_Usr_DEF_USRS_SHOWN :
|
|
||||||
TL_Usr_MAX_USRS_SHOWN,
|
|
||||||
&mysql_res);
|
|
||||||
else
|
|
||||||
NumFirstUsrs = 0;
|
|
||||||
|
|
||||||
/***** Show users *****/
|
|
||||||
/* Number of users */
|
|
||||||
HTM_DIV_Begin ("class=\"TL_NUM_USRS\"");
|
|
||||||
TL_Usr_ShowNumSharersOrFavers (Not->NumShared);
|
|
||||||
HTM_DIV_End ();
|
|
||||||
|
|
||||||
/* List users one by one */
|
|
||||||
HTM_DIV_Begin ("class=\"TL_USRS\"");
|
|
||||||
TL_Usr_ShowSharersOrFavers (&mysql_res,Not->NumShared,NumFirstUsrs);
|
|
||||||
if (NumFirstUsrs < Not->NumShared)
|
|
||||||
/* Clickable ellipsis to show all users */
|
|
||||||
TL_Frm_PutFormToSeeAllFaversSharers (TL_Frm_ALL_SHA_NOTE,
|
|
||||||
"NotCod=%ld",Not->NotCod,
|
|
||||||
HowManyUsrs);
|
|
||||||
HTM_DIV_End ();
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
if (Not->NumShared)
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
}
|
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define TL_Sha_ICON_SHARE "share-alt.svg"
|
||||||
|
#define TL_Sha_ICON_SHARED "share-alt-green.svg"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************************** Public types *******************************/
|
/******************************** Public types *******************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "swad_timeline.h"
|
#include "swad_timeline.h"
|
||||||
#include "swad_timeline_database.h"
|
#include "swad_timeline_database.h"
|
||||||
#include "swad_timeline_favourite.h"
|
#include "swad_timeline_favourite.h"
|
||||||
|
#include "swad_timeline_form.h"
|
||||||
#include "swad_timeline_user.h"
|
#include "swad_timeline_user.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -67,20 +68,20 @@ void TL_Usr_RemoveUsrContent (long UsrCod)
|
||||||
{
|
{
|
||||||
/***** Remove favs for comments *****/
|
/***** Remove favs for comments *****/
|
||||||
/* Remove all favs made by this user to any comment */
|
/* Remove all favs made by this user to any comment */
|
||||||
TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_COMM,UsrCod);
|
TL_DB_RemoveAllFavsMadeByUsr (TL_Usr_FAV_UNF_COMM,UsrCod);
|
||||||
|
|
||||||
/* Remove all favs to comments of this user */
|
/* Remove all favs to comments of this user */
|
||||||
TL_DB_RemoveAllFavsToPubsBy (TL_Fav_COMM,UsrCod);
|
TL_DB_RemoveAllFavsToPubsBy (TL_Usr_FAV_UNF_COMM,UsrCod);
|
||||||
|
|
||||||
/* Remove all favs to all comments in all notes authored by this user */
|
/* Remove all favs to all comments in all notes authored by this user */
|
||||||
TL_DB_RemoveAllFavsToAllCommsInAllNotesBy (UsrCod);
|
TL_DB_RemoveAllFavsToAllCommsInAllNotesBy (UsrCod);
|
||||||
|
|
||||||
/***** Remove favs for notes *****/
|
/***** Remove favs for notes *****/
|
||||||
/* Remove all favs made by this user to any note */
|
/* Remove all favs made by this user to any note */
|
||||||
TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_NOTE,UsrCod);
|
TL_DB_RemoveAllFavsMadeByUsr (TL_Usr_FAV_UNF_NOTE,UsrCod);
|
||||||
|
|
||||||
/* Remove all favs to notes of this user */
|
/* Remove all favs to notes of this user */
|
||||||
TL_DB_RemoveAllFavsToPubsBy (TL_Fav_NOTE,UsrCod);
|
TL_DB_RemoveAllFavsToPubsBy (TL_Usr_FAV_UNF_NOTE,UsrCod);
|
||||||
|
|
||||||
/***** Remove comments *****/
|
/***** Remove comments *****/
|
||||||
/* Remove all comments in all the notes of this user */
|
/* Remove all comments in all the notes of this user */
|
||||||
|
@ -107,6 +108,60 @@ void TL_Usr_RemoveUsrContent (long UsrCod)
|
||||||
TL_DB_RemoveAllNotesUsr (UsrCod);
|
TL_DB_RemoveAllNotesUsr (UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************** Show users who have faved/shared a note/comment **************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void TL_Usr_GetAndShowSharersOrFavers (TL_Usr_FavSha_t FavSha,
|
||||||
|
long Cod,long UsrCod,unsigned NumUsrs,
|
||||||
|
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
||||||
|
{
|
||||||
|
static const TL_Frm_Action_t Action[TL_Usr_NUM_FAV_SHA] =
|
||||||
|
{
|
||||||
|
[TL_Usr_FAV_UNF_NOTE] = TL_Frm_ALL_FAV_NOTE,
|
||||||
|
[TL_Usr_FAV_UNF_COMM] = TL_Frm_ALL_FAV_COMM,
|
||||||
|
[TL_Usr_SHA_UNS_NOTE] = TL_Frm_ALL_SHA_NOTE,
|
||||||
|
};
|
||||||
|
static const char *ParamFormat[TL_Usr_NUM_FAV_SHA] =
|
||||||
|
{
|
||||||
|
[TL_Usr_FAV_UNF_NOTE] = "NotCod=%ld",
|
||||||
|
[TL_Usr_FAV_UNF_COMM] = "PubCod=%ld",
|
||||||
|
[TL_Usr_SHA_UNS_NOTE] = "NotCod=%ld",
|
||||||
|
};
|
||||||
|
MYSQL_RES *mysql_res;
|
||||||
|
unsigned NumFirstUsrs;
|
||||||
|
|
||||||
|
/***** Get users who have faved/shared *****/
|
||||||
|
if (NumUsrs)
|
||||||
|
NumFirstUsrs =
|
||||||
|
TL_Usr_GetListFaversOrSharers (FavSha,Cod,UsrCod,
|
||||||
|
HowManyUsrs == TL_Usr_SHOW_FEW_USRS ? TL_Usr_DEF_USRS_SHOWN :
|
||||||
|
TL_Usr_MAX_USRS_SHOWN,
|
||||||
|
&mysql_res);
|
||||||
|
else
|
||||||
|
NumFirstUsrs = 0;
|
||||||
|
|
||||||
|
/***** Show users *****/
|
||||||
|
/* Number of users */
|
||||||
|
HTM_DIV_Begin ("class=\"TL_NUM_USRS\"");
|
||||||
|
TL_Usr_ShowNumSharersOrFavers (NumUsrs);
|
||||||
|
HTM_DIV_End ();
|
||||||
|
|
||||||
|
/* List users one by one */
|
||||||
|
HTM_DIV_Begin ("class=\"TL_USRS\"");
|
||||||
|
TL_Usr_ListSharersOrFavers (&mysql_res,NumUsrs,NumFirstUsrs);
|
||||||
|
if (NumFirstUsrs < NumUsrs) // Not all are shown
|
||||||
|
/* Clickable ellipsis to show all users */
|
||||||
|
TL_Frm_PutFormToSeeAllFaversSharers (Action[FavSha],
|
||||||
|
ParamFormat[FavSha],Cod,
|
||||||
|
HowManyUsrs);
|
||||||
|
HTM_DIV_End ();
|
||||||
|
|
||||||
|
/***** Free structure that stores the query result *****/
|
||||||
|
if (NumUsrs)
|
||||||
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************************ Show sharers or favouriters ************************/
|
/************************ Show sharers or favouriters ************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -118,7 +173,7 @@ void TL_Usr_ShowNumSharersOrFavers (unsigned NumUsrs)
|
||||||
HTM_TxtF (" %u",NumUsrs);
|
HTM_TxtF (" %u",NumUsrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TL_Usr_ShowSharersOrFavers (MYSQL_RES **mysql_res,
|
void TL_Usr_ListSharersOrFavers (MYSQL_RES **mysql_res,
|
||||||
unsigned NumUsrs,unsigned NumFirstUsrs)
|
unsigned NumUsrs,unsigned NumFirstUsrs)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
@ -188,3 +243,45 @@ bool TL_Usr_CheckICanFavSha (long Cod,long UsrCod)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************* Check if a user has faved/shared a note/comment ***************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
bool TL_Usr_CheckIfFavedSharedByUsr (TL_Usr_FavSha_t FavSha,long Cod,long UsrCod)
|
||||||
|
{
|
||||||
|
switch (FavSha)
|
||||||
|
{
|
||||||
|
case TL_Usr_FAV_UNF_NOTE:
|
||||||
|
case TL_Usr_FAV_UNF_COMM:
|
||||||
|
return TL_DB_CheckIfFavedByUsr (FavSha,Cod,UsrCod);
|
||||||
|
case TL_Usr_SHA_UNS_NOTE:
|
||||||
|
return TL_DB_CheckIfSharedByUsr (Cod,UsrCod);
|
||||||
|
default:
|
||||||
|
Lay_ShowErrorAndExit ("Wrong fav/share action.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false; // Not reached
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******* Get list of users who have marked a note/comment as favourite *******/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned TL_Usr_GetListFaversOrSharers (TL_Usr_FavSha_t FavSha,
|
||||||
|
long Cod,long UsrCod,unsigned MaxUsrs,
|
||||||
|
MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
switch (FavSha)
|
||||||
|
{
|
||||||
|
case TL_Usr_FAV_UNF_NOTE:
|
||||||
|
case TL_Usr_FAV_UNF_COMM:
|
||||||
|
return TL_DB_GetFavers (FavSha,Cod,UsrCod,MaxUsrs,mysql_res);
|
||||||
|
case TL_Usr_SHA_UNS_NOTE:
|
||||||
|
return TL_DB_GetSharers (Cod,UsrCod,MaxUsrs,mysql_res);
|
||||||
|
default:
|
||||||
|
Lay_ShowErrorAndExit ("Wrong fav/share action.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0; // Not reached
|
||||||
|
}
|
||||||
|
|
|
@ -55,15 +55,30 @@ typedef enum
|
||||||
TL_Usr_SHOW_ALL_USRS, // Show all favers/sharers
|
TL_Usr_SHOW_ALL_USRS, // Show all favers/sharers
|
||||||
} TL_Usr_HowManyUsrs_t;
|
} TL_Usr_HowManyUsrs_t;
|
||||||
|
|
||||||
|
#define TL_Usr_NUM_FAV_SHA 3
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
TL_Usr_FAV_UNF_NOTE = 0,
|
||||||
|
TL_Usr_FAV_UNF_COMM = 1,
|
||||||
|
TL_Usr_SHA_UNS_NOTE = 2,
|
||||||
|
} TL_Usr_FavSha_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************************** Public prototypes ****************************/
|
/****************************** Public prototypes ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void TL_Usr_RemoveUsrContent (long UsrCod);
|
void TL_Usr_RemoveUsrContent (long UsrCod);
|
||||||
|
|
||||||
|
void TL_Usr_GetAndShowSharersOrFavers (TL_Usr_FavSha_t FavSha,
|
||||||
|
long Cod,long UsrCod,unsigned NumUsrs,
|
||||||
|
TL_Usr_HowManyUsrs_t HowManyUsrs);
|
||||||
void TL_Usr_ShowNumSharersOrFavers (unsigned NumUsrs);
|
void TL_Usr_ShowNumSharersOrFavers (unsigned NumUsrs);
|
||||||
void TL_Usr_ShowSharersOrFavers (MYSQL_RES **mysql_res,
|
void TL_Usr_ListSharersOrFavers (MYSQL_RES **mysql_res,
|
||||||
unsigned NumUsrs,unsigned NumFirstUsrs);
|
unsigned NumUsrs,unsigned NumFirstUsrs);
|
||||||
bool TL_Usr_CheckICanFavSha (long Cod,long UsrCod);
|
bool TL_Usr_CheckICanFavSha (long Cod,long UsrCod);
|
||||||
|
bool TL_Usr_CheckIfFavedSharedByUsr (TL_Usr_FavSha_t FavSha,long Cod,long UsrCod);
|
||||||
|
unsigned TL_Usr_GetListFaversOrSharers (TL_Usr_FavSha_t FavSha,
|
||||||
|
long Cod,long UsrCod,unsigned MaxUsrs,
|
||||||
|
MYSQL_RES **mysql_res);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue