mirror of https://github.com/acanas/swad-core.git
Version 20.36.13: Feb 27, 2021 Functions moved to module swad_timeline_database.
This commit is contained in:
parent
ad76b62131
commit
d5428a11c9
|
@ -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.12 (2021-02-07)"
|
#define Log_PLATFORM_VERSION "SWAD 20.36.13 (2021-02-27)"
|
||||||
#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.13: Feb 27, 2021 Functions moved to module swad_timeline_database. (305285 lines)
|
||||||
Version 20.36.12: Feb 27, 2021 Queries moved to module swad_timeline_database. (305282 lines)
|
Version 20.36.12: Feb 27, 2021 Queries moved to module swad_timeline_database. (305282 lines)
|
||||||
Version 20.36.11: Feb 27, 2021 Query moved to module swad_timeline_database. (305246 lines)
|
Version 20.36.11: Feb 27, 2021 Query moved to module swad_timeline_database. (305246 lines)
|
||||||
Version 20.36.10: Feb 27, 2021 Query moved to module swad_timeline_database. (305243 lines)
|
Version 20.36.10: Feb 27, 2021 Query moved to module swad_timeline_database. (305243 lines)
|
||||||
|
|
|
@ -130,6 +130,64 @@ void TL_DB_InsertNoteInVisibleTimeline (long NotCod)
|
||||||
NotCod);
|
NotCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/****** Add just retrieved notes to current timeline for this session ********/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void TL_DB_AddNotesJustRetrievedToVisibleTimelineOfSession (char SessionId[Cns_BYTES_SESSION_ID + 1])
|
||||||
|
{
|
||||||
|
/* tl_timelines contains the distinct notes in timeline of each open session:
|
||||||
|
mysql> SELECT SessionId,COUNT(*) FROM tl_timelines GROUP BY SessionId;
|
||||||
|
+---------------------------------------------+----------+
|
||||||
|
| SessionId | COUNT(*) |
|
||||||
|
+---------------------------------------------+----------+
|
||||||
|
| u-X-R3gKki7eKMXrNCP8bGhwOAZuVngRy7FNGZFMKzI | 52 | --> 52 distinct notes
|
||||||
|
| u1CoqL1YWl3_hR4wk4bI7vhnc-uRcCmIDyKYAgBB6kk | 10 |
|
||||||
|
| u8xqamzkorHfY4BvYRMXjNhzHvQyigZUZemO0YiMn48 | 10 |
|
||||||
|
| u_n2V_L3KrFjnd4SqZk0gxMFwZHRuWZ8_EIVTU9sdpI | 10 |
|
||||||
|
| V6pGe1kGGS_uO5i__waqXKnuDkPYaDZHNAYr-Zv-GJQ | 2 |
|
||||||
|
| vqDRz-iiM8v10Dl8ThwqIqmDRIklz8szJaqflwXZucs | 10 |
|
||||||
|
| w11juqKPx6lg-f_pL2ZBYqlagU1mEepSvvk9L3gDGac | 10 | --> 10 distinct notes
|
||||||
|
| wLg4e8KQljCcVuFWIkJjNeti89kAiwOZ3iyXdzm_eDk | 10 |
|
||||||
|
| wnU85YrwJHhZGWIZhd7LQfQTPrclIWHfMF3DcB-Rcgw | 4 |
|
||||||
|
| wRzRJFnHfzW61fZYnvMIaMRlkuWUeEyqXVQ6JeWA32k | 11 |
|
||||||
|
+---------------------------------------------+----------+
|
||||||
|
10 rows in set (0,01 sec)
|
||||||
|
*/
|
||||||
|
DB_QueryINSERT ("can not insert notes in timeline",
|
||||||
|
"INSERT IGNORE INTO tl_timelines"
|
||||||
|
" (SessionId,NotCod)"
|
||||||
|
" SELECT '%s',NotCod FROM tl_tmp_just_retrieved_notes",
|
||||||
|
SessionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*************** Get code of publication of the original note ****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
long TL_DB_GetPubCodOfOriginalNote (long NotCod)
|
||||||
|
{
|
||||||
|
MYSQL_RES *mysql_res;
|
||||||
|
MYSQL_ROW row;
|
||||||
|
long OriginalPubCod = -1L; // Default value
|
||||||
|
|
||||||
|
/***** Get code of publication of the original note *****/
|
||||||
|
if (DB_QuerySELECT (&mysql_res,"can not get code of publication",
|
||||||
|
"SELECT PubCod FROM tl_pubs"
|
||||||
|
" WHERE NotCod=%ld AND PubType=%u",
|
||||||
|
NotCod,(unsigned) TL_Pub_ORIGINAL_NOTE) == 1) // Result should have a unique row
|
||||||
|
{
|
||||||
|
/* Get code of publication (row[0]) */
|
||||||
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
OriginalPubCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Free structure that stores the query result *****/
|
||||||
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
|
return OriginalPubCod;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*************************** Remove favs for a note **************************/
|
/*************************** Remove favs for a note **************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -54,6 +54,8 @@ void TL_DB_MarkNotesChildrenOfFolderAsUnavailable (TL_Not_NoteType_t NoteType,
|
||||||
const char *Path);
|
const char *Path);
|
||||||
void TL_DB_InsertNoteInJustRetrievedNotes (long NotCod);
|
void TL_DB_InsertNoteInJustRetrievedNotes (long NotCod);
|
||||||
void TL_DB_InsertNoteInVisibleTimeline (long NotCod);
|
void TL_DB_InsertNoteInVisibleTimeline (long NotCod);
|
||||||
|
void TL_DB_AddNotesJustRetrievedToVisibleTimelineOfSession (char SessionId[Cns_BYTES_SESSION_ID + 1]);
|
||||||
|
long TL_DB_GetPubCodOfOriginalNote (long NotCod);
|
||||||
void TL_DB_RemoveNoteFavs (long NotCod);
|
void TL_DB_RemoveNoteFavs (long NotCod);
|
||||||
void TL_DB_RemoveNotePubs (long NotCod);
|
void TL_DB_RemoveNotePubs (long NotCod);
|
||||||
void TL_DB_RemoveNote (long NotCod,long PublisherCod);
|
void TL_DB_RemoveNote (long NotCod,long PublisherCod);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "swad_database.h"
|
#include "swad_database.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_favourite.h"
|
||||||
#include "swad_timeline_form.h"
|
#include "swad_timeline_form.h"
|
||||||
#include "swad_timeline_notification.h"
|
#include "swad_timeline_notification.h"
|
||||||
|
@ -187,7 +188,7 @@ static void TL_Fav_FavNote (struct TL_Not_Note *Not)
|
||||||
|
|
||||||
/***** Create notification about favourite post
|
/***** Create notification about favourite post
|
||||||
for the author of the post *****/
|
for the author of the post *****/
|
||||||
OriginalPubCod = TL_Not_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,
|
||||||
Ntf_EVENT_TIMELINE_FAV);
|
Ntf_EVENT_TIMELINE_FAV);
|
||||||
|
@ -221,7 +222,7 @@ static void TL_Fav_UnfNote (struct TL_Not_Note *Not)
|
||||||
TL_Fav_GetNumTimesANoteHasBeenFav (Not);
|
TL_Fav_GetNumTimesANoteHasBeenFav (Not);
|
||||||
|
|
||||||
/***** Mark possible notifications on this note as removed *****/
|
/***** Mark possible notifications on this note as removed *****/
|
||||||
OriginalPubCod = TL_Not_GetPubCodOfOriginalNote (Not->NotCod);
|
OriginalPubCod = TL_DB_GetPubCodOfOriginalNote (Not->NotCod);
|
||||||
if (OriginalPubCod > 0)
|
if (OriginalPubCod > 0)
|
||||||
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV,OriginalPubCod);
|
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV,OriginalPubCod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1233,7 +1233,7 @@ static void TL_Not_RemoveNoteMediaAndDBEntries (struct TL_Not_Note *Not)
|
||||||
|
|
||||||
/***** Mark possible notifications on the publications
|
/***** Mark possible notifications on the publications
|
||||||
of this note as removed *****/
|
of this note as removed *****/
|
||||||
PubCod = TL_Not_GetPubCodOfOriginalNote (Not->NotCod);
|
PubCod = TL_DB_GetPubCodOfOriginalNote (Not->NotCod);
|
||||||
if (PubCod > 0)
|
if (PubCod > 0)
|
||||||
{
|
{
|
||||||
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,PubCod);
|
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,PubCod);
|
||||||
|
@ -1329,64 +1329,6 @@ static void TL_Not_ResetNote (struct TL_Not_Note *Not)
|
||||||
Not->NumShared = 0;
|
Not->NumShared = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*************** Get code of publication of the original note ****************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
long TL_Not_GetPubCodOfOriginalNote (long NotCod)
|
|
||||||
{
|
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
long OriginalPubCod = -1L;
|
|
||||||
|
|
||||||
/***** Get code of publication of the original note *****/
|
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get code of publication",
|
|
||||||
"SELECT PubCod FROM tl_pubs"
|
|
||||||
" WHERE NotCod=%ld AND PubType=%u",
|
|
||||||
NotCod,(unsigned) TL_Pub_ORIGINAL_NOTE) == 1) // Result should have a unique row
|
|
||||||
{
|
|
||||||
/* Get code of publication (row[0]) */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
OriginalPubCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return OriginalPubCod;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/****** Add just retrieved notes to current timeline for this session ********/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
void TL_Not_AddNotesJustRetrievedToVisibleTimelineThisSession (void)
|
|
||||||
{
|
|
||||||
/* tl_timelines contains the distinct notes in timeline of each open session:
|
|
||||||
mysql> SELECT SessionId,COUNT(*) FROM tl_timelines GROUP BY SessionId;
|
|
||||||
+---------------------------------------------+----------+
|
|
||||||
| SessionId | COUNT(*) |
|
|
||||||
+---------------------------------------------+----------+
|
|
||||||
| u-X-R3gKki7eKMXrNCP8bGhwOAZuVngRy7FNGZFMKzI | 52 | --> 52 distinct notes
|
|
||||||
| u1CoqL1YWl3_hR4wk4bI7vhnc-uRcCmIDyKYAgBB6kk | 10 |
|
|
||||||
| u8xqamzkorHfY4BvYRMXjNhzHvQyigZUZemO0YiMn48 | 10 |
|
|
||||||
| u_n2V_L3KrFjnd4SqZk0gxMFwZHRuWZ8_EIVTU9sdpI | 10 |
|
|
||||||
| V6pGe1kGGS_uO5i__waqXKnuDkPYaDZHNAYr-Zv-GJQ | 2 |
|
|
||||||
| vqDRz-iiM8v10Dl8ThwqIqmDRIklz8szJaqflwXZucs | 10 |
|
|
||||||
| w11juqKPx6lg-f_pL2ZBYqlagU1mEepSvvk9L3gDGac | 10 | --> 10 distinct notes
|
|
||||||
| wLg4e8KQljCcVuFWIkJjNeti89kAiwOZ3iyXdzm_eDk | 10 |
|
|
||||||
| wnU85YrwJHhZGWIZhd7LQfQTPrclIWHfMF3DcB-Rcgw | 4 |
|
|
||||||
| wRzRJFnHfzW61fZYnvMIaMRlkuWUeEyqXVQ6JeWA32k | 11 |
|
|
||||||
+---------------------------------------------+----------+
|
|
||||||
10 rows in set (0,01 sec)
|
|
||||||
*/
|
|
||||||
DB_QueryINSERT ("can not insert notes in timeline",
|
|
||||||
"INSERT IGNORE INTO tl_timelines"
|
|
||||||
" (SessionId,NotCod)"
|
|
||||||
" SELECT '%s',NotCod FROM tl_tmp_just_retrieved_notes",
|
|
||||||
Gbl.Session.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************** Get data of note using its code ************************/
|
/******************** Get data of note using its code ************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -110,10 +110,6 @@ void TL_Not_RequestRemNoteGbl (void);
|
||||||
void TL_Not_RemoveNoteUsr (void);
|
void TL_Not_RemoveNoteUsr (void);
|
||||||
void TL_Not_RemoveNoteGbl (void);
|
void TL_Not_RemoveNoteGbl (void);
|
||||||
|
|
||||||
long TL_Not_GetPubCodOfOriginalNote (long NotCod);
|
|
||||||
|
|
||||||
void TL_Not_AddNotesJustRetrievedToVisibleTimelineThisSession (void);
|
|
||||||
|
|
||||||
void TL_Not_GetDataOfNoteByCod (struct TL_Not_Note *Not);
|
void TL_Not_GetDataOfNoteByCod (struct TL_Not_Note *Not);
|
||||||
|
|
||||||
void TL_Not_ClearOldTimelinesNotesFromDB (void);
|
void TL_Not_ClearOldTimelinesNotesFromDB (void);
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
#include "swad_profile.h"
|
#include "swad_profile.h"
|
||||||
#include "swad_timeline.h"
|
#include "swad_timeline.h"
|
||||||
|
#include "swad_timeline_database.h"
|
||||||
#include "swad_timeline_favourite.h"
|
#include "swad_timeline_favourite.h"
|
||||||
#include "swad_timeline_note.h"
|
#include "swad_timeline_note.h"
|
||||||
#include "swad_timeline_publication.h"
|
#include "swad_timeline_publication.h"
|
||||||
|
@ -236,7 +237,7 @@ void TL_Pub_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline)
|
||||||
TL_Pub_UpdateFirstLastPubCodesIntoSession (Timeline);
|
TL_Pub_UpdateFirstLastPubCodesIntoSession (Timeline);
|
||||||
|
|
||||||
/***** Add notes just retrieved to visible timeline for this session *****/
|
/***** Add notes just retrieved to visible timeline for this session *****/
|
||||||
TL_Not_AddNotesJustRetrievedToVisibleTimelineThisSession ();
|
TL_DB_AddNotesJustRetrievedToVisibleTimelineOfSession (Gbl.Session.Id);
|
||||||
|
|
||||||
/***** Drop temporary tables *****/
|
/***** Drop temporary tables *****/
|
||||||
TL_Pub_DropTemporaryTables (Timeline);
|
TL_Pub_DropTemporaryTables (Timeline);
|
||||||
|
|
|
@ -140,7 +140,7 @@ static void TL_Sha_ShaNote (struct TL_Not_Note *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_Not_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,
|
||||||
Ntf_EVENT_TIMELINE_SHARE);
|
Ntf_EVENT_TIMELINE_SHARE);
|
||||||
|
@ -200,7 +200,7 @@ static void TL_Sha_UnsNote (struct TL_Not_Note *Not)
|
||||||
TL_Sha_UpdateNumTimesANoteHasBeenShared (Not);
|
TL_Sha_UpdateNumTimesANoteHasBeenShared (Not);
|
||||||
|
|
||||||
/***** Mark possible notifications on this note as removed *****/
|
/***** Mark possible notifications on this note as removed *****/
|
||||||
OriginalPubCod = TL_Not_GetPubCodOfOriginalNote (Not->NotCod);
|
OriginalPubCod = TL_DB_GetPubCodOfOriginalNote (Not->NotCod);
|
||||||
if (OriginalPubCod > 0)
|
if (OriginalPubCod > 0)
|
||||||
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE,OriginalPubCod);
|
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE,OriginalPubCod);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue