From 66b0edb994548ab56c933ba1505d8a46d5c26379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Mon, 4 Jan 2016 17:36:28 +0100 Subject: [PATCH] Version 15.97.5 --- swad_changelog.h | 3 ++- swad_social.c | 66 +++++++++++++++++++++++++----------------------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index d45895440..c03dff063 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -118,13 +118,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.97.4 (2016-01-04)" +#define Log_PLATFORM_VERSION "SWAD 15.97.5 (2016-01-04)" #define CSS_FILE "swad15.97.css" #define JS_FILE "swad15.77.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.97.5: Jan 04, 2016 Button to remove a social note is not shown if author already removed the note (but it yet exists because another user shared it). (190763 lines) Version 15.97.4: Jan 04, 2016 Guests can see and write in global forums. (190758 lines) Version 15.97.3: Jan 04, 2016 Link to user's privacy in my public profile. (190755 lines) Version 15.97.2: Jan 04, 2016 New option in user's privacy. (190743 lines) diff --git a/swad_social.c b/swad_social.c index 11cae2e70..c0aa1b05c 100644 --- a/swad_social.c +++ b/swad_social.c @@ -167,7 +167,7 @@ static void Soc_RemoveASocialPublishingFromDB (const struct SocialPublishing *So const struct SocialNote *SocNot); static void Soc_CheckAndDeleteASocialNoteFromDB (const struct SocialNote *SocNot); -static bool Soc_CheckIfNoteIsYetPublishedByMe (long NotCod); +static bool Soc_CheckIfNoteIsPublishedInTimelineByUsr (long NotCod,long UsrCod); static unsigned long Soc_GetNumPubsOfANote (long NotCod); static void Soc_GetNumTimesANoteHasBeenShared (struct SocialNote *SocNot); static void Soc_ShowUsrsWhoHaveSharedSocialNote (const struct SocialNote *SocNot); @@ -529,7 +529,7 @@ static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub, Soc_PutIconShared (); else // I am not the author && not unavailable { - if (Soc_CheckIfNoteIsYetPublishedByMe (SocNot->NotCod)) + if (Soc_CheckIfNoteIsPublishedInTimelineByUsr (SocNot->NotCod,Gbl.Usrs.Me.UsrDat.UsrCod)) // I have yet published this social note /* Put icon to unshare this publishing */ Soc_PutFormToUnshareSocialPublishing (SocPub->PubCod); @@ -546,8 +546,9 @@ static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub, if (WritingTimeline && Gbl.Usrs.Me.Logged && UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author - /* Put icon to remove this publishing */ - Soc_PutFormToRemoveSocialPublishing (SocPub->PubCod); + if (Soc_CheckIfNoteIsPublishedInTimelineByUsr (SocNot->NotCod,SocNot->UsrCod)) + /* Put icon to remove this publishing */ + Soc_PutFormToRemoveSocialPublishing (SocPub->PubCod); /* End of right part */ fprintf (Gbl.F.Out,""); @@ -1311,7 +1312,7 @@ static void Soc_ShareSocialNote (void) if (ICanShare) { /***** Check if I have yet shared this social note *****/ - IHavePublishedThisNote = Soc_CheckIfNoteIsYetPublishedByMe (SocNot.NotCod); + IHavePublishedThisNote = Soc_CheckIfNoteIsPublishedInTimelineByUsr (SocNot.NotCod,Gbl.Usrs.Me.UsrDat.UsrCod); if (!IHavePublishedThisNote) { /***** Share (publish social note in timeline) *****/ @@ -1488,30 +1489,33 @@ static void Soc_RequestRemovalSocialPublishing (void) SocPub.PublisherCod == Gbl.Usrs.Me.UsrDat.UsrCod); if (ICanRemove) { - /***** Form to ask for confirmation to remove this social post *****/ - /* Start form */ - if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) + if (Soc_CheckIfNoteIsPublishedInTimelineByUsr (SocNot.NotCod,SocNot.UsrCod)) { - Act_FormStartAnchor (ActRemSocPubUsr,"timeline"); - Usr_PutParamOtherUsrCodEncrypted (); + /***** Form to ask for confirmation to remove this social post *****/ + /* Start form */ + if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) + { + Act_FormStartAnchor (ActRemSocPubUsr,"timeline"); + Usr_PutParamOtherUsrCodEncrypted (); + } + else + Act_FormStart (ActRemSocPubGbl); + Soc_PutHiddenParamPubCod (SocPub.PubCod); + + /* Warning message */ + Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_remove_the_following_comment); + + /* Show social note */ + Lay_StartRoundFrame (Soc_WIDTH_TIMELINE,NULL); + fprintf (Gbl.F.Out,""); + Lay_EndRoundFrame (); + + /* End form */ + Lay_PutRemoveButton (Txt_Remove); + Act_FormEnd (); } - else - Act_FormStart (ActRemSocPubGbl); - Soc_PutHiddenParamPubCod (SocPub.PubCod); - - /* Warning message */ - Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_remove_the_following_comment); - - /* Show social note */ - Lay_StartRoundFrame (Soc_WIDTH_TIMELINE,NULL); - fprintf (Gbl.F.Out,""); - Lay_EndRoundFrame (); - - /* End form */ - Lay_PutRemoveButton (Txt_Remove); - Act_FormEnd (); } } @@ -1640,17 +1644,17 @@ static void Soc_CheckAndDeleteASocialNoteFromDB (const struct SocialNote *SocNot } /*****************************************************************************/ -/***** Check if I have published a social note (I authored or shared it) *****/ +/**************** Check if a user has published a social note ****************/ /*****************************************************************************/ -static bool Soc_CheckIfNoteIsYetPublishedByMe (long NotCod) +static bool Soc_CheckIfNoteIsPublishedInTimelineByUsr (long NotCod,long UsrCod) { char Query[128]; sprintf (Query,"SELECT COUNT(*) FROM social_timeline" " WHERE NotCod='%ld' AND PublisherCod='%ld'", - NotCod,Gbl.Usrs.Me.UsrDat.UsrCod); - return (DB_QueryCOUNT (Query,"can not check if you have published a social note") != 0); + NotCod,UsrCod); + return (DB_QueryCOUNT (Query,"can not check if a user has published a social note") != 0); } /*****************************************************************************/