Version20.29

This commit is contained in:
acanas 2021-02-11 17:45:16 +01:00
parent f9b172af63
commit 5772c77ddf
9 changed files with 15 additions and 199 deletions

View File

@ -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

View File

@ -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)

View File

@ -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"
/*****************************************************************************/

View File

@ -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 *******************************/
/*****************************************************************************/

View File

@ -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);

View File

@ -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"
/*****************************************************************************/

View File

@ -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 **********************/
/*****************************************************************************/

View File

@ -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);

View File

@ -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"