diff --git a/swad_changelog.h b/swad_changelog.h index 45861847c..60456b6e8 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -118,21 +118,21 @@ // TODO: Width of column for data in notifications is too short // TODO: Increment one second after each refresh in social timeline? -// TODO: Remove favs when user is removed -// TODO: Remove favs when note is removed // TODO: Fav comments (remove favs when comment is removed) /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.120.4 (2016-01-19)" +#define Log_PLATFORM_VERSION "SWAD 15.120.5 (2016-01-19)" #define CSS_FILE "swad15.120.3.css" #define JS_FILE "swad15.118.4.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.120.5: Jan 19, 2016 Remove favs when a social note is removed. + Remove favs when a user is removed. (193544 lines) Version 15.120.4: Jan 19, 2016 Changes in database table social_notes_fav. (193527 lines) 2 changes necessary in database: DROP TABLE social_notes_fav; diff --git a/swad_social.c b/swad_social.c index aaa2fd2e9..0608575f9 100644 --- a/swad_social.c +++ b/swad_social.c @@ -3098,6 +3098,11 @@ static void Soc_RemoveASocialNoteFromDB (struct SocialNote *SocNot) { char Query[256]; + /***** Remove favs for this note *****/ + sprintf (Query,"DELETE FROM social_notes_fav WHERE NotCod='%ld'", + SocNot->NotCod); + DB_QueryDELETE (Query,"can not remove favs for social note"); + /***** Remove content of the comments of this social note *****/ sprintf (Query,"DELETE FROM social_comments" " USING social_pubs,social_comments" @@ -3307,6 +3312,21 @@ void Soc_RemoveUsrSocialContent (long UsrCod) { char Query[512]; + /***** Remove favs *****/ + /* Remove all favs made by this user in any social note */ + sprintf (Query,"DELETE FROM social_notes_fav" + " WHERE UsrCod='%ld'", + UsrCod); + DB_QueryDELETE (Query,"can not remove favs for social note"); + + /* Remove all favs for all notes of this user */ + sprintf (Query,"DELETE FROM social_notes_fav" + " USING social_notes,social_notes_fav" + " WHERE social_notes.UsrCod='%ld'" // Author + " AND social_notes.NotCod=social_notes_fav.NotCod", + UsrCod); + DB_QueryDELETE (Query,"can not remove favs for social note"); + /***** Remove social comments *****/ /* Remove content of all the comments in all the social notes of the user */ sprintf (Query,"DELETE FROM social_comments"