mirror of https://github.com/acanas/swad-core.git
Version 20.36.31: Mar 01, 2021 Code refactoring in timeline favourites.
This commit is contained in:
parent
7b70bb8262
commit
afeb492c4c
|
@ -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.30 (2021-02-28)"
|
#define Log_PLATFORM_VERSION "SWAD 20.36.31 (2021-03-01)"
|
||||||
#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.31: Mar 01, 2021 Code refactoring in timeline favourites. (305432 lines)
|
||||||
Version 20.36.30: Feb 28, 2021 Code refactoring in timeline favourites. (305411 lines)
|
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)
|
||||||
|
|
|
@ -917,11 +917,22 @@ 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_GetListUsrsHaveFaved (const char *Table,const char *Field,
|
unsigned TL_DB_GetListUsrsHaveFaved (TL_Fav_WhatToFav_t WhatToFav,
|
||||||
long Cod,long UsrCod,
|
long Cod,long UsrCod,
|
||||||
unsigned MaxUsrs,
|
unsigned MaxUsrs,
|
||||||
MYSQL_RES **mysql_res)
|
MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
|
const char *Table[TL_Fav_NUM_WHAT_TO_FAV] =
|
||||||
|
{
|
||||||
|
"tl_notes_fav",
|
||||||
|
"tl_comments_fav",
|
||||||
|
};
|
||||||
|
const char *Field[TL_Fav_NUM_WHAT_TO_FAV] =
|
||||||
|
{
|
||||||
|
"NotCod",
|
||||||
|
"PubCod",
|
||||||
|
};
|
||||||
|
|
||||||
/***** 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)
|
||||||
DB_QuerySELECT (mysql_res,"can not get favers",
|
DB_QuerySELECT (mysql_res,"can not get favers",
|
||||||
|
@ -930,8 +941,8 @@ unsigned TL_DB_GetListUsrsHaveFaved (const char *Table,const char *Field,
|
||||||
" 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",
|
||||||
Table,
|
Table[WhatToFav],
|
||||||
Field,Cod,
|
Field[WhatToFav],Cod,
|
||||||
UsrCod,
|
UsrCod,
|
||||||
MaxUsrs);
|
MaxUsrs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_file_browser.h"
|
#include "swad_file_browser.h"
|
||||||
#include "swad_timeline_comment.h"
|
#include "swad_timeline_comment.h"
|
||||||
|
#include "swad_timeline_favourite.h"
|
||||||
#include "swad_timeline_note.h"
|
#include "swad_timeline_note.h"
|
||||||
#include "swad_timeline_post.h"
|
#include "swad_timeline_post.h"
|
||||||
#include "swad_timeline_publication.h"
|
#include "swad_timeline_publication.h"
|
||||||
|
@ -116,7 +117,7 @@ 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_GetListUsrsHaveFaved (const char *Table,const char *Field,
|
unsigned TL_DB_GetListUsrsHaveFaved (TL_Fav_WhatToFav_t WhatToFav,
|
||||||
long Cod,long UsrCod,
|
long Cod,long UsrCod,
|
||||||
unsigned MaxUsrs,
|
unsigned MaxUsrs,
|
||||||
MYSQL_RES **mysql_res);
|
MYSQL_RES **mysql_res);
|
||||||
|
|
|
@ -69,9 +69,7 @@ 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_ShowUsrsWhoHaveMarkedAsFav (const char *Table,const char *Field,
|
static void TL_Fav_ShowUsrsWhoHaveMarkedAsFav (TL_Fav_WhatToFav_t WhatToFav,
|
||||||
TL_Frm_Action_t Action,
|
|
||||||
const char *ParamFormat,
|
|
||||||
long Cod,long UsrCod,
|
long Cod,long UsrCod,
|
||||||
unsigned NumFavs,
|
unsigned NumFavs,
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs);
|
TL_Usr_HowManyUsrs_t HowManyUsrs);
|
||||||
|
@ -155,8 +153,7 @@ 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_ShowUsrsWhoHaveMarkedAsFav ("tl_notes_fav","NotCod",
|
TL_Fav_ShowUsrsWhoHaveMarkedAsFav (TL_Fav_NOTE,
|
||||||
TL_Frm_ALL_FAV_NOTE,"NotCod=%ld",
|
|
||||||
Not->NotCod,Not->UsrCod,Not->NumFavs,
|
Not->NotCod,Not->UsrCod,Not->NumFavs,
|
||||||
HowManyUsrs);
|
HowManyUsrs);
|
||||||
}
|
}
|
||||||
|
@ -300,8 +297,7 @@ 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_ShowUsrsWhoHaveMarkedAsFav ("tl_comments_fav","PubCod",
|
TL_Fav_ShowUsrsWhoHaveMarkedAsFav (TL_Fav_NOTE,
|
||||||
TL_Frm_ALL_FAV_COMM,"PubCod=%ld",
|
|
||||||
Com->PubCod,Com->UsrCod,Com->NumFavs,
|
Com->PubCod,Com->UsrCod,Com->NumFavs,
|
||||||
HowManyUsrs);
|
HowManyUsrs);
|
||||||
}
|
}
|
||||||
|
@ -456,20 +452,28 @@ static void TL_Fav_PutFormToFavUnfComm (long PubCod)
|
||||||
/********** Show users who have marked a note/comment as favourite ***********/
|
/********** Show users who have marked a note/comment as favourite ***********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void TL_Fav_ShowUsrsWhoHaveMarkedAsFav (const char *Table,const char *Field,
|
static void TL_Fav_ShowUsrsWhoHaveMarkedAsFav (TL_Fav_WhatToFav_t WhatToFav,
|
||||||
TL_Frm_Action_t Action,
|
|
||||||
const char *ParamFormat,
|
|
||||||
long Cod,long UsrCod,
|
long Cod,long UsrCod,
|
||||||
unsigned NumFavs,
|
unsigned NumFavs,
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
||||||
{
|
{
|
||||||
|
TL_Frm_Action_t Action[TL_Fav_NUM_WHAT_TO_FAV] =
|
||||||
|
{
|
||||||
|
TL_Frm_ALL_FAV_NOTE,
|
||||||
|
TL_Frm_ALL_FAV_COMM,
|
||||||
|
};
|
||||||
|
const char *ParamFormat[TL_Fav_NUM_WHAT_TO_FAV] =
|
||||||
|
{
|
||||||
|
"NotCod=%ld",
|
||||||
|
"PubCod=%ld",
|
||||||
|
};
|
||||||
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 (NumFavs)
|
if (NumFavs)
|
||||||
/***** Get list of users from database *****/
|
/***** Get list of users from database *****/
|
||||||
NumFirstUsrs = TL_DB_GetListUsrsHaveFaved (Table,Field,Cod,UsrCod,
|
NumFirstUsrs = TL_DB_GetListUsrsHaveFaved (WhatToFav,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);
|
||||||
|
@ -487,7 +491,9 @@ static void TL_Fav_ShowUsrsWhoHaveMarkedAsFav (const char *Table,const char *Fie
|
||||||
TL_Usr_ShowSharersOrFavers (&mysql_res,NumFavs,NumFirstUsrs);
|
TL_Usr_ShowSharersOrFavers (&mysql_res,NumFavs,NumFirstUsrs);
|
||||||
if (NumFirstUsrs < 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 (Action,ParamFormat,Cod,HowManyUsrs);
|
TL_Frm_PutFormToSeeAllFaversSharers (Action[WhatToFav],
|
||||||
|
ParamFormat[WhatToFav],Cod,
|
||||||
|
HowManyUsrs);
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
|
|
@ -31,15 +31,18 @@
|
||||||
#include "swad_timeline_note.h"
|
#include "swad_timeline_note.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************************** Public constants *****************************/
|
/************************ Public constants and types *************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/*****************************************************************************/
|
#define TL_Fav_NUM_WHAT_TO_FAV 2
|
||||||
/******************************** Public types *******************************/
|
typedef enum
|
||||||
/*****************************************************************************/
|
{
|
||||||
|
TL_Fav_NOTE = 0,
|
||||||
|
TL_Fav_COMM = 1,
|
||||||
|
} TL_Fav_WhatToFav_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************************** Public prototypes ****************************/
|
/***************************** Public prototypes *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void TL_Fav_PutFormToSeeAllFaversNote (long NotCod,
|
void TL_Fav_PutFormToSeeAllFaversNote (long NotCod,
|
||||||
|
|
Loading…
Reference in New Issue