Version 15.124

This commit is contained in:
Antonio Cañas Vargas 2016-01-23 01:38:55 +01:00
parent a3379035aa
commit ce6a016418
8 changed files with 291 additions and 148 deletions

View File

@ -117,17 +117,22 @@
// 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: Change ComCod to PubCod in social_comments and social_comments_fav
// TODO: When receiving a new post, create first the publishing, then the post
// TODO: Change PstCod to PubCod in social_posts, removing AUTO_INCREMENT
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.123.7 (2016-01-22)"
#define Log_PLATFORM_VERSION "SWAD 15.124 (2016-01-23)"
#define CSS_FILE "swad15.121.7.css"
#define JS_FILE "swad15.121.7.js"
// 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
/*
Version 15.123: Jan 23, 2016 New social notifications. Not finished. (194466 lines)
Version 15.123.7: Jan 22, 2016 New social notifications. Not finished. (194347 lines)
Version 15.123.6: Jan 22, 2016 New social notifications. Not finished. (194342 lines)
Version 15.123.5: Jan 22, 2016 New social notifications. Not finished. (194328 lines)

View File

@ -415,7 +415,7 @@ void Fol_ListFollowers (void)
/***** If it's me, mark possible notification as seen *****/
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)
Ntf_MarkNotifAsSeen (Ntf_EVENT_FOLLOWER,
Ntf_MarkNotifAsSeen (Ntf_EVENT_SOCIAL_FOLLOWER,
-1L,-1L,
Gbl.Usrs.Me.UsrDat.UsrCod);
}
@ -539,14 +539,14 @@ void Fol_FollowUsr (void)
DB_QueryREPLACE (Query,"can not follow user");
/***** This follow must be notified by e-mail? *****/
CreateNotif = (Gbl.Usrs.Other.UsrDat.Prefs.NotifNtfEvents & (1 << Ntf_EVENT_FOLLOWER));
CreateNotif = (Gbl.Usrs.Other.UsrDat.Prefs.NotifNtfEvents & (1 << Ntf_EVENT_SOCIAL_FOLLOWER));
NotifyByEmail = CreateNotif &&
(Gbl.Usrs.Other.UsrDat.Prefs.EmailNtfEvents & (1 << Ntf_EVENT_FOLLOWER));
(Gbl.Usrs.Other.UsrDat.Prefs.EmailNtfEvents & (1 << Ntf_EVENT_SOCIAL_FOLLOWER));
/***** Create notification for this followed.
If this followed wants to receive notifications by e-mail, activate the sending of a notification *****/
if (CreateNotif)
Ntf_StoreNotifyEventToOneUser (Ntf_EVENT_FOLLOWER,&Gbl.Usrs.Other.UsrDat,Gbl.Usrs.Me.UsrDat.UsrCod,
Ntf_StoreNotifyEventToOneUser (Ntf_EVENT_SOCIAL_FOLLOWER,&Gbl.Usrs.Other.UsrDat,Gbl.Usrs.Me.UsrDat.UsrCod,
(Ntf_Status_t) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL :
0));
}

View File

@ -57,37 +57,37 @@ extern struct Globals Gbl;
const char *Ntf_WSNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] =
{
"unknown", // Ntf_EVENT_UNKNOWN
"unknown", // Ntf_EVENT_UNKNOWN
/* Course tab */
"documentFile", // Ntf_EVENT_DOCUMENT_FILE
"sharedFile", // Ntf_EVENT_SHARED_FILE
"documentFile", // Ntf_EVENT_DOCUMENT_FILE
"sharedFile", // Ntf_EVENT_SHARED_FILE
/* Assessment tab */
"assignment", // Ntf_EVENT_ASSIGNMENT
"examAnnouncement", // Ntf_EVENT_EXAM_ANNOUNCEMENT
"marksFile", // Ntf_EVENT_MARKS_FILE
"assignment", // Ntf_EVENT_ASSIGNMENT
"examAnnouncement", // Ntf_EVENT_EXAM_ANNOUNCEMENT
"marksFile", // Ntf_EVENT_MARKS_FILE
/* Users tab */
"enrollmentStudent", // Ntf_EVENT_ENROLLMENT_STUDENT
"enrollmentTeacher", // Ntf_EVENT_ENROLLMENT_TEACHER
"enrollmentRequest", // Ntf_EVENT_ENROLLMENT_REQUEST
"enrollmentStudent", // Ntf_EVENT_ENROLLMENT_STUDENT
"enrollmentTeacher", // Ntf_EVENT_ENROLLMENT_TEACHER
"enrollmentRequest", // Ntf_EVENT_ENROLLMENT_REQUEST
/* Social tab */
"socialPost", // Ntf_EVENT_SOCIAL_POST
"socialComment", // Ntf_EVENT_SOCIAL_COMMENT
"socialFav", // Ntf_EVENT_SOCIAL_FAV
"socialShare", // Ntf_EVENT_SOCIAL_SHARE
"follower", // Ntf_EVENT_FOLLOWER
"forumPostCourse", // Ntf_EVENT_FORUM_POST_COURSE
"forumReply", // Ntf_EVENT_FORUM_REPLY
"socialNewPubByFollowed", // Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED
"socialPubCommented", // Ntf_EVENT_SOCIAL_PUB_COMMENTED
"socialPubFaved", // Ntf_EVENT_SOCIAL_PUB_FAVED
"socialPubShared", // Ntf_EVENT_SOCIAL_PUB_SHARED
"socialfollower", // Ntf_EVENT_SOCIAL_FOLLOWER
"forumPostCourse", // Ntf_EVENT_FORUM_POST_COURSE
"forumReply", // Ntf_EVENT_FORUM_REPLY
/* Messages tab */
"notice", // Ntf_EVENT_NOTICE
"message", // Ntf_EVENT_MESSAGE
"notice", // Ntf_EVENT_NOTICE
"message", // Ntf_EVENT_MESSAGE
/* Statistics tab */
"survey", // Ntf_EVENT_SURVEY
"survey", // Ntf_EVENT_SURVEY
/* Profile tab */
};
@ -111,11 +111,11 @@ static const Act_Action_t Ntf_DefaultActions[Ntf_NUM_NOTIFY_EVENTS] =
ActSeeSignUpReq, // Ntf_EVENT_ENROLLMENT_REQUEST
/* Social tab */
ActSeeSocTmlGbl, // Ntf_EVENT_SOCIAL_POST
ActSeeSocTmlGbl, // Ntf_EVENT_SOCIAL_COMMENT
ActSeeSocTmlGbl, // Ntf_EVENT_SOCIAL_FAV
ActSeeSocTmlGbl, // Ntf_EVENT_SOCIAL_SHARE
ActSeeFlr, // Ntf_EVENT_FOLLOWER
ActSeeSocTmlGbl, // Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED
ActSeeSocTmlGbl, // Ntf_EVENT_SOCIAL_PUB_COMMENTED
ActSeeSocTmlGbl, // Ntf_EVENT_SOCIAL_PUB_FAVED
ActSeeSocTmlGbl, // Ntf_EVENT_SOCIAL_PUB_SHARED
ActSeeFlr, // Ntf_EVENT_SOCIAL_FOLLOWER
ActSeeFor, // Ntf_EVENT_FORUM_POST_COURSE
ActSeeFor, // Ntf_EVENT_FORUM_REPLY
@ -153,11 +153,11 @@ static const char *Ntf_ParamNotifMeAboutNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] =
"NotifyNtfEventEnrollmentRequest", // Ntf_EVENT_ENROLLMENT_REQUEST
/* Social tab */
"NotifyNtfEventSocialPost", // Ntf_EVENT_SOCIAL_POST
"NotifyNtfEventSocialComment", // Ntf_EVENT_SOCIAL_COMMENT
"NotifyNtfEventSocialFav", // Ntf_EVENT_SOCIAL_FAV
"NotifyNtfEventSocialShare", // Ntf_EVENT_SOCIAL_SHARE
"NotifyNtfEventFollower", // Ntf_EVENT_FOLLOWER
"NotifyNtfEventSocialPost", // Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED
"NotifyNtfEventSocialComment", // Ntf_EVENT_SOCIAL_PUB_COMMENTED
"NotifyNtfEventSocialFavPost", // Ntf_EVENT_SOCIAL_PUB_FAVED
"NotifyNtfEventSocialShared", // Ntf_EVENT_SOCIAL_PUB_SHARED
"NotifyNtfEventSocialFollower", // Ntf_EVENT_SOCIAL_FOLLOWER
"NotifyNtfEventForumPostCourse", // Ntf_EVENT_FORUM_POST_COURSE
"NotifyNtfEventForumReply", // Ntf_EVENT_FORUM_REPLY
@ -191,11 +191,11 @@ static const char *Ntf_ParamEmailMeAboutNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] =
"EmailNtfEventEnrollmentRequest", // Ntf_EVENT_ENROLLMENT_REQUEST
/* Social tab */
"EmailNtfEventSocialPost", // Ntf_EVENT_SOCIAL_POST
"EmailNtfEventSocialComment", // Ntf_EVENT_SOCIAL_COMMENT
"EmailNtfEventSocialFav", // Ntf_EVENT_SOCIAL_FAV
"EmailNtfEventSocialShare", // Ntf_EVENT_SOCIAL_SHARE
"EmailNtfEventFollower", // Ntf_EVENT_FOLLOWER
"EmailNtfEventSocialPost", // Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED
"EmailNtfEventSocialComment", // Ntf_EVENT_SOCIAL_PUB_COMMENTED
"EmailNtfEventSocialFavPost", // Ntf_EVENT_SOCIAL_PUB_FAVED
"EmailNtfEventSocialShared", // Ntf_EVENT_SOCIAL_PUB_SHARED
"EmailNtfEventSocialFollower", // Ntf_EVENT_SOCIAL_FOLLOWER
"EmailNtfEventForumPostCourse", // Ntf_EVENT_FORUM_POST_COURSE
"EmailNtfEventForumReply", // Ntf_EVENT_FORUM_REPLY
@ -229,11 +229,11 @@ static const char *Ntf_Icons[Ntf_NUM_NOTIFY_EVENTS] =
"enrollmentrequest16x16.gif", // Ntf_EVENT_ENROLLMENT_REQUEST
/* Social tab */
"soc64x64.png", // Ntf_EVENT_SOCIAL_POST
"soc64x64.png", // Ntf_EVENT_SOCIAL_COMMENT
"fav64x64.png", // Ntf_EVENT_SOCIAL_FAV
"share64x64.png", // Ntf_EVENT_SOCIAL_SHARE
"follow64x64.png", // Ntf_EVENT_FOLLOWER
"soc64x64.png", // Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED
"soc64x64.png", // Ntf_EVENT_SOCIAL_PUB_COMMENTED
"fav64x64.png", // Ntf_EVENT_SOCIAL_PUB_FAVED
"share64x64.png", // Ntf_EVENT_SOCIAL_PUB_SHARED
"follow64x64.png", // Ntf_EVENT_SOCIAL_FOLLOWER
"forum16x16.gif", // Ntf_EVENT_FORUM_POST_COURSE
"forum16x16.gif", // Ntf_EVENT_FORUM_REPLY
@ -720,14 +720,15 @@ static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
Brw_PutHiddenParamFilCod (FileMetadata.FilCod);
}
break;
case Ntf_EVENT_SOCIAL_POST:
case Ntf_EVENT_SOCIAL_COMMENT:
case Ntf_EVENT_SOCIAL_FAV:
case Ntf_EVENT_SOCIAL_SHARE:
case Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED:
case Ntf_EVENT_SOCIAL_PUB_COMMENTED:
case Ntf_EVENT_SOCIAL_PUB_FAVED:
case Ntf_EVENT_SOCIAL_PUB_SHARED:
// Cod is the code of the social publishing
Act_FormStart (ActSeeSocTmlGbl);
Soc_PutHiddenParamNotCod (Cod); // TODO: For future display of selected social note at top
// Soc_PutHiddenParamPubCod (Cod); // TODO: For future display of selected social note at top
break;
case Ntf_EVENT_FOLLOWER:
case Ntf_EVENT_SOCIAL_FOLLOWER:
UsrDat.UsrCod = Cod; // Cod is the follower's code
Usr_GetEncryptedUsrCodFromUsrCod (&UsrDat);
if (UsrDat.EncryptedUsrCod[0]) // User's code found ==>
@ -840,17 +841,14 @@ void Ntf_GetNotifSummaryAndContent (char *SummaryStr,char **ContentStr,
case Ntf_EVENT_ENROLLMENT_REQUEST:
Enr_GetNotifEnrollmentRequest (SummaryStr,ContentStr,Cod,MaxChars,GetContent);
break;
case Ntf_EVENT_SOCIAL_POST:
Soc_GetNotifNewSocialPost (SummaryStr,ContentStr,Cod,MaxChars,GetContent);
case Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED:
case Ntf_EVENT_SOCIAL_PUB_COMMENTED:
case Ntf_EVENT_SOCIAL_PUB_FAVED:
case Ntf_EVENT_SOCIAL_PUB_SHARED:
// Cod is the code of the social publishing
Soc_GetNotifSocialPublishing (SummaryStr,ContentStr,Cod,MaxChars,GetContent);
break;
case Ntf_EVENT_SOCIAL_COMMENT:
Soc_GetNotifNewSocialComment (SummaryStr,ContentStr,Cod,MaxChars,GetContent);
break;
case Ntf_EVENT_SOCIAL_FAV:
break;
case Ntf_EVENT_SOCIAL_SHARE:
break;
case Ntf_EVENT_FOLLOWER:
case Ntf_EVENT_SOCIAL_FOLLOWER:
Fol_GetNotifFollower (SummaryStr,ContentStr);
break;
case Ntf_EVENT_FORUM_POST_COURSE:
@ -1198,20 +1196,25 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
Gbl.CurrentDeg.Deg.DegCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
break;
case Ntf_EVENT_SOCIAL_POST: // New social post from one of the users I follow
case Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED: // New social publishing from one of the users I follow
// Cod is the code of the social publishing (not used in the following query)
// Get all my followers
sprintf (Query,"SELECT FollowerCod FROM usr_follow"
" WHERE FollowedCod='%ld'",
Gbl.Usrs.Me.UsrDat.UsrCod);
break;
case Ntf_EVENT_SOCIAL_COMMENT: // New comment to one of my social notes
!!!
case Ntf_EVENT_SOCIAL_PUB_COMMENTED: // New comment to one of my social notes or comments
// Cod is the code of the social publishing
sprintf (Query,"SELECT DISTINCT(PublisherCod) FROM social_pubs"
" WHERE NotCod = (SELECT NotCod FROM social_pubs"
" WHERE PubCod='%ld')"
" AND PublisherCod<>'%ld'",
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
break;
case Ntf_EVENT_SOCIAL_FAV: // New favourite to one of my social notes or comments
break;
case Ntf_EVENT_SOCIAL_SHARE: // New sharing of one of my social notes
break;
case Ntf_EVENT_FOLLOWER: // This function should not be called in this case
case Ntf_EVENT_SOCIAL_PUB_FAVED: // New favourite to one of my social notes or comments
case Ntf_EVENT_SOCIAL_PUB_SHARED: // New sharing of one of my social notes
case Ntf_EVENT_SOCIAL_FOLLOWER:
// This function should not be called in these cases
return 0;
case Ntf_EVENT_FORUM_POST_COURSE:
// Check if forum is for users or for all users in the course
@ -1557,11 +1560,11 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
switch (NotifyEvent)
{
case Ntf_EVENT_UNKNOWN:
case Ntf_EVENT_SOCIAL_POST:
case Ntf_EVENT_SOCIAL_COMMENT:
case Ntf_EVENT_SOCIAL_FAV:
case Ntf_EVENT_SOCIAL_SHARE:
case Ntf_EVENT_FOLLOWER:
case Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED:
case Ntf_EVENT_SOCIAL_PUB_COMMENTED:
case Ntf_EVENT_SOCIAL_PUB_FAVED:
case Ntf_EVENT_SOCIAL_PUB_SHARED:
case Ntf_EVENT_SOCIAL_FOLLOWER:
break;
case Ntf_EVENT_DOCUMENT_FILE:
case Ntf_EVENT_SHARED_FILE:

View File

@ -42,37 +42,37 @@
// it is necessary to change old numbers to new ones in database tables notif and sta_notif
typedef enum
{
Ntf_EVENT_UNKNOWN = 0,
Ntf_EVENT_UNKNOWN = 0,
/* Course tab */
Ntf_EVENT_DOCUMENT_FILE = 1,
Ntf_EVENT_SHARED_FILE = 2,
Ntf_EVENT_DOCUMENT_FILE = 1,
Ntf_EVENT_SHARED_FILE = 2,
/* Assessment tab */
Ntf_EVENT_ASSIGNMENT = 3,
Ntf_EVENT_EXAM_ANNOUNCEMENT = 4,
Ntf_EVENT_MARKS_FILE = 5,
Ntf_EVENT_ASSIGNMENT = 3,
Ntf_EVENT_EXAM_ANNOUNCEMENT = 4,
Ntf_EVENT_MARKS_FILE = 5,
/* Users tab */
Ntf_EVENT_ENROLLMENT_STUDENT = 6,
Ntf_EVENT_ENROLLMENT_TEACHER = 7,
Ntf_EVENT_ENROLLMENT_REQUEST = 8,
Ntf_EVENT_ENROLLMENT_STUDENT = 6,
Ntf_EVENT_ENROLLMENT_TEACHER = 7,
Ntf_EVENT_ENROLLMENT_REQUEST = 8,
/* Social tab */
Ntf_EVENT_SOCIAL_POST = 9, // New social post from one of the users I follow
Ntf_EVENT_SOCIAL_COMMENT = 10, // New comment to one of my social notes
Ntf_EVENT_SOCIAL_FAV = 11, // New favourite to one of my social notes or comments
Ntf_EVENT_SOCIAL_SHARE = 12, // New sharing of one of my social notes
Ntf_EVENT_FOLLOWER = 13, // Old 14
Ntf_EVENT_FORUM_POST_COURSE = 14, // Old 10 // New post in forums of my courses
Ntf_EVENT_FORUM_REPLY = 15, // Old 11 // New reply to one of my posts in any forum
Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED = 9, // New social publishing (post or comment) from one of the users I follow
Ntf_EVENT_SOCIAL_PUB_COMMENTED = 10, // New comment to one of my social publishings (notes or comments)
Ntf_EVENT_SOCIAL_PUB_FAVED = 11, // New fav of one of my social publishings (notes or comments)
Ntf_EVENT_SOCIAL_PUB_SHARED = 12, // New sharing of one of my social notes
Ntf_EVENT_SOCIAL_FOLLOWER = 13, // Old 14
Ntf_EVENT_FORUM_POST_COURSE = 14, // Old 10 // New post in forums of my courses
Ntf_EVENT_FORUM_REPLY = 15, // Old 11 // New reply to one of my posts in any forum
/* Messages tab */
Ntf_EVENT_NOTICE = 16, // Old 9
Ntf_EVENT_MESSAGE = 17, // Old 12
Ntf_EVENT_NOTICE = 16, // Old 9
Ntf_EVENT_MESSAGE = 17, // Old 12
/* Statistics tab */
Ntf_EVENT_SURVEY = 18, // Old 13
Ntf_EVENT_SURVEY = 18, // Old 13
/* Profile tab */

View File

@ -209,7 +209,7 @@ void Prf_GetUsrDatAndShowUserProfile (void)
/***** If it's not me, mark possible notification as seen *****/
if (Gbl.Usrs.Other.UsrDat.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod)
Ntf_MarkNotifAsSeen (Ntf_EVENT_FOLLOWER,
Ntf_MarkNotifAsSeen (Ntf_EVENT_SOCIAL_FOLLOWER,
Gbl.Usrs.Other.UsrDat.UsrCod,-1L,
Gbl.Usrs.Me.UsrDat.UsrCod);
}

View File

@ -295,6 +295,7 @@ static long Soc_ReceiveComment (void);
static long Soc_ShareSocialNote (void);
static long Soc_FavSocialNote (void);
static long Soc_FavSocialComment (void);
static void Soc_CreateFavNotifToAuthor (long AuthorCod,long PubCod);
static long Soc_UnshareSocialNote (void);
static long Soc_UnfavSocialNote (void);
@ -683,6 +684,15 @@ static void Soc_BuildQueryToGetTimeline (Soc_TimelineUsrOrGbl_t TimelineUsrOrGbl
/* Get code of social publishing (row[0]) */
PubCod = Str_ConvertStrCodToLongCod (row[0]);
}
else
PubCod = -1L;
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
if (PubCod > 0)
{
sprintf (Query,"INSERT INTO pub_codes SET PubCod='%ld'",PubCod);
DB_QueryINSERT (Query,"can not store publishing code");
RangePubsToGet.Top = PubCod; // Narrow the range for the next iteration
@ -738,6 +748,9 @@ static long Soc_GetPubCodFromSession (const char *FieldName)
if (sscanf (row[0],"%ld",&PubCod) != 1)
PubCod = 0;
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return PubCod;
}
@ -874,6 +887,9 @@ static void Soc_ShowTimeline (const char *Query,const char *Title,
}
fprintf (Gbl.F.Out,"</ul>");
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** Store first publishing code into session *****/
Soc_UpdateFirstPubCodIntoSession (SocPub.PubCod);
@ -888,9 +904,6 @@ static void Soc_ShowTimeline (const char *Query,const char *Title,
/***** End frame *****/
Lay_EndRoundFrame ();
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
@ -969,11 +982,11 @@ static void Soc_ShowOldPubsInTimeline (const char *Query)
false,false);
}
/***** Store first publishing code into session *****/
Soc_UpdateFirstPubCodIntoSession (SocPub.PubCod);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** Store first publishing code into session *****/
Soc_UpdateFirstPubCodIntoSession (SocPub.PubCod);
}
/*****************************************************************************/
@ -1833,6 +1846,9 @@ static void Soc_PublishSocialNoteInTimeline (struct SocialPublishing *SocPub)
SocPub->PublisherCod,
(unsigned) SocPub->PubType);
SocPub->PubCod = DB_QueryINSERTandReturnCode (Query,"can not publish social note");
/***** Store notification about the new publishing *****/
Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED,SocPub->PubCod);
}
/*****************************************************************************/
@ -1991,9 +2007,6 @@ static long Soc_ReceiveSocialPost (void)
/* Insert post in social notes */
NotCod = Soc_StoreAndPublishSocialNote (Soc_NOTE_SOCIAL_POST,PstCod);
/***** Store notification about the new post *****/
Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_SOCIAL_POST,NotCod);
}
else
NotCod = -1L;
@ -2215,7 +2228,7 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
IAmTheAuthor = (Gbl.Usrs.Me.Logged &&
UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
IAmAFavouriterOfThisSocCom = Soc_CheckIfCommIsFavouritedByUsr (SocCom->ComCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Left: write author's photo *****/
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_COMMENT_PHOTO\">");
@ -2707,7 +2720,7 @@ static long Soc_ReceiveComment (void)
DB_QueryINSERT (Query,"can not store comment content");
/***** Store notification about the new comment *****/
Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_SOCIAL_COMMENT,SocNot.NotCod);
Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_SOCIAL_PUB_COMMENTED,SocPub.PubCod);
/***** Show the social note just commented *****/
Soc_WriteSocialNote (&SocNot,
@ -2844,11 +2857,14 @@ void Soc_FavSocialNoteUsr (void)
static long Soc_FavSocialNote (void)
{
extern const char *Txt_The_original_post_no_longer_exists;
char Query[256];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
struct SocialNote SocNot;
bool IAmTheAuthor;
bool IAmAFavouriterOfThisSocNot;
bool ICanFav;
char Query[256];
long PubCod;
/***** Get the code of the social note to mark as favourite *****/
SocNot.NotCod = Soc_GetParamNotCod ();
@ -2860,7 +2876,7 @@ static long Soc_FavSocialNote (void)
{
IAmTheAuthor = (SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
IAmAFavouriterOfThisSocNot = Soc_CheckIfNoteIsFavouritedByUsr (SocNot.NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
Gbl.Usrs.Me.UsrDat.UsrCod);
ICanFav = (Gbl.Usrs.Me.Logged &&
!IAmTheAuthor && // I am not the author
!IAmAFavouriterOfThisSocNot); // I have not favourited the note
@ -2876,6 +2892,24 @@ static long Soc_FavSocialNote (void)
/* Update number of times this social note is favourited */
SocNot.NumFavs = Soc_GetNumTimesANoteHasBeenFav (&SocNot);
/**** Create notification about favourite post
for the author of the post ***/
sprintf (Query,"SELECT PubCod FROM social_pubs"
" WHERE NotCod='%ld' AND PubType='%u'",
SocNot.NotCod,(unsigned) Soc_PUB_ORIGINAL_NOTE);
if (DB_QuerySELECT (Query,&mysql_res,"can not get publishing") == 1)
{
row = mysql_fetch_row (mysql_res);
/* Get code of social publishing (row[0]) */
PubCod = Str_ConvertStrCodToLongCod (row[0]);
Soc_CreateFavNotifToAuthor (SocNot.UsrCod,PubCod);
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** Show the social note just favourited *****/
Soc_WriteSocialNote (&SocNot,
Soc_TOP_MESSAGE_FAV,Gbl.Usrs.Me.UsrDat.UsrCod,
@ -2946,7 +2980,7 @@ static long Soc_FavSocialComment (void)
{
IAmTheAuthor = (SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
IAmAFavouriterOfThisSocCom = Soc_CheckIfCommIsFavouritedByUsr (SocCom.ComCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
Gbl.Usrs.Me.UsrDat.UsrCod);
ICanFav = (Gbl.Usrs.Me.Logged &&
!IAmTheAuthor && // I am not the author
!IAmAFavouriterOfThisSocCom); // I have not favourited the comment
@ -2962,6 +2996,10 @@ static long Soc_FavSocialComment (void)
/* Update number of times this social comment is favourited */
SocCom.NumFavs = Soc_GetNumTimesACommHasBeenFav (&SocCom);
/**** Create notification about favourite post
for the author of the post ***/
Soc_CreateFavNotifToAuthor (SocCom.UsrCod,SocCom.ComCod);
/***** Show the social comment just favourited *****/
Soc_WriteSocialComment (&SocCom,
Soc_TOP_MESSAGE_FAV,Gbl.Usrs.Me.UsrDat.UsrCod,
@ -2974,6 +3012,40 @@ static long Soc_FavSocialComment (void)
return SocCom.NotCod;
}
/*****************************************************************************/
/**** Create notif. about fav. post/comment for the author of post/comment ***/
/*****************************************************************************/
static void Soc_CreateFavNotifToAuthor (long AuthorCod,long PubCod)
{
struct UsrData UsrDat;
bool CreateNotif;
bool NotifyByEmail;
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
UsrDat.UsrCod = AuthorCod;
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat))
{
/***** This fav must be notified by e-mail? *****/
CreateNotif = (UsrDat.Prefs.NotifNtfEvents & (1 << Ntf_EVENT_SOCIAL_PUB_FAVED));
NotifyByEmail = CreateNotif &&
(UsrDat.Prefs.EmailNtfEvents & (1 << Ntf_EVENT_SOCIAL_PUB_FAVED));
/***** Create notification for the author of the post.
If this author wants to receive notifications by e-mail,
activate the sending of a notification *****/
if (CreateNotif)
Ntf_StoreNotifyEventToOneUser (Ntf_EVENT_SOCIAL_PUB_FAVED,&UsrDat,PubCod,
(Ntf_Status_t) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL :
0));
}
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
/*****************************************************************************/
/***************** Unshare a previously shared social note *******************/
/*****************************************************************************/
@ -3187,7 +3259,7 @@ static long Soc_UnfavSocialComment (void)
IAmTheAuthor = (SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
IAmAFavouriterOfThisSocCom = Soc_CheckIfCommIsFavouritedByUsr (SocCom.ComCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
Gbl.Usrs.Me.UsrDat.UsrCod);
ICanUnfav = (Gbl.Usrs.Me.Logged &&
!IAmTheAuthor && // I am not the author
IAmAFavouriterOfThisSocCom); // I have favourited the comment
@ -3897,6 +3969,9 @@ static void Soc_ShowSharersOrFavers (unsigned NumUsrs,const char *Query)
Usr_UsrDataDestructor (&UsrDat);
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
if (NumUsrs > NumUsrsShown)
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_SHARER\">"
"<img src=\"%s/ellipsis32x32.gif\""
@ -3935,6 +4010,9 @@ static void Soc_GetDataOfSocialNotByCod (struct SocialNote *SocNot)
else
/***** Reset fields of social note *****/
Soc_ResetSocialNote (SocNot);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
else
/***** Reset fields of social note *****/
@ -3972,6 +4050,9 @@ static void Soc_GetDataOfSocialComByCod (struct SocialComment *SocCom)
else
/***** Reset fields of social comment *****/
Soc_ResetSocialComment (SocCom);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
else
/***** Reset fields of social comment *****/
@ -4195,45 +4276,99 @@ static void Soc_AddNotesJustRetrievedToTimelineThisSession (void)
/*****************************************************************************/
/******************* Get notification of a new social post *******************/
/*****************************************************************************/
// This function may be called inside a web service, so don't report error
void Soc_GetNotifNewSocialPost (char *SummaryStr,char **ContentStr,long NotCod,
unsigned MaxChars,bool GetContent)
void Soc_GetNotifSocialPublishing (char *SummaryStr,char **ContentStr,long PubCod,
unsigned MaxChars,bool GetContent)
{
char Query[512];
char Query[256];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
struct SocialPublishing SocPub;
struct SocialNote SocNot;
char Content[Cns_MAX_BYTES_LONG_TEXT+1];
SummaryStr[0] = '\0'; // Return nothing on error
/***** Return nothing on error *****/
SocPub.PubType = Soc_PUB_UNKNOWN;
SummaryStr[0] = '\0';
Content[0] = '\0';
/***** Get social post from database *****/
sprintf (Query,"SELECT social_posts.Content FROM social_notes,social_posts"
" WHERE social_notes.NotCod='%ld'"
" AND social_notes.NoteType='%u' AND"
" AND social_notes.Cod=social_posts.PstCod",
NotCod,(unsigned) Soc_NOTE_SOCIAL_POST);
if (DB_QuerySELECT (Query,&mysql_res,"can not get the content of a social post") == 1) // Result should have a unique row
/***** Get summary and content from social post from database *****/
sprintf (Query,"SELECT PubCod,NotCod,PublisherCod,PubType,UNIX_TIMESTAMP(TimePublish)"
" FROM social_pubs WHERE PubCod='%ld'",
PubCod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get data of social publishing") == 1) // Result should have a unique row
{
/***** Get row *****/
/* Get data of social publishing */
row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/
strncpy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT);
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
Soc_GetDataOfSocialPublishingFromRow (row,&SocPub);
}
else
Content[0] = '\0';
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** Get summary and content *****/
switch (SocPub.PubType)
{
case Soc_PUB_UNKNOWN:
break;
case Soc_PUB_ORIGINAL_NOTE:
case Soc_PUB_SHARED_NOTE:
/* Get data of social note */
SocNot.NotCod = SocPub.NotCod;
Soc_GetDataOfSocialNotByCod (&SocNot);
if (SocNot.NoteType == Soc_NOTE_SOCIAL_POST)
{
/***** Get content of social post from database *****/
sprintf (Query,"SELECT Content FROM social_posts"
" WHERE PstCod='%ld'",
SocNot.Cod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get the content of a social post") == 1) // Result should have a unique row
{
/***** Get row *****/
row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/
strncpy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT);
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** Copy summary string *****/
Str_LimitLengthHTMLStr (Content,MaxChars);
strcpy (SummaryStr,Content);
}
else
Soc_GetNoteSummary (&SocNot,SummaryStr,Soc_MAX_BYTES_SUMMARY);
break;
case Soc_PUB_COMMENT_TO_NOTE:
/***** Get content of social post from database *****/
sprintf (Query,"SELECT Content FROM social_comments"
" WHERE ComCod='%ld'",
SocPub.PubCod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get the content of a comment to a social note") == 1) // Result should have a unique row
{
/***** Get row *****/
row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/
strncpy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT);
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** Copy summary string *****/
Str_LimitLengthHTMLStr (Content,MaxChars);
strcpy (SummaryStr,Content);
break;
}
/***** Copy content string *****/
if (GetContent)
if ((*ContentStr = (char *) malloc (strlen (Content)+1)) != NULL)
strcpy (*ContentStr,Content);
/***** Copy summary string *****/
Str_LimitLengthHTMLStr (Content,MaxChars);
strcpy (SummaryStr,Content);
}

View File

@ -141,7 +141,7 @@ void Soc_RemoveUsrSocialContent (long UsrCod);
void Soc_ClearOldTimelinesDB (void);
void Soc_GetNotifNewSocialPost (char *SummaryStr,char **ContentStr,long NotCod,
unsigned MaxChars,bool GetContent);
void Soc_GetNotifSocialPublishing (char *SummaryStr,char **ContentStr,long PubCod,
unsigned MaxChars,bool GetContent);
#endif

View File

@ -662,7 +662,7 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR_NO_HTML[Ntf_NUM_NOTIFY_EVENTS][1+Txt_NUM_
"Novo pedido de inscrição",
},
{
// Ntf_EVENT_SOCIAL_POST
// Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED
"",
"Novo missatge social",
"Neue soziale Beitrag",
@ -675,7 +675,7 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR_NO_HTML[Ntf_NUM_NOTIFY_EVENTS][1+Txt_NUM_
"Novo post sociais",
},
{
// Ntf_EVENT_SOCIAL_COMMENT
// Ntf_EVENT_SOCIAL_PUB_COMMENTED
"",
"Nou comentari a un missatge social",
"Neue Kommentar zu soziale Beitrag",
@ -688,7 +688,7 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR_NO_HTML[Ntf_NUM_NOTIFY_EVENTS][1+Txt_NUM_
"Novo comentário a um post sociais",
},
{
// Ntf_EVENT_SOCIAL_FAV
// Ntf_EVENT_SOCIAL_PUB_FAVED
"",
"Nou favorit a un missatge social",
"Neue Favorit zu soziale Beitrag",
@ -701,7 +701,7 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR_NO_HTML[Ntf_NUM_NOTIFY_EVENTS][1+Txt_NUM_
"Novo favorito a um post sociais",
},
{
// Ntf_EVENT_SOCIAL_SHARE
// Ntf_EVENT_SOCIAL_PUB_SHARED
"",
"Nova compartició de missatge social",
"Neue gemeinsame Nutzung von soziale Beitrag",
@ -714,7 +714,7 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR_NO_HTML[Ntf_NUM_NOTIFY_EVENTS][1+Txt_NUM_
"Nova partilha de post sociais",
},
{
// Ntf_EVENT_FOLLOWER
// Ntf_EVENT_SOCIAL_FOLLOWER
"",
"Nou seguidor",
"Neue Anh&auml;nger",
@ -25121,7 +25121,7 @@ const char *Txt_NOTIFY_EVENTS_PLURAL[Ntf_NUM_NOTIFY_EVENTS] =
"Novos pedidos de inscri&ccedil;&atilde;o"
#endif
,
#if L==1 // Ntf_EVENT_SOCIAL_POST
#if L==1 // Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED
"Nous missatges socials"
#elif L==2
"Neue sozialen Beitr&auml;ge"
@ -25141,7 +25141,7 @@ const char *Txt_NOTIFY_EVENTS_PLURAL[Ntf_NUM_NOTIFY_EVENTS] =
"Novos post sociais"
#endif
,
#if L==1 // Ntf_EVENT_SOCIAL_COMMENT
#if L==1 // Ntf_EVENT_SOCIAL_PUB_COMMENTED
"Nous comentaris a missatges socials"
#elif L==2
"Neue Kommentare zu sozialen Beitr&auml;ge"
@ -25161,7 +25161,7 @@ const char *Txt_NOTIFY_EVENTS_PLURAL[Ntf_NUM_NOTIFY_EVENTS] =
"Novos coment&aacute;rio a post sociais"
#endif
,
#if L==1 // Ntf_EVENT_SOCIAL_FAV
#if L==1 // Ntf_EVENT_SOCIAL_PUB_FAVED
"Nous favorits a missatges socials"
#elif L==2
"Neue Favorit zu sozialen Beitr&auml;ge"
@ -25181,7 +25181,7 @@ const char *Txt_NOTIFY_EVENTS_PLURAL[Ntf_NUM_NOTIFY_EVENTS] =
"Novos favoritos a post sociais"
#endif
,
#if L==1 // Ntf_EVENT_SOCIAL_SHARE
#if L==1 // Ntf_EVENT_SOCIAL_PUB_SHARED
"Noves comparticions de missatges socials"
#elif L==2
"Neue gemeinsame Nutzung zu sozialen Beitr&auml;ge"
@ -25201,7 +25201,7 @@ const char *Txt_NOTIFY_EVENTS_PLURAL[Ntf_NUM_NOTIFY_EVENTS] =
"Novas partilhas de post sociais"
#endif
,
#if L==1 // Ntf_EVENT_FOLLOWER
#if L==1 // Ntf_EVENT_SOCIAL_FOLLOWER
"Nous seguidors"
#elif L==2
"Neue Anh&auml;nger"
@ -25504,7 +25504,7 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR[Ntf_NUM_NOTIFY_EVENTS] =
"Pedido de inscri&ccedil;&atilde;o"
#endif
,
#if L==1 // Ntf_EVENT_SOCIAL_POST
#if L==1 // Ntf_EVENT_SOCIAL_NEW_PUB_BY_FOLLOWED
"Novo missatge social"
#elif L==2
"Neue soziale Beitrag"
@ -25524,7 +25524,7 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR[Ntf_NUM_NOTIFY_EVENTS] =
"Novo post sociais"
#endif
,
#if L==1 // Ntf_EVENT_SOCIAL_COMMENT
#if L==1 // Ntf_EVENT_SOCIAL_PUB_COMMENTED
"Nou comentari a un missatge social"
#elif L==2
"Neue Kommentar zu soziale Beitrag"
@ -25544,7 +25544,7 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR[Ntf_NUM_NOTIFY_EVENTS] =
"Novo coment&aacute;rio a um post sociais"
#endif
,
#if L==1 // Ntf_EVENT_SOCIAL_FAV
#if L==1 // Ntf_EVENT_SOCIAL_PUB_FAVED
"Nou favorit a un missatge social"
#elif L==2
"Neue Favorit zu soziale Beitrag"
@ -25564,7 +25564,7 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR[Ntf_NUM_NOTIFY_EVENTS] =
"Novo favorito a um post sociais"
#endif
,
#if L==1 // Ntf_EVENT_SOCIAL_SHARE
#if L==1 // Ntf_EVENT_SOCIAL_PUB_SHARED
"Nova compartici&oacute; d'un missatge social"
#elif L==2
"gemeinsame Nutzung von soziale Beitrag"
@ -25584,7 +25584,7 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR[Ntf_NUM_NOTIFY_EVENTS] =
"Nova partilha de um post sociais"
#endif
,
#if L==1 // Ntf_EVENT_FOLLOWER
#if L==1 // Ntf_EVENT_SOCIAL_FOLLOWER
"Seguidor"
#elif L==2
"Anh&auml;nger"