Version 15.107.5

This commit is contained in:
Antonio Cañas Vargas 2016-01-11 01:46:33 +01:00
parent 177761bcba
commit 1de926674f
2 changed files with 50 additions and 20 deletions

View File

@ -117,19 +117,19 @@
// TODO: Increment one second after each refresh in social timeline? // TODO: Increment one second after each refresh in social timeline?
// TODO: Include time of last comment in table social_timeline to display social publishings with new comments when refreshing // TODO: Include time of last comment in table social_timeline to display social publishings with new comments when refreshing
// TODO: Show error message when trying to send a comment in a removed social note // TODO: Show error message when trying to send a comment in a removed social note
// TODO: Check if I can comment a social note
/*****************************************************************************/ /*****************************************************************************/
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.107.4 (2016-01-11)" #define Log_PLATFORM_VERSION "SWAD 15.107.5 (2016-01-11)"
#define CSS_FILE "swad15.107.2.css" #define CSS_FILE "swad15.107.2.css"
#define JS_FILE "swad15.107.2.js" #define JS_FILE "swad15.107.2.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.107.5: Jan 11, 2016 Check if a user can comment a social note. (192225 lines)
Version 15.107.4: Jan 11, 2016 Show separated social note at top when a new comment is added. Version 15.107.4: Jan 11, 2016 Show separated social note at top when a new comment is added.
Message of success when publishing a social note or comment. (192199 lines) Message of success when publishing a social note or comment. (192199 lines)
Version 15.107.3: Jan 11, 2016 Fixed bug and code refactoring in social comments. (192160 lines) Version 15.107.3: Jan 11, 2016 Fixed bug and code refactoring in social comments. (192160 lines)

View File

@ -242,6 +242,8 @@ static long Soc_GetParamPubCod (void);
static long Soc_GetParamComCod (void); static long Soc_GetParamComCod (void);
static void Soc_ReceiveComment (void); static void Soc_ReceiveComment (void);
static bool Soc_CheckIfICanCommentNote (long NotCod);
static void Soc_ShareSocialNote (void); static void Soc_ShareSocialNote (void);
static void Soc_UnshareSocialPublishing (void); static void Soc_UnshareSocialPublishing (void);
static void Soc_UnshareASocialPublishingFromDB (struct SocialNote *SocNot); static void Soc_UnshareASocialPublishingFromDB (struct SocialNote *SocNot);
@ -2012,32 +2014,60 @@ static void Soc_ReceiveComment (void)
Par_GetParAndChangeFormat ("Comment",Content,Cns_MAX_BYTES_LONG_TEXT, Par_GetParAndChangeFormat ("Comment",Content,Cns_MAX_BYTES_LONG_TEXT,
Str_TO_RIGOROUS_HTML,true); Str_TO_RIGOROUS_HTML,true);
// TODO: Check if I can comment <=>
// <=> if I can view this note <=>
// <=> if I am a publisher or if I follow at least one publisher (sharer)
if (Content[0]) if (Content[0])
{ {
/***** Publish *****/ /***** Check if I can comment *****/
/* Insert comment in the database */ if (Soc_CheckIfICanCommentNote (SocNot.NotCod))
sprintf (Query,"INSERT INTO social_comments (NotCod,UsrCod,TimeComment)" {
" VALUES ('%ld','%ld',NOW())", /***** Publish *****/
SocNot.NotCod,Gbl.Usrs.Me.UsrDat.UsrCod); /* Insert comment in the database */
ComCod = DB_QueryINSERTandReturnCode (Query,"can not create comment"); sprintf (Query,"INSERT INTO social_comments (NotCod,UsrCod,TimeComment)"
" VALUES ('%ld','%ld',NOW())",
SocNot.NotCod,Gbl.Usrs.Me.UsrDat.UsrCod);
ComCod = DB_QueryINSERTandReturnCode (Query,"can not create comment");
/* Insert comment content in the database */ /* Insert comment content in the database */
sprintf (Query,"INSERT INTO social_comments_content (ComCod,Content)" sprintf (Query,"INSERT INTO social_comments_content (ComCod,Content)"
" VALUES ('%ld','%s')", " VALUES ('%ld','%s')",
ComCod,Content); ComCod,Content);
DB_QueryINSERT (Query,"can not store comment content"); DB_QueryINSERT (Query,"can not store comment content");
/***** Message of success *****/ /***** Message of success *****/
Lay_ShowAlert (Lay_SUCCESS,Txt_SOCIAL_PUBLISHING_Published); Lay_ShowAlert (Lay_SUCCESS,Txt_SOCIAL_PUBLISHING_Published);
/***** Show the social note just commented *****/ /***** Show the social note just commented *****/
Soc_WriteSocialNote (&SocPub,&SocNot,true,false); Soc_WriteSocialNote (&SocPub,&SocNot,true,false);
}
else
Lay_ShowErrorAndExit ("You can not comment this note.");
} }
} }
/*****************************************************************************/
/******************* Check if I can comment a social note ********************/
/*****************************************************************************/
// I can comment a social note <=>
// <=> if I can view the note <=>
// <=> if I am a publisher (author or sharer)
// or I follow at least one publisher (author or sharer)
static bool Soc_CheckIfICanCommentNote (long NotCod)
{
char Query[256];
/***** Check if I am a publisher of this note
or I follow any of the publishers of this note *****/
sprintf (Query,"SELECT COUNT(*) FROM social_timeline"
" WHERE NotCod='%ld' AND PublisherCod IN"
" (SELECT '%ld'"
" UNION"
" SELECT FollowedCod FROM usr_follow WHERE FollowerCod='%ld')",
NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
return (DB_QueryCOUNT (Query,"can not check if I can comment a social note") != 0);
}
/*****************************************************************************/ /*****************************************************************************/
/**************************** Share a social note ****************************/ /**************************** Share a social note ****************************/
/*****************************************************************************/ /*****************************************************************************/