Version 15.127.3

This commit is contained in:
Antonio Cañas Vargas 2016-01-25 12:32:13 +01:00
parent 2c93cbce9a
commit 7a3bafc8a9
4 changed files with 93 additions and 89 deletions

View File

@ -918,20 +918,20 @@ CREATE TABLE IF NOT EXISTS sessions (
-- Table social_comments: stores the content of comments to social notes -- Table social_comments: stores the content of comments to social notes
-- --
CREATE TABLE IF NOT EXISTS social_comments ( CREATE TABLE IF NOT EXISTS social_comments (
ComCod BIGINT NOT NULL, PubCod BIGINT NOT NULL,
Content LONGTEXT NOT NULL, Content LONGTEXT NOT NULL,
UNIQUE INDEX(ComCod), UNIQUE INDEX(PubCod),
FULLTEXT(Content)) ENGINE = MYISAM; FULLTEXT(Content)) ENGINE = MYISAM;
-- --
-- Table social_comments_fav: stores users who marked social comments as favourite -- Table social_comments_fav: stores users who marked social comments as favourite
-- --
CREATE TABLE IF NOT EXISTS social_comments_fav ( CREATE TABLE IF NOT EXISTS social_comments_fav (
FavCod BIGINT AUTO_INCREMENT, FavCod BIGINT AUTO_INCREMENT,
ComCod BIGINT NOT NULL, PubCod BIGINT NOT NULL,
UsrCod INT NOT NULL, UsrCod INT NOT NULL,
TimeFav DATETIME NOT NULL, TimeFav DATETIME NOT NULL,
UNIQUE INDEX(FavCod), UNIQUE INDEX(FavCod),
UNIQUE INDEX(ComCod,UsrCod), UNIQUE INDEX(PubCod,UsrCod),
INDEX(UsrCod)); INDEX(UsrCod));
-- --
-- Table social_notes: stores social notes -- Table social_notes: stores social notes

View File

@ -117,7 +117,6 @@
// TODO: Go to forum post (or at least to forum thread) from social timeline and notifications? // 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: 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: When receiving a new post, create first the publishing, then the post
// TODO: Change PstCod to PubCod in social_posts, removing AUTO_INCREMENT // TODO: Change PstCod to PubCod in social_posts, removing AUTO_INCREMENT
// TODO: View highlighted social note when clicking in timeline notification // TODO: View highlighted social note when clicking in timeline notification
@ -126,13 +125,18 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.127.2 (2016-01-25)" #define Log_PLATFORM_VERSION "SWAD 15.127.3 (2016-01-25)"
#define CSS_FILE "swad15.121.7.css" #define CSS_FILE "swad15.121.7.css"
#define JS_FILE "swad15.121.7.js" #define JS_FILE "swad15.121.7.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.127.3: Jan 25, 2016 Changed ComCod to PubCod in social_comments and social_comments_fav. (194841 lines)
2 changes necessary in database:
ALTER TABLE social_comments_fav CHANGE COLUMN ComCod PubCod BIGINT NOT NULL;
ALTER TABLE social_comments CHANGE COLUMN ComCod PubCod BIGINT NOT NULL;
Version 15.127.2: Jan 25, 2016 Mark timeline notifications as removed when a social note/comment is unfaved. (194838 lines) Version 15.127.2: Jan 25, 2016 Mark timeline notifications as removed when a social note/comment is unfaved. (194838 lines)
Version 15.127.1: Jan 25, 2016 Mark timeline notifications as removed when a social note is unshared. (194831 lines) Version 15.127.1: Jan 25, 2016 Mark timeline notifications as removed when a social note is unshared. (194831 lines)
Version 15.127: Jan 25, 2016 New function to count the number of @nicknames in a text and store it in social publishing. (194825 lines) Version 15.127: Jan 25, 2016 New function to count the number of @nicknames in a text and store it in social publishing. (194825 lines)

View File

@ -1946,15 +1946,15 @@ mysql> DESCRIBE social_comments;
+---------+------------+------+-----+---------+-------+ +---------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+---------+------------+------+-----+---------+-------+ +---------+------------+------+-----+---------+-------+
| ComCod | bigint(20) | NO | PRI | NULL | | | PubCod | bigint(20) | NO | PRI | NULL | |
| Content | longtext | NO | MUL | NULL | | | Content | longtext | NO | MUL | NULL | |
+---------+------------+------+-----+---------+-------+ +---------+------------+------+-----+---------+-------+
2 rows in set (0.00 sec) 2 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_comments (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_comments ("
"ComCod BIGINT NOT NULL," "PubCod BIGINT NOT NULL,"
"Content LONGTEXT NOT NULL," "Content LONGTEXT NOT NULL,"
"UNIQUE INDEX(ComCod)," "UNIQUE INDEX(PubCod),"
"FULLTEXT(Content)) ENGINE = MYISAM;"); "FULLTEXT(Content)) ENGINE = MYISAM;");
/***** Table social_comments_fav *****/ /***** Table social_comments_fav *****/
@ -1964,7 +1964,7 @@ mysql> DESCRIBE social_comments_fav;
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+---------+------------+------+-----+---------+----------------+ +---------+------------+------+-----+---------+----------------+
| FavCod | bigint(20) | NO | PRI | NULL | auto_increment | | FavCod | bigint(20) | NO | PRI | NULL | auto_increment |
| ComCod | bigint(20) | NO | MUL | NULL | | | PubCod | bigint(20) | NO | MUL | NULL | |
| UsrCod | int(11) | NO | MUL | NULL | | | UsrCod | int(11) | NO | MUL | NULL | |
| TimeFav | datetime | NO | | NULL | | | TimeFav | datetime | NO | | NULL | |
+---------+------------+------+-----+---------+----------------+ +---------+------------+------+-----+---------+----------------+
@ -1972,11 +1972,11 @@ mysql> DESCRIBE social_comments_fav;
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_comments_fav (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_comments_fav ("
"FavCod BIGINT AUTO_INCREMENT," "FavCod BIGINT AUTO_INCREMENT,"
"ComCod BIGINT NOT NULL," "PubCod BIGINT NOT NULL,"
"UsrCod INT NOT NULL," "UsrCod INT NOT NULL,"
"TimeFav DATETIME NOT NULL," // Not used. For future use "TimeFav DATETIME NOT NULL," // Not used. For future use
"UNIQUE INDEX(FavCod)," "UNIQUE INDEX(FavCod),"
"UNIQUE INDEX(ComCod,UsrCod)," "UNIQUE INDEX(PubCod,UsrCod),"
"INDEX(UsrCod))"); "INDEX(UsrCod))");
/***** Table social_notes *****/ /***** Table social_notes *****/

View File

@ -176,7 +176,7 @@ struct SocialNote
struct SocialComment struct SocialComment
{ {
long ComCod; long PubCod;
long UsrCod; long UsrCod;
long NotCod; // Note code long NotCod; // Note code
time_t DateTimeUTC; time_t DateTimeUTC;
@ -251,8 +251,8 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
bool ShowCommentAlone); bool ShowCommentAlone);
static void Soc_WriteAuthorComment (struct UsrData *UsrDat); static void Soc_WriteAuthorComment (struct UsrData *UsrDat);
static void Soc_PutFormToRemoveComment (long ComCod); static void Soc_PutFormToRemoveComment (long PubCod);
static void Soc_PutFormToFavSocialComment (long ComCod); static void Soc_PutFormToFavSocialComment (long PubCod);
static void Soc_PutDisabledIconShare (unsigned NumShared); static void Soc_PutDisabledIconShare (unsigned NumShared);
static void Soc_PutDisabledIconFav (unsigned NumFavs); static void Soc_PutDisabledIconFav (unsigned NumFavs);
@ -262,13 +262,13 @@ static void Soc_PutFormToFavSocialNote (long NotCod);
static void Soc_PutFormToUnshareSocialNote (long NotCod); static void Soc_PutFormToUnshareSocialNote (long NotCod);
static void Soc_PutFormToUnfavSocialNote (long NotCod); static void Soc_PutFormToUnfavSocialNote (long NotCod);
static void Soc_PutFormToUnfavSocialComment (long ComCod); static void Soc_PutFormToUnfavSocialComment (long PubCod);
static void Soc_PutFormToRemoveSocialPublishing (long NotCod); static void Soc_PutFormToRemoveSocialPublishing (long NotCod);
static void Soc_PutHiddenParamComCod (long ComCod); static void Soc_PutHiddenParamPubCod (long PubCod);
static long Soc_GetParamNotCod (void); static long Soc_GetParamNotCod (void);
static long Soc_GetParamComCod (void); static long Soc_GetParamPubCod (void);
static long Soc_ReceiveComment (void); static long Soc_ReceiveComment (void);
@ -292,7 +292,7 @@ static void Soc_RemoveASocialCommentFromDB (struct SocialComment *SocCom);
static bool Soc_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod); static bool Soc_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod);
static bool Soc_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod); static bool Soc_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod);
static bool Soc_CheckIfCommIsFavedByUsr (long ComCod,long UsrCod); static bool Soc_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod);
static unsigned Soc_UpdateNumTimesANoteHasBeenShared (struct SocialNote *SocNot); static unsigned Soc_UpdateNumTimesANoteHasBeenShared (struct SocialNote *SocNot);
static unsigned Soc_GetNumTimesANoteHasBeenFav (struct SocialNote *SocNot); static unsigned Soc_GetNumTimesANoteHasBeenFav (struct SocialNote *SocNot);
@ -2134,7 +2134,7 @@ static void Soc_WriteCommentsInSocialNote (const struct SocialNote *SocNot)
" FROM social_pubs,social_comments" " FROM social_pubs,social_comments"
" WHERE social_pubs.NotCod='%ld'" " WHERE social_pubs.NotCod='%ld'"
" AND social_pubs.PubType='%u'" " AND social_pubs.PubType='%u'"
" AND social_pubs.PubCod=social_comments.ComCod" " AND social_pubs.PubCod=social_comments.PubCod"
" ORDER BY social_pubs.PubCod", " ORDER BY social_pubs.PubCod",
SocNot->NotCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE); SocNot->NotCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE);
NumComments = DB_QuerySELECT (Query,&mysql_res,"can not get social comments"); NumComments = DB_QuerySELECT (Query,&mysql_res,"can not get social comments");
@ -2207,7 +2207,7 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
fprintf (Gbl.F.Out," class=\"SOCIAL_COMMENT\""); fprintf (Gbl.F.Out," class=\"SOCIAL_COMMENT\"");
fprintf (Gbl.F.Out,">"); fprintf (Gbl.F.Out,">");
if (SocCom->ComCod <= 0 || if (SocCom->PubCod <= 0 ||
SocCom->NotCod <= 0 || SocCom->NotCod <= 0 ||
SocCom->UsrCod <= 0) SocCom->UsrCod <= 0)
Lay_ShowAlert (Lay_ERROR,"Error in social comment."); Lay_ShowAlert (Lay_ERROR,"Error in social comment.");
@ -2220,7 +2220,7 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
IAmTheAuthor = (Gbl.Usrs.Me.Logged && IAmTheAuthor = (Gbl.Usrs.Me.Logged &&
UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod); UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
if (!IAmTheAuthor) if (!IAmTheAuthor)
IAmAFaverOfThisSocCom = Soc_CheckIfCommIsFavedByUsr (SocCom->ComCod, IAmAFaverOfThisSocCom = Soc_CheckIfCommIsFavedByUsr (SocCom->PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Left: write author's photo *****/ /***** Left: write author's photo *****/
@ -2250,17 +2250,17 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
Soc_PutDisabledIconFav (SocCom->NumFavs); Soc_PutDisabledIconFav (SocCom->NumFavs);
else if (IAmAFaverOfThisSocCom) // I have favourited this social note else if (IAmAFaverOfThisSocCom) // I have favourited this social note
/* Put icon to unfav this publishing */ /* Put icon to unfav this publishing */
Soc_PutFormToUnfavSocialComment (SocCom->ComCod); Soc_PutFormToUnfavSocialComment (SocCom->PubCod);
else // I am not the author and I am not a favouriter else // I am not the author and I am not a favouriter
/* Put icon to mark this social comment as favourite */ /* Put icon to mark this social comment as favourite */
Soc_PutFormToFavSocialComment (SocCom->ComCod); Soc_PutFormToFavSocialComment (SocCom->PubCod);
/* Show who have marked this social comment as favourite */ /* Show who have marked this social comment as favourite */
Soc_ShowUsrsWhoHaveMarkedSocialCommAsFav (SocCom); Soc_ShowUsrsWhoHaveMarkedSocialCommAsFav (SocCom);
/* Put icon to remove this social comment */ /* Put icon to remove this social comment */
if (IAmTheAuthor && !ShowCommentAlone) if (IAmTheAuthor && !ShowCommentAlone)
Soc_PutFormToRemoveComment (SocCom->ComCod); Soc_PutFormToRemoveComment (SocCom->PubCod);
/***** Free memory used for user's data *****/ /***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat); Usr_UsrDataDestructor (&UsrDat);
@ -2311,7 +2311,7 @@ static void Soc_WriteAuthorComment (struct UsrData *UsrDat)
/*****************************************************************************/ /*****************************************************************************/
// All forms in this function and nested functions must have unique identifiers // All forms in this function and nested functions must have unique identifiers
static void Soc_PutFormToRemoveComment (long ComCod) static void Soc_PutFormToRemoveComment (long PubCod)
{ {
extern const char *Txt_Remove; extern const char *Txt_Remove;
@ -2323,7 +2323,7 @@ static void Soc_PutFormToRemoveComment (long ComCod)
} }
else else
Act_FormStartUnique (ActReqRemSocComGbl); Act_FormStartUnique (ActReqRemSocComGbl);
Soc_PutHiddenParamComCod (ComCod); Soc_PutHiddenParamPubCod (PubCod);
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_REMOVE ICON_HIGHLIGHT\">" fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_REMOVE ICON_HIGHLIGHT\">"
"<input type=\"image\"" "<input type=\"image\""
" src=\"%s/remove-on64x64.png\"" " src=\"%s/remove-on64x64.png\""
@ -2341,7 +2341,7 @@ static void Soc_PutFormToRemoveComment (long ComCod)
/*****************************************************************************/ /*****************************************************************************/
// All forms in this function and nested functions must have unique identifiers // All forms in this function and nested functions must have unique identifiers
static void Soc_PutFormToFavSocialComment (long ComCod) static void Soc_PutFormToFavSocialComment (long PubCod)
{ {
extern const char *Txt_Mark_as_favourite; extern const char *Txt_Mark_as_favourite;
@ -2353,7 +2353,7 @@ static void Soc_PutFormToFavSocialComment (long ComCod)
} }
else else
Act_FormStartUnique (ActFavSocComGbl); Act_FormStartUnique (ActFavSocComGbl);
Soc_PutHiddenParamComCod (ComCod); Soc_PutHiddenParamPubCod (PubCod);
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_FAV ICON_HIGHLIGHT\">" fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_FAV ICON_HIGHLIGHT\">"
"<input type=\"image\"" "<input type=\"image\""
" src=\"%s/fav64x64.png\"" " src=\"%s/fav64x64.png\""
@ -2534,7 +2534,7 @@ static void Soc_PutFormToUnfavSocialNote (long NotCod)
/*****************************************************************************/ /*****************************************************************************/
// All forms in this function and nested functions must have unique identifiers // All forms in this function and nested functions must have unique identifiers
static void Soc_PutFormToUnfavSocialComment (long ComCod) static void Soc_PutFormToUnfavSocialComment (long PubCod)
{ {
extern const char *Txt_SOCIAL_NOTE_Favourite; extern const char *Txt_SOCIAL_NOTE_Favourite;
@ -2546,7 +2546,7 @@ static void Soc_PutFormToUnfavSocialComment (long ComCod)
} }
else else
Act_FormStartUnique (ActUnfSocComGbl); Act_FormStartUnique (ActUnfSocComGbl);
Soc_PutHiddenParamComCod (ComCod); Soc_PutHiddenParamPubCod (PubCod);
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_FAV ICON_HIGHLIGHT\">" fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_FAV ICON_HIGHLIGHT\">"
"<input type=\"image\"" "<input type=\"image\""
" src=\"%s/faved64x64.png\"" " src=\"%s/faved64x64.png\""
@ -2598,12 +2598,12 @@ void Soc_PutHiddenParamNotCod (long NotCod)
} }
/*****************************************************************************/ /*****************************************************************************/
/************* Put parameter with the code of a social comment ***************/ /*********** Put parameter with the code of a social publishing **************/
/*****************************************************************************/ /*****************************************************************************/
static void Soc_PutHiddenParamComCod (long ComCod) static void Soc_PutHiddenParamPubCod (long PubCod)
{ {
Par_PutHiddenParamLong ("ComCod",ComCod); Par_PutHiddenParamLong ("PubCod",PubCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2624,20 +2624,20 @@ static long Soc_GetParamNotCod (void)
} }
/*****************************************************************************/ /*****************************************************************************/
/************* Get parameter with the code of a social comment ***************/ /************ Get parameter with the code of a social publishing *************/
/*****************************************************************************/ /*****************************************************************************/
static long Soc_GetParamComCod (void) static long Soc_GetParamPubCod (void)
{ {
char LongStr[1+10+1]; // String that holds the social comment code char LongStr[1+10+1]; // String that holds the code
long ComCod; long PubCod;
/* Get social comment code */ /* Get social comment code */
Par_GetParToText ("ComCod",LongStr,1+10); Par_GetParToText ("PubCod",LongStr,1+10);
if (sscanf (LongStr,"%ld",&ComCod) != 1) if (sscanf (LongStr,"%ld",&PubCod) != 1)
Lay_ShowErrorAndExit ("Wrong code of social comment."); Lay_ShowErrorAndExit ("Wrong code of social publishing.");
return ComCod; return PubCod;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2706,7 +2706,7 @@ static long Soc_ReceiveComment (void)
Soc_PublishSocialNoteInTimeline (&SocPub); // Set SocPub.PubCod Soc_PublishSocialNoteInTimeline (&SocPub); // Set SocPub.PubCod
/* Insert comment content in the database */ /* Insert comment content in the database */
sprintf (Query,"INSERT INTO social_comments (ComCod,Content)" sprintf (Query,"INSERT INTO social_comments (PubCod,Content)"
" VALUES ('%ld','%s')", " VALUES ('%ld','%s')",
SocPub.PubCod, SocPub.PubCod,
Content); Content);
@ -2953,23 +2953,23 @@ static long Soc_FavSocialComment (void)
struct SocialComment SocCom; struct SocialComment SocCom;
char Query[256]; char Query[256];
/***** Get the code of the social note to mark as favourite *****/ /***** Get the code of the social publishing to mark as favourite *****/
SocCom.ComCod = Soc_GetParamComCod (); SocCom.PubCod = Soc_GetParamPubCod ();
/***** Get data of social note *****/ /***** Get data of social note *****/
Soc_GetDataOfSocialComByCod (&SocCom); Soc_GetDataOfSocialComByCod (&SocCom);
if (SocCom.ComCod > 0) if (SocCom.PubCod > 0)
{ {
if (Gbl.Usrs.Me.Logged && if (Gbl.Usrs.Me.Logged &&
SocCom.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author SocCom.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
if (!Soc_CheckIfCommIsFavedByUsr (SocCom.ComCod, if (!Soc_CheckIfCommIsFavedByUsr (SocCom.PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the comment Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the comment
{ {
/***** Mark as favourite in database *****/ /***** Mark as favourite in database *****/
sprintf (Query,"INSERT IGNORE INTO social_comments_fav" sprintf (Query,"INSERT IGNORE INTO social_comments_fav"
" (ComCod,UsrCod,TimeFav) VALUES ('%ld','%ld',NOW())", " (PubCod,UsrCod,TimeFav) VALUES ('%ld','%ld',NOW())",
SocCom.ComCod, SocCom.PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryINSERT (Query,"can not favourite social comment"); DB_QueryINSERT (Query,"can not favourite social comment");
@ -2978,7 +2978,7 @@ static long Soc_FavSocialComment (void)
/**** Create notification about favourite post /**** Create notification about favourite post
for the author of the post ***/ for the author of the post ***/
Soc_CreateFavNotifToAuthor (SocCom.UsrCod,SocCom.ComCod); Soc_CreateFavNotifToAuthor (SocCom.UsrCod,SocCom.PubCod);
/***** Show the social comment just favourited *****/ /***** Show the social comment just favourited *****/
Soc_WriteSocialComment (&SocCom, Soc_WriteSocialComment (&SocCom,
@ -3243,21 +3243,21 @@ static long Soc_UnfavSocialComment (void)
char Query[256]; char Query[256];
/***** Get data of social comment *****/ /***** Get data of social comment *****/
SocCom.ComCod = Soc_GetParamComCod (); SocCom.PubCod = Soc_GetParamPubCod ();
Soc_GetDataOfSocialComByCod (&SocCom); Soc_GetDataOfSocialComByCod (&SocCom);
if (SocCom.ComCod > 0) if (SocCom.PubCod > 0)
{ {
if (SocCom.NumFavs && if (SocCom.NumFavs &&
Gbl.Usrs.Me.Logged && Gbl.Usrs.Me.Logged &&
SocCom.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author SocCom.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
if (Soc_CheckIfCommIsFavedByUsr (SocCom.ComCod, if (Soc_CheckIfCommIsFavedByUsr (SocCom.PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the comment Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the comment
{ {
/***** Delete the mark as favourite from database *****/ /***** Delete the mark as favourite from database *****/
sprintf (Query,"DELETE FROM social_comments_fav" sprintf (Query,"DELETE FROM social_comments_fav"
" WHERE ComCod='%ld' AND UsrCod='%ld'", " WHERE PubCod='%ld' AND UsrCod='%ld'",
SocCom.ComCod, SocCom.PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryDELETE (Query,"can not unfavourite social comment"); DB_QueryDELETE (Query,"can not unfavourite social comment");
@ -3265,7 +3265,7 @@ static long Soc_UnfavSocialComment (void)
SocCom.NumFavs = Soc_GetNumTimesACommHasBeenFav (&SocCom); SocCom.NumFavs = Soc_GetNumTimesACommHasBeenFav (&SocCom);
/***** Mark possible notifications on this social comment as removed *****/ /***** Mark possible notifications on this social comment as removed *****/
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV,SocCom.ComCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV,SocCom.PubCod);
/***** Show the social comment just unfavourited *****/ /***** Show the social comment just unfavourited *****/
Soc_WriteSocialComment (&SocCom, Soc_WriteSocialComment (&SocCom,
@ -3477,7 +3477,7 @@ static void Soc_RemoveASocialNoteFromDB (struct SocialNote *SocNot)
" USING social_pubs,social_comments_fav" " USING social_pubs,social_comments_fav"
" WHERE social_pubs.NotCod='%ld'" " WHERE social_pubs.NotCod='%ld'"
" AND social_pubs.PubType='%u'" " AND social_pubs.PubType='%u'"
" AND social_pubs.PubCod=social_comments_fav.ComCod", " AND social_pubs.PubCod=social_comments_fav.PubCod",
SocNot->NotCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE); SocNot->NotCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE);
DB_QueryDELETE (Query,"can not remove favs for social note"); DB_QueryDELETE (Query,"can not remove favs for social note");
@ -3491,7 +3491,7 @@ static void Soc_RemoveASocialNoteFromDB (struct SocialNote *SocNot)
" USING social_pubs,social_comments" " USING social_pubs,social_comments"
" WHERE social_pubs.NotCod='%ld'" " WHERE social_pubs.NotCod='%ld'"
" AND social_pubs.PubType='%u'" " AND social_pubs.PubType='%u'"
" AND social_pubs.PubCod=social_comments.ComCod", " AND social_pubs.PubCod=social_comments.PubCod",
SocNot->NotCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE); SocNot->NotCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE);
DB_QueryDELETE (Query,"can not remove social comments"); DB_QueryDELETE (Query,"can not remove social comments");
@ -3586,12 +3586,12 @@ static void Soc_RequestRemovalSocialComment (void)
struct SocialComment SocCom; struct SocialComment SocCom;
/***** Get the code of the social comment to remove *****/ /***** Get the code of the social comment to remove *****/
SocCom.ComCod = Soc_GetParamComCod (); SocCom.PubCod = Soc_GetParamPubCod ();
/***** Get data of social comment *****/ /***** Get data of social comment *****/
Soc_GetDataOfSocialComByCod (&SocCom); Soc_GetDataOfSocialComByCod (&SocCom);
if (SocCom.ComCod > 0) if (SocCom.PubCod > 0)
{ {
if (Gbl.Usrs.Me.Logged && if (Gbl.Usrs.Me.Logged &&
SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this comment SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this comment
@ -3614,7 +3614,7 @@ static void Soc_RequestRemovalSocialComment (void)
} }
else else
Act_FormStart (ActRemSocComGbl); Act_FormStart (ActRemSocComGbl);
Soc_PutHiddenParamComCod (SocCom.ComCod); Soc_PutHiddenParamPubCod (SocCom.PubCod);
/* End form */ /* End form */
Lay_PutRemoveButton (Txt_Remove); Lay_PutRemoveButton (Txt_Remove);
@ -3666,12 +3666,12 @@ static void Soc_RemoveSocialComment (void)
struct SocialComment SocCom; struct SocialComment SocCom;
/***** Get the code of the social comment to remove *****/ /***** Get the code of the social comment to remove *****/
SocCom.ComCod = Soc_GetParamComCod (); SocCom.PubCod = Soc_GetParamPubCod ();
/***** Get data of social comment *****/ /***** Get data of social comment *****/
Soc_GetDataOfSocialComByCod (&SocCom); Soc_GetDataOfSocialComByCod (&SocCom);
if (SocCom.ComCod > 0) if (SocCom.PubCod > 0)
{ {
if (Gbl.Usrs.Me.Logged && if (Gbl.Usrs.Me.Logged &&
SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this comment SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this comment
@ -3696,19 +3696,19 @@ static void Soc_RemoveASocialCommentFromDB (struct SocialComment *SocCom)
char Query[128]; char Query[128];
/***** Mark possible notifications on this comment as removed *****/ /***** Mark possible notifications on this comment as removed *****/
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_PUBLISH,SocCom->ComCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_PUBLISH,SocCom->PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_COMMENT,SocCom->ComCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_COMMENT,SocCom->PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,SocCom->ComCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,SocCom->PubCod);
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,SocCom->ComCod); Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,SocCom->PubCod);
/***** Remove favs for this comment *****/ /***** Remove favs for this comment *****/
sprintf (Query,"DELETE FROM social_comments_fav WHERE ComCod='%ld'", sprintf (Query,"DELETE FROM social_comments_fav WHERE PubCod='%ld'",
SocCom->ComCod); SocCom->PubCod);
DB_QueryDELETE (Query,"can not remove favs for social comment"); DB_QueryDELETE (Query,"can not remove favs for social comment");
/***** Remove content of this social comment *****/ /***** Remove content of this social comment *****/
sprintf (Query,"DELETE FROM social_comments WHERE ComCod='%ld'", sprintf (Query,"DELETE FROM social_comments WHERE PubCod='%ld'",
SocCom->ComCod); SocCom->PubCod);
DB_QueryDELETE (Query,"can not remove a social comment"); DB_QueryDELETE (Query,"can not remove a social comment");
/***** Remove this social comment *****/ /***** Remove this social comment *****/
@ -3716,7 +3716,7 @@ static void Soc_RemoveASocialCommentFromDB (struct SocialComment *SocCom)
" WHERE PubCod='%ld'" " WHERE PubCod='%ld'"
" AND PublisherCod='%ld'" // Extra check: I am the author " AND PublisherCod='%ld'" // Extra check: I am the author
" AND PubType='%u'", // Extra check: it's a comment " AND PubType='%u'", // Extra check: it's a comment
SocCom->ComCod, SocCom->PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Soc_PUB_COMMENT_TO_NOTE); (unsigned) Soc_PUB_COMMENT_TO_NOTE);
DB_QueryDELETE (Query,"can not remove a social comment"); DB_QueryDELETE (Query,"can not remove a social comment");
@ -3744,7 +3744,7 @@ void Soc_RemoveUsrSocialContent (long UsrCod)
" USING social_pubs,social_comments_fav" " USING social_pubs,social_comments_fav"
" WHERE social_pubs.PublisherCod='%ld'" // Author of the comment " WHERE social_pubs.PublisherCod='%ld'" // Author of the comment
" AND social_pubs.PubType='%u'" " AND social_pubs.PubType='%u'"
" AND social_pubs.PubCod=social_comments_fav.ComCod", " AND social_pubs.PubCod=social_comments_fav.PubCod",
UsrCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE); UsrCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE);
DB_QueryDELETE (Query,"can not remove favs"); DB_QueryDELETE (Query,"can not remove favs");
@ -3754,7 +3754,7 @@ void Soc_RemoveUsrSocialContent (long UsrCod)
" WHERE social_notes.UsrCod='%ld'" // Author of the note " WHERE social_notes.UsrCod='%ld'" // Author of the note
" AND social_notes.NotCod=social_pubs.NotCod" " AND social_notes.NotCod=social_pubs.NotCod"
" AND social_pubs.PubType='%u'" " AND social_pubs.PubType='%u'"
" AND social_pubs.PubCod=social_comments_fav.ComCod", " AND social_pubs.PubCod=social_comments_fav.PubCod",
UsrCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE); UsrCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE);
DB_QueryDELETE (Query,"can not remove social comments"); DB_QueryDELETE (Query,"can not remove social comments");
@ -3779,7 +3779,7 @@ void Soc_RemoveUsrSocialContent (long UsrCod)
" WHERE social_notes.UsrCod='%ld'" " WHERE social_notes.UsrCod='%ld'"
" AND social_notes.NotCod=social_pubs.NotCod" " AND social_notes.NotCod=social_pubs.NotCod"
" AND social_pubs.PubType='%u'" " AND social_pubs.PubType='%u'"
" AND social_pubs.PubCod=social_comments.ComCod", " AND social_pubs.PubCod=social_comments.PubCod",
UsrCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE); UsrCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE);
DB_QueryDELETE (Query,"can not remove social comments"); DB_QueryDELETE (Query,"can not remove social comments");
@ -3797,7 +3797,7 @@ void Soc_RemoveUsrSocialContent (long UsrCod)
" USING social_pubs,social_comments" " USING social_pubs,social_comments"
" WHERE social_pubs.PublisherCod='%ld'" " WHERE social_pubs.PublisherCod='%ld'"
" AND social_pubs.PubType='%u'" " AND social_pubs.PubType='%u'"
" AND social_pubs.PubCod=social_comments.ComCod", " AND social_pubs.PubCod=social_comments.PubCod",
UsrCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE); UsrCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE);
DB_QueryDELETE (Query,"can not remove social comments"); DB_QueryDELETE (Query,"can not remove social comments");
@ -3860,13 +3860,13 @@ static bool Soc_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod)
/************* Check if a user has favourited a social comment ***************/ /************* Check if a user has favourited a social comment ***************/
/*****************************************************************************/ /*****************************************************************************/
static bool Soc_CheckIfCommIsFavedByUsr (long ComCod,long UsrCod) static bool Soc_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod)
{ {
char Query[256]; char Query[256];
sprintf (Query,"SELECT COUNT(*) FROM social_comments_fav" sprintf (Query,"SELECT COUNT(*) FROM social_comments_fav"
" WHERE ComCod='%ld' AND UsrCod='%ld'", " WHERE PubCod='%ld' AND UsrCod='%ld'",
ComCod,UsrCod); PubCod,UsrCod);
return (DB_QueryCOUNT (Query,"can not check if a user has favourited a social comment") != 0); return (DB_QueryCOUNT (Query,"can not check if a user has favourited a social comment") != 0);
} }
@ -3916,9 +3916,9 @@ static unsigned Soc_GetNumTimesACommHasBeenFav (struct SocialComment *SocCom)
/***** Get number of times (users) this comment has been favourited *****/ /***** Get number of times (users) this comment has been favourited *****/
sprintf (Query,"SELECT COUNT(*) FROM social_comments_fav" sprintf (Query,"SELECT COUNT(*) FROM social_comments_fav"
" WHERE ComCod='%ld'" " WHERE PubCod='%ld'"
" AND UsrCod<>'%ld'", // Extra check " AND UsrCod<>'%ld'", // Extra check
SocCom->ComCod, SocCom->PubCod,
SocCom->UsrCod); // The author SocCom->UsrCod); // The author
return (unsigned) DB_QueryCOUNT (Query,"can not get number of times a comment has been favourited"); return (unsigned) DB_QueryCOUNT (Query,"can not get number of times a comment has been favourited");
} }
@ -3973,10 +3973,10 @@ static void Soc_ShowUsrsWhoHaveMarkedSocialCommAsFav (const struct SocialComment
/***** Get users who have marked this comment as favourite *****/ /***** Get users who have marked this comment as favourite *****/
sprintf (Query,"SELECT UsrCod FROM social_comments_fav" sprintf (Query,"SELECT UsrCod FROM social_comments_fav"
" WHERE ComCod='%ld'" " WHERE PubCod='%ld'"
" AND UsrCod<>'%ld'" // Extra check " AND UsrCod<>'%ld'" // Extra check
" ORDER BY FavCod LIMIT %u", " ORDER BY FavCod LIMIT %u",
SocCom->ComCod, SocCom->PubCod,
SocCom->UsrCod, SocCom->UsrCod,
Soc_MAX_SHARERS_FAVERS_SHOWN); Soc_MAX_SHARERS_FAVERS_SHOWN);
Soc_ShowSharersOrFavers (SocCom->NumFavs,Query); Soc_ShowSharersOrFavers (SocCom->NumFavs,Query);
@ -4100,7 +4100,7 @@ static void Soc_GetDataOfSocialComByCod (struct SocialComment *SocCom)
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
if (SocCom->ComCod > 0) if (SocCom->PubCod > 0)
{ {
/***** Get data of social comment from database *****/ /***** Get data of social comment from database *****/
sprintf (Query,"SELECT social_pubs.PubCod,social_pubs.PublisherCod," sprintf (Query,"SELECT social_pubs.PubCod,social_pubs.PublisherCod,"
@ -4110,8 +4110,8 @@ static void Soc_GetDataOfSocialComByCod (struct SocialComment *SocCom)
" FROM social_pubs,social_comments" " FROM social_pubs,social_comments"
" WHERE social_pubs.PubCod='%ld'" " WHERE social_pubs.PubCod='%ld'"
" AND social_pubs.PubType='%u'" " AND social_pubs.PubType='%u'"
" AND social_pubs.PubCod=social_comments.ComCod", " AND social_pubs.PubCod=social_comments.PubCod",
SocCom->ComCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE); SocCom->PubCod,(unsigned) Soc_PUB_COMMENT_TO_NOTE);
if (DB_QuerySELECT (Query,&mysql_res,"can not get data of social comment")) if (DB_QuerySELECT (Query,&mysql_res,"can not get data of social comment"))
{ {
/***** Get data of social comment *****/ /***** Get data of social comment *****/
@ -4236,7 +4236,7 @@ static Soc_NoteType_t Soc_GetNoteTypeFromStr (const char *Str)
static void Soc_GetDataOfSocialCommentFromRow (MYSQL_ROW row,struct SocialComment *SocCom) static void Soc_GetDataOfSocialCommentFromRow (MYSQL_ROW row,struct SocialComment *SocCom)
{ {
/***** Get code of social comment (row[0]) *****/ /***** Get code of social comment (row[0]) *****/
SocCom->ComCod = Str_ConvertStrCodToLongCod (row[0]); SocCom->PubCod = Str_ConvertStrCodToLongCod (row[0]);
/***** Get (from) user code (row[1]) *****/ /***** Get (from) user code (row[1]) *****/
SocCom->UsrCod = Str_ConvertStrCodToLongCod (row[1]); SocCom->UsrCod = Str_ConvertStrCodToLongCod (row[1]);
@ -4277,7 +4277,7 @@ static void Soc_ResetSocialNote (struct SocialNote *SocNot)
static void Soc_ResetSocialComment (struct SocialComment *SocCom) static void Soc_ResetSocialComment (struct SocialComment *SocCom)
{ {
SocCom->ComCod = -1L; SocCom->PubCod = -1L;
SocCom->UsrCod = -1L; SocCom->UsrCod = -1L;
SocCom->NotCod = -1L; SocCom->NotCod = -1L;
SocCom->DateTimeUTC = (time_t) 0; SocCom->DateTimeUTC = (time_t) 0;
@ -4417,7 +4417,7 @@ void Soc_GetNotifSocialPublishing (char *SummaryStr,char **ContentStr,long PubCo
case Soc_PUB_COMMENT_TO_NOTE: case Soc_PUB_COMMENT_TO_NOTE:
/***** Get content of social post from database *****/ /***** Get content of social post from database *****/
sprintf (Query,"SELECT Content FROM social_comments" sprintf (Query,"SELECT Content FROM social_comments"
" WHERE ComCod='%ld'", " WHERE PubCod='%ld'",
SocPub.PubCod); 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 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
{ {