mirror of https://github.com/acanas/swad-core.git
Version 20.36.30: Feb 28, 2021 Code refactoring in timeline favourites.
This commit is contained in:
parent
e779ee524e
commit
7b70bb8262
|
@ -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.29 (2021-02-28)"
|
#define Log_PLATFORM_VERSION "SWAD 20.36.30 (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.30: Feb 28, 2021 Code refactoring in timeline favourites. (305411 lines)
|
||||||
Version 20.36.29: Feb 28, 2021 Code refactoring in module swad_timeline_database. (305457 lines)
|
Version 20.36.29: Feb 28, 2021 Code refactoring in module swad_timeline_database. (305457 lines)
|
||||||
Version 20.36.28: Feb 28, 2021 Functions moved to module swad_timeline_database. (305426 lines)
|
Version 20.36.28: Feb 28, 2021 Functions moved to module swad_timeline_database. (305426 lines)
|
||||||
Version 20.36.27: Feb 28, 2021 Functions moved to module swad_timeline_database. (305424 lines)
|
Version 20.36.27: Feb 28, 2021 Functions moved to module swad_timeline_database. (305424 lines)
|
||||||
|
|
|
@ -62,10 +62,6 @@ static bool TL_DB_CheckIfFavedByUsr (const char *Table,const char *Field,
|
||||||
long Cod,long UsrCod);
|
long Cod,long UsrCod);
|
||||||
static unsigned TL_DB_GetNumTimesHasBeenFav (const char *Table,const char *Field,
|
static unsigned TL_DB_GetNumTimesHasBeenFav (const char *Table,const char *Field,
|
||||||
long Cod,long UsrCod);
|
long Cod,long UsrCod);
|
||||||
static unsigned TL_DB_GetListUsrsHaveFaved (const char *Table,const char *Field,
|
|
||||||
long Cod,long UsrCod,
|
|
||||||
unsigned MaxUsrs,
|
|
||||||
MYSQL_RES **mysql_res);
|
|
||||||
static void TL_DB_MarkAsFav (const char *Table,const char *Field,long Cod);
|
static void TL_DB_MarkAsFav (const char *Table,const char *Field,long Cod);
|
||||||
static void TL_DB_UnmarkAsFav (const char *Table,const char *Field,long Cod);
|
static void TL_DB_UnmarkAsFav (const char *Table,const char *Field,long Cod);
|
||||||
|
|
||||||
|
@ -921,28 +917,10 @@ static unsigned TL_DB_GetNumTimesHasBeenFav (const char *Table,const char *Field
|
||||||
/******* 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_GetListUsrsHaveFavedANote (const struct TL_Not_Note *Not,
|
unsigned TL_DB_GetListUsrsHaveFaved (const char *Table,const char *Field,
|
||||||
unsigned MaxUsrs,
|
long Cod,long UsrCod,
|
||||||
MYSQL_RES **mysql_res)
|
unsigned MaxUsrs,
|
||||||
{
|
MYSQL_RES **mysql_res)
|
||||||
return TL_DB_GetListUsrsHaveFaved ("tl_notes_fav","NotCod",
|
|
||||||
Not->NotCod,Not->UsrCod,MaxUsrs,
|
|
||||||
mysql_res);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned TL_DB_GetListUsrsHaveFavedAComm (const struct TL_Com_Comment *Com,
|
|
||||||
unsigned MaxUsrs,
|
|
||||||
MYSQL_RES **mysql_res)
|
|
||||||
{
|
|
||||||
return TL_DB_GetListUsrsHaveFaved ("tl_comments_fav","PubCod",
|
|
||||||
Com->PubCod,Com->UsrCod,MaxUsrs,
|
|
||||||
mysql_res);
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned TL_DB_GetListUsrsHaveFaved (const char *Table,const char *Field,
|
|
||||||
long Cod,long UsrCod,
|
|
||||||
unsigned MaxUsrs,
|
|
||||||
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)
|
||||||
|
|
|
@ -116,12 +116,10 @@ bool TL_DB_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod);
|
||||||
bool TL_DB_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod);
|
bool TL_DB_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod);
|
||||||
unsigned TL_DB_GetNumTimesANoteHasBeenFav (const struct TL_Not_Note *Not);
|
unsigned TL_DB_GetNumTimesANoteHasBeenFav (const struct TL_Not_Note *Not);
|
||||||
unsigned TL_DB_GetNumTimesACommHasBeenFav (const struct TL_Com_Comment *Com);
|
unsigned TL_DB_GetNumTimesACommHasBeenFav (const struct TL_Com_Comment *Com);
|
||||||
unsigned TL_DB_GetListUsrsHaveFavedANote (const struct TL_Not_Note *Not,
|
unsigned TL_DB_GetListUsrsHaveFaved (const char *Table,const char *Field,
|
||||||
unsigned MaxUsrs,
|
long Cod,long UsrCod,
|
||||||
MYSQL_RES **mysql_res);
|
unsigned MaxUsrs,
|
||||||
unsigned TL_DB_GetListUsrsHaveFavedAComm (const struct TL_Com_Comment *Com,
|
MYSQL_RES **mysql_res);
|
||||||
unsigned MaxUsrs,
|
|
||||||
MYSQL_RES **mysql_res);
|
|
||||||
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);
|
||||||
|
|
|
@ -69,10 +69,12 @@ 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 void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Not_Note *Not,
|
static void TL_Fav_ShowUsrsWhoHaveMarkedAsFav (const char *Table,const char *Field,
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs);
|
TL_Frm_Action_t Action,
|
||||||
static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Com_Comment *Com,
|
const char *ParamFormat,
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs);
|
long Cod,long UsrCod,
|
||||||
|
unsigned NumFavs,
|
||||||
|
TL_Usr_HowManyUsrs_t HowManyUsrs);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********************** Mark/unmark a note as favourite **********************/
|
/********************** Mark/unmark a note as favourite **********************/
|
||||||
|
@ -153,7 +155,10 @@ void TL_Fav_PutIconToFavUnfNote (const struct TL_Not_Note *Not,
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
|
||||||
/***** Show who have marked this note as favourite *****/
|
/***** Show who have marked this note as favourite *****/
|
||||||
TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (Not,HowManyUsrs);
|
TL_Fav_ShowUsrsWhoHaveMarkedAsFav ("tl_notes_fav","NotCod",
|
||||||
|
TL_Frm_ALL_FAV_NOTE,"NotCod=%ld",
|
||||||
|
Not->NotCod,Not->UsrCod,Not->NumFavs,
|
||||||
|
HowManyUsrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TL_Fav_FavNote (struct TL_Not_Note *Not)
|
static void TL_Fav_FavNote (struct TL_Not_Note *Not)
|
||||||
|
@ -295,7 +300,10 @@ void TL_Fav_PutIconToFavUnfComment (const struct TL_Com_Comment *Com,
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
|
||||||
/***** Show who have marked this comment as favourite *****/
|
/***** Show who have marked this comment as favourite *****/
|
||||||
TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (Com,HowManyUsrs);
|
TL_Fav_ShowUsrsWhoHaveMarkedAsFav ("tl_comments_fav","PubCod",
|
||||||
|
TL_Frm_ALL_FAV_COMM,"PubCod=%ld",
|
||||||
|
Com->PubCod,Com->UsrCod,Com->NumFavs,
|
||||||
|
HowManyUsrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TL_Fav_FavComment (struct TL_Com_Comment *Com)
|
static void TL_Fav_FavComment (struct TL_Com_Comment *Com)
|
||||||
|
@ -310,7 +318,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_DB_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 *****/
|
||||||
TL_DB_MarkCommAsFav (Com->PubCod);
|
TL_DB_MarkCommAsFav (Com->PubCod);
|
||||||
|
@ -445,83 +453,44 @@ static void TL_Fav_PutFormToFavUnfComm (long PubCod)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************ Show users who have marked this note as favourite **************/
|
/********** Show users who have marked a note/comment as favourite ***********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Not_Note *Not,
|
static void TL_Fav_ShowUsrsWhoHaveMarkedAsFav (const char *Table,const char *Field,
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
TL_Frm_Action_t Action,
|
||||||
|
const char *ParamFormat,
|
||||||
|
long Cod,long UsrCod,
|
||||||
|
unsigned NumFavs,
|
||||||
|
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned NumFirstUsrs;
|
unsigned NumFirstUsrs;
|
||||||
|
|
||||||
/***** Get users who have marked this note as favourite *****/
|
/***** Get users who have marked this note as favourite *****/
|
||||||
if (Not->NumFavs)
|
if (NumFavs)
|
||||||
/***** Get list of users from database *****/
|
/***** Get list of users from database *****/
|
||||||
NumFirstUsrs = TL_DB_GetListUsrsHaveFavedANote (Not,
|
NumFirstUsrs = TL_DB_GetListUsrsHaveFaved (Table,Field,Cod,UsrCod,
|
||||||
HowManyUsrs == TL_Usr_SHOW_FEW_USRS ? TL_Usr_DEF_USRS_SHOWN :
|
HowManyUsrs == TL_Usr_SHOW_FEW_USRS ? TL_Usr_DEF_USRS_SHOWN :
|
||||||
TL_Usr_MAX_USRS_SHOWN,
|
TL_Usr_MAX_USRS_SHOWN,
|
||||||
&mysql_res);
|
&mysql_res);
|
||||||
else
|
else
|
||||||
NumFirstUsrs = 0;
|
NumFirstUsrs = 0;
|
||||||
|
|
||||||
/***** Show users *****/
|
/***** Show users *****/
|
||||||
/* Number of users */
|
/* Number of users */
|
||||||
HTM_DIV_Begin ("class=\"TL_NUM_USRS\"");
|
HTM_DIV_Begin ("class=\"TL_NUM_USRS\"");
|
||||||
TL_Usr_ShowNumSharersOrFavers (Not->NumFavs);
|
TL_Usr_ShowNumSharersOrFavers (NumFavs);
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
|
||||||
/* List users one by one */
|
/* List users one by one */
|
||||||
HTM_DIV_Begin ("class=\"TL_USRS\"");
|
HTM_DIV_Begin ("class=\"TL_USRS\"");
|
||||||
TL_Usr_ShowSharersOrFavers (&mysql_res,Not->NumFavs,NumFirstUsrs);
|
TL_Usr_ShowSharersOrFavers (&mysql_res,NumFavs,NumFirstUsrs);
|
||||||
if (NumFirstUsrs < Not->NumFavs) // Not all are shown
|
if (NumFirstUsrs < NumFavs) // Not all are shown
|
||||||
/* Clickable ellipsis to show all users */
|
/* Clickable ellipsis to show all users */
|
||||||
TL_Frm_PutFormToSeeAllFaversSharers (TL_Frm_ALL_FAV_NOTE,
|
TL_Frm_PutFormToSeeAllFaversSharers (Action,ParamFormat,Cod,HowManyUsrs);
|
||||||
"NotCod=%ld",Not->NotCod,
|
|
||||||
HowManyUsrs);
|
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
if (Not->NumFavs)
|
if (NumFavs)
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/************ Show users who have marked this note as favourite **************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Com_Comment *Com,
|
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
|
||||||
{
|
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
unsigned NumFirstUsrs;
|
|
||||||
|
|
||||||
/***** Get users who have marked this comment as favourite *****/
|
|
||||||
if (Com->NumFavs)
|
|
||||||
/***** Get list of users from database *****/
|
|
||||||
NumFirstUsrs = TL_DB_GetListUsrsHaveFavedAComm (Com,
|
|
||||||
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 (Com->NumFavs);
|
|
||||||
HTM_DIV_End ();
|
|
||||||
|
|
||||||
/* List users one by one */
|
|
||||||
HTM_DIV_Begin ("class=\"TL_USRS\"");
|
|
||||||
TL_Usr_ShowSharersOrFavers (&mysql_res,Com->NumFavs,NumFirstUsrs);
|
|
||||||
if (NumFirstUsrs < Com->NumFavs)
|
|
||||||
/* Clickable ellipsis to show all users */
|
|
||||||
TL_Frm_PutFormToSeeAllFaversSharers (TL_Frm_ALL_FAV_COMM,
|
|
||||||
"PubCod=%ld",Com->PubCod,
|
|
||||||
HowManyUsrs);
|
|
||||||
HTM_DIV_End ();
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
if (Com->NumFavs)
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue