mirror of
https://github.com/acanas/swad-core.git
synced 2024-09-22 00:00:40 +02:00
Version 15.125
This commit is contained in:
parent
83995fea4e
commit
fc51cdb747
|
@ -120,20 +120,23 @@
|
|||
// 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
|
||||
// TODO: View highlighted social note when clicking in timeline notification
|
||||
// TODO: Mark timeline notifications as removed when post/comment are removed or fav/share are undone
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.124.3 (2016-01-24)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.125 (2016-01-24)"
|
||||
#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.124.3: Jan 24, 2016 Mark timeline notifications as seen after viewing social timeline. (? lines)
|
||||
Version 15.125: Jan 24, 2016 Mark notification about shared social note as removed after unsharing.
|
||||
Code refactoring in social timeline. (194563 lines)
|
||||
Version 15.124.3: Jan 24, 2016 Mark timeline notifications as seen after viewing social timeline. (194554 lines)
|
||||
Version 15.124.2: Jan 23, 2016 Changed numeration of notifications in database. (194546 lines)
|
||||
14 changes necessary in database:
|
||||
UPDATE notif SET NotifyEvent=17 WHERE NotifyEvent=9;
|
||||
|
|
246
swad_social.c
246
swad_social.c
|
@ -309,9 +309,9 @@ static void Soc_RequestRemovalSocialComment (void);
|
|||
static void Soc_RemoveSocialComment (void);
|
||||
static void Soc_RemoveASocialCommentFromDB (struct SocialComment *SocCom);
|
||||
|
||||
static bool Soc_CheckIfNoteIsPublishedInTimelineByUsr (long NotCod,long UsrCod);
|
||||
static bool Soc_CheckIfNoteIsFavouritedByUsr (long NotCod,long UsrCod);
|
||||
static bool Soc_CheckIfCommIsFavouritedByUsr (long ComCod,long UsrCod);
|
||||
static bool Soc_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod);
|
||||
static bool Soc_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod);
|
||||
static bool Soc_CheckIfCommIsFavedByUsr (long ComCod,long UsrCod);
|
||||
|
||||
static unsigned Soc_UpdateNumTimesANoteHasBeenShared (struct SocialNote *SocNot);
|
||||
static unsigned Soc_GetNumTimesANoteHasBeenFav (struct SocialNote *SocNot);
|
||||
|
@ -1057,8 +1057,8 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot,
|
|||
extern const char *Txt_Institution;
|
||||
struct UsrData UsrDat;
|
||||
bool IAmTheAuthor = false;
|
||||
bool IAmAPublisherOfThisSocNot = false;
|
||||
bool IAmAFavouriterOfThisSocNot = false;
|
||||
bool IAmASharerOfThisSocNot = false;
|
||||
bool IAmAFaverOfThisSocNot = false;
|
||||
struct Institution Ins;
|
||||
struct Centre Ctr;
|
||||
struct Degree Deg;
|
||||
|
@ -1114,11 +1114,14 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot,
|
|||
if (Gbl.Usrs.Me.Logged)
|
||||
{
|
||||
IAmTheAuthor = (UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
IAmAPublisherOfThisSocNot = Soc_CheckIfNoteIsPublishedInTimelineByUsr (SocNot->NotCod,
|
||||
if (!IAmTheAuthor)
|
||||
{
|
||||
IAmASharerOfThisSocNot = Soc_CheckIfNoteIsSharedByUsr (SocNot->NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
IAmAFavouriterOfThisSocNot = Soc_CheckIfNoteIsFavouritedByUsr (SocNot->NotCod,
|
||||
IAmAFaverOfThisSocNot = Soc_CheckIfNoteIsFavedByUsr (SocNot->NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
}
|
||||
|
||||
/***** Left: write author's photo *****/
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_NOTE_LEFT_PHOTO\">");
|
||||
|
@ -1271,7 +1274,7 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot,
|
|||
/* Put icon to mark this social note as favourite */
|
||||
if (IAmTheAuthor) // I am the author
|
||||
Soc_PutDisabledIconFav (SocNot->NumFavs);
|
||||
else if (IAmAFavouriterOfThisSocNot) // I have favourited this social note
|
||||
else if (IAmAFaverOfThisSocNot) // I have favourited this social note
|
||||
/* Put icon to unfav this publishing */
|
||||
Soc_PutFormToUnfavSocialNote (SocNot->NotCod);
|
||||
else // I am not the author and I am not a sharer
|
||||
|
@ -1289,7 +1292,7 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot,
|
|||
/* Put icons to share/unshare */
|
||||
if (IAmTheAuthor) // I am the author
|
||||
Soc_PutDisabledIconShare (SocNot->NumShared);
|
||||
else if (IAmAPublisherOfThisSocNot) // I am a sharer of this social note,
|
||||
else if (IAmASharerOfThisSocNot) // I am a sharer of this social note,
|
||||
// but not the author ==> I have shared this social note
|
||||
/* Put icon to unshare this publishing */
|
||||
Soc_PutFormToUnshareSocialNote (SocNot->NotCod);
|
||||
|
@ -2199,7 +2202,7 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
|
|||
extern const char *Txt_Institution;
|
||||
struct UsrData UsrDat;
|
||||
bool IAmTheAuthor;
|
||||
bool IAmAFavouriterOfThisSocCom;
|
||||
bool IAmAFaverOfThisSocCom = false;
|
||||
bool ShowPhoto = false;
|
||||
char PhotoURL[PATH_MAX+1];
|
||||
|
||||
|
@ -2234,7 +2237,8 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
|
|||
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat);
|
||||
IAmTheAuthor = (Gbl.Usrs.Me.Logged &&
|
||||
UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
IAmAFavouriterOfThisSocCom = Soc_CheckIfCommIsFavouritedByUsr (SocCom->ComCod,
|
||||
if (!IAmTheAuthor)
|
||||
IAmAFaverOfThisSocCom = Soc_CheckIfCommIsFavedByUsr (SocCom->ComCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
|
||||
/***** Left: write author's photo *****/
|
||||
|
@ -2262,7 +2266,7 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
|
|||
/* Put icon to mark this social comment as favourite */
|
||||
if (IAmTheAuthor) // I am the author
|
||||
Soc_PutDisabledIconFav (SocCom->NumFavs);
|
||||
else if (IAmAFavouriterOfThisSocCom) // I have favourited this social note
|
||||
else if (IAmAFaverOfThisSocCom) // I have favourited this social note
|
||||
/* Put icon to unfav this publishing */
|
||||
Soc_PutFormToUnfavSocialComment (SocCom->ComCod);
|
||||
else // I am not the author and I am not a favouriter
|
||||
|
@ -2784,9 +2788,6 @@ static long Soc_ShareSocialNote (void)
|
|||
extern const char *Txt_The_original_post_no_longer_exists;
|
||||
struct SocialNote SocNot;
|
||||
struct SocialPublishing SocPub;
|
||||
bool IAmTheAuthor;
|
||||
bool IAmAPublisherOfThisSocNot;
|
||||
bool ICanShare;
|
||||
|
||||
/***** Get the code of the social note to share *****/
|
||||
SocNot.NotCod = Soc_GetParamNotCod ();
|
||||
|
@ -2796,16 +2797,10 @@ static long Soc_ShareSocialNote (void)
|
|||
|
||||
if (SocNot.NotCod > 0)
|
||||
{
|
||||
IAmTheAuthor = (SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
if (IAmTheAuthor)
|
||||
IAmAPublisherOfThisSocNot = true;
|
||||
else
|
||||
IAmAPublisherOfThisSocNot = Soc_CheckIfNoteIsPublishedInTimelineByUsr (SocNot.NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
ICanShare = (Gbl.Usrs.Me.Logged &&
|
||||
!IAmTheAuthor && // I am not the author
|
||||
!IAmAPublisherOfThisSocNot); // I have not shared the note
|
||||
if (ICanShare)
|
||||
if (Gbl.Usrs.Me.Logged &&
|
||||
SocNot.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
|
||||
if (!Soc_CheckIfNoteIsSharedByUsr (SocNot.NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // Not yet shared by me
|
||||
{
|
||||
/***** Share (publish social note in timeline) *****/
|
||||
SocPub.NotCod = SocNot.NotCod;
|
||||
|
@ -2868,9 +2863,6 @@ static long Soc_FavSocialNote (void)
|
|||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
struct SocialNote SocNot;
|
||||
bool IAmTheAuthor;
|
||||
bool IAmAFavouriterOfThisSocNot;
|
||||
bool ICanFav;
|
||||
long PubCod;
|
||||
|
||||
/***** Get the code of the social note to mark as favourite *****/
|
||||
|
@ -2881,13 +2873,10 @@ static long Soc_FavSocialNote (void)
|
|||
|
||||
if (SocNot.NotCod > 0)
|
||||
{
|
||||
IAmTheAuthor = (SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
IAmAFavouriterOfThisSocNot = Soc_CheckIfNoteIsFavouritedByUsr (SocNot.NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
ICanFav = (Gbl.Usrs.Me.Logged &&
|
||||
!IAmTheAuthor && // I am not the author
|
||||
!IAmAFavouriterOfThisSocNot); // I have not favourited the note
|
||||
if (ICanFav)
|
||||
if (Gbl.Usrs.Me.Logged &&
|
||||
SocNot.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
|
||||
if (!Soc_CheckIfNoteIsFavedByUsr (SocNot.NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the note
|
||||
{
|
||||
/***** Mark as favourite in database *****/
|
||||
sprintf (Query,"INSERT IGNORE INTO social_notes_fav"
|
||||
|
@ -2971,9 +2960,6 @@ static long Soc_FavSocialComment (void)
|
|||
{
|
||||
extern const char *Txt_The_comment_no_longer_exists;
|
||||
struct SocialComment SocCom;
|
||||
bool IAmTheAuthor;
|
||||
bool IAmAFavouriterOfThisSocCom;
|
||||
bool ICanFav;
|
||||
char Query[256];
|
||||
|
||||
/***** Get the code of the social note to mark as favourite *****/
|
||||
|
@ -2982,16 +2968,12 @@ static long Soc_FavSocialComment (void)
|
|||
/***** Get data of social note *****/
|
||||
Soc_GetDataOfSocialComByCod (&SocCom);
|
||||
|
||||
if (SocCom.ComCod > 0 &&
|
||||
SocCom.NotCod > 0) // Extra check
|
||||
if (SocCom.ComCod > 0)
|
||||
{
|
||||
IAmTheAuthor = (SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
IAmAFavouriterOfThisSocCom = Soc_CheckIfCommIsFavouritedByUsr (SocCom.ComCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
ICanFav = (Gbl.Usrs.Me.Logged &&
|
||||
!IAmTheAuthor && // I am not the author
|
||||
!IAmAFavouriterOfThisSocCom); // I have not favourited the comment
|
||||
if (ICanFav)
|
||||
if (Gbl.Usrs.Me.Logged &&
|
||||
SocCom.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
|
||||
if (!Soc_CheckIfCommIsFavedByUsr (SocCom.ComCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the comment
|
||||
{
|
||||
/***** Mark as favourite in database *****/
|
||||
sprintf (Query,"INSERT IGNORE INTO social_comments_fav"
|
||||
|
@ -3093,37 +3075,56 @@ void Soc_UnshareSocialNoteUsr (void)
|
|||
|
||||
static long Soc_UnshareSocialNote (void)
|
||||
{
|
||||
struct SocialNote SocNot;
|
||||
bool IAmTheAuthor;
|
||||
bool IAmAPublisherOfThisSocNot;
|
||||
bool ICanUnshare;
|
||||
extern const char *Txt_The_original_post_no_longer_exists;
|
||||
char Query[256];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
struct SocialNote SocNot;
|
||||
long PubCod;
|
||||
|
||||
/***** Get data of social note *****/
|
||||
SocNot.NotCod = Soc_GetParamNotCod ();
|
||||
Soc_GetDataOfSocialNotByCod (&SocNot);
|
||||
|
||||
IAmTheAuthor = (SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
if (IAmTheAuthor)
|
||||
IAmAPublisherOfThisSocNot = true;
|
||||
else
|
||||
IAmAPublisherOfThisSocNot = Soc_CheckIfNoteIsPublishedInTimelineByUsr (SocNot.NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
ICanUnshare = (Gbl.Usrs.Me.Logged &&
|
||||
!IAmTheAuthor && // I am not the author
|
||||
IAmAPublisherOfThisSocNot); // I have shared the note
|
||||
if (ICanUnshare)
|
||||
if (SocNot.NotCod > 0)
|
||||
{
|
||||
/***** Delete social publishing from database *****/
|
||||
sprintf (Query,"DELETE FROM social_pubs"
|
||||
if (SocNot.NumShared &&
|
||||
Gbl.Usrs.Me.Logged &&
|
||||
SocNot.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
|
||||
if (Soc_CheckIfNoteIsSharedByUsr (SocNot.NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // I am a sharer
|
||||
{
|
||||
/***** Get code of social publishing from database *****/
|
||||
sprintf (Query,"SELECT PubCod FROM social_pubs"
|
||||
" WHERE NotCod='%ld'"
|
||||
" AND PublisherCod='%ld'" // I have share this note
|
||||
" AND PubType='%u'", // It's a shared note
|
||||
SocNot.NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
(unsigned) Soc_PUB_SHARED_NOTE);
|
||||
if (DB_QuerySELECT (Query,&mysql_res,"can not get code of social publishing") == 1) // Result should have a unique row
|
||||
{
|
||||
/* Get code of social publishing (row[0]) */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
PubCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
}
|
||||
else
|
||||
PubCod = -1L;
|
||||
|
||||
/* Free structure that stores the query result */
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
if (PubCod > 0)
|
||||
{
|
||||
/***** Delete social publishing from database *****/
|
||||
sprintf (Query,"DELETE FROM social_pubs WHERE PubCod='%ld'",
|
||||
PubCod);
|
||||
DB_QueryDELETE (Query,"can not remove a social publishing");
|
||||
|
||||
/***** Mark possible notification as removed *****/
|
||||
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE,PubCod);
|
||||
}
|
||||
|
||||
/***** Update number of times this social note is shared *****/
|
||||
SocNot.NumShared = Soc_UpdateNumTimesANoteHasBeenShared (&SocNot);
|
||||
|
||||
|
@ -3133,6 +3134,9 @@ static long Soc_UnshareSocialNote (void)
|
|||
Soc_TOP_MESSAGE_UNSHARED,Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
true,true);
|
||||
}
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_The_original_post_no_longer_exists);
|
||||
|
||||
return SocNot.NotCod;
|
||||
}
|
||||
|
@ -3177,23 +3181,21 @@ void Soc_UnfavSocialNoteUsr (void)
|
|||
|
||||
static long Soc_UnfavSocialNote (void)
|
||||
{
|
||||
extern const char *Txt_The_original_post_no_longer_exists;
|
||||
struct SocialNote SocNot;
|
||||
bool IAmTheAuthor;
|
||||
bool IAmAFavouriterOfThisSocNot;
|
||||
bool ICanUnfav;
|
||||
char Query[256];
|
||||
|
||||
/***** Get data of social note *****/
|
||||
SocNot.NotCod = Soc_GetParamNotCod ();
|
||||
Soc_GetDataOfSocialNotByCod (&SocNot);
|
||||
|
||||
IAmTheAuthor = (SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
IAmAFavouriterOfThisSocNot = Soc_CheckIfNoteIsFavouritedByUsr (SocNot.NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
ICanUnfav = (Gbl.Usrs.Me.Logged &&
|
||||
!IAmTheAuthor && // I am not the author
|
||||
IAmAFavouriterOfThisSocNot); // I have favourited the note
|
||||
if (ICanUnfav)
|
||||
if (SocNot.NotCod > 0)
|
||||
{
|
||||
if (SocNot.NumFavs &&
|
||||
Gbl.Usrs.Me.Logged &&
|
||||
SocNot.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
|
||||
if (Soc_CheckIfNoteIsFavedByUsr (SocNot.NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the note
|
||||
{
|
||||
/***** Delete the mark as favourite from database *****/
|
||||
sprintf (Query,"DELETE FROM social_notes_fav"
|
||||
|
@ -3210,6 +3212,9 @@ static long Soc_UnfavSocialNote (void)
|
|||
Soc_TOP_MESSAGE_UNFAV,Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
true,true);
|
||||
}
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_The_original_post_no_longer_exists);
|
||||
|
||||
return SocNot.NotCod;
|
||||
}
|
||||
|
@ -3254,23 +3259,21 @@ void Soc_UnfavSocialCommentUsr (void)
|
|||
|
||||
static long Soc_UnfavSocialComment (void)
|
||||
{
|
||||
extern const char *Txt_The_comment_no_longer_exists;
|
||||
struct SocialComment SocCom;
|
||||
bool IAmTheAuthor;
|
||||
bool IAmAFavouriterOfThisSocCom;
|
||||
bool ICanUnfav;
|
||||
char Query[256];
|
||||
|
||||
/***** Get data of social comment *****/
|
||||
SocCom.ComCod = Soc_GetParamComCod ();
|
||||
Soc_GetDataOfSocialComByCod (&SocCom);
|
||||
|
||||
IAmTheAuthor = (SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
IAmAFavouriterOfThisSocCom = Soc_CheckIfCommIsFavouritedByUsr (SocCom.ComCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
ICanUnfav = (Gbl.Usrs.Me.Logged &&
|
||||
!IAmTheAuthor && // I am not the author
|
||||
IAmAFavouriterOfThisSocCom); // I have favourited the comment
|
||||
if (ICanUnfav)
|
||||
if (SocCom.ComCod > 0)
|
||||
{
|
||||
if (SocCom.NumFavs &&
|
||||
Gbl.Usrs.Me.Logged &&
|
||||
SocCom.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
|
||||
if (Soc_CheckIfCommIsFavedByUsr (SocCom.ComCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the comment
|
||||
{
|
||||
/***** Delete the mark as favourite from database *****/
|
||||
sprintf (Query,"DELETE FROM social_comments_fav"
|
||||
|
@ -3287,6 +3290,9 @@ static long Soc_UnfavSocialComment (void)
|
|||
Soc_TOP_MESSAGE_UNFAV,Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
true);
|
||||
}
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_The_comment_no_longer_exists);
|
||||
|
||||
return SocCom.NotCod;
|
||||
}
|
||||
|
@ -3327,20 +3333,19 @@ void Soc_RequestRemSocialNoteUsr (void)
|
|||
|
||||
static void Soc_RequestRemovalSocialNote (void)
|
||||
{
|
||||
extern const char *Txt_The_original_post_no_longer_exists;
|
||||
extern const char *Txt_Do_you_really_want_to_remove_the_following_post;
|
||||
extern const char *Txt_Remove;
|
||||
struct SocialNote SocNot;
|
||||
bool ICanRemove;
|
||||
|
||||
/***** Get data of social note *****/
|
||||
SocNot.NotCod = Soc_GetParamNotCod ();
|
||||
Soc_GetDataOfSocialNotByCod (&SocNot);
|
||||
|
||||
ICanRemove = (Gbl.Usrs.Me.Logged &&
|
||||
SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod); // I am the author of this note
|
||||
if (ICanRemove)
|
||||
if (SocNot.NotCod > 0)
|
||||
{
|
||||
if (Soc_CheckIfNoteIsPublishedInTimelineByUsr (SocNot.NotCod,SocNot.UsrCod))
|
||||
if (Gbl.Usrs.Me.Logged &&
|
||||
SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this note
|
||||
{
|
||||
/***** Show warning and social note *****/
|
||||
/* Warning message */
|
||||
|
@ -3367,6 +3372,8 @@ static void Soc_RequestRemovalSocialNote (void)
|
|||
Act_FormEnd ();
|
||||
}
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_The_original_post_no_longer_exists);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3405,17 +3412,18 @@ void Soc_RemoveSocialNoteUsr (void)
|
|||
|
||||
static void Soc_RemoveSocialNote (void)
|
||||
{
|
||||
extern const char *Txt_The_original_post_no_longer_exists;
|
||||
extern const char *Txt_Post_removed;
|
||||
struct SocialNote SocNot;
|
||||
bool ICanRemove;
|
||||
|
||||
/***** Get data of social note *****/
|
||||
SocNot.NotCod = Soc_GetParamNotCod ();
|
||||
Soc_GetDataOfSocialNotByCod (&SocNot);
|
||||
|
||||
ICanRemove = (Gbl.Usrs.Me.Logged &&
|
||||
SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod); // I am the author of this note
|
||||
if (ICanRemove)
|
||||
if (SocNot.NotCod > 0)
|
||||
{
|
||||
if (Gbl.Usrs.Me.Logged &&
|
||||
SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this note
|
||||
{
|
||||
/***** Delete social publishing from database *****/
|
||||
Soc_RemoveASocialNoteFromDB (&SocNot);
|
||||
|
@ -3424,6 +3432,9 @@ static void Soc_RemoveSocialNote (void)
|
|||
Lay_ShowAlert (Lay_SUCCESS,Txt_Post_removed);
|
||||
}
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_The_original_post_no_longer_exists);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Remove a social note from database **********************/
|
||||
|
@ -3519,10 +3530,10 @@ void Soc_RequestRemSocialComUsr (void)
|
|||
|
||||
static void Soc_RequestRemovalSocialComment (void)
|
||||
{
|
||||
extern const char *Txt_The_comment_no_longer_exists;
|
||||
extern const char *Txt_Do_you_really_want_to_remove_the_following_comment;
|
||||
extern const char *Txt_Remove;
|
||||
struct SocialComment SocCom;
|
||||
bool ICanRemove;
|
||||
|
||||
/***** Get the code of the social comment to remove *****/
|
||||
SocCom.ComCod = Soc_GetParamComCod ();
|
||||
|
@ -3530,9 +3541,10 @@ static void Soc_RequestRemovalSocialComment (void)
|
|||
/***** Get data of social comment *****/
|
||||
Soc_GetDataOfSocialComByCod (&SocCom);
|
||||
|
||||
ICanRemove = (Gbl.Usrs.Me.Logged &&
|
||||
SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
if (ICanRemove)
|
||||
if (SocCom.ComCod > 0)
|
||||
{
|
||||
if (Gbl.Usrs.Me.Logged &&
|
||||
SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this comment
|
||||
{
|
||||
/***** Show warning and social comment *****/
|
||||
/* Warning message */
|
||||
|
@ -3559,6 +3571,9 @@ static void Soc_RequestRemovalSocialComment (void)
|
|||
Act_FormEnd ();
|
||||
}
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_The_comment_no_longer_exists);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Remove a social comment **************************/
|
||||
|
@ -3596,10 +3611,9 @@ void Soc_RemoveSocialComUsr (void)
|
|||
|
||||
static void Soc_RemoveSocialComment (void)
|
||||
{
|
||||
extern const char *Txt_The_comment_no_longer_exists;
|
||||
extern const char *Txt_Comment_removed;
|
||||
struct SocialComment SocCom;
|
||||
struct SocialNote SocNot;
|
||||
bool ICanRemove;
|
||||
|
||||
/***** Get the code of the social comment to remove *****/
|
||||
SocCom.ComCod = Soc_GetParamComCod ();
|
||||
|
@ -3607,13 +3621,10 @@ static void Soc_RemoveSocialComment (void)
|
|||
/***** Get data of social comment *****/
|
||||
Soc_GetDataOfSocialComByCod (&SocCom);
|
||||
|
||||
/***** Get data of social note *****/
|
||||
SocNot.NotCod = SocCom.NotCod;
|
||||
Soc_GetDataOfSocialNotByCod (&SocNot);
|
||||
|
||||
ICanRemove = (Gbl.Usrs.Me.Logged &&
|
||||
SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
if (ICanRemove)
|
||||
if (SocCom.ComCod > 0)
|
||||
{
|
||||
if (Gbl.Usrs.Me.Logged &&
|
||||
SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this comment
|
||||
{
|
||||
/***** Delete social comment from database *****/
|
||||
Soc_RemoveASocialCommentFromDB (&SocCom);
|
||||
|
@ -3622,6 +3633,9 @@ static void Soc_RemoveSocialComment (void)
|
|||
Lay_ShowAlert (Lay_SUCCESS,Txt_Comment_removed);
|
||||
}
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_The_comment_no_longer_exists);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Remove a social comment from database ********************/
|
||||
|
@ -3748,14 +3762,12 @@ void Soc_RemoveUsrSocialContent (long UsrCod)
|
|||
DB_QueryDELETE (Query,"can not remove social publishings");
|
||||
|
||||
/***** Remove all the social publishings of the user *****/
|
||||
sprintf (Query,"DELETE FROM social_pubs"
|
||||
" WHERE PublisherCod='%ld'",
|
||||
sprintf (Query,"DELETE FROM social_pubs WHERE PublisherCod='%ld'",
|
||||
UsrCod);
|
||||
DB_QueryDELETE (Query,"can not remove social publishings");
|
||||
|
||||
/***** Remove all the social notes of the user *****/
|
||||
sprintf (Query,"DELETE FROM social_notes"
|
||||
" WHERE UsrCod='%ld'",
|
||||
sprintf (Query,"DELETE FROM social_notes WHERE UsrCod='%ld'",
|
||||
UsrCod);
|
||||
DB_QueryDELETE (Query,"can not remove social notes");
|
||||
}
|
||||
|
@ -3764,25 +3776,21 @@ void Soc_RemoveUsrSocialContent (long UsrCod)
|
|||
/**************** Check if a user has published a social note ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static bool Soc_CheckIfNoteIsPublishedInTimelineByUsr (long NotCod,long UsrCod)
|
||||
static bool Soc_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
sprintf (Query,"SELECT COUNT(*) FROM social_pubs"
|
||||
" WHERE NotCod='%ld'"
|
||||
" AND PublisherCod='%ld'"
|
||||
" AND PubType IN ('%u','%u')",
|
||||
NotCod,UsrCod,
|
||||
(unsigned) Soc_PUB_ORIGINAL_NOTE,
|
||||
(unsigned) Soc_PUB_SHARED_NOTE);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a user has published a social note") != 0);
|
||||
" WHERE NotCod='%ld' AND PublisherCod='%ld' AND PubType='%u'",
|
||||
NotCod,UsrCod,(unsigned) Soc_PUB_SHARED_NOTE);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a user has shared a social note") != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Check if a user has favourited a social note ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static bool Soc_CheckIfNoteIsFavouritedByUsr (long NotCod,long UsrCod)
|
||||
static bool Soc_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
|
@ -3796,7 +3804,7 @@ static bool Soc_CheckIfNoteIsFavouritedByUsr (long NotCod,long UsrCod)
|
|||
/************* Check if a user has favourited a social comment ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static bool Soc_CheckIfCommIsFavouritedByUsr (long ComCod,long UsrCod)
|
||||
static bool Soc_CheckIfCommIsFavedByUsr (long ComCod,long UsrCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user