Version 15.129

This commit is contained in:
Antonio Cañas Vargas 2016-01-25 20:28:33 +01:00
parent 0c115d88ec
commit 12d47161e3
4 changed files with 91 additions and 61 deletions

View File

@ -117,17 +117,21 @@
// TODO: Go to forum post (or at least to forum thread) from social timeline and notifications? // TODO: Go to forum post (or at least to forum thread) from social timeline and notifications?
// TODO: Width of column for data in notifications is too short // TODO: Width of column for data in notifications is too short
// TODO: Remove timeline notifications when clicking on "Show new activity" or "Show more"
// TODO: Do not show top message for original publishings
/*****************************************************************************/ /*****************************************************************************/
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.128.5 (2016-01-25)" #define Log_PLATFORM_VERSION "SWAD 15.129 (2016-01-25)"
#define CSS_FILE "swad15.121.7.css" #define CSS_FILE "swad15.121.7.css"
#define JS_FILE "swad15.121.7.js" #define JS_FILE "swad15.121.7.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/* /*
Version 15.129: Jan 25, 2016 Do not notify new social sharings or comments. (194979 lines)
Version 15.128.5: Jan 25, 2016 Fixed bug and code optimization when sharing a social note. (194958 lines) Version 15.128.5: Jan 25, 2016 Fixed bug and code optimization when sharing a social note. (194958 lines)
Version 15.128.4: Jan 25, 2016 Fixed bug when removing a social note. (194961 lines) Version 15.128.4: Jan 25, 2016 Fixed bug when removing a social note. (194961 lines)
Version 15.128.3: Jan 25, 2016 Optimization in top message of social note. (194969 lines) Version 15.128.3: Jan 25, 2016 Optimization in top message of social note. (194969 lines)

View File

@ -1235,7 +1235,7 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
Gbl.CurrentDeg.Deg.DegCod, Gbl.CurrentDeg.Deg.DegCod,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod);
break; break;
case Ntf_EVENT_TIMELINE_PUBLISH: // New social publishing from one of the users I follow case Ntf_EVENT_TIMELINE_PUBLISH: // New social publishing (original, no comment or sharing) from one of the users I follow
// Cod is the code of the social publishing (not used in the following query) // Cod is the code of the social publishing (not used in the following query)
// Get all my followers // Get all my followers
sprintf (Query,"SELECT FollowerCod FROM usr_follow" sprintf (Query,"SELECT FollowerCod FROM usr_follow"

View File

@ -64,16 +64,16 @@ typedef enum
Ntf_EVENT_TIMELINE_FAV = 11, // New fav of one of my social publishings (notes or comments) Ntf_EVENT_TIMELINE_FAV = 11, // New fav of one of my social publishings (notes or comments)
Ntf_EVENT_TIMELINE_SHARE = 12, // New sharing of one of my social notes Ntf_EVENT_TIMELINE_SHARE = 12, // New sharing of one of my social notes
Ntf_EVENT_TIMELINE_MENTION = 13, // New mention (reserved for future use) Ntf_EVENT_TIMELINE_MENTION = 13, // New mention (reserved for future use)
Ntf_EVENT_FOLLOWER = 14, // Old 14 Ntf_EVENT_FOLLOWER = 14,
Ntf_EVENT_FORUM_POST_COURSE = 15, // Old 10 // New post in forums of my courses Ntf_EVENT_FORUM_POST_COURSE = 15, // New post in forums of my courses
Ntf_EVENT_FORUM_REPLY = 16, // Old 11 // New reply to one of my posts in any forum Ntf_EVENT_FORUM_REPLY = 16, // New reply to one of my posts in any forum
/* Messages tab */ /* Messages tab */
Ntf_EVENT_NOTICE = 17, // Old 9 Ntf_EVENT_NOTICE = 17,
Ntf_EVENT_MESSAGE = 18, // Old 12 Ntf_EVENT_MESSAGE = 18,
/* Statistics tab */ /* Statistics tab */
Ntf_EVENT_SURVEY = 19, // Old 13 Ntf_EVENT_SURVEY = 19,
/* Profile tab */ /* Profile tab */

View File

@ -209,6 +209,8 @@ static long Soc_UnfavSocialComment (void);
static void Soc_RequestRemovalSocialNote (void); static void Soc_RequestRemovalSocialNote (void);
static void Soc_RemoveSocialNote (void); static void Soc_RemoveSocialNote (void);
static void Soc_RemoveASocialNoteFromDB (struct SocialNote *SocNot); static void Soc_RemoveASocialNoteFromDB (struct SocialNote *SocNot);
static long Soc_GetNotCodOfSocialPublishing (long PubCod);
static long Soc_GetPubCodOfOriginalSocialNote (long NotCod); static long Soc_GetPubCodOfOriginalSocialNote (long NotCod);
static void Soc_RequestRemovalSocialComment (void); static void Soc_RequestRemovalSocialComment (void);
@ -253,9 +255,6 @@ static void Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (long PubCod,const
void Soc_ShowTimelineGbl (void) void Soc_ShowTimelineGbl (void)
{ {
char Query[128];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long PubCod; long PubCod;
struct SocialNote SocNot; struct SocialNote SocNot;
struct UsrData UsrDat; struct UsrData UsrDat;
@ -306,20 +305,8 @@ void Soc_ShowTimelineGbl (void)
// If > 0 ==> the social note is shown highlighted above the timeline // If > 0 ==> the social note is shown highlighted above the timeline
PubCod = Soc_GetParamPubCod (); PubCod = Soc_GetParamPubCod ();
if (PubCod > 0) if (PubCod > 0)
{
/***** Get code of social note from database *****/ /***** Get code of social note from database *****/
sprintf (Query,"SELECT NotCod FROM social_pubs WHERE PubCod='%ld'", SocNot.NotCod = Soc_GetNotCodOfSocialPublishing (PubCod);
PubCod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get code of social note") == 1) // Result should have a unique row
{
/* Get code of social note */
row = mysql_fetch_row (mysql_res);
SocNot.NotCod = Str_ConvertStrCodToLongCod (row[0]);
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
if (SocNot.NotCod > 0) if (SocNot.NotCod > 0)
{ {
@ -2770,9 +2757,6 @@ static long Soc_ReceiveComment (void)
Content); Content);
DB_QueryINSERT (Query,"can not store comment content"); DB_QueryINSERT (Query,"can not store comment content");
/***** Store notifications about the new publishing *****/
Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_TIMELINE_PUBLISH,SocPub.PubCod);
/***** Store notifications about the new comment *****/ /***** Store notifications about the new comment *****/
Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_TIMELINE_COMMENT,SocPub.PubCod); Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_TIMELINE_COMMENT,SocPub.PubCod);
@ -2834,7 +2818,7 @@ static long Soc_ShareSocialNote (void)
extern const char *Txt_The_original_post_no_longer_exists; extern const char *Txt_The_original_post_no_longer_exists;
struct SocialNote SocNot; struct SocialNote SocNot;
struct SocialPublishing SocPub; struct SocialPublishing SocPub;
long PubCod; long OriginalPubCod;
/***** Get data of social note *****/ /***** Get data of social note *****/
SocNot.NotCod = Soc_GetParamNotCod (); SocNot.NotCod = Soc_GetParamNotCod ();
@ -2856,14 +2840,15 @@ static long Soc_ShareSocialNote (void)
/* Update number of times this social note is shared */ /* Update number of times this social note is shared */
SocNot.NumShared = Soc_UpdateNumTimesANoteHasBeenShared (&SocNot); SocNot.NumShared = Soc_UpdateNumTimesANoteHasBeenShared (&SocNot);
/***** Store notifications about the new publishing *****/
Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_TIMELINE_PUBLISH,SocPub.PubCod);
/**** Create notification about shared post /**** Create notification about shared post
for the author of the post ***/ for the author of the post ***/
PubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot.NotCod); OriginalPubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot.NotCod);
if (PubCod > 0)
Soc_CreateNotifToAuthor (SocNot.UsrCod,PubCod,Ntf_EVENT_TIMELINE_SHARE); sprintf (Gbl.Message,"OriginalPubCod = %ld",OriginalPubCod);
Lay_ShowAlert (Lay_INFO,Gbl.Message);
if (OriginalPubCod > 0)
Soc_CreateNotifToAuthor (SocNot.UsrCod,OriginalPubCod,Ntf_EVENT_TIMELINE_SHARE);
} }
} }
else else
@ -2915,7 +2900,7 @@ static long Soc_FavSocialNote (void)
extern const char *Txt_The_original_post_no_longer_exists; extern const char *Txt_The_original_post_no_longer_exists;
char Query[256]; char Query[256];
struct SocialNote SocNot; struct SocialNote SocNot;
long PubCod; long OriginalPubCod;
/***** Get data of social note *****/ /***** Get data of social note *****/
SocNot.NotCod = Soc_GetParamNotCod (); SocNot.NotCod = Soc_GetParamNotCod ();
@ -2940,9 +2925,9 @@ static long Soc_FavSocialNote (void)
/**** Create notification about favourite post /**** Create notification about favourite post
for the author of the post ***/ for the author of the post ***/
PubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot.NotCod); OriginalPubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot.NotCod);
if (PubCod > 0) if (OriginalPubCod > 0)
Soc_CreateNotifToAuthor (SocNot.UsrCod,PubCod,Ntf_EVENT_TIMELINE_FAV); Soc_CreateNotifToAuthor (SocNot.UsrCod,OriginalPubCod,Ntf_EVENT_TIMELINE_FAV);
/***** Show the social note just favourited *****/ /***** Show the social note just favourited *****/
Soc_WriteSocialNote (&SocNot, Soc_WriteSocialNote (&SocNot,
@ -3115,7 +3100,7 @@ static long Soc_UnshareSocialNote (void)
extern const char *Txt_The_original_post_no_longer_exists; extern const char *Txt_The_original_post_no_longer_exists;
char Query[256]; char Query[256];
struct SocialNote SocNot; struct SocialNote SocNot;
long PubCod; long OriginalPubCod;
/***** Get data of social note *****/ /***** Get data of social note *****/
SocNot.NotCod = Soc_GetParamNotCod (); SocNot.NotCod = Soc_GetParamNotCod ();
@ -3143,9 +3128,9 @@ static long Soc_UnshareSocialNote (void)
SocNot.NumShared = Soc_UpdateNumTimesANoteHasBeenShared (&SocNot); SocNot.NumShared = Soc_UpdateNumTimesANoteHasBeenShared (&SocNot);
/***** Mark possible notifications on this social note as removed *****/ /***** Mark possible notifications on this social note as removed *****/
PubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot.NotCod); OriginalPubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot.NotCod);
if (PubCod > 0) if (OriginalPubCod > 0)
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE,PubCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE,OriginalPubCod);
/***** Show the social note corresponding /***** Show the social note corresponding
to the publishing just unshared *****/ to the publishing just unshared *****/
@ -3203,7 +3188,7 @@ static long Soc_UnfavSocialNote (void)
extern const char *Txt_The_original_post_no_longer_exists; extern const char *Txt_The_original_post_no_longer_exists;
struct SocialNote SocNot; struct SocialNote SocNot;
char Query[256]; char Query[256];
long PubCod; long OriginalPubCod;
/***** Get data of social note *****/ /***** Get data of social note *****/
SocNot.NotCod = Soc_GetParamNotCod (); SocNot.NotCod = Soc_GetParamNotCod ();
@ -3228,9 +3213,9 @@ static long Soc_UnfavSocialNote (void)
SocNot.NumFavs = Soc_GetNumTimesANoteHasBeenFav (&SocNot); SocNot.NumFavs = Soc_GetNumTimesANoteHasBeenFav (&SocNot);
/***** Mark possible notifications on this social note as removed *****/ /***** Mark possible notifications on this social note as removed *****/
PubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot.NotCod); OriginalPubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot.NotCod);
if (PubCod > 0) if (OriginalPubCod > 0)
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV,PubCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV,OriginalPubCod);
/***** Show the social note just unfavourited *****/ /***** Show the social note just unfavourited *****/
Soc_WriteSocialNote (&SocNot, Soc_WriteSocialNote (&SocNot,
@ -3474,20 +3459,32 @@ static void Soc_RemoveASocialNoteFromDB (struct SocialNote *SocNot)
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
long PubCod; long PubCod;
unsigned long NumPublishings; unsigned long NumComments;
unsigned long NumPub; unsigned long NumCom;
/***** Mark possible notifications on the publishings /***** Mark possible notifications on the publishings
of this social note as removed *****/ of this social note as removed *****/
/* Get publishings (original, shared or comments) of this social note */ /* Mark notifications of the original social note as removed */
sprintf (Query,"SELECT PubCod FROM social_pubs WHERE NotCod='%ld'", PubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot->NotCod);
SocNot->NotCod); if (PubCod > 0)
NumPublishings = DB_QuerySELECT (Query,&mysql_res,"can not get social comments"); {
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_PUBLISH,PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_COMMENT,PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE ,PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,PubCod);
}
/* For each publishing... */ /* Get comments of this social note */
for (NumPub = 0; sprintf (Query,"SELECT PubCod FROM social_pubs"
NumPub < NumPublishings; " WHERE NotCod='%ld' AND PubType ='%u'",
NumPub++) SocNot->NotCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE);
NumComments = DB_QuerySELECT (Query,&mysql_res,"can not get social comments");
/* For each comment... */
for (NumCom = 0;
NumCom < NumComments;
NumCom++)
{ {
/* Get code of social comment **/ /* Get code of social comment **/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
@ -3496,10 +3493,8 @@ static void Soc_RemoveASocialNoteFromDB (struct SocialNote *SocNot)
/* Mark notifications as removed */ /* Mark notifications as removed */
if (PubCod > 0) if (PubCod > 0)
{ {
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_PUBLISH,PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_COMMENT,PubCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_COMMENT,PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,PubCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE ,PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,PubCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,PubCod);
} }
} }
@ -3557,6 +3552,33 @@ static void Soc_RemoveASocialNoteFromDB (struct SocialNote *SocNot)
Soc_ResetSocialNote (SocNot); Soc_ResetSocialNote (SocNot);
} }
/*****************************************************************************/
/******************* Get code of social note of a publishing *****************/
/*****************************************************************************/
static long Soc_GetNotCodOfSocialPublishing (long PubCod)
{
char Query[128];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long NotCod = -1L;
/***** Get code of social note from database *****/
sprintf (Query,"SELECT NotCod FROM social_pubs WHERE PubCod='%ld'",
PubCod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get code of social note") == 1) // Result should have a unique row
{
/* Get code of social note */
row = mysql_fetch_row (mysql_res);
NotCod = Str_ConvertStrCodToLongCod (row[0]);
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return NotCod;
}
/*****************************************************************************/ /*****************************************************************************/
/************ Get code of social publishing of the original note *************/ /************ Get code of social publishing of the original note *************/
/*****************************************************************************/ /*****************************************************************************/
@ -3566,6 +3588,7 @@ static long Soc_GetPubCodOfOriginalSocialNote (long NotCod)
char Query[256]; char Query[256];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
long OriginalPubCod = -1L;
/***** Get code of social publishing of the original note *****/ /***** Get code of social publishing of the original note *****/
sprintf (Query,"SELECT PubCod FROM social_pubs" sprintf (Query,"SELECT PubCod FROM social_pubs"
@ -3575,9 +3598,13 @@ static long Soc_GetPubCodOfOriginalSocialNote (long NotCod)
{ {
/* Get code of social publishing (row[0]) */ /* Get code of social publishing (row[0]) */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
return Str_ConvertStrCodToLongCod (row[0]); OriginalPubCod = Str_ConvertStrCodToLongCod (row[0]);
} }
return -1L;
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return OriginalPubCod;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -3728,7 +3755,6 @@ static void Soc_RemoveASocialCommentFromDB (struct SocialComment *SocCom)
char Query[128]; char Query[128];
/***** Mark possible notifications on this comment as removed *****/ /***** Mark possible notifications on this comment as removed *****/
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_PUBLISH,SocCom->PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_COMMENT,SocCom->PubCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_COMMENT,SocCom->PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,SocCom->PubCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,SocCom->PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,SocCom->PubCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,SocCom->PubCod);