From 5772c77ddf1ea6302354ed8d524a5e8d3005e1b2 Mon Sep 17 00:00:00 2001 From: acanas Date: Thu, 11 Feb 2021 17:45:16 +0100 Subject: [PATCH] Version20.29 --- Makefile | 8 +- swad_changelog.h | 3 +- swad_notification.c | 1 + swad_timeline.c | 14 +-- swad_timeline.h | 2 - swad_timeline_favourite.c | 1 + swad_timeline_publication.c | 176 +----------------------------------- swad_timeline_publication.h | 8 +- swad_timeline_share.c | 1 + 9 files changed, 15 insertions(+), 199 deletions(-) diff --git a/Makefile b/Makefile index 9dba6773..b39c0ae7 100644 --- a/Makefile +++ b/Makefile @@ -61,10 +61,12 @@ OBJS = swad_account.o swad_action.o swad_agenda.o swad_alert.o \ swad_system_config.o \ swad_tab.o swad_tag.o swad_test.o swad_test_config.o \ swad_test_import.o swad_test_print.o swad_test_visibility.o \ - swad_theme.o swad_timeline.o swad_timeline_comment.o \ - swad_timeline_favourite.o swad_timeline_note.o swad_timeline_post.o \ + swad_theme.o \ + swad_timeline.o swad_timeline_comment.o swad_timeline_favourite.o \ + swad_timeline_note.o swad_timeline_notification.o swad_timeline_post.o \ swad_timeline_publication.o swad_timeline_share.o swad_timeline_user.o \ - swad_timeline_who.o swad_timetable.o \ + swad_timeline_who.o \ + swad_timetable.o \ swad_user.o \ swad_xml.o \ swad_zip.o diff --git a/swad_changelog.h b/swad_changelog.h index 58224a73..ba17d149 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -553,7 +553,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 20.28 (2021-02-11)" +#define Log_PLATFORM_VERSION "SWAD 20.29 (2021-02-11)" #define CSS_FILE "swad20.8.css" #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: Salvador Romero Cortés: @acanas opción para editar posts + Version 20.29: Feb 11, 2021 New module swad_timeline_notification. (305767 lines) Version 20.28: Feb 11, 2021 New module swad_timeline_user. (305675 lines) Version 20.27: Feb 11, 2021 New module swad_timeline_post. (305593 lines) Version 20.26.1: Feb 11, 2021 Code refactoring in timeline. (305504 lines) diff --git a/swad_notification.c b/swad_notification.c index 387f92df..ed001f28 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -51,6 +51,7 @@ #include "swad_parameter.h" #include "swad_survey.h" #include "swad_timeline.h" +#include "swad_timeline_notification.h" #include "swad_timeline_publication.h" /*****************************************************************************/ diff --git a/swad_timeline.c b/swad_timeline.c index aecc86a8..96729782 100644 --- a/swad_timeline.c +++ b/swad_timeline.c @@ -137,6 +137,7 @@ mysql> SHOW TABLES LIKE 'tl_%'; #include "swad_timeline.h" #include "swad_timeline_favourite.h" #include "swad_timeline_note.h" +#include "swad_timeline_notification.h" #include "swad_timeline_publication.h" #include "swad_timeline_share.h" #include "swad_timeline_who.h" @@ -385,19 +386,6 @@ static void TL_GetAndShowOldTimeline (struct TL_Timeline *Timeline) TL_Pub_FreeListPubs (Timeline); } -/*****************************************************************************/ -/************ Mark all my notifications about timeline as seen ***************/ -/*****************************************************************************/ -// Must be executed as a priori function - -void TL_Ntf_MarkMyNotifAsSeen (void) - { - Ntf_MarkNotifAsSeen (Ntf_EVENT_TIMELINE_COMMENT,-1L,-1L,Gbl.Usrs.Me.UsrDat.UsrCod); - Ntf_MarkNotifAsSeen (Ntf_EVENT_TIMELINE_FAV ,-1L,-1L,Gbl.Usrs.Me.UsrDat.UsrCod); - Ntf_MarkNotifAsSeen (Ntf_EVENT_TIMELINE_SHARE ,-1L,-1L,Gbl.Usrs.Me.UsrDat.UsrCod); - Ntf_MarkNotifAsSeen (Ntf_EVENT_TIMELINE_MENTION,-1L,-1L,Gbl.Usrs.Me.UsrDat.UsrCod); - } - /*****************************************************************************/ /******************************* Show timeline *******************************/ /*****************************************************************************/ diff --git a/swad_timeline.h b/swad_timeline.h index dce1b2e9..229ab16a 100644 --- a/swad_timeline.h +++ b/swad_timeline.h @@ -125,8 +125,6 @@ void TL_RefreshNewTimelineGbl (void); void TL_RefreshOldTimelineGbl (void); void TL_RefreshOldTimelineUsr (void); -void TL_Ntf_MarkMyNotifAsSeen (void); - void TL_FormStart (const struct TL_Timeline *Timeline, Act_Action_t ActionGbl, Act_Action_t ActionUsr); diff --git a/swad_timeline_favourite.c b/swad_timeline_favourite.c index 56dcc44f..987bc405 100644 --- a/swad_timeline_favourite.c +++ b/swad_timeline_favourite.c @@ -29,6 +29,7 @@ #include "swad_global.h" #include "swad_timeline.h" #include "swad_timeline_favourite.h" +#include "swad_timeline_notification.h" #include "swad_timeline_publication.h" /*****************************************************************************/ diff --git a/swad_timeline_publication.c b/swad_timeline_publication.c index dfade573..ed8b5bb8 100644 --- a/swad_timeline_publication.c +++ b/swad_timeline_publication.c @@ -95,8 +95,6 @@ static void TL_Pub_UpdateFirstLastPubCodesIntoSession (const struct TL_Timeline static struct TL_Pub_Publication *TL_Pub_SelectTheMostRecentPub (const struct TL_Pub_SubQueries *SubQueries); -static void TL_Pub_GetDataOfPublicationFromNextRow (MYSQL_RES *mysql_res, - struct TL_Pub_Publication *Pub); static TL_Pub_PubType_t TL_Pub_GetPubTypeFromStr (const char *Str); /*****************************************************************************/ @@ -686,45 +684,6 @@ long TL_Pub_GetParamPubCod (void) return Par_GetParToLong ("PubCod"); } -/*****************************************************************************/ -/*********** Create a notification for the author of a post/comment **********/ -/*****************************************************************************/ - -void TL_Ntf_CreateNotifToAuthor (long AuthorCod,long PubCod, - Ntf_NotifyEvent_t NotifyEvent) - { - struct UsrData UsrDat; - bool CreateNotif; - bool NotifyByEmail; - - /***** Initialize structure with user's data *****/ - Usr_UsrDataConstructor (&UsrDat); - - UsrDat.UsrCod = AuthorCod; - if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) - { - /***** This fav must be notified by email? *****/ - CreateNotif = (UsrDat.NtfEvents.CreateNotif & (1 << NotifyEvent)); - NotifyByEmail = CreateNotif && - (UsrDat.NtfEvents.SendEmail & (1 << NotifyEvent)); - - /***** Create notification for the author of the post. - If this author wants to receive notifications by email, - activate the sending of a notification *****/ - if (CreateNotif) - Ntf_StoreNotifyEventToOneUser (NotifyEvent,&UsrDat,PubCod, - (Ntf_Status_t) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL : - 0), - Gbl.Hierarchy.Ins.InsCod, - Gbl.Hierarchy.Ctr.CtrCod, - Gbl.Hierarchy.Deg.DegCod, - Gbl.Hierarchy.Crs.CrsCod); - } - - /***** Free memory used for user's data *****/ - Usr_UsrDataDestructor (&UsrDat); - } - /*****************************************************************************/ /*********************** Get code of note of a publication *******************/ /*****************************************************************************/ @@ -756,8 +715,8 @@ long TL_Pub_GetNotCodFromPubCod (long PubCod) /***************** Get data of publication using its code ********************/ /*****************************************************************************/ -static void TL_Pub_GetDataOfPublicationFromNextRow (MYSQL_RES *mysql_res, - struct TL_Pub_Publication *Pub) +void TL_Pub_GetDataOfPublicationFromNextRow (MYSQL_RES *mysql_res, + struct TL_Pub_Publication *Pub) { static const TL_TopMessage_t TopMessages[TL_NUM_PUB_TYPES] = { @@ -806,137 +765,6 @@ static TL_Pub_PubType_t TL_Pub_GetPubTypeFromStr (const char *Str) return TL_PUB_UNKNOWN; } -/*****************************************************************************/ -/***************** Get notification of a new publication *********************/ -/*****************************************************************************/ - -void TL_Ntf_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], - char **ContentStr, - long PubCod,bool GetContent) - { - MYSQL_RES *mysql_res; - MYSQL_ROW row; - struct TL_Pub_Publication Pub; - struct TL_Not_Note Not; - struct TL_Pst_PostContent Content; - size_t Length; - bool ContentCopied = false; - - /***** Return nothing on error *****/ - Pub.PubType = TL_PUB_UNKNOWN; - SummaryStr[0] = '\0'; // Return nothing on error - Content.Txt[0] = '\0'; - - /***** Get summary and content from post from database *****/ - if (DB_QuerySELECT (&mysql_res,"can not get data of publication", - "SELECT PubCod," // row[0] - "NotCod," // row[1] - "PublisherCod," // row[2] - "PubType" // row[3] - " FROM tl_pubs WHERE PubCod=%ld", - PubCod) == 1) // Result should have a unique row - /* Get data of publication from row */ - TL_Pub_GetDataOfPublicationFromNextRow (mysql_res,&Pub); - - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); - - /***** Get summary and content *****/ - switch (Pub.PubType) - { - case TL_PUB_UNKNOWN: - break; - case TL_PUB_ORIGINAL_NOTE: - case TL_PUB_SHARED_NOTE: - /* Get data of note */ - Not.NotCod = Pub.NotCod; - TL_Not_GetDataOfNoteByCod (&Not); - - if (Not.NoteType == TL_NOTE_POST) - { - /***** Get content of post from database *****/ - if (DB_QuerySELECT (&mysql_res,"can not get the content of a post", - "SELECT Txt" // row[0] - " FROM tl_posts" - " WHERE PstCod=%ld", - Not.Cod) == 1) // Result should have a unique row - { - /***** Get row *****/ - row = mysql_fetch_row (mysql_res); - - /****** Get content (row[0]) *****/ - Str_Copy (Content.Txt,row[0], - Cns_MAX_BYTES_LONG_TEXT); - } - - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); - - /***** Copy content string *****/ - if (GetContent) - { - Length = strlen (Content.Txt); - if ((*ContentStr = (char *) malloc (Length + 1)) != NULL) - { - Str_Copy (*ContentStr,Content.Txt, - Length); - ContentCopied = true; - } - } - - /***** Copy summary string *****/ - Str_LimitLengthHTMLStr (Content.Txt,Ntf_MAX_CHARS_SUMMARY); - Str_Copy (SummaryStr,Content.Txt, - Ntf_MAX_BYTES_SUMMARY); - } - else - TL_Not_GetNoteSummary (&Not,SummaryStr); - break; - case TL_Pub_COMMENT_TO_NOTE: - /***** Get content of post from database *****/ - if (DB_QuerySELECT (&mysql_res,"can not get the content" - " of a comment to a note", - "SELECT Txt" // row[0] - " FROM tl_comments" - " WHERE PubCod=%ld", - Pub.PubCod) == 1) // Result should have a unique row - { - /***** Get row *****/ - row = mysql_fetch_row (mysql_res); - - /****** Get content (row[0]) *****/ - Str_Copy (Content.Txt,row[0], - Cns_MAX_BYTES_LONG_TEXT); - } - - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); - - /***** Copy content string *****/ - if (GetContent) - { - Length = strlen (Content.Txt); - if ((*ContentStr = (char *) malloc (Length + 1)) != NULL) - { - Str_Copy (*ContentStr,Content.Txt, - Length); - ContentCopied = true; - } - } - - /***** Copy summary string *****/ - Str_LimitLengthHTMLStr (Content.Txt,Ntf_MAX_CHARS_SUMMARY); - Str_Copy (SummaryStr,Content.Txt, - Ntf_MAX_BYTES_SUMMARY); - break; - } - - /***** Create empty content string if nothing copied *****/ - if (GetContent && !ContentCopied) - if ((*ContentStr = (char *) malloc (1)) != NULL) - (*ContentStr)[0] = '\0'; - } - /*****************************************************************************/ /********************* Publish note/comment in timeline **********************/ /*****************************************************************************/ diff --git a/swad_timeline_publication.h b/swad_timeline_publication.h index db4decaf..3551dcb4 100644 --- a/swad_timeline_publication.h +++ b/swad_timeline_publication.h @@ -82,14 +82,10 @@ void TL_Pub_PutLinkToViewOldPublications (void); void TL_Pub_PutHiddenParamPubCod (long PubCod); long TL_Pub_GetParamPubCod (void); -void TL_Ntf_CreateNotifToAuthor (long AuthorCod,long PubCod, - Ntf_NotifyEvent_t NotifyEvent); - long TL_Pub_GetNotCodFromPubCod (long PubCod); -void TL_Ntf_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], - char **ContentStr, - long PubCod,bool GetContent); +void TL_Pub_GetDataOfPublicationFromNextRow (MYSQL_RES *mysql_res, + struct TL_Pub_Publication *Pub); void TL_Pub_PublishPubInTimeline (struct TL_Pub_Publication *Pub); diff --git a/swad_timeline_share.c b/swad_timeline_share.c index 8ada278d..d2fc1908 100644 --- a/swad_timeline_share.c +++ b/swad_timeline_share.c @@ -28,6 +28,7 @@ #include "swad_database.h" #include "swad_global.h" #include "swad_timeline.h" +#include "swad_timeline_notification.h" #include "swad_timeline_publication.h" #include "swad_timeline_share.h"