Version 20.36.36: Mar 01, 2021 Query moved to module swad_timeline_database.

This commit is contained in:
acanas 2021-03-01 13:15:50 +01:00
parent 5fc917c664
commit 99006c5f98
7 changed files with 104 additions and 128 deletions

View File

@ -553,7 +553,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD: En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 20.36.34 (2021-03-01)" #define Log_PLATFORM_VERSION "SWAD 20.36.36 (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,8 @@ 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.36: Mar 01, 2021 Query moved to module swad_timeline_database. (305429 lines)
Version 20.36.35: Mar 01, 2021 Code refactoring in timeline favourites. (305411 lines)
Version 20.36.34: Mar 01, 2021 Function moved to module swad_timeline_database. (305446 lines) Version 20.36.34: Mar 01, 2021 Function moved to module swad_timeline_database. (305446 lines)
Version 20.36.33: Mar 01, 2021 Function moved to module swad_timeline_database. (305446 lines) Version 20.36.33: Mar 01, 2021 Function moved to module swad_timeline_database. (305446 lines)
Version 20.36.32: Mar 01, 2021 Query moved to module swad_timeline_database. (305444 lines) Version 20.36.32: Mar 01, 2021 Query moved to module swad_timeline_database. (305444 lines)

View File

@ -1016,7 +1016,8 @@ static void TL_Com_GetDataOfCommentFromRow (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_GetNumTimesACommHasBeenFav (Com); Com->NumFavs = TL_DB_GetNumTimesHasBeenFav (TL_Fav_COMM,
Com->PubCod,Com->UsrCod);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -40,6 +40,17 @@
/************************* Private constants and types ***********************/ /************************* Private constants and types ***********************/
/*****************************************************************************/ /*****************************************************************************/
static const char *TL_DB_Table[TL_Fav_NUM_WHAT_TO_FAV] =
{
[TL_Fav_NOTE] = "tl_notes_fav",
[TL_Fav_COMM] = "tl_comments_fav",
};
static const char *TL_DB_Field[TL_Fav_NUM_WHAT_TO_FAV] =
{
[TL_Fav_NOTE] = "NotCod",
[TL_Fav_COMM] = "PubCod",
};
/*****************************************************************************/ /*****************************************************************************/
/************** External global variables from others modules ****************/ /************** External global variables from others modules ****************/
/*****************************************************************************/ /*****************************************************************************/
@ -54,17 +65,8 @@ extern struct Globals Gbl;
/***************************** Private prototypes ****************************/ /***************************** Private prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
/****************************** Publications *********************************/
static long TL_DB_GetMedCodFromPub (long PubCod,const char *DBTable); static long TL_DB_GetMedCodFromPub (long PubCod,const char *DBTable);
/******************************* Favourites **********************************/
static bool TL_DB_CheckIfFavedByUsr (const char *Table,const char *Field,
long Cod,long UsrCod);
static unsigned TL_DB_GetNumTimesHasBeenFav (const char *Table,const char *Field,
long Cod,long UsrCod);
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);
/*****************************************************************************/ /*****************************************************************************/
/********************* Get data of note using its code ***********************/ /********************* Get data of note using its code ***********************/
/*****************************************************************************/ /*****************************************************************************/
@ -861,45 +863,23 @@ void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod)
/****************** Check if a user has favourited a note ********************/ /****************** Check if a user has favourited a note ********************/
/*****************************************************************************/ /*****************************************************************************/
bool TL_DB_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod) bool TL_DB_CheckIfFavedByUsr (TL_Fav_WhatToFav_t WhatToFav,
{ long Cod,long UsrCod)
return TL_DB_CheckIfFavedByUsr ("tl_notes_fav","NotCod",NotCod,UsrCod);
}
bool TL_DB_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod)
{
return TL_DB_CheckIfFavedByUsr ("tl_comments_fav","PubCod",PubCod,UsrCod);
}
static bool TL_DB_CheckIfFavedByUsr (const char *Table,const char *Field,
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 PubCod=%ld AND UsrCod=%ld", " WHERE PubCod=%ld AND UsrCod=%ld",
Table, TL_DB_Table[WhatToFav],
Field,Cod,UsrCod) != 0); TL_DB_Field[WhatToFav],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_GetNumTimesANoteHasBeenFav (const struct TL_Not_Note *Not) unsigned TL_DB_GetNumTimesHasBeenFav (TL_Fav_WhatToFav_t WhatToFav,
{ long Cod,long UsrCod)
return TL_DB_GetNumTimesHasBeenFav ("tl_notes_fav","NotCod",
Not->NotCod,Not->UsrCod);
}
unsigned TL_DB_GetNumTimesACommHasBeenFav (const struct TL_Com_Comment *Com)
{
return TL_DB_GetNumTimesHasBeenFav ("tl_comments_fav","PubCod",
Com->PubCod,Com->UsrCod);
}
static unsigned TL_DB_GetNumTimesHasBeenFav (const char *Table,const char *Field,
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)
@ -907,8 +887,8 @@ static unsigned TL_DB_GetNumTimesHasBeenFav (const char *Table,const char *Field
"SELECT COUNT(*) FROM %s" "SELECT COUNT(*) FROM %s"
" WHERE %s=%ld" " WHERE %s=%ld"
" AND UsrCod<>%ld", // Extra check " AND UsrCod<>%ld", // Extra check
Table, TL_DB_Table[WhatToFav],
Field,Cod, TL_DB_Field[WhatToFav],Cod,
UsrCod); // The author UsrCod); // The author
} }
@ -921,17 +901,6 @@ unsigned TL_DB_GetListUsrsHaveFaved (TL_Fav_WhatToFav_t WhatToFav,
unsigned MaxUsrs, unsigned MaxUsrs,
MYSQL_RES **mysql_res) MYSQL_RES **mysql_res)
{ {
const char *Table[TL_Fav_NUM_WHAT_TO_FAV] =
{
[TL_Fav_NOTE] = "tl_notes_fav",
[TL_Fav_COMM] = "tl_comments_fav",
};
const char *Field[TL_Fav_NUM_WHAT_TO_FAV] =
{
[TL_Fav_NOTE] = "NotCod",
[TL_Fav_COMM] = "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",
@ -940,8 +909,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",
Table[WhatToFav], TL_DB_Table[WhatToFav],
Field[WhatToFav],Cod, TL_DB_Field[WhatToFav],Cod,
UsrCod, UsrCod,
MaxUsrs); MaxUsrs);
} }
@ -950,17 +919,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_MarkNoteAsFav (long NotCod) void TL_DB_MarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod)
{
TL_DB_MarkAsFav ("tl_notes_fav","NotCod",NotCod);
}
void TL_DB_MarkCommAsFav (long PubCod)
{
TL_DB_MarkAsFav ("tl_comments_fav","PubCod",PubCod);
}
static void TL_DB_MarkAsFav (const char *Table,const char *Field,long Cod)
{ {
/***** Insert in favourited in database *****/ /***** Insert in favourited in database *****/
DB_QueryINSERT ("can not favourite comment", DB_QueryINSERT ("can not favourite comment",
@ -968,8 +927,8 @@ static void TL_DB_MarkAsFav (const char *Table,const char *Field,long Cod)
" (%s,UsrCod,TimeFav)" " (%s,UsrCod,TimeFav)"
" VALUES" " VALUES"
" (%ld,%ld,NOW())", " (%ld,%ld,NOW())",
Table, TL_DB_Table[WhatToFav],
Field, TL_DB_Field[WhatToFav],
Cod,Gbl.Usrs.Me.UsrDat.UsrCod); Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
} }
@ -977,24 +936,14 @@ static void TL_DB_MarkAsFav (const char *Table,const char *Field,long Cod)
/*************** Unmark note/comment as favourite in database ****************/ /*************** Unmark note/comment as favourite in database ****************/
/*****************************************************************************/ /*****************************************************************************/
void TL_DB_UnmarkNoteAsFav (long NotCod) void TL_DB_UnmarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod)
{
TL_DB_UnmarkAsFav ("tl_notes_fav","NotCod",NotCod);
}
void TL_DB_UnmarkCommAsFav (long PubCod)
{
TL_DB_UnmarkAsFav ("tl_comments_fav","PubCod",PubCod);
}
static void TL_DB_UnmarkAsFav (const char *Table,const char *Field,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",
Table, TL_DB_Table[WhatToFav],
Field,Cod,Gbl.Usrs.Me.UsrDat.UsrCod); TL_DB_Field[WhatToFav],Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1031,6 +980,29 @@ unsigned TL_DB_GetNumTimesANoteHasBeenShared (struct TL_Not_Note *Not)
(unsigned) TL_Pub_SHARED_NOTE); (unsigned) TL_Pub_SHARED_NOTE);
} }
/*****************************************************************************/
/***************** Get list of users who have shared a note ******************/
/*****************************************************************************/
unsigned TL_DB_GetListUsrsHaveShared (long NotCod,long UsrCod,
unsigned MaxUsrs,
MYSQL_RES **mysql_res)
{
/***** Get list of users who have shared a note from database *****/
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get users",
"SELECT PublisherCod" // row[0]
" FROM tl_pubs"
" WHERE NotCod=%ld"
" AND PublisherCod<>%ld"
" AND PubType=%u"
" ORDER BY PubCod LIMIT %u",
NotCod,
UsrCod,
(unsigned) TL_Pub_SHARED_NOTE,
MaxUsrs);
}
/*****************************************************************************/ /*****************************************************************************/
/****************** Remove shared publication from database ******************/ /****************** Remove shared publication from database ******************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -113,22 +113,23 @@ void TL_DB_UpdateLastPubCodInSession (void);
void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod); void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod);
/****************************** Favourites ***********************************/ /****************************** Favourites ***********************************/
bool TL_DB_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod); bool TL_DB_CheckIfFavedByUsr (TL_Fav_WhatToFav_t WhatToFav,
bool TL_DB_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod); long Cod,long UsrCod);
unsigned TL_DB_GetNumTimesANoteHasBeenFav (const struct TL_Not_Note *Not); unsigned TL_DB_GetNumTimesHasBeenFav (TL_Fav_WhatToFav_t WhatToFav,
unsigned TL_DB_GetNumTimesACommHasBeenFav (const struct TL_Com_Comment *Com); long Cod,long UsrCod);
unsigned TL_DB_GetListUsrsHaveFaved (TL_Fav_WhatToFav_t WhatToFav, 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);
void TL_DB_MarkNoteAsFav (long NotCod); void TL_DB_MarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod);
void TL_DB_MarkCommAsFav (long PubCod); void TL_DB_UnmarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod);
void TL_DB_UnmarkNoteAsFav (long NotCod);
void TL_DB_UnmarkCommAsFav (long PubCod);
/******************************** Shared *************************************/ /******************************** Shared *************************************/
bool TL_DB_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod); bool TL_DB_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod);
unsigned TL_DB_GetNumTimesANoteHasBeenShared (struct TL_Not_Note *Not); unsigned TL_DB_GetNumTimesANoteHasBeenShared (struct TL_Not_Note *Not);
unsigned TL_DB_GetListUsrsHaveShared (long NotCod,long UsrCod,
unsigned MaxUsrs,
MYSQL_RES **mysql_res);
void TL_DB_RemoveSharedPub (long NotCod); void TL_DB_RemoveSharedPub (long NotCod);
#endif #endif

View File

@ -170,14 +170,15 @@ static void TL_Fav_FavNote (struct TL_Not_Note *Not)
{ {
if (Gbl.Usrs.Me.Logged && // I am logged... if (Gbl.Usrs.Me.Logged && // I am logged...
!Usr_ItsMe (Not->UsrCod)) // ...but I am not the author !Usr_ItsMe (Not->UsrCod)) // ...but I am not the author
if (!TL_DB_CheckIfNoteIsFavedByUsr (Not->NotCod, if (!TL_DB_CheckIfFavedByUsr (TL_Fav_NOTE,Not->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the note Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the note
{ {
/***** Mark note as favourite in database *****/ /***** Mark note as favourite in database *****/
TL_DB_MarkNoteAsFav (Not->NotCod); TL_DB_MarkAsFav (TL_Fav_NOTE,Not->NotCod);
/***** Update number of times this note is favourited *****/ /***** Update number of times this note is favourited *****/
TL_DB_GetNumTimesANoteHasBeenFav (Not); Not->NumFavs = TL_DB_GetNumTimesHasBeenFav (TL_Fav_NOTE,
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 *****/
@ -201,14 +202,15 @@ static void TL_Fav_UnfNote (struct TL_Not_Note *Not)
if (Not->NumFavs && if (Not->NumFavs &&
Gbl.Usrs.Me.Logged && // I am logged... Gbl.Usrs.Me.Logged && // I am logged...
!Usr_ItsMe (Not->UsrCod)) // ...but I am not the author !Usr_ItsMe (Not->UsrCod)) // ...but I am not the author
if (TL_DB_CheckIfNoteIsFavedByUsr (Not->NotCod, if (TL_DB_CheckIfFavedByUsr (TL_Fav_NOTE,Not->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the note Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the note
{ {
/***** Delete the mark as favourite from database *****/ /***** Delete the mark as favourite from database *****/
TL_DB_UnmarkNoteAsFav (Not->NotCod); TL_DB_UnmarkAsFav (TL_Fav_NOTE,Not->NotCod);
/***** Update number of times this note is favourited *****/ /***** Update number of times this note is favourited *****/
TL_DB_GetNumTimesANoteHasBeenFav (Not); Not->NumFavs = TL_DB_GetNumTimesHasBeenFav (TL_Fav_NOTE,
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);
@ -313,17 +315,18 @@ 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_CheckIfFavedByUsr (TL_Fav_COMM,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_MarkAsFav (TL_Fav_COMM,Com->PubCod);
/* Update number of times this comment is favourited */ /***** Update number of times this comment is favourited *****/
TL_DB_GetNumTimesACommHasBeenFav (Com); Com->NumFavs = TL_DB_GetNumTimesHasBeenFav (TL_Fav_COMM,
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 *****/
TL_Ntf_CreateNotifToAuthor (Com->UsrCod,Com->PubCod, TL_Ntf_CreateNotifToAuthor (Com->UsrCod,Com->PubCod,
Ntf_EVENT_TIMELINE_FAV); Ntf_EVENT_TIMELINE_FAV);
} }
@ -344,14 +347,15 @@ static void TL_Fav_UnfComment (struct TL_Com_Comment *Com)
if (Com->PubCod > 0) if (Com->PubCod > 0)
if (Com->NumFavs && if (Com->NumFavs &&
!Usr_ItsMe (Com->UsrCod)) // I am not the author !Usr_ItsMe (Com->UsrCod)) // I am not the author
if (TL_DB_CheckIfCommIsFavedByUsr (Com->PubCod, if (TL_DB_CheckIfFavedByUsr (TL_Fav_COMM,Com->PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the comment Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the comment
{ {
/***** Delete the mark as favourite from database *****/ /***** Delete the mark as favourite from database *****/
TL_DB_UnmarkCommAsFav (Com->PubCod); TL_DB_UnmarkAsFav (TL_Fav_COMM,Com->PubCod);
/***** Update number of times this comment is favourited *****/ /***** Update number of times this comment is favourited *****/
TL_DB_GetNumTimesACommHasBeenFav (Com); Com->NumFavs = TL_DB_GetNumTimesHasBeenFav (TL_Fav_COMM,
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);
@ -413,7 +417,8 @@ static void TL_Fav_PutFormToFavUnfNote (long NotCod)
}; };
/***** Form and icon to fav/unfav note *****/ /***** Form and icon to fav/unfav note *****/
TL_Frm_FormFavSha (&Form[TL_DB_CheckIfNoteIsFavedByUsr (NotCod,Gbl.Usrs.Me.UsrDat.UsrCod)]); TL_Frm_FormFavSha (&Form[TL_DB_CheckIfFavedByUsr (TL_Fav_NOTE,NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)]);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -445,7 +450,8 @@ static void TL_Fav_PutFormToFavUnfComm (long PubCod)
}; };
/***** Form and icon to fav/unfav *****/ /***** Form and icon to fav/unfav *****/
TL_Frm_FormFavSha (&Form[TL_DB_CheckIfNoteIsFavedByUsr (PubCod,Gbl.Usrs.Me.UsrDat.UsrCod)]); TL_Frm_FormFavSha (&Form[TL_DB_CheckIfFavedByUsr (TL_Fav_COMM,PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod)]);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -89,8 +89,8 @@ static void TL_Not_PutFormGoToAction (const struct TL_Not_Note *Not,
const struct For_Forums *Forums); const struct For_Forums *Forums);
static void TL_Not_WriteButtonsAndComments (const struct TL_Timeline *Timeline, static void TL_Not_WriteButtonsAndComments (const struct TL_Timeline *Timeline,
const struct TL_Not_Note *Not, const struct TL_Not_Note *Not,
const struct UsrData *UsrDat); const struct UsrData *UsrDat);
static void TL_Not_WriteButtonToAddAComment (const struct TL_Not_Note *Not, static void TL_Not_WriteButtonToAddAComment (const struct TL_Not_Note *Not,
const char IdNewComment[Frm_MAX_BYTES_ID + 1]); const char IdNewComment[Frm_MAX_BYTES_ID + 1]);
static void TL_Not_WriteFavShaRemAndComments (const struct TL_Timeline *Timeline, static void TL_Not_WriteFavShaRemAndComments (const struct TL_Timeline *Timeline,
@ -724,8 +724,8 @@ void TL_Not_GetNoteSummary (const struct TL_Not_Note *Not,
/*****************************************************************************/ /*****************************************************************************/
static void TL_Not_WriteButtonsAndComments (const struct TL_Timeline *Timeline, static void TL_Not_WriteButtonsAndComments (const struct TL_Timeline *Timeline,
const struct TL_Not_Note *Not, const struct TL_Not_Note *Not,
const struct UsrData *UsrDat) // Author const struct UsrData *UsrDat) // Author
{ {
char IdNewComment[Frm_MAX_BYTES_ID + 1]; char IdNewComment[Frm_MAX_BYTES_ID + 1];
@ -1294,7 +1294,8 @@ static void TL_Not_GetDataOfNoteFromRow (MYSQL_ROW row,struct TL_Not_Note *Not)
Not->NumShared = TL_DB_GetNumTimesANoteHasBeenShared (Not); Not->NumShared = TL_DB_GetNumTimesANoteHasBeenShared (Not);
/***** Get number of times this note has been favourited *****/ /***** Get number of times this note has been favourited *****/
Not->NumFavs = TL_DB_GetNumTimesANoteHasBeenFav (Not); Not->NumFavs = TL_DB_GetNumTimesHasBeenFav (TL_Fav_NOTE,
Not->NotCod,Not->UsrCod);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -134,11 +134,11 @@ static void TL_Sha_ShaNote (struct TL_Not_Note *Not)
Pub.PubType = TL_Pub_SHARED_NOTE; Pub.PubType = TL_Pub_SHARED_NOTE;
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_GetNumTimesANoteHasBeenShared (Not);
/**** Create notification about shared post /***** Create notification about shared post
for the author of the post ***/ for the author of the post *****/
OriginalPubCod = TL_DB_GetPubCodOfOriginalNote (Not->NotCod); OriginalPubCod = TL_DB_GetPubCodOfOriginalNote (Not->NotCod);
if (OriginalPubCod > 0) if (OriginalPubCod > 0)
TL_Ntf_CreateNotifToAuthor (Not->UsrCod,OriginalPubCod, TL_Ntf_CreateNotifToAuthor (Not->UsrCod,OriginalPubCod,
@ -284,17 +284,10 @@ static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Not_Note *Not,
/***** Get users who have shared this note *****/ /***** Get users who have shared this note *****/
if (Not->NumShared) if (Not->NumShared)
NumFirstUsrs = NumFirstUsrs =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get users", TL_DB_GetListUsrsHaveShared (Not->NotCod,Not->UsrCod,
"SELECT PublisherCod FROM tl_pubs" HowManyUsrs == TL_Usr_SHOW_FEW_USRS ? TL_Usr_DEF_USRS_SHOWN :
" WHERE NotCod=%ld" TL_Usr_MAX_USRS_SHOWN,
" AND PublisherCod<>%ld" &mysql_res);
" AND PubType=%u"
" ORDER BY PubCod LIMIT %u",
Not->NotCod,
Not->UsrCod,
(unsigned) TL_Pub_SHARED_NOTE,
HowManyUsrs == TL_Usr_SHOW_FEW_USRS ? TL_Usr_DEF_USRS_SHOWN :
TL_Usr_MAX_USRS_SHOWN);
else else
NumFirstUsrs = 0; NumFirstUsrs = 0;