swad-core/swad_social.c

2585 lines
88 KiB
C
Raw Normal View History

2015-12-31 14:25:28 +01:00
// swad_social.c: social networking (timeline)
2015-12-28 19:23:42 +01:00
/*
SWAD (Shared Workspace At a Distance),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
2016-01-01 20:19:43 +01:00
Copyright (C) 1999-2016 Antonio Ca<EFBFBD>as Vargas
2015-12-28 19:23:42 +01:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/*********************************** Headers *********************************/
/*****************************************************************************/
#include <linux/limits.h> // For PATH_MAX
2015-12-28 20:46:48 +01:00
#include <stdlib.h> // For malloc and free
2015-12-29 23:44:28 +01:00
#include <string.h> // For string functions
2015-12-28 19:23:42 +01:00
#include <sys/types.h> // For time_t
#include "swad_constant.h"
#include "swad_database.h"
2015-12-29 02:09:50 +01:00
#include "swad_exam.h"
2015-12-29 14:24:37 +01:00
#include "swad_follow.h"
2015-12-28 19:23:42 +01:00
#include "swad_global.h"
#include "swad_layout.h"
2015-12-29 01:28:17 +01:00
#include "swad_notice.h"
2015-12-29 22:29:51 +01:00
#include "swad_parameter.h"
2016-01-02 01:56:48 +01:00
#include "swad_profile.h"
2015-12-28 19:23:42 +01:00
#include "swad_social.h"
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
2015-12-29 01:28:17 +01:00
#define Soc_MAX_BYTES_SUMMARY 100
2016-01-01 20:35:43 +01:00
#define Soc_NUM_PUBS_IN_TIMELINE 100
2016-01-02 15:09:08 +01:00
#define Soc_WIDTH_TIMELINE "560px"
2016-01-04 14:49:10 +01:00
#define Soc_MAX_NUM_SHARERS_SHOWN 10 // Maximum number of users shown who have share a social note
2015-12-28 19:23:42 +01:00
2015-12-31 14:25:28 +01:00
static const Act_Action_t Soc_DefaultActions[Soc_NUM_SOCIAL_NOTES] =
2015-12-29 13:18:25 +01:00
{
2015-12-31 14:25:28 +01:00
ActUnk, // Soc_NOTE_UNKNOWN
2015-12-29 13:18:25 +01:00
/* Institution tab */
2016-01-03 01:13:57 +01:00
ActReqDatSeeDocIns, // Soc_NOTE_INS_DOC_PUB_FILE
ActReqDatShaIns, // Soc_NOTE_INS_SHA_PUB_FILE
2015-12-29 13:18:25 +01:00
/* Centre tab */
2016-01-03 01:13:57 +01:00
ActReqDatSeeDocCtr, // Soc_NOTE_CTR_DOC_PUB_FILE
ActReqDatShaCtr, // Soc_NOTE_CTR_SHA_PUB_FILE
2015-12-29 13:18:25 +01:00
/* Degree tab */
2016-01-03 01:13:57 +01:00
ActReqDatSeeDocDeg, // Soc_NOTE_DEG_DOC_PUB_FILE
ActReqDatShaDeg, // Soc_NOTE_DEG_SHA_PUB_FILE
2015-12-29 13:18:25 +01:00
/* Course tab */
2016-01-03 01:13:57 +01:00
ActReqDatSeeDocCrs, // Soc_NOTE_CRS_DOC_PUB_FILE
ActReqDatShaCrs, // Soc_NOTE_CRS_SHA_PUB_FILE
2015-12-29 13:18:25 +01:00
/* Assessment tab */
2015-12-31 14:25:28 +01:00
ActSeeExaAnn, // Soc_NOTE_EXAM_ANNOUNCEMENT
2015-12-29 13:18:25 +01:00
/* Users tab */
/* Social tab */
2016-01-02 14:36:34 +01:00
ActUnk, // Soc_NOTE_SOCIAL_POST (action not used)
2015-12-31 14:25:28 +01:00
ActSeeFor, // Soc_NOTE_FORUM_POST
2015-12-29 13:18:25 +01:00
/* Messages tab */
2015-12-31 14:25:28 +01:00
ActShoNot, // Soc_NOTE_NOTICE
2015-12-29 13:18:25 +01:00
/* Statistics tab */
/* Profile tab */
};
2015-12-28 19:23:42 +01:00
/*****************************************************************************/
/****************************** Internal types *******************************/
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
struct SocialPublishing
{
long PubCod;
long NotCod;
2016-01-04 14:49:10 +01:00
long PublisherCod;
long AuthorCod;
2015-12-31 18:40:45 +01:00
time_t DateTimeUTC;
};
2015-12-31 14:25:28 +01:00
struct SocialNote
2015-12-30 12:40:13 +01:00
{
2015-12-31 14:47:22 +01:00
long NotCod;
2015-12-31 18:40:45 +01:00
Soc_NoteType_t NoteType;
2016-01-04 02:54:04 +01:00
long UsrCod; // TODO: Rename as AuthorCod here and in database?
2016-01-03 17:34:06 +01:00
long HieCod; // Hierarchy code (institution/centre/degree/course)
long Cod; // Code of file, forum post, notice,...
bool Unavailable; // File, forum post, notice,... unavailable (removed)
2015-12-30 12:40:13 +01:00
time_t DateTimeUTC;
2016-01-04 16:10:27 +01:00
unsigned NumShared; // Number of times (users) this note has been shared
2015-12-30 12:40:13 +01:00
};
2016-01-08 01:53:37 +01:00
struct SocialComment
{
long ComCod;
long UsrCod; // TODO: Rename as AuthorCod here and in database?
long NotCod; // Note code
time_t DateTimeUTC;
char Content[Cns_MAX_BYTES_LONG_TEXT];
};
2015-12-28 19:23:42 +01:00
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/************************* Internal global variables *************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
2016-01-04 13:20:47 +01:00
static void Soc_ShowTimeline (const char *Query,Act_Action_t UpdateAction,
const char *Title);
2015-12-31 18:40:45 +01:00
static void Soc_GetDataOfSocialPublishingFromRow (MYSQL_ROW row,struct SocialPublishing *SocPub);
static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub,
2016-01-05 21:30:10 +01:00
const struct SocialNote *SocNot,
bool ShowAlone,
bool LastInList);
2016-01-08 01:53:37 +01:00
static void Soc_WriteDateTime (time_t TimeUTC);
2016-01-02 01:56:48 +01:00
static void Soc_GetAndWriteSocialPost (long PstCod);
2016-01-04 10:27:32 +01:00
static void Soc_PutFormGoToAction (const struct SocialNote *SocNot);
2015-12-31 18:40:45 +01:00
static void Soc_GetNoteSummary (const struct SocialNote *SocNot,
2015-12-31 14:25:28 +01:00
char *SummaryStr,unsigned MaxChars);
2016-01-01 20:19:43 +01:00
static void Soc_PublishSocialNoteInTimeline (struct SocialPublishing *SocPub);
2015-12-28 19:23:42 +01:00
2016-01-02 01:56:48 +01:00
static void Soc_PutLinkToWriteANewPost (Act_Action_t Action,void (*FuncParams) ());
static void Soc_FormSocialPost (void);
static void Soc_ReceiveSocialPost (void);
2015-12-30 12:40:13 +01:00
2016-01-07 00:42:35 +01:00
static void Soc_PutFormToCommentSocialNote (long NotCod);
2016-01-08 02:55:18 +01:00
static unsigned long Soc_GetNumCommentsInSocialNote (long NotCod);
2016-01-07 16:45:35 +01:00
static void Soc_WriteCommentsInSocialNote (long NotCod);
2016-01-08 02:55:18 +01:00
static void Soc_WriteSocialComment (struct SocialComment *SocCom,
bool ShowAlone);
2016-01-08 01:53:37 +01:00
static void Soc_PutFormToRemoveComment (long ComCod);
2016-01-07 11:31:36 +01:00
static void Soc_PutHiddenFormToSendCommentToASocialNote (long NotCod);
2016-01-05 21:30:10 +01:00
static void Soc_PutDisabledIconShare (unsigned NumShared);
static void Soc_PutFormToShareSocialNote (long NotCod);
2016-01-01 20:19:43 +01:00
static void Soc_PutFormToUnshareSocialPublishing (long PubCod);
2015-12-31 18:40:45 +01:00
static void Soc_PutFormToRemoveSocialPublishing (long PubCod);
2016-01-08 01:53:37 +01:00
2016-01-05 21:30:10 +01:00
static void Soc_PutHiddenParamNotCod (long NotCod);
2016-01-04 02:54:04 +01:00
static void Soc_PutHiddenParamPubCod (long PubCod);
2016-01-08 01:53:37 +01:00
static void Soc_PutHiddenParamComCod (long ComCod);
2016-01-05 21:30:10 +01:00
static long Soc_GetParamNotCod (void);
2015-12-31 18:40:45 +01:00
static long Soc_GetParamPubCod (void);
2016-01-08 01:53:37 +01:00
static long Soc_GetParamComCod (void);
2016-01-01 20:19:43 +01:00
2016-01-07 14:21:21 +01:00
static void Soc_ReceiveComment (void);
2016-01-04 02:54:04 +01:00
static void Soc_ShareSocialNote (void);
2016-01-02 01:56:48 +01:00
static void Soc_UnshareSocialPublishing (void);
2016-01-05 04:54:00 +01:00
static void Soc_UnshareASocialPublishingFromDB (struct SocialNote *SocNot);
2016-01-02 01:56:48 +01:00
2016-01-08 01:53:37 +01:00
static void Soc_RequestRemovalSocialNote (void);
2016-01-07 00:42:35 +01:00
static void Soc_RemoveSocialNote (void);
2016-01-08 01:53:37 +01:00
static void Soc_RemoveASocialNoteFromDB (struct SocialNote *SocNot);
static void Soc_RequestRemovalSocialComment (void);
static void Soc_RemoveSocialComment (void);
static void Soc_RemoveASocialCommentFromDB (struct SocialComment *SocCom);
2016-01-01 20:19:43 +01:00
2016-01-04 17:36:28 +01:00
static bool Soc_CheckIfNoteIsPublishedInTimelineByUsr (long NotCod,long UsrCod);
2016-01-05 21:30:10 +01:00
static void Soc_UpdateNumTimesANoteHasBeenShared (struct SocialNote *SocNot);
2016-01-04 14:49:10 +01:00
static void Soc_ShowUsrsWhoHaveSharedSocialNote (const struct SocialNote *SocNot);
2016-01-08 01:53:37 +01:00
2015-12-31 18:40:45 +01:00
static void Soc_GetDataOfSocialPublishingByCod (struct SocialPublishing *SocPub);
static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *SocNot);
2016-01-08 01:53:37 +01:00
static void Soc_GetDataOfSocialCommentByCod (struct SocialComment *SocCom);
static void Soc_GetDataOfSocialPublishingFromRow (MYSQL_ROW row,struct SocialPublishing *SocPub);
2015-12-31 18:40:45 +01:00
static void Soc_GetDataOfSocialNoteFromRow (MYSQL_ROW row,struct SocialNote *SocNot);
2016-01-04 11:58:36 +01:00
static Soc_NoteType_t Soc_GetNoteTypeFromStr (const char *Str);
2016-01-08 01:53:37 +01:00
static void Soc_GetDataOfSocialCommentFromRow (MYSQL_ROW row,struct SocialComment *SocCom);
2016-01-05 04:54:00 +01:00
static void Soc_ResetSocialPublishing (struct SocialPublishing *SocPub);
static void Soc_ResetSocialNote (struct SocialNote *SocNot);
2016-01-08 01:53:37 +01:00
static void Soc_ResetSocialComment (struct SocialComment *SocCom);
2015-12-29 23:44:28 +01:00
2015-12-29 14:24:37 +01:00
/*****************************************************************************/
/*********** Show social activity (timeline) of a selected user **************/
/*****************************************************************************/
2016-01-02 01:56:48 +01:00
void Soc_ShowTimelineUsr (void)
2015-12-29 14:24:37 +01:00
{
2016-01-04 13:20:47 +01:00
extern const char *Txt_Public_activity_OF_A_USER;
2015-12-29 14:24:37 +01:00
char Query[512];
2016-01-01 21:42:04 +01:00
/***** Link to write a new social post (public comment) *****/
2016-01-02 01:56:48 +01:00
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod && // It's me
Gbl.CurrentAct != ActReqSocPstUsr) // Not writing a new post
Soc_PutLinkToWriteANewPost (ActReqSocPstUsr,Usr_PutParamOtherUsrCodEncrypted);
2016-01-01 21:42:04 +01:00
2015-12-31 18:40:45 +01:00
/***** Build query to show timeline with publishing of a unique user *****/
2016-01-04 14:49:10 +01:00
sprintf (Query,"SELECT PubCod,NotCod,PublisherCod,AuthorCod,UNIX_TIMESTAMP(TimePublish)"
2015-12-31 18:40:45 +01:00
" FROM social_timeline"
" WHERE PublisherCod='%ld'"
2016-01-01 20:35:43 +01:00
" ORDER BY PubCod DESC LIMIT %u",
2016-01-02 01:56:48 +01:00
Gbl.Usrs.Other.UsrDat.UsrCod,
2016-01-01 20:35:43 +01:00
Soc_NUM_PUBS_IN_TIMELINE);
2015-12-29 14:24:37 +01:00
/***** Show timeline *****/
2016-01-04 13:20:47 +01:00
sprintf (Gbl.Title,Txt_Public_activity_OF_A_USER,Gbl.Usrs.Other.UsrDat.FirstName);
Soc_ShowTimeline (Query,ActSeePubPrf,Gbl.Title);
2015-12-29 14:24:37 +01:00
}
/*****************************************************************************/
/***** Show social activity (timeline) including all the users I follow ******/
/*****************************************************************************/
2016-01-02 01:56:48 +01:00
void Soc_ShowTimelineGbl (void)
2015-12-29 14:24:37 +01:00
{
2016-01-04 13:20:47 +01:00
extern const char *Txt_Public_activity;
2016-01-01 21:18:44 +01:00
extern const char *Txt_You_dont_follow_any_user;
2015-12-29 14:24:37 +01:00
char Query[512];
2015-12-31 14:25:28 +01:00
/***** Link to write a new social post (public comment) *****/
2016-01-02 01:56:48 +01:00
if (Gbl.CurrentAct != ActReqSocPstGbl) // Not writing a new post
Soc_PutLinkToWriteANewPost (ActReqSocPstGbl,NULL);
2015-12-30 00:58:25 +01:00
2016-01-01 21:18:44 +01:00
/***** If I follow someone... *****/
if (Fol_GetNumFollowing (Gbl.Usrs.Me.UsrDat.UsrCod))
{
/***** Create temporary table with publishing codes *****/
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS pub_cods");
if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not remove temporary tables");
sprintf (Query,"CREATE TEMPORARY TABLE pub_cods (PubCod BIGINT NOT NULL,UNIQUE INDEX(PubCod)) ENGINE=MEMORY"
" SELECT MIN(PubCod) AS PubCod"
" FROM social_timeline"
" WHERE PublisherCod IN"
" (SELECT '%ld'"
" UNION"
" SELECT FollowedCod FROM usr_follow WHERE FollowerCod='%ld')"
" GROUP BY NotCod"
" ORDER BY PubCod DESC LIMIT %u",
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
Soc_NUM_PUBS_IN_TIMELINE);
if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not create temporary table");
/***** Build query to show timeline including the users I am following *****/
2016-01-04 14:49:10 +01:00
sprintf (Query,"SELECT PubCod,NotCod,PublisherCod,AuthorCod,UNIX_TIMESTAMP(TimePublish)"
2016-01-01 21:18:44 +01:00
" FROM social_timeline WHERE PubCod IN "
"(SELECT PubCod FROM pub_cods)"
" ORDER BY PubCod DESC");
/***** Show timeline *****/
2016-01-04 13:20:47 +01:00
Soc_ShowTimeline (Query,ActSeeSocTmlGbl,Txt_Public_activity);
2016-01-01 21:18:44 +01:00
/***** Drop temporary table with publishing codes *****/
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS pub_cods");
if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not remove temporary tables");
}
else // I do not follow anyone
/***** Show warning if I do not follow anyone *****/
Lay_ShowAlert (Lay_INFO,Txt_You_dont_follow_any_user);
2015-12-29 14:24:37 +01:00
}
2015-12-28 19:23:42 +01:00
/*****************************************************************************/
/*********************** Show social activity (timeline) *********************/
/*****************************************************************************/
2016-01-04 13:20:47 +01:00
static void Soc_ShowTimeline (const char *Query,Act_Action_t UpdateAction,
const char *Title)
2015-12-28 19:23:42 +01:00
{
2016-01-02 02:49:21 +01:00
extern const char *The_ClassFormBold[The_NUM_THEMES];
extern const char *Txt_Update;
2016-01-01 21:18:44 +01:00
extern const char *Txt_No_public_activity;
2015-12-28 19:23:42 +01:00
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2015-12-31 18:40:45 +01:00
unsigned long NumPublishings;
unsigned long NumPub;
struct SocialPublishing SocPub;
struct SocialNote SocNot;
2015-12-28 19:23:42 +01:00
2015-12-29 14:24:37 +01:00
/***** Get timeline from database *****/
2015-12-31 18:40:45 +01:00
NumPublishings = DB_QuerySELECT (Query,&mysql_res,"can not get social notes");
2015-12-28 19:23:42 +01:00
/***** List my timeline *****/
2015-12-31 18:40:45 +01:00
if (NumPublishings) // Publishings found in timeline
2015-12-28 19:23:42 +01:00
{
2015-12-30 18:36:10 +01:00
/***** Start frame *****/
2016-01-04 13:20:47 +01:00
Lay_StartRoundFrame (Soc_WIDTH_TIMELINE,Title);
2015-12-30 18:36:10 +01:00
/***** Form to update timeline *****/
2016-01-02 02:49:21 +01:00
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
Act_FormStartAnchor (UpdateAction,"timeline");
Usr_PutParamOtherUsrCodEncrypted ();
}
else
Act_FormStart (UpdateAction);
Act_LinkFormSubmitAnimated (Txt_Update,The_ClassFormBold[Gbl.Prefs.Theme]);
Lay_PutCalculateIconWithText (Txt_Update,Txt_Update);
Act_FormEnd ();
fprintf (Gbl.F.Out,"</div>");
2015-12-30 18:36:10 +01:00
/***** Start list *****/
2015-12-28 20:46:48 +01:00
fprintf (Gbl.F.Out,"<ul class=\"LIST_LEFT\">");
2015-12-28 19:23:42 +01:00
2015-12-31 18:40:45 +01:00
/***** List publishings in timeline one by one *****/
for (NumPub = 0;
NumPub < NumPublishings;
NumPub++)
2015-12-28 19:23:42 +01:00
{
2016-01-05 04:54:00 +01:00
/* Get data of social publishing */
2015-12-28 19:23:42 +01:00
row = mysql_fetch_row (mysql_res);
2015-12-31 18:40:45 +01:00
Soc_GetDataOfSocialPublishingFromRow (row,&SocPub);
2015-12-28 19:23:42 +01:00
2016-01-05 04:54:00 +01:00
/* Get data of social note */
SocNot.NotCod = SocPub.NotCod;
Soc_GetDataOfSocialNoteByCod (&SocNot);
/* Write social note */
2016-01-05 21:30:10 +01:00
Soc_WriteSocialNote (&SocPub,&SocNot,false,NumPub == NumPublishings - 1);
2015-12-28 19:23:42 +01:00
}
2015-12-30 18:36:10 +01:00
/***** End list *****/
2015-12-28 19:23:42 +01:00
fprintf (Gbl.F.Out,"</ul>");
2015-12-30 18:36:10 +01:00
/***** End frame *****/
2015-12-28 19:23:42 +01:00
Lay_EndRoundFrame ();
}
2016-01-01 21:18:44 +01:00
else // No publishing found in timeline
Lay_ShowAlert (Lay_INFO,Txt_No_public_activity);
2015-12-28 19:23:42 +01:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
2015-12-30 16:33:36 +01:00
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
/***************************** Write social note *****************************/
2015-12-30 16:33:36 +01:00
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub,
2016-01-05 21:30:10 +01:00
const struct SocialNote *SocNot,
bool ShowAlone, // Social note is shown alone, not in a list
bool LastInList) // Social note is shown in a list and it's the last one
2015-12-30 16:33:36 +01:00
{
extern const char *Txt_Forum;
extern const char *Txt_Course;
extern const char *Txt_Degree;
extern const char *Txt_Centre;
extern const char *Txt_Institution;
2016-01-02 14:56:38 +01:00
struct UsrData UsrDat;
2016-01-05 04:54:00 +01:00
bool IAmTheAuthor = false;
bool IAmAPublisherOfThisSocNot = false;
2015-12-30 16:33:36 +01:00
struct Institution Ins;
struct Centre Ctr;
struct Degree Deg;
struct Course Crs;
bool ShowPhoto = false;
char PhotoURL[PATH_MAX+1];
char ForumName[512];
char SummaryStr[Cns_MAX_BYTES_TEXT+1];
2016-01-08 02:55:18 +01:00
unsigned NumComments;
2015-12-30 16:33:36 +01:00
2016-01-05 21:30:10 +01:00
if (ShowAlone)
{
Lay_StartRoundFrame (Soc_WIDTH_TIMELINE,NULL);
fprintf (Gbl.F.Out,"<ul class=\"LIST_LEFT\">");
}
2015-12-30 16:33:36 +01:00
/***** Start list item *****/
2016-01-02 14:56:38 +01:00
fprintf (Gbl.F.Out,"<li");
2016-01-05 21:30:10 +01:00
if (!(ShowAlone || LastInList))
2016-01-02 14:56:38 +01:00
fprintf (Gbl.F.Out," class=\"SOCIAL_PUB\"");
fprintf (Gbl.F.Out,">");
2015-12-30 16:33:36 +01:00
2016-01-05 04:54:00 +01:00
if (SocPub->PubCod <= 0 ||
SocPub->NotCod <= 0 ||
SocPub->PublisherCod <= 0 ||
SocPub->AuthorCod <= 0 ||
SocNot->NoteType == Soc_NOTE_UNKNOWN ||
SocNot->UsrCod <= 0)
Lay_ShowAlert (Lay_ERROR,"Error in social note.");
else
{
/***** Initialize location in hierarchy *****/
Ins.InsCod = -1L;
Ctr.CtrCod = -1L;
Deg.DegCod = -1L;
Crs.CrsCod = -1L;
/***** Get author data *****/
Usr_UsrDataConstructor (&UsrDat);
UsrDat.UsrCod = SocNot->UsrCod;
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat);
if (Gbl.Usrs.Me.Logged)
{
IAmTheAuthor = (UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
IAmAPublisherOfThisSocNot = Soc_CheckIfNoteIsPublishedInTimelineByUsr (SocNot->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
}
2015-12-30 16:33:36 +01:00
2016-01-05 04:54:00 +01:00
/***** Left: write author's photo *****/
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_LEFT_PHOTO\">");
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (&UsrDat,PhotoURL);
Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL :
NULL,
2016-01-07 21:21:33 +01:00
"PHOTO45x60",Pho_ZOOM);
2016-01-05 04:54:00 +01:00
fprintf (Gbl.F.Out,"</div>");
2015-12-30 16:33:36 +01:00
2016-01-05 04:54:00 +01:00
/***** Right: author's name, time, summary and buttons *****/
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_RIGHT_CONTAINER\">");
2015-12-30 16:33:36 +01:00
2016-01-05 04:54:00 +01:00
/* Write author's full name and nickname */
2016-01-07 21:21:33 +01:00
Str_LimitLengthHTMLStr (UsrDat.FullName,16);
2016-01-05 04:54:00 +01:00
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_RIGHT_AUTHOR\">"
"<span class=\"DAT_N_BOLD\">%s</span>"
"<span class=\"DAT_LIGHT\"> @%s</span>"
"</div>",
UsrDat.FullName,UsrDat.Nickname);
2015-12-30 16:33:36 +01:00
2016-01-05 04:54:00 +01:00
/* Write date and time */
2016-01-08 01:53:37 +01:00
Soc_WriteDateTime (SocNot->DateTimeUTC);
2016-01-02 17:07:58 +01:00
2016-01-05 04:54:00 +01:00
/* Write content of the note */
if (SocNot->NoteType == Soc_NOTE_SOCIAL_POST)
{
/* Write post content */
fprintf (Gbl.F.Out,"<div class=\"DAT\">");
Soc_GetAndWriteSocialPost (SocNot->Cod);
fprintf (Gbl.F.Out,"</div>");
}
else
{
/* Get location in hierarchy */
if (!SocNot->Unavailable)
switch (SocNot->NoteType)
{
case Soc_NOTE_INS_DOC_PUB_FILE:
case Soc_NOTE_INS_SHA_PUB_FILE:
/* Get institution data */
Ins.InsCod = SocNot->HieCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
break;
case Soc_NOTE_CTR_DOC_PUB_FILE:
case Soc_NOTE_CTR_SHA_PUB_FILE:
/* Get centre data */
Ctr.CtrCod = SocNot->HieCod;
Ctr_GetDataOfCentreByCod (&Ctr);
break;
case Soc_NOTE_DEG_DOC_PUB_FILE:
case Soc_NOTE_DEG_SHA_PUB_FILE:
/* Get degree data */
Deg.DegCod = SocNot->HieCod;
Deg_GetDataOfDegreeByCod (&Deg);
break;
case Soc_NOTE_CRS_DOC_PUB_FILE:
case Soc_NOTE_CRS_SHA_PUB_FILE:
case Soc_NOTE_EXAM_ANNOUNCEMENT:
case Soc_NOTE_NOTICE:
/* Get course data */
Crs.CrsCod = SocNot->HieCod;
Crs_GetDataOfCourseByCod (&Crs);
break;
case Soc_NOTE_FORUM_POST:
/* Get forum type of the post */
Gbl.Forum.ForumType = For_GetForumTypeOfAPost (SocNot->Cod);
For_SetForumName (Gbl.Forum.ForumType,
&Ins,
&Ctr,
&Deg,
&Crs,
ForumName,Gbl.Prefs.Language,false); // Set forum name in recipient's language
Gbl.Forum.Ins.InsCod = Ins.InsCod;
Gbl.Forum.Ctr.CtrCod = Ctr.CtrCod;
Gbl.Forum.Deg.DegCod = Deg.DegCod;
Gbl.Forum.Crs.CrsCod = Crs.CrsCod;
break;
default:
break;
}
/* Write note type */
fprintf (Gbl.F.Out,"<div>");
Soc_PutFormGoToAction (SocNot);
fprintf (Gbl.F.Out,"</div>");
/* Write location in hierarchy */
if (!SocNot->Unavailable)
switch (SocNot->NoteType)
{
case Soc_NOTE_INS_DOC_PUB_FILE:
case Soc_NOTE_INS_SHA_PUB_FILE:
/* Write location (institution) in hierarchy */
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
Txt_Institution,Ins.ShortName);
break;
case Soc_NOTE_CTR_DOC_PUB_FILE:
case Soc_NOTE_CTR_SHA_PUB_FILE:
/* Write location (centre) in hierarchy */
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
Txt_Centre,Ctr.ShortName);
break;
case Soc_NOTE_DEG_DOC_PUB_FILE:
case Soc_NOTE_DEG_SHA_PUB_FILE:
/* Write location (degree) in hierarchy */
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
Txt_Degree,Deg.ShortName);
break;
case Soc_NOTE_CRS_DOC_PUB_FILE:
case Soc_NOTE_CRS_SHA_PUB_FILE:
case Soc_NOTE_EXAM_ANNOUNCEMENT:
case Soc_NOTE_NOTICE:
/* Write location (course) in hierarchy */
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
Txt_Course,Crs.ShortName);
break;
case Soc_NOTE_FORUM_POST:
/* Write forum name */
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
Txt_Forum,ForumName);
break;
default:
break;
}
2015-12-30 16:33:36 +01:00
2016-01-05 04:54:00 +01:00
/* Write note summary */
Soc_GetNoteSummary (SocNot,SummaryStr,Soc_MAX_BYTES_SUMMARY);
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s</div>",SummaryStr);
}
2016-01-08 02:55:18 +01:00
/* Get number of comments in this social note */
NumComments = Soc_GetNumCommentsInSocialNote (SocNot->NotCod);
/* Put icon to add a comment */
if (!NumComments)
Soc_PutFormToCommentSocialNote (SocNot->NotCod);
2016-01-07 00:42:35 +01:00
2016-01-05 21:30:10 +01:00
/* Put icons to share/unshare */
if (IAmTheAuthor) // I am the author
Soc_PutDisabledIconShare (SocNot->NumShared);
else if (IAmAPublisherOfThisSocNot) // I am a publisher of this social note,
// but not the author ==> I have shared this social note
/* Put icon to unshare this publishing */
Soc_PutFormToUnshareSocialPublishing (SocPub->PubCod);
else // I am not the author and I am not a publisher
2016-01-05 04:54:00 +01:00
{
2016-01-05 21:30:10 +01:00
if (SocNot->Unavailable) // Unavailable social notes can not be shared
Soc_PutDisabledIconShare (SocNot->NumShared);
else
/* Put icon to share this publishing */
Soc_PutFormToShareSocialNote (SocNot->NotCod);
}
2015-12-30 16:33:36 +01:00
2016-01-05 21:30:10 +01:00
/* Show who have shared this social note */
Soc_ShowUsrsWhoHaveSharedSocialNote (SocNot);
2016-01-04 14:49:10 +01:00
2016-01-08 01:53:37 +01:00
/* Put icon to remove this publishing */
if (IAmTheAuthor && !ShowAlone)
2016-01-05 21:30:10 +01:00
Soc_PutFormToRemoveSocialPublishing (SocPub->PubCod);
2016-01-04 11:58:36 +01:00
2016-01-08 02:55:18 +01:00
if (NumComments)
/* Show current comments */
Soc_WriteCommentsInSocialNote (SocNot->NotCod);
2016-01-07 15:19:54 +01:00
2016-01-07 11:31:36 +01:00
/* Put hidden form to write comment */
Soc_PutHiddenFormToSendCommentToASocialNote (SocNot->NotCod);
2016-01-05 04:54:00 +01:00
/* End of right part */
fprintf (Gbl.F.Out,"</div>");
2016-01-02 14:36:34 +01:00
2016-01-05 04:54:00 +01:00
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
2015-12-30 16:33:36 +01:00
/***** End list item *****/
fprintf (Gbl.F.Out,"</li>");
2016-01-05 21:30:10 +01:00
if (ShowAlone)
{
fprintf (Gbl.F.Out,"</ul>");
Lay_EndRoundFrame ();
}
2015-12-30 16:33:36 +01:00
}
2015-12-28 19:23:42 +01:00
/*****************************************************************************/
2015-12-31 14:47:22 +01:00
/**************** Write the date of creation of a social note ****************/
2015-12-28 19:23:42 +01:00
/*****************************************************************************/
// TimeUTC holds UTC date and time in UNIX format (seconds since 1970)
2016-01-08 01:53:37 +01:00
static void Soc_WriteDateTime (time_t TimeUTC)
2015-12-28 19:23:42 +01:00
{
2015-12-29 11:35:01 +01:00
extern const char *Txt_Today;
2015-12-28 19:23:42 +01:00
static unsigned UniqueId = 0;
UniqueId++;
/***** Start cell *****/
2015-12-29 02:09:50 +01:00
fprintf (Gbl.F.Out,"<div id=\"date_%u\" class=\"SOCIAL_RIGHT_TIME DAT_LIGHT\""
2015-12-28 20:46:48 +01:00
" style=\"display:inline-block;\">",
2015-12-28 19:23:42 +01:00
UniqueId);
/***** Write date and time *****/
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">"
2015-12-29 11:35:01 +01:00
"writeLocalDateTimeFromUTC('date_%u',%ld,'&nbsp;','%s');"
2015-12-28 19:23:42 +01:00
"</script>",
2015-12-29 11:35:01 +01:00
UniqueId,(long) TimeUTC,Txt_Today);
2015-12-28 19:23:42 +01:00
/***** End cell *****/
2015-12-28 20:46:48 +01:00
fprintf (Gbl.F.Out,"</div>");
2015-12-28 19:23:42 +01:00
}
2016-01-02 01:56:48 +01:00
/*****************************************************************************/
/***************** Get from database and write public post *******************/
/*****************************************************************************/
static void Soc_GetAndWriteSocialPost (long PstCod)
{
char Query[128];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
char Content[Cns_MAX_BYTES_LONG_TEXT+1];
/***** Get social post from database *****/
sprintf (Query,"SELECT Content FROM social_posts WHERE PstCod='%ld'",
PstCod);
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get the content of a social post");
/***** Result should have a unique row *****/
if (NumRows == 1)
{
/***** Get number of rows *****/
row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/
strncpy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT);
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
}
else
Content[0] = '\0';
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** Write content *****/
Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,true,false);
}
2015-12-29 13:18:25 +01:00
/*****************************************************************************/
2015-12-31 14:25:28 +01:00
/********* Put form to go to an action depending on the social note **********/
2015-12-29 13:18:25 +01:00
/*****************************************************************************/
2016-01-04 10:27:32 +01:00
static void Soc_PutFormGoToAction (const struct SocialNote *SocNot)
2015-12-29 13:18:25 +01:00
{
extern const Act_Action_t For_ActionsSeeFor[For_NUM_TYPES_FORUM];
2016-01-03 01:13:57 +01:00
extern const char *The_ClassForm[The_NUM_THEMES];
extern const char *Txt_SOCIAL_NOTE[Soc_NUM_SOCIAL_NOTES];
2016-01-03 01:54:19 +01:00
extern const char *Txt_not_available;
2015-12-29 13:18:25 +01:00
2016-01-03 19:30:59 +01:00
if (SocNot->Unavailable || // File/notice... pointer by this social note is unavailable
Gbl.InsideForm) // Inside another form
2015-12-29 13:18:25 +01:00
{
2016-01-03 19:30:59 +01:00
/***** Do not put form *****/
2016-01-04 02:08:16 +01:00
fprintf (Gbl.F.Out,"<span class=\"DAT_LIGHT\">%s",
Txt_SOCIAL_NOTE[SocNot->NoteType]);
2016-01-03 19:30:59 +01:00
if (SocNot->Unavailable)
fprintf (Gbl.F.Out," (%s)",Txt_not_available);
2016-01-04 02:08:16 +01:00
fprintf (Gbl.F.Out,"</span>");
2015-12-29 13:18:25 +01:00
}
2016-01-03 19:30:59 +01:00
else // Not inside another form
2016-01-02 17:07:58 +01:00
{
2016-01-03 19:30:59 +01:00
/***** Parameters depending on the type of note *****/
switch (SocNot->NoteType)
2016-01-03 01:13:57 +01:00
{
2016-01-03 19:30:59 +01:00
case Soc_NOTE_INS_DOC_PUB_FILE:
case Soc_NOTE_INS_SHA_PUB_FILE:
2016-01-04 10:27:32 +01:00
Act_FormStart (Soc_DefaultActions[SocNot->NoteType]);
Brw_PutHiddenParamFilCod (SocNot->Cod);
if (SocNot->HieCod != Gbl.CurrentIns.Ins.InsCod) // Not the current institution
Ins_PutParamInsCod (SocNot->HieCod); // Go to another institution
break;
2016-01-03 19:30:59 +01:00
case Soc_NOTE_CTR_DOC_PUB_FILE:
case Soc_NOTE_CTR_SHA_PUB_FILE:
2016-01-04 10:27:32 +01:00
Act_FormStart (Soc_DefaultActions[SocNot->NoteType]);
Brw_PutHiddenParamFilCod (SocNot->Cod);
if (SocNot->HieCod != Gbl.CurrentCtr.Ctr.CtrCod) // Not the current centre
Ctr_PutParamCtrCod (SocNot->HieCod); // Go to another centre
break;
2016-01-03 19:30:59 +01:00
case Soc_NOTE_DEG_DOC_PUB_FILE:
case Soc_NOTE_DEG_SHA_PUB_FILE:
2016-01-04 10:27:32 +01:00
Act_FormStart (Soc_DefaultActions[SocNot->NoteType]);
Brw_PutHiddenParamFilCod (SocNot->Cod);
if (SocNot->HieCod != Gbl.CurrentDeg.Deg.DegCod) // Not the current degree
Deg_PutParamDegCod (SocNot->HieCod); // Go to another degree
break;
2016-01-03 19:30:59 +01:00
case Soc_NOTE_CRS_DOC_PUB_FILE:
case Soc_NOTE_CRS_SHA_PUB_FILE:
2016-01-04 10:27:32 +01:00
Act_FormStart (Soc_DefaultActions[SocNot->NoteType]);
Brw_PutHiddenParamFilCod (SocNot->Cod);
if (SocNot->HieCod != Gbl.CurrentCrs.Crs.CrsCod) // Not the current course
Crs_PutParamCrsCod (SocNot->HieCod); // Go to another course
2016-01-03 19:30:59 +01:00
break;
2016-01-05 04:54:00 +01:00
case Soc_NOTE_EXAM_ANNOUNCEMENT:
2016-01-03 19:30:59 +01:00
Act_FormStart (Soc_DefaultActions[SocNot->NoteType]);
Not_PutHiddenParamNotCod (SocNot->Cod);
2016-01-04 10:27:32 +01:00
if (SocNot->HieCod != Gbl.CurrentCrs.Crs.CrsCod) // Not the current course
Crs_PutParamCrsCod (SocNot->HieCod); // Go to another course
2016-01-03 19:30:59 +01:00
break;
2016-01-05 04:54:00 +01:00
case Soc_NOTE_SOCIAL_POST: // Not applicable
return;
2016-01-03 19:30:59 +01:00
case Soc_NOTE_FORUM_POST:
Act_FormStart (For_ActionsSeeFor[Gbl.Forum.ForumType]);
For_PutAllHiddenParamsForum ();
2016-01-04 10:27:32 +01:00
if (SocNot->HieCod != Gbl.CurrentCrs.Crs.CrsCod) // Not the current course
Crs_PutParamCrsCod (SocNot->HieCod); // Go to another course
2016-01-03 19:30:59 +01:00
break;
2016-01-05 04:54:00 +01:00
case Soc_NOTE_NOTICE:
Act_FormStart (Soc_DefaultActions[SocNot->NoteType]);
Not_PutHiddenParamNotCod (SocNot->Cod);
if (SocNot->HieCod != Gbl.CurrentCrs.Crs.CrsCod) // Not the current course
Crs_PutParamCrsCod (SocNot->HieCod); // Go to another course
2016-01-03 19:30:59 +01:00
break;
2016-01-05 04:54:00 +01:00
default: // Not applicable
return;
2016-01-03 01:13:57 +01:00
}
2016-01-03 19:30:59 +01:00
2016-01-04 10:27:32 +01:00
/***** Link and end form *****/
Act_LinkFormSubmit (Txt_SOCIAL_NOTE[SocNot->NoteType],
The_ClassForm[Gbl.Prefs.Theme]);
fprintf (Gbl.F.Out,"%s</a>",Txt_SOCIAL_NOTE[SocNot->NoteType]);
Act_FormEnd ();
2016-01-02 17:07:58 +01:00
}
2015-12-29 13:18:25 +01:00
}
2015-12-28 19:23:42 +01:00
/*****************************************************************************/
2015-12-31 14:47:22 +01:00
/******************* Get social note summary and content *********************/
2015-12-28 19:23:42 +01:00
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
static void Soc_GetNoteSummary (const struct SocialNote *SocNot,
2015-12-31 14:25:28 +01:00
char *SummaryStr,unsigned MaxChars)
2015-12-28 19:23:42 +01:00
{
SummaryStr[0] = '\0';
2015-12-31 18:40:45 +01:00
switch (SocNot->NoteType)
2015-12-28 19:23:42 +01:00
{
2015-12-31 14:25:28 +01:00
case Soc_NOTE_UNKNOWN:
2015-12-28 19:23:42 +01:00
break;
2015-12-31 14:25:28 +01:00
case Soc_NOTE_INS_DOC_PUB_FILE:
case Soc_NOTE_INS_SHA_PUB_FILE:
case Soc_NOTE_CTR_DOC_PUB_FILE:
case Soc_NOTE_CTR_SHA_PUB_FILE:
case Soc_NOTE_DEG_DOC_PUB_FILE:
case Soc_NOTE_DEG_SHA_PUB_FILE:
case Soc_NOTE_CRS_DOC_PUB_FILE:
case Soc_NOTE_CRS_SHA_PUB_FILE:
2015-12-31 18:40:45 +01:00
Brw_GetSummaryAndContentOrSharedFile (SummaryStr,NULL,SocNot->Cod,MaxChars,false);
2015-12-28 19:23:42 +01:00
break;
2015-12-31 14:25:28 +01:00
case Soc_NOTE_EXAM_ANNOUNCEMENT:
2015-12-31 18:40:45 +01:00
Exa_GetSummaryAndContentExamAnnouncement (SummaryStr,NULL,SocNot->Cod,MaxChars,false);
2015-12-28 19:23:42 +01:00
break;
2015-12-31 14:25:28 +01:00
case Soc_NOTE_SOCIAL_POST:
2015-12-30 16:33:36 +01:00
// Not applicable
2015-12-28 19:23:42 +01:00
break;
2015-12-31 14:25:28 +01:00
case Soc_NOTE_FORUM_POST:
2015-12-31 18:40:45 +01:00
For_GetSummaryAndContentForumPst (SummaryStr,NULL,SocNot->Cod,MaxChars,false);
2015-12-28 19:23:42 +01:00
break;
2015-12-31 14:25:28 +01:00
case Soc_NOTE_NOTICE:
2015-12-31 18:40:45 +01:00
Not_GetSummaryAndContentNotice (SummaryStr,NULL,SocNot->Cod,MaxChars,false);
2015-12-30 20:11:50 +01:00
break;
2015-12-28 19:23:42 +01:00
}
}
2015-12-28 20:46:48 +01:00
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
/************** Store and publish a social note into database ****************/
2015-12-28 20:46:48 +01:00
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
void Soc_StoreAndPublishSocialNote (Soc_NoteType_t NoteType,long Cod)
2015-12-28 20:46:48 +01:00
{
2016-01-02 13:21:25 +01:00
char Query[256];
long HieCod; // Hierarchy code (institution/centre/degree/course)
2016-01-01 20:19:43 +01:00
struct SocialPublishing SocPub;
2015-12-28 20:46:48 +01:00
2016-01-02 13:21:25 +01:00
switch (NoteType)
2015-12-28 20:46:48 +01:00
{
2016-01-02 13:21:25 +01:00
case Soc_NOTE_INS_DOC_PUB_FILE:
case Soc_NOTE_INS_SHA_PUB_FILE:
HieCod = Gbl.CurrentIns.Ins.InsCod;
break;
case Soc_NOTE_CTR_DOC_PUB_FILE:
case Soc_NOTE_CTR_SHA_PUB_FILE:
HieCod = Gbl.CurrentCtr.Ctr.CtrCod;
break;
case Soc_NOTE_DEG_DOC_PUB_FILE:
case Soc_NOTE_DEG_SHA_PUB_FILE:
HieCod = Gbl.CurrentDeg.Deg.DegCod;
break;
case Soc_NOTE_CRS_DOC_PUB_FILE:
case Soc_NOTE_CRS_SHA_PUB_FILE:
case Soc_NOTE_EXAM_ANNOUNCEMENT:
case Soc_NOTE_NOTICE:
HieCod = Gbl.CurrentCrs.Crs.CrsCod;
break;
default:
HieCod = -1L;
break;
2015-12-28 20:46:48 +01:00
}
2015-12-31 14:25:28 +01:00
/***** Store social note *****/
2016-01-02 13:21:25 +01:00
sprintf (Query,"INSERT INTO social_notes"
2016-01-03 17:34:06 +01:00
" (NoteType,UsrCod,HieCod,Cod,Unavailable,TimeNote)"
" VALUES ('%u','%ld','%ld','%ld','N',NOW())",
2016-01-02 13:21:25 +01:00
(unsigned) NoteType,Gbl.Usrs.Me.UsrDat.UsrCod,HieCod,Cod);
2016-01-01 20:19:43 +01:00
SocPub.NotCod = DB_QueryINSERTandReturnCode (Query,"can not create new social note");
/***** Publish social note in timeline *****/
SocPub.AuthorCod =
SocPub.PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod;
Soc_PublishSocialNoteInTimeline (&SocPub);
}
2015-12-31 18:40:45 +01:00
2016-01-03 19:30:59 +01:00
/*****************************************************************************/
/********************** Mark a social note as unavailable ********************/
/*****************************************************************************/
void Soc_MarkSocialNoteAsUnavailableUsingNotCod (long NotCod)
{
char Query[256];
/***** Mark the social note as unavailable *****/
sprintf (Query,"UPDATE social_notes SET Unavailable='Y'"
" WHERE NotCod='%ld'",
NotCod);
DB_QueryUPDATE (Query,"can not mark social note as unavailable");
}
void Soc_MarkSocialNoteAsUnavailableUsingNoteTypeAndCod (Soc_NoteType_t NoteType,long Cod)
{
char Query[256];
/***** Mark the social note as unavailable *****/
sprintf (Query,"UPDATE social_notes SET Unavailable='Y'"
" WHERE NoteType='%u' AND Cod='%ld'",
(unsigned) NoteType,Cod);
DB_QueryUPDATE (Query,"can not mark social note as unavailable");
}
2016-01-04 01:56:28 +01:00
/*****************************************************************************/
/*********** Mark possible notifications of one file as removed **************/
/*****************************************************************************/
void Soc_MarkSocialNoteOneFileAsRemoved (const char *Path)
{
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
Brw_FileBrowser_t FileBrowser = Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type];
long FilCod;
Soc_NoteType_t NoteType;
switch (FileBrowser)
{
case Brw_ADMI_DOCUM_INS:
case Brw_ADMI_SHARE_INS:
case Brw_ADMI_DOCUM_CTR:
case Brw_ADMI_SHARE_CTR:
case Brw_ADMI_DOCUM_DEG:
case Brw_ADMI_SHARE_DEG:
case Brw_ADMI_DOCUM_CRS:
case Brw_ADMI_SHARE_CRS:
/***** Get file code *****/
FilCod = Brw_GetFilCodByPath (Path,true); // Only if file is public
if (FilCod > 0)
{
/***** Mark possible social note as unavailable *****/
switch (FileBrowser)
{
case Brw_ADMI_DOCUM_INS:
NoteType = Soc_NOTE_INS_DOC_PUB_FILE;
break;
case Brw_ADMI_SHARE_INS:
NoteType = Soc_NOTE_INS_SHA_PUB_FILE;
break;
case Brw_ADMI_DOCUM_CTR:
NoteType = Soc_NOTE_CTR_DOC_PUB_FILE;
break;
case Brw_ADMI_SHARE_CTR:
NoteType = Soc_NOTE_CTR_SHA_PUB_FILE;
break;
case Brw_ADMI_DOCUM_DEG:
NoteType = Soc_NOTE_DEG_DOC_PUB_FILE;
break;
case Brw_ADMI_SHARE_DEG:
NoteType = Soc_NOTE_DEG_SHA_PUB_FILE;
break;
case Brw_ADMI_DOCUM_CRS:
NoteType = Soc_NOTE_CRS_DOC_PUB_FILE;
break;
case Brw_ADMI_SHARE_CRS:
NoteType = Soc_NOTE_CRS_SHA_PUB_FILE;
break;
default:
return;
}
Soc_MarkSocialNoteAsUnavailableUsingNoteTypeAndCod (NoteType,FilCod);
}
break;
default:
break;
}
}
/*****************************************************************************/
/** Mark possible social notes involving children of a folder as unavailable */
/*****************************************************************************/
void Soc_MarkSocialNotesChildrenOfFolderAsUnavailable (const char *Path)
{
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
Brw_FileBrowser_t FileBrowser = Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type];
long Cod = Brw_GetCodForFiles ();
char Query[512];
Soc_NoteType_t NoteType;
switch (FileBrowser)
{
case Brw_ADMI_DOCUM_INS:
case Brw_ADMI_SHARE_INS:
case Brw_ADMI_DOCUM_CTR:
case Brw_ADMI_SHARE_CTR:
case Brw_ADMI_DOCUM_DEG:
case Brw_ADMI_SHARE_DEG:
case Brw_ADMI_DOCUM_CRS:
case Brw_ADMI_SHARE_CRS:
/***** Mark possible social note as unavailable *****/
switch (FileBrowser)
{
case Brw_ADMI_DOCUM_INS:
NoteType = Soc_NOTE_INS_DOC_PUB_FILE;
break;
case Brw_ADMI_SHARE_INS:
NoteType = Soc_NOTE_INS_SHA_PUB_FILE;
break;
case Brw_ADMI_DOCUM_CTR:
NoteType = Soc_NOTE_CTR_DOC_PUB_FILE;
break;
case Brw_ADMI_SHARE_CTR:
NoteType = Soc_NOTE_CTR_SHA_PUB_FILE;
break;
case Brw_ADMI_DOCUM_DEG:
NoteType = Soc_NOTE_DEG_DOC_PUB_FILE;
break;
case Brw_ADMI_SHARE_DEG:
NoteType = Soc_NOTE_DEG_SHA_PUB_FILE;
break;
case Brw_ADMI_DOCUM_CRS:
NoteType = Soc_NOTE_CRS_DOC_PUB_FILE;
break;
case Brw_ADMI_SHARE_CRS:
NoteType = Soc_NOTE_CRS_SHA_PUB_FILE;
break;
default:
return;
}
sprintf (Query,"UPDATE social_notes SET Unavailable='Y'"
" WHERE NoteType='%u' AND Cod IN"
" (SELECT FilCod FROM files"
" WHERE FileBrowser='%u' AND Cod='%ld'"
" AND Path LIKE '%s/%%' AND Public='Y')", // Only public files
(unsigned) NoteType,
(unsigned) FileBrowser,Cod,
Path);
DB_QueryUPDATE (Query,"can not mark social notes as unavailable");
break;
default:
break;
}
}
2016-01-01 20:19:43 +01:00
/*****************************************************************************/
/***************** Put contextual link to write a new post *******************/
/*****************************************************************************/
2016-01-04 02:54:04 +01:00
// SocPub->PubCod is set
2016-01-01 20:19:43 +01:00
static void Soc_PublishSocialNoteInTimeline (struct SocialPublishing *SocPub)
{
char Query[256];
/***** Publish social note in timeline *****/
2015-12-31 18:40:45 +01:00
sprintf (Query,"INSERT INTO social_timeline"
2016-01-04 14:49:10 +01:00
" (NotCod,PublisherCod,AuthorCod,TimePublish)"
2015-12-31 18:40:45 +01:00
" VALUES"
" ('%ld','%ld','%ld',NOW())",
2016-01-04 14:49:10 +01:00
SocPub->NotCod,SocPub->PublisherCod,SocPub->AuthorCod);
2016-01-04 02:54:04 +01:00
SocPub->PubCod = DB_QueryINSERTandReturnCode (Query,"can not publish social note");
2015-12-28 20:46:48 +01:00
}
2015-12-30 02:08:08 +01:00
2015-12-30 12:40:13 +01:00
/*****************************************************************************/
/***************** Put contextual link to write a new post *******************/
/*****************************************************************************/
2016-01-02 01:56:48 +01:00
static void Soc_PutLinkToWriteANewPost (Act_Action_t Action,void (*FuncParams) ())
2015-12-30 12:40:13 +01:00
{
extern const char *Txt_New_comment;
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2016-01-02 02:33:23 +01:00
Lay_PutContextualLinkAnchor (Action,"timeline",
FuncParams,
"write64x64.gif",
Txt_New_comment,Txt_New_comment);
2015-12-30 12:40:13 +01:00
fprintf (Gbl.F.Out,"</div>");
}
/*****************************************************************************/
/****************** Form to write a new public comment ***********************/
/*****************************************************************************/
2016-01-02 01:56:48 +01:00
void Soc_FormSocialPostGbl (void)
{
/***** Form to write a new public comment *****/
Soc_FormSocialPost ();
/***** Write current timeline (global) *****/
Soc_ShowTimelineGbl ();
}
void Soc_FormSocialPostUsr (void)
{
/***** Get user whom profile is displayed *****/
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/
Prf_ShowUserProfile ();
2016-01-02 02:33:23 +01:00
/***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
2016-01-02 01:56:48 +01:00
/***** Form to write a new public comment *****/
Soc_FormSocialPost ();
/***** Write current timeline (user) *****/
Soc_ShowTimelineUsr ();
2016-01-02 02:33:23 +01:00
/***** End section *****/
fprintf (Gbl.F.Out,"</section>");
2016-01-02 01:56:48 +01:00
}
static void Soc_FormSocialPost (void)
2015-12-30 12:40:13 +01:00
{
extern const char *Txt_New_comment;
extern const char *Txt_Send_comment;
/***** Form to write a new public comment *****/
/* Start frame */
2016-01-02 15:05:27 +01:00
Lay_StartRoundFrame (Soc_WIDTH_TIMELINE,Txt_New_comment);
2015-12-30 12:40:13 +01:00
/* Start form to write the post */
2016-01-02 01:56:48 +01:00
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
2016-01-02 02:33:23 +01:00
Act_FormStartAnchor (ActRcvSocPstUsr,"timeline");
2016-01-02 01:56:48 +01:00
Usr_PutParamOtherUsrCodEncrypted ();
}
else
Act_FormStart (ActRcvSocPstGbl);
2015-12-30 12:40:13 +01:00
/* Content of new post */
fprintf (Gbl.F.Out,"<textarea name=\"Content\" cols=\"50\" rows=\"5\">"
"</textarea>");
2015-12-30 17:27:11 +01:00
Lay_HelpPlainEditor ();
2015-12-30 12:40:13 +01:00
/* Send button */
Lay_PutCreateButton (Txt_Send_comment);
/* End form */
Act_FormEnd ();
/* End frame */
Lay_EndRoundFrame ();
}
/*****************************************************************************/
/******************* Receive and store a new public post *********************/
/*****************************************************************************/
2016-01-02 01:56:48 +01:00
void Soc_ReceiveSocialPostGbl (void)
{
/***** Receive and store social post *****/
Soc_ReceiveSocialPost ();
/***** Write updated timeline after publishing (global) *****/
Soc_ShowTimelineGbl ();
}
void Soc_ReceiveSocialPostUsr (void)
{
/***** Get user whom profile is displayed *****/
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/
Prf_ShowUserProfile ();
2016-01-02 02:33:23 +01:00
/***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
2016-01-02 01:56:48 +01:00
/***** Receive and store social post *****/
Soc_ReceiveSocialPost ();
/***** Write updated timeline after publishing (user) *****/
Soc_ShowTimelineUsr ();
2016-01-02 02:33:23 +01:00
/***** End section *****/
fprintf (Gbl.F.Out,"</section>");
2016-01-02 01:56:48 +01:00
}
static void Soc_ReceiveSocialPost (void)
2015-12-30 12:40:13 +01:00
{
char Content[Cns_MAX_BYTES_LONG_TEXT+1];
char Query[128+Cns_MAX_BYTES_LONG_TEXT];
long PstCod;
/***** Get and store new post *****/
/* Get the content of the post */
Par_GetParAndChangeFormat ("Content",Content,Cns_MAX_BYTES_LONG_TEXT,
Str_TO_RIGOROUS_HTML,true);
/* Insert post content in the database */
2015-12-31 14:25:28 +01:00
sprintf (Query,"INSERT INTO social_posts (Content) VALUES ('%s')",
2015-12-30 12:40:13 +01:00
Content);
PstCod = DB_QueryINSERTandReturnCode (Query,"can not create post");
2015-12-31 14:25:28 +01:00
/* Insert post in social notes */
2015-12-31 18:40:45 +01:00
Soc_StoreAndPublishSocialNote (Soc_NOTE_SOCIAL_POST,PstCod);
2015-12-30 12:40:13 +01:00
}
2016-01-07 00:42:35 +01:00
/*****************************************************************************/
/******************* Form to comment a social publishing *********************/
/*****************************************************************************/
static void Soc_PutFormToCommentSocialNote (long NotCod)
{
extern const char *Txt_Comment;
2016-01-07 14:21:21 +01:00
/***** Link to show/hide comment form in a social note *****/
2016-01-07 00:42:35 +01:00
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_COMMENT ICON_HIGHLIGHT\">"
"<input type=\"image\""
" src=\"%s/write64x64.gif\""
" alt=\"%s\" title=\"%s\""
2016-01-07 11:31:36 +01:00
" class=\"ICON20x20\""
" onclick=\""
"toggleDisplay('div_comment_%ld');"
"return false;\" />"
2016-01-07 00:42:35 +01:00
"</div>",
Gbl.Prefs.IconsURL,
Txt_Comment,
2016-01-07 11:31:36 +01:00
Txt_Comment,
NotCod);
}
2016-01-08 02:55:18 +01:00
/*****************************************************************************/
/****************** Get number of comments in a social note ******************/
/*****************************************************************************/
static unsigned long Soc_GetNumCommentsInSocialNote (long NotCod)
{
char Query[128];
sprintf (Query,"SELECT COUNT(*) FROM social_comments"
" WHERE NotCod='%ld'",
NotCod);
return DB_QueryCOUNT (Query,"can not get number of comments in a social note");
}
2016-01-07 11:31:36 +01:00
/*****************************************************************************/
/******************* Form to comment a social publishing *********************/
/*****************************************************************************/
2016-01-07 15:19:54 +01:00
static void Soc_WriteCommentsInSocialNote (long NotCod)
{
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumComments;
unsigned long NumCom;
2016-01-08 01:53:37 +01:00
struct SocialComment SocCom;
2016-01-07 15:19:54 +01:00
/***** Get comments of this social note from database *****/
sprintf (Query,"SELECT social_comments.ComCod,social_comments.UsrCod,"
2016-01-08 01:53:37 +01:00
"social_comments.NotCod,"
2016-01-07 16:45:35 +01:00
"UNIX_TIMESTAMP(social_comments.TimeComment),"
2016-01-07 15:19:54 +01:00
"social_comments_content.Content"
" FROM social_comments,social_comments_content"
" WHERE social_comments.NotCod='%ld'"
" AND social_comments.ComCod=social_comments_content.ComCod"
" ORDER BY social_comments.ComCod",
NotCod);
NumComments = DB_QuerySELECT (Query,&mysql_res,"can not get social comments");
/***** List comments *****/
if (NumComments) // Comments to this social note found
{
/***** Start list *****/
2016-01-08 01:53:37 +01:00
fprintf (Gbl.F.Out,"<ul class=\"LIST_LEFT SOCIAL_COMMENTS\">");
2016-01-07 15:19:54 +01:00
/***** List comments one by one *****/
for (NumCom = 0;
NumCom < NumComments;
NumCom++)
{
/* Get data of social comment */
row = mysql_fetch_row (mysql_res);
2016-01-08 01:53:37 +01:00
Soc_GetDataOfSocialCommentFromRow (row,&SocCom);
2016-01-07 15:19:54 +01:00
2016-01-08 01:53:37 +01:00
/* Write social comment */
Soc_WriteSocialComment (&SocCom,false);
2016-01-08 02:55:18 +01:00
}
/* Put icon to add a comment */
fprintf (Gbl.F.Out,"<li class=\"SOCIAL_COMMENT\">");
Soc_PutFormToCommentSocialNote (NotCod);
fprintf (Gbl.F.Out,"</li>");
2016-01-07 15:19:54 +01:00
/***** End list *****/
fprintf (Gbl.F.Out,"</ul>");
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
2016-01-08 02:55:18 +01:00
/*****************************************************************************/
/**************************** Write social comment ***************************/
/*****************************************************************************/
static void Soc_WriteSocialComment (struct SocialComment *SocCom,
bool ShowAlone) // Social comment is shown alone, not in a lis
{
extern const char *Txt_Forum;
extern const char *Txt_Course;
extern const char *Txt_Degree;
extern const char *Txt_Centre;
extern const char *Txt_Institution;
struct UsrData UsrDat;
bool IAmTheAuthor;
bool ShowPhoto = false;
char PhotoURL[PATH_MAX+1];
if (ShowAlone)
{
Lay_StartRoundFrame (Soc_WIDTH_TIMELINE,NULL);
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_LEFT_PHOTO\">"
"</div>"
"<div class=\"SOCIAL_RIGHT_CONTAINER\">"
"<ul class=\"LIST_LEFT\">");
}
/***** Start list item *****/
fprintf (Gbl.F.Out,"<li");
if (!ShowAlone)
fprintf (Gbl.F.Out," class=\"SOCIAL_COMMENT\"");
fprintf (Gbl.F.Out,">");
if (SocCom->ComCod <= 0 ||
SocCom->NotCod <= 0 ||
SocCom->UsrCod <= 0)
Lay_ShowAlert (Lay_ERROR,"Error in social comment.");
else
{
/***** Get author's data *****/
Usr_UsrDataConstructor (&UsrDat);
UsrDat.UsrCod = SocCom->UsrCod;
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat);
IAmTheAuthor = (Gbl.Usrs.Me.Logged &&
UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Left: write author's photo *****/
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_COMMENT_PHOTO\">");
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (&UsrDat,PhotoURL);
Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL :
NULL,
"PHOTO30x40",Pho_ZOOM);
fprintf (Gbl.F.Out,"</div>");
/***** Right: author's name, time, summary and buttons *****/
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_COMMENT_RIGHT_CONTAINER\">");
/* Write author's full name and nickname */
Str_LimitLengthHTMLStr (UsrDat.FullName,12);
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_COMMENT_RIGHT_AUTHOR\">"
"<span class=\"DAT_BOLD\">%s</span>"
"<span class=\"DAT_LIGHT\"> @%s</span>"
"</div>",
UsrDat.FullName,UsrDat.Nickname);
/* Write date and time */
Soc_WriteDateTime (SocCom->DateTimeUTC);
/* Write content of the social comment */
fprintf (Gbl.F.Out,"<div class=\"DAT\">");
Msg_WriteMsgContent (SocCom->Content,Cns_MAX_BYTES_LONG_TEXT,true,false);
fprintf (Gbl.F.Out,"</div>");
/* Put icon to remove this social comment */
if (IAmTheAuthor && !ShowAlone)
Soc_PutFormToRemoveComment (SocCom->ComCod);
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
/***** End list item *****/
fprintf (Gbl.F.Out,"</li>");
if (ShowAlone)
{
fprintf (Gbl.F.Out,"</ul>"
"</div>");
Lay_EndRoundFrame ();
}
}
2016-01-07 16:45:35 +01:00
/*****************************************************************************/
2016-01-08 01:53:37 +01:00
/********************** Form to remove social comment ************************/
2016-01-07 16:45:35 +01:00
/*****************************************************************************/
2016-01-08 01:53:37 +01:00
static void Soc_PutFormToRemoveComment (long ComCod)
2016-01-07 16:45:35 +01:00
{
2016-01-08 01:53:37 +01:00
extern const char *Txt_Remove;
2016-01-07 16:45:35 +01:00
2016-01-08 01:53:37 +01:00
/***** Form to remove social publishing *****/
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
Act_FormStartAnchor (ActReqRemSocComUsr,"timeline");
Usr_PutParamOtherUsrCodEncrypted ();
}
else
Act_FormStart (ActReqRemSocComGbl);
Soc_PutHiddenParamComCod (ComCod);
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_REMOVE ICON_HIGHLIGHT\">"
"<input type=\"image\""
" src=\"%s/remove-on64x64.png\""
" alt=\"%s\" title=\"%s\""
" class=\"ICON20x20\" />"
"</div>",
Gbl.Prefs.IconsURL,
Txt_Remove,
Txt_Remove);
Act_FormEnd ();
2016-01-07 16:45:35 +01:00
}
2016-01-07 15:19:54 +01:00
/*****************************************************************************/
/******************* Form to comment a social publishing *********************/
/*****************************************************************************/
2016-01-07 11:31:36 +01:00
static void Soc_PutHiddenFormToSendCommentToASocialNote (long NotCod)
{
extern const char *Txt_Send_comment;
/***** Start container *****/
fprintf (Gbl.F.Out,"<div id=\"div_comment_%ld\""
" class=\"SOCIAL_FORM_COMMENT\""
" style=\"display:none;\">",
NotCod);
/***** Start form to write the post *****/
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
2016-01-08 01:53:37 +01:00
Act_FormStartAnchor (ActRcvSocComUsr,"timeline");
2016-01-07 11:31:36 +01:00
Usr_PutParamOtherUsrCodEncrypted ();
}
else
2016-01-08 01:53:37 +01:00
Act_FormStart (ActRcvSocComGbl);
2016-01-07 14:21:21 +01:00
Soc_PutHiddenParamNotCod (NotCod);
2016-01-08 01:53:37 +01:00
fprintf (Gbl.F.Out,"<textarea name=\"Comment%ld\" cols=\"47\" rows=\"5\">"
2016-01-07 11:31:36 +01:00
"</textarea>",
NotCod);
/***** Send button *****/
2016-01-08 02:55:18 +01:00
fprintf (Gbl.F.Out,"<button type=\"submit\" class=\"BT_SUBMIT_INLINE BT_CREATE\">"
2016-01-07 11:31:36 +01:00
"%s"
"</button>",
Txt_Send_comment);
/***** End form *****/
2016-01-07 00:42:35 +01:00
Act_FormEnd ();
2016-01-07 11:31:36 +01:00
/***** En container *****/
fprintf (Gbl.F.Out,"</div>");
2016-01-07 00:42:35 +01:00
}
2016-01-04 11:58:36 +01:00
/*****************************************************************************/
2016-01-05 04:54:00 +01:00
/*********************** Put disabled icon to share **************************/
2016-01-04 11:58:36 +01:00
/*****************************************************************************/
2016-01-05 21:30:10 +01:00
static void Soc_PutDisabledIconShare (unsigned NumShared)
2016-01-04 11:58:36 +01:00
{
2016-01-05 21:30:10 +01:00
extern const char *Txt_SOCIAL_PUBLISHING_Shared_by_X_USERS;
2016-01-05 21:58:25 +01:00
extern const char *Txt_SOCIAL_PUBLISHING_Not_shared_by_anyone;
2016-01-05 21:30:10 +01:00
2016-01-05 21:58:25 +01:00
if (NumShared)
sprintf (Gbl.Title,Txt_SOCIAL_PUBLISHING_Shared_by_X_USERS,NumShared);
else
strcpy (Gbl.Title,Txt_SOCIAL_PUBLISHING_Not_shared_by_anyone);
2016-01-04 11:58:36 +01:00
2016-01-05 04:54:00 +01:00
/***** Disabled icon to share *****/
2016-01-07 00:42:35 +01:00
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_SHARE_DISABLED\">"
2016-01-04 11:58:36 +01:00
"<img src=\"%s/share64x64.png\""
" alt=\"%s\" title=\"%s\""
" class=\"ICON20x20\" />"
"</div>",
Gbl.Prefs.IconsURL,
2016-01-05 21:30:10 +01:00
Gbl.Title,Gbl.Title);
2016-01-04 11:58:36 +01:00
}
2015-12-30 02:08:08 +01:00
/*****************************************************************************/
2016-01-04 02:54:04 +01:00
/************************* Form to share social note *************************/
2016-01-01 20:19:43 +01:00
/*****************************************************************************/
2016-01-05 21:30:10 +01:00
static void Soc_PutFormToShareSocialNote (long NotCod)
2016-01-01 20:19:43 +01:00
{
extern const char *Txt_Share;
2016-01-04 02:54:04 +01:00
/***** Form to share social note *****/
2016-01-02 01:56:48 +01:00
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
2016-01-04 02:54:04 +01:00
Act_FormStartAnchor (ActShaSocNotUsr,"timeline");
2016-01-02 01:56:48 +01:00
Usr_PutParamOtherUsrCodEncrypted ();
}
else
2016-01-04 02:54:04 +01:00
Act_FormStart (ActShaSocNotGbl);
2016-01-05 21:30:10 +01:00
Soc_PutHiddenParamNotCod (NotCod);
2016-01-07 00:42:35 +01:00
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_SHARE ICON_HIGHLIGHT\">"
2016-01-01 20:19:43 +01:00
"<input type=\"image\""
" src=\"%s/share64x64.png\""
" alt=\"%s\" title=\"%s\""
" class=\"ICON20x20\" />"
"</div>",
Gbl.Prefs.IconsURL,
Txt_Share,
Txt_Share);
Act_FormEnd ();
}
/*****************************************************************************/
/************ Form to unshare (stop sharing) social publishing ***************/
/*****************************************************************************/
static void Soc_PutFormToUnshareSocialPublishing (long PubCod)
{
2016-01-05 21:30:10 +01:00
extern const char *Txt_Unshare;
2016-01-01 20:19:43 +01:00
/***** Form to share social publishing *****/
2016-01-02 01:56:48 +01:00
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
2016-01-02 02:33:23 +01:00
Act_FormStartAnchor (ActUnsSocPubUsr,"timeline");
2016-01-02 01:56:48 +01:00
Usr_PutParamOtherUsrCodEncrypted ();
}
else
Act_FormStart (ActUnsSocPubGbl);
2016-01-01 20:19:43 +01:00
Soc_PutHiddenParamPubCod (PubCod);
2016-01-07 00:42:35 +01:00
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_SHARE ICON_HIGHLIGHT\">"
2016-01-01 20:19:43 +01:00
"<input type=\"image\""
" src=\"%s/shared64x64.png\""
" alt=\"%s\" title=\"%s\""
" class=\"ICON20x20\" />"
"</div>",
Gbl.Prefs.IconsURL,
2016-01-05 21:30:10 +01:00
Txt_Unshare,Txt_Unshare);
2016-01-01 20:19:43 +01:00
Act_FormEnd ();
}
/*****************************************************************************/
/******************** Form to remove social publishing ***********************/
2015-12-30 02:08:08 +01:00
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
static void Soc_PutFormToRemoveSocialPublishing (long PubCod)
2015-12-30 02:08:08 +01:00
{
extern const char *Txt_Remove;
2015-12-31 18:40:45 +01:00
/***** Form to remove social publishing *****/
2016-01-02 01:56:48 +01:00
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
2016-01-02 02:33:23 +01:00
Act_FormStartAnchor (ActReqRemSocPubUsr,"timeline");
2016-01-02 01:56:48 +01:00
Usr_PutParamOtherUsrCodEncrypted ();
}
else
Act_FormStart (ActReqRemSocPubGbl);
2015-12-31 18:40:45 +01:00
Soc_PutHiddenParamPubCod (PubCod);
2016-01-07 00:42:35 +01:00
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_REMOVE ICON_HIGHLIGHT\">"
2015-12-30 02:08:08 +01:00
"<input type=\"image\""
" src=\"%s/remove-on64x64.png\""
" alt=\"%s\" title=\"%s\""
" class=\"ICON20x20\" />"
"</div>",
Gbl.Prefs.IconsURL,
Txt_Remove,
Txt_Remove);
Act_FormEnd ();
}
2016-01-05 21:30:10 +01:00
/*****************************************************************************/
/************** Put parameter with the code of a social note *****************/
/*****************************************************************************/
static void Soc_PutHiddenParamNotCod (long NotCod)
{
Par_PutHiddenParamLong ("NotCod",NotCod);
}
2015-12-30 02:08:08 +01:00
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
/*********** Put parameter with the code of a social publishing **************/
2015-12-30 02:08:08 +01:00
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
static void Soc_PutHiddenParamPubCod (long PubCod)
2015-12-30 02:08:08 +01:00
{
2015-12-31 18:40:45 +01:00
Par_PutHiddenParamLong ("PubCod",PubCod);
2015-12-30 02:08:08 +01:00
}
2016-01-08 01:53:37 +01:00
/*****************************************************************************/
/************* Put parameter with the code of a social comment ***************/
/*****************************************************************************/
static void Soc_PutHiddenParamComCod (long ComCod)
{
Par_PutHiddenParamLong ("ComCod",ComCod);
}
2016-01-05 21:30:10 +01:00
/*****************************************************************************/
/************** Get parameter with the code of a social note *****************/
/*****************************************************************************/
static long Soc_GetParamNotCod (void)
{
char LongStr[1+10+1]; // String that holds the social note code
long NotCod;
/* Get social note code */
Par_GetParToText ("NotCod",LongStr,1+10);
if (sscanf (LongStr,"%ld",&NotCod) != 1)
Lay_ShowErrorAndExit ("Wrong code of social note.");
return NotCod;
}
2015-12-30 12:40:13 +01:00
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
/*********** Get parameter with the code of a social publishing **************/
2015-12-30 12:40:13 +01:00
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
static long Soc_GetParamPubCod (void)
2015-12-30 12:40:13 +01:00
{
2016-01-04 02:54:04 +01:00
char LongStr[1+10+1]; // String that holds the social publishing code
2015-12-31 18:40:45 +01:00
long PubCod;
2015-12-30 12:40:13 +01:00
2016-01-08 01:53:37 +01:00
/* Get social punlishing code */
2015-12-31 18:40:45 +01:00
Par_GetParToText ("PubCod",LongStr,1+10);
if (sscanf (LongStr,"%ld",&PubCod) != 1)
Lay_ShowErrorAndExit ("Wrong code of social publishing.");
2015-12-30 12:40:13 +01:00
2015-12-31 18:40:45 +01:00
return PubCod;
2015-12-30 12:40:13 +01:00
}
2016-01-08 01:53:37 +01:00
/*****************************************************************************/
/************* Get parameter with the code of a social comment ***************/
/*****************************************************************************/
static long Soc_GetParamComCod (void)
{
char LongStr[1+10+1]; // String that holds the social comment code
long ComCod;
/* Get social comment code */
Par_GetParToText ("ComCod",LongStr,1+10);
if (sscanf (LongStr,"%ld",&ComCod) != 1)
Lay_ShowErrorAndExit ("Wrong code of social comment.");
return ComCod;
}
2016-01-07 00:42:35 +01:00
/*****************************************************************************/
/*************************** Comment a social note ***************************/
/*****************************************************************************/
2016-01-07 14:21:21 +01:00
void Soc_ReceiveCommentGbl (void)
2016-01-07 00:42:35 +01:00
{
2016-01-07 14:21:21 +01:00
/***** Receive comment in a social note *****/
Soc_ReceiveComment ();
2016-01-07 00:42:35 +01:00
/***** Write updated timeline after commenting (global) *****/
Soc_ShowTimelineGbl ();
}
2016-01-07 14:21:21 +01:00
void Soc_ReceiveCommentUsr (void)
2016-01-07 00:42:35 +01:00
{
/***** Get user whom profile is displayed *****/
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/
Prf_ShowUserProfile ();
/***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
2016-01-07 14:21:21 +01:00
/***** Receive comment in a social note *****/
Soc_ReceiveComment ();
2016-01-07 00:42:35 +01:00
/***** Write updated timeline after commenting (user) *****/
Soc_ShowTimelineUsr ();
/***** End section *****/
fprintf (Gbl.F.Out,"</section>");
}
2016-01-07 14:21:21 +01:00
static void Soc_ReceiveComment (void)
2016-01-07 00:42:35 +01:00
{
2016-01-07 14:21:21 +01:00
char Content[Cns_MAX_BYTES_LONG_TEXT+1];
2016-01-07 14:57:35 +01:00
char Query[128+Cns_MAX_BYTES_LONG_TEXT];
2016-01-07 14:21:21 +01:00
struct SocialNote SocNot;
char ParamName[32];
2016-01-07 14:57:35 +01:00
long ComCod;
2016-01-07 14:21:21 +01:00
/***** Get and store new comment *****/
/* Get the code of the social note */
SocNot.NotCod = Soc_GetParamNotCod ();
/* Get the content of the comment */
sprintf (ParamName,"Comment%ld",SocNot.NotCod);
Par_GetParAndChangeFormat (ParamName,Content,Cns_MAX_BYTES_LONG_TEXT,
Str_TO_RIGOROUS_HTML,true);
2016-01-07 14:57:35 +01:00
/* Insert comment in the database */
sprintf (Query,"INSERT INTO social_comments (NotCod,UsrCod,TimeComment)"
" VALUES ('%ld','%ld',NOW())",
SocNot.NotCod,Gbl.Usrs.Me.UsrDat.UsrCod);
2016-01-07 14:21:21 +01:00
ComCod = DB_QueryINSERTandReturnCode (Query,"can not create comment");
2016-01-07 14:57:35 +01:00
/* Insert comment content in the database */
sprintf (Query,"INSERT INTO social_comments_content (ComCod,Content)"
" VALUES ('%ld','%s')",
ComCod,Content);
DB_QueryINSERT (Query,"can not store comment content");
2016-01-07 00:42:35 +01:00
}
2016-01-01 20:19:43 +01:00
/*****************************************************************************/
2016-01-04 02:54:04 +01:00
/**************************** Share a social note ****************************/
2016-01-01 20:19:43 +01:00
/*****************************************************************************/
2016-01-04 02:54:04 +01:00
void Soc_ShareSocialNoteGbl (void)
2016-01-02 01:56:48 +01:00
{
2016-01-04 02:54:04 +01:00
/***** Share social note *****/
Soc_ShareSocialNote ();
2016-01-02 01:56:48 +01:00
/***** Write updated timeline after sharing (global) *****/
Soc_ShowTimelineGbl ();
}
2016-01-04 02:54:04 +01:00
void Soc_ShareSocialNoteUsr (void)
2016-01-02 01:56:48 +01:00
{
/***** Get user whom profile is displayed *****/
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
2016-01-04 02:54:04 +01:00
/***** Show user's profile *****/
2016-01-02 01:56:48 +01:00
Prf_ShowUserProfile ();
2016-01-02 02:33:23 +01:00
/***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
2016-01-04 02:54:04 +01:00
/***** Share social note *****/
Soc_ShareSocialNote ();
2016-01-02 01:56:48 +01:00
/***** Write updated timeline after sharing (user) *****/
Soc_ShowTimelineUsr ();
2016-01-02 02:33:23 +01:00
/***** End section *****/
fprintf (Gbl.F.Out,"</section>");
2016-01-02 01:56:48 +01:00
}
2016-01-04 02:54:04 +01:00
static void Soc_ShareSocialNote (void)
2016-01-01 20:19:43 +01:00
{
2016-01-02 14:36:34 +01:00
extern const char *Txt_SOCIAL_PUBLISHING_Shared;
2016-01-02 14:56:38 +01:00
struct SocialNote SocNot;
2016-01-04 02:54:04 +01:00
struct SocialPublishing SocPub;
2016-01-07 11:31:36 +01:00
bool IAmTheAuthor;
bool IAmAPublisherOfThisSocNot;
2016-01-01 20:19:43 +01:00
bool ICanShare;
2016-01-07 14:21:21 +01:00
/***** Get the code of the social note to share *****/
SocNot.NotCod = Soc_GetParamNotCod ();
2016-01-01 20:19:43 +01:00
2016-01-02 14:56:38 +01:00
/***** Get data of social note *****/
Soc_GetDataOfSocialNoteByCod (&SocNot);
2016-01-07 11:31:36 +01:00
IAmTheAuthor = (SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
if (IAmTheAuthor)
IAmAPublisherOfThisSocNot = true;
else
IAmAPublisherOfThisSocNot = Soc_CheckIfNoteIsPublishedInTimelineByUsr (SocNot.NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
2016-01-01 20:19:43 +01:00
ICanShare = (Gbl.Usrs.Me.Logged &&
2016-01-07 11:31:36 +01:00
!IAmTheAuthor && // I am not the author
!IAmAPublisherOfThisSocNot); // I have not shared the note
2016-01-01 20:19:43 +01:00
if (ICanShare)
{
2016-01-07 11:31:36 +01:00
/***** Share (publish social note in timeline) *****/
SocPub.AuthorCod = SocNot.UsrCod;
SocPub.PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod;
SocPub.NotCod = SocNot.NotCod;
Soc_PublishSocialNoteInTimeline (&SocPub); // Set SocPub.PubCod
2016-01-01 20:19:43 +01:00
2016-01-07 11:31:36 +01:00
/* Update number of times this social note is shared */
Soc_UpdateNumTimesANoteHasBeenShared (&SocNot);
2016-01-05 21:30:10 +01:00
2016-01-07 11:31:36 +01:00
/***** Message of success *****/
Lay_ShowAlert (Lay_SUCCESS,Txt_SOCIAL_PUBLISHING_Shared);
2016-01-05 21:30:10 +01:00
2016-01-07 11:31:36 +01:00
/***** Show the social note just shared *****/
Soc_WriteSocialNote (&SocPub,&SocNot,true,true);
2016-01-01 20:19:43 +01:00
}
}
/*****************************************************************************/
/************** Unshare a previously shared social publishing ****************/
/*****************************************************************************/
2016-01-02 01:56:48 +01:00
void Soc_UnshareSocialPubGbl (void)
{
/***** Unshare a previously shared social publishing *****/
Soc_UnshareSocialPublishing ();
/***** Write updated timeline after unsharing (global) *****/
Soc_ShowTimelineGbl ();
}
void Soc_UnshareSocialPubUsr (void)
{
/***** Get user whom profile is displayed *****/
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/
Prf_ShowUserProfile ();
2016-01-02 02:33:23 +01:00
/***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
2016-01-02 01:56:48 +01:00
/***** Unshare a previously shared social publishing *****/
Soc_UnshareSocialPublishing ();
/***** Write updated timeline after unsharing (user) *****/
Soc_ShowTimelineUsr ();
2016-01-02 02:33:23 +01:00
/***** End section *****/
fprintf (Gbl.F.Out,"</section>");
2016-01-02 01:56:48 +01:00
}
static void Soc_UnshareSocialPublishing (void)
2016-01-01 20:19:43 +01:00
{
2016-01-02 14:36:34 +01:00
extern const char *Txt_SOCIAL_PUBLISHING_Unshared;
2016-01-01 20:19:43 +01:00
struct SocialPublishing SocPub;
struct SocialNote SocNot;
2016-01-07 11:31:36 +01:00
bool IAmTheAuthor;
bool IAmAPublisherOfThisSocNot;
2016-01-01 20:19:43 +01:00
bool ICanUnshare;
/***** Get the code of the social publishing to unshare *****/
SocPub.PubCod = Soc_GetParamPubCod ();
/***** Get data of social publishing *****/
Soc_GetDataOfSocialPublishingByCod (&SocPub);
/***** Get data of social note *****/
SocNot.NotCod = SocPub.NotCod;
Soc_GetDataOfSocialNoteByCod (&SocNot);
2016-01-07 11:31:36 +01:00
IAmTheAuthor = (SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
if (IAmTheAuthor)
IAmAPublisherOfThisSocNot = true;
else
IAmAPublisherOfThisSocNot = Soc_CheckIfNoteIsPublishedInTimelineByUsr (SocNot.NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
2016-01-01 20:19:43 +01:00
ICanUnshare = (Gbl.Usrs.Me.Logged &&
2016-01-07 11:31:36 +01:00
!IAmTheAuthor && // I am not the author
IAmAPublisherOfThisSocNot); // I have shared the note
2016-01-01 20:19:43 +01:00
if (ICanUnshare)
{
2016-01-05 04:54:00 +01:00
/***** Delete social publishing from database *****/
Soc_UnshareASocialPublishingFromDB (&SocNot);
2016-01-06 22:16:08 +01:00
/***** Update number of times this social note is shared *****/
Soc_UpdateNumTimesANoteHasBeenShared (&SocNot);
2016-01-05 21:30:10 +01:00
2016-01-05 04:54:00 +01:00
/***** Message of success *****/
Lay_ShowAlert (Lay_SUCCESS,Txt_SOCIAL_PUBLISHING_Unshared);
2016-01-05 21:30:10 +01:00
2016-01-06 22:16:08 +01:00
/***** Show the social note corresponding
to the publishing just unshared *****/
Soc_WriteSocialNote (&SocPub,&SocNot,true,true);
2016-01-01 20:19:43 +01:00
}
}
2016-01-02 14:36:34 +01:00
/*****************************************************************************/
/**************** Unshare a social publishing from database ******************/
/*****************************************************************************/
2016-01-05 04:54:00 +01:00
static void Soc_UnshareASocialPublishingFromDB (struct SocialNote *SocNot)
2016-01-02 14:36:34 +01:00
{
char Query[128];
/***** Remove social publishing *****/
sprintf (Query,"DELETE FROM social_timeline"
" WHERE NotCod='%ld'"
" AND PublisherCod='%ld'" // I have share this note
" AND AuthorCod<>'%ld'", // I am not the author
SocNot->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryDELETE (Query,"can not remove a social publishing");
}
2015-12-30 02:08:08 +01:00
/*****************************************************************************/
2016-01-08 01:53:37 +01:00
/******************* Request the removal of a social note ********************/
2015-12-30 16:33:36 +01:00
/*****************************************************************************/
2016-01-08 01:53:37 +01:00
void Soc_RequestRemSocialNoteGbl (void)
2016-01-02 01:56:48 +01:00
{
2016-01-08 01:53:37 +01:00
/***** Request the removal of social note *****/
Soc_RequestRemovalSocialNote ();
2016-01-02 01:56:48 +01:00
/***** Write timeline again (global) *****/
Soc_ShowTimelineGbl ();
}
2016-01-08 01:53:37 +01:00
void Soc_RequestRemSocialNoteUsr (void)
2016-01-02 01:56:48 +01:00
{
/***** Get user whom profile is displayed *****/
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
2016-01-08 01:53:37 +01:00
/***** Show user's profile *****/
2016-01-02 01:56:48 +01:00
Prf_ShowUserProfile ();
2016-01-02 02:33:23 +01:00
/***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
2016-01-08 01:53:37 +01:00
/***** Request the removal of social note *****/
Soc_RequestRemovalSocialNote ();
2016-01-02 01:56:48 +01:00
/***** Write timeline again (user) *****/
Soc_ShowTimelineUsr ();
2016-01-02 02:33:23 +01:00
/***** End section *****/
fprintf (Gbl.F.Out,"</section>");
2016-01-02 01:56:48 +01:00
}
2016-01-08 01:53:37 +01:00
static void Soc_RequestRemovalSocialNote (void)
2015-12-30 16:33:36 +01:00
{
extern const char *Txt_Do_you_really_want_to_remove_the_following_comment;
extern const char *Txt_Remove;
2015-12-31 18:40:45 +01:00
struct SocialPublishing SocPub;
struct SocialNote SocNot;
2015-12-30 16:33:36 +01:00
bool ICanRemove;
2015-12-31 18:40:45 +01:00
/***** Get the code of the social publishing to remove *****/
SocPub.PubCod = Soc_GetParamPubCod ();
/***** Get data of social publishing *****/
Soc_GetDataOfSocialPublishingByCod (&SocPub);
2015-12-30 16:33:36 +01:00
2015-12-31 14:25:28 +01:00
/***** Get data of social note *****/
2015-12-31 18:40:45 +01:00
SocNot.NotCod = SocPub.NotCod;
Soc_GetDataOfSocialNoteByCod (&SocNot);
2015-12-30 16:33:36 +01:00
ICanRemove = (Gbl.Usrs.Me.Logged &&
2016-01-06 22:16:08 +01:00
SocPub.PublisherCod == Gbl.Usrs.Me.UsrDat.UsrCod &&
SocPub.AuthorCod == Gbl.Usrs.Me.UsrDat.UsrCod &&
SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
2015-12-30 16:33:36 +01:00
if (ICanRemove)
{
2016-01-04 17:36:28 +01:00
if (Soc_CheckIfNoteIsPublishedInTimelineByUsr (SocNot.NotCod,SocNot.UsrCod))
2016-01-02 01:56:48 +01:00
{
2016-01-05 21:30:10 +01:00
/***** Show warning and social note *****/
/* Warning message */
Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_remove_the_following_comment);
/* Show social note */
Soc_WriteSocialNote (&SocPub,&SocNot,true,true);
2016-01-04 17:36:28 +01:00
/***** 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);
2016-01-03 19:30:59 +01:00
2016-01-04 17:36:28 +01:00
/* End form */
Lay_PutRemoveButton (Txt_Remove);
Act_FormEnd ();
}
2015-12-30 16:33:36 +01:00
}
}
/*****************************************************************************/
2016-01-07 00:42:35 +01:00
/*************************** Remove a social note ****************************/
2015-12-30 02:08:08 +01:00
/*****************************************************************************/
2016-01-08 01:53:37 +01:00
void Soc_RemoveSocialNoteGbl (void)
2016-01-02 01:56:48 +01:00
{
2016-01-07 00:42:35 +01:00
/***** Remove a social note *****/
Soc_RemoveSocialNote ();
2016-01-02 01:56:48 +01:00
/***** Write updated timeline after removing (global) *****/
Soc_ShowTimelineGbl ();
}
2016-01-08 01:53:37 +01:00
void Soc_RemoveSocialNoteUsr (void)
2016-01-02 01:56:48 +01:00
{
/***** Get user whom profile is displayed *****/
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
2016-01-07 00:42:35 +01:00
/***** Show user's profile *****/
2016-01-02 01:56:48 +01:00
Prf_ShowUserProfile ();
2016-01-02 02:33:23 +01:00
/***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
2016-01-07 00:42:35 +01:00
/***** Remove a social note *****/
Soc_RemoveSocialNote ();
2016-01-02 01:56:48 +01:00
/***** Write updated timeline after removing (user) *****/
Soc_ShowTimelineUsr ();
2016-01-02 02:33:23 +01:00
/***** End section *****/
fprintf (Gbl.F.Out,"</section>");
2016-01-02 01:56:48 +01:00
}
2016-01-07 00:42:35 +01:00
static void Soc_RemoveSocialNote (void)
2015-12-30 02:08:08 +01:00
{
2016-01-02 14:36:34 +01:00
extern const char *Txt_SOCIAL_PUBLISHING_Removed;
2015-12-31 18:40:45 +01:00
struct SocialPublishing SocPub;
struct SocialNote SocNot;
2015-12-30 12:40:13 +01:00
bool ICanRemove;
2015-12-30 02:08:08 +01:00
2015-12-31 18:40:45 +01:00
/***** Get the code of the social publishing to remove *****/
SocPub.PubCod = Soc_GetParamPubCod ();
/***** Get data of social publishing *****/
Soc_GetDataOfSocialPublishingByCod (&SocPub);
2015-12-30 12:40:13 +01:00
2015-12-31 14:25:28 +01:00
/***** Get data of social note *****/
2015-12-31 18:40:45 +01:00
SocNot.NotCod = SocPub.NotCod;
Soc_GetDataOfSocialNoteByCod (&SocNot);
2015-12-30 12:40:13 +01:00
ICanRemove = (Gbl.Usrs.Me.Logged &&
2016-01-06 22:16:08 +01:00
SocPub.PublisherCod == Gbl.Usrs.Me.UsrDat.UsrCod &&
SocPub.AuthorCod == Gbl.Usrs.Me.UsrDat.UsrCod &&
SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
2015-12-30 12:40:13 +01:00
if (ICanRemove)
{
2016-01-01 20:19:43 +01:00
/***** Delete social publishing from database *****/
2016-01-08 01:53:37 +01:00
Soc_RemoveASocialNoteFromDB (&SocNot);
2015-12-30 16:33:36 +01:00
/***** Message of success *****/
2016-01-06 22:16:08 +01:00
Lay_ShowAlert (Lay_SUCCESS,Txt_SOCIAL_PUBLISHING_Removed);
2015-12-30 12:40:13 +01:00
}
2015-12-30 02:08:08 +01:00
}
2015-12-30 12:40:13 +01:00
2016-01-01 20:19:43 +01:00
/*****************************************************************************/
2016-01-08 01:53:37 +01:00
/******************* Remove a social note from database **********************/
2016-01-01 20:19:43 +01:00
/*****************************************************************************/
2016-01-08 01:53:37 +01:00
static void Soc_RemoveASocialNoteFromDB (struct SocialNote *SocNot)
2016-01-01 20:19:43 +01:00
{
2016-01-08 01:53:37 +01:00
char Query[256];
2016-01-01 20:19:43 +01:00
2016-01-06 22:16:08 +01:00
/***** Remove all the social publishings of this note *****/
2016-01-02 14:36:34 +01:00
sprintf (Query,"DELETE FROM social_timeline"
2016-01-06 22:16:08 +01:00
" WHERE NotCod='%ld'"
2016-01-02 14:36:34 +01:00
" AND AuthorCod='%ld'", // Extra check: I am the author
SocNot->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
2016-01-01 20:19:43 +01:00
DB_QueryDELETE (Query,"can not remove a social publishing");
2016-01-06 22:16:08 +01:00
/***** Remove social note *****/
sprintf (Query,"DELETE FROM social_notes"
" WHERE NotCod='%ld'"
" AND UsrCod='%ld'", // Extra check: I am the author
SocNot->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryDELETE (Query,"can not remove a social note");
2016-01-02 14:36:34 +01:00
2016-01-06 22:16:08 +01:00
if (SocNot->NoteType == Soc_NOTE_SOCIAL_POST)
2016-01-01 20:19:43 +01:00
{
2016-01-06 22:16:08 +01:00
/***** Remove social post *****/
sprintf (Query,"DELETE FROM social_posts"
" WHERE PstCod='%ld'",
SocNot->Cod);
DB_QueryDELETE (Query,"can not remove a social post");
2016-01-01 20:19:43 +01:00
}
2016-01-06 22:16:08 +01:00
2016-01-08 01:53:37 +01:00
/***** Remove content of the comments of this social note *****/
sprintf (Query,"DELETE FROM social_comments_content"
" USING social_comments,social_comments_content"
" WHERE social_comments.NotCod='%ld'"
" AND social_comments.ComCod=social_comments_content.ComCod",
SocNot->NotCod);
DB_QueryDELETE (Query,"can not remove social comments");
/***** Remove comments of this social note *****/
sprintf (Query,"DELETE FROM social_comments"
" WHERE NotCod='%ld'",
SocNot->NotCod);
DB_QueryDELETE (Query,"can not remove social comments");
2016-01-06 22:16:08 +01:00
/***** Reset social note *****/
Soc_ResetSocialNote (SocNot);
2016-01-01 20:19:43 +01:00
}
2016-01-08 01:53:37 +01:00
/*****************************************************************************/
/************* Request the removal of a comment in a social note *************/
/*****************************************************************************/
void Soc_RequestRemSocialComGbl (void)
{
/***** Request the removal of comment in social note *****/
Soc_RequestRemovalSocialComment ();
/***** Write timeline again (global) *****/
Soc_ShowTimelineGbl ();
}
void Soc_RequestRemSocialComUsr (void)
{
/***** Get user whom profile is displayed *****/
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/
Prf_ShowUserProfile ();
/***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
/***** Request the removal of comment in social note *****/
Soc_RequestRemovalSocialComment ();
/***** Write timeline again (user) *****/
Soc_ShowTimelineUsr ();
/***** End section *****/
fprintf (Gbl.F.Out,"</section>");
}
static void Soc_RequestRemovalSocialComment (void)
{
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 ();
/***** Get data of social comment *****/
Soc_GetDataOfSocialCommentByCod (&SocCom);
ICanRemove = (Gbl.Usrs.Me.Logged &&
SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
if (ICanRemove)
{
/***** Show warning and social comment *****/
/* Warning message */
Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_remove_the_following_comment);
/* Show social comment */
Soc_WriteSocialComment (&SocCom,true);
/***** Form to ask for confirmation to remove this social comment *****/
/* Start form */
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
Act_FormStartAnchor (ActRemSocComUsr,"timeline");
Usr_PutParamOtherUsrCodEncrypted ();
}
else
Act_FormStart (ActRemSocComGbl);
Soc_PutHiddenParamComCod (SocCom.ComCod);
/* End form */
Lay_PutRemoveButton (Txt_Remove);
Act_FormEnd ();
}
}
/*****************************************************************************/
/************************** Remove a social comment **************************/
/*****************************************************************************/
void Soc_RemoveSocialComGbl (void)
{
/***** Remove a social comment *****/
Soc_RemoveSocialComment ();
/***** Write updated timeline after removing (global) *****/
Soc_ShowTimelineGbl ();
}
void Soc_RemoveSocialComUsr (void)
{
/***** Get user whom profile is displayed *****/
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/
Prf_ShowUserProfile ();
/***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
/***** Remove a social comment *****/
Soc_RemoveSocialComment ();
/***** Write updated timeline after removing (user) *****/
Soc_ShowTimelineUsr ();
/***** End section *****/
fprintf (Gbl.F.Out,"</section>");
}
static void Soc_RemoveSocialComment (void)
{
extern const char *Txt_SOCIAL_PUBLISHING_Removed;
struct SocialComment SocCom;
struct SocialNote SocNot;
bool ICanRemove;
/***** Get the code of the social comment to remove *****/
SocCom.ComCod = Soc_GetParamComCod ();
/***** Get data of social comment *****/
Soc_GetDataOfSocialCommentByCod (&SocCom);
/***** Get data of social note *****/
SocNot.NotCod = SocCom.NotCod;
Soc_GetDataOfSocialNoteByCod (&SocNot);
ICanRemove = (Gbl.Usrs.Me.Logged &&
SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
if (ICanRemove)
{
/***** Delete social comment from database *****/
Soc_RemoveASocialCommentFromDB (&SocCom);
/***** Message of success *****/
Lay_ShowAlert (Lay_SUCCESS,Txt_SOCIAL_PUBLISHING_Removed);
}
}
/*****************************************************************************/
/****************** Remove a social comment from database ********************/
/*****************************************************************************/
static void Soc_RemoveASocialCommentFromDB (struct SocialComment *SocCom)
{
char Query[128];
/***** Remove content of this social comment *****/
sprintf (Query,"DELETE FROM social_comments_content"
" WHERE ComCod='%ld'",
SocCom->ComCod);
DB_QueryDELETE (Query,"can not remove a social comment");
/***** Remove this social comment *****/
sprintf (Query,"DELETE FROM social_comments"
" WHERE ComCod='%ld'"
" AND UsrCod='%ld'", // Extra check: I am the author
SocCom->ComCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryDELETE (Query,"can not remove a social comment");
/***** Reset social comment *****/
Soc_ResetSocialComment (SocCom);
}
2016-01-08 10:13:28 +01:00
/*****************************************************************************/
/******************* Remove a social note from database **********************/
/*****************************************************************************/
void Soc_RemoveUsrSocialContent (long UsrCod)
{
char Query[512];
/***** Remove social comments *****/
/* Remove content of all the comments in all the social notes of the user */
sprintf (Query,"DELETE FROM social_comments_content"
" USING social_comments,social_comments_content"
" WHERE social_comments.NotCod IN"
" (SELECT NotCod FROM social_notes WHERE UsrCod='%ld')"
" AND social_comments.ComCod=social_comments_content.ComCod",
UsrCod);
DB_QueryDELETE (Query,"can not remove social comments");
/* Remove all the comments in all the social notes of the user */
sprintf (Query,"DELETE FROM social_comments"
" WHERE NotCod IN"
" (SELECT NotCod FROM social_notes WHERE UsrCod='%ld')",
UsrCod);
DB_QueryDELETE (Query,"can not remove social comments");
/* Remove content of all the comments of the user in any social note */
sprintf (Query,"DELETE FROM social_comments_content"
" USING social_comments,social_comments_content"
" WHERE social_comments.UsrCod='%ld'"
" AND social_comments.ComCod=social_comments_content.ComCod",
UsrCod);
DB_QueryDELETE (Query,"can not remove social comments");
/* Remove all the comments of the user in any social note */
sprintf (Query,"DELETE FROM social_comments"
" WHERE UsrCod='%ld'",
UsrCod);
DB_QueryDELETE (Query,"can not remove social comments");
/***** Remove all the social posts of the user *****/
sprintf (Query,"DELETE FROM social_posts"
" WHERE PstCod IN"
" (SELECT Cod FROM social_notes"
" WHERE UsrCod='%ld' AND NoteType='%u')",
UsrCod,(unsigned) Soc_NOTE_SOCIAL_POST);
DB_QueryDELETE (Query,"can not remove social posts");
/***** Remove all the social publishings of the user *****/
sprintf (Query,"DELETE FROM social_timeline"
" WHERE AuthorCod='%ld' OR PublisherCod='%ld'",
UsrCod,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'",
UsrCod);
DB_QueryDELETE (Query,"can not remove social notes");
}
2016-01-01 20:19:43 +01:00
/*****************************************************************************/
2016-01-04 17:36:28 +01:00
/**************** Check if a user has published a social note ****************/
2016-01-01 20:19:43 +01:00
/*****************************************************************************/
2016-01-04 17:36:28 +01:00
static bool Soc_CheckIfNoteIsPublishedInTimelineByUsr (long NotCod,long UsrCod)
2016-01-01 20:19:43 +01:00
{
char Query[128];
sprintf (Query,"SELECT COUNT(*) FROM social_timeline"
" WHERE NotCod='%ld' AND PublisherCod='%ld'",
2016-01-04 17:36:28 +01:00
NotCod,UsrCod);
return (DB_QueryCOUNT (Query,"can not check if a user has published a social note") != 0);
2016-01-01 20:19:43 +01:00
}
2016-01-04 11:58:36 +01:00
/*****************************************************************************/
/******** Get number of times a note code has been shared in timeline ********/
/*****************************************************************************/
2016-01-05 21:30:10 +01:00
static void Soc_UpdateNumTimesANoteHasBeenShared (struct SocialNote *SocNot)
2016-01-04 11:58:36 +01:00
{
char Query[128];
2016-01-04 14:49:10 +01:00
/***** Get number of times (users) this note has been shared *****/
2016-01-04 11:58:36 +01:00
sprintf (Query,"SELECT COUNT(*) FROM social_timeline"
" WHERE NotCod='%ld' AND PublisherCod<>'%ld'",
2016-01-04 14:49:10 +01:00
SocNot->NotCod,
SocNot->UsrCod); // The author
SocNot->NumShared = (unsigned) DB_QueryCOUNT (Query,"can not get number of times a note has been shared");
}
/*****************************************************************************/
/**************** Show users who have shared this social note ****************/
/*****************************************************************************/
static void Soc_ShowUsrsWhoHaveSharedSocialNote (const struct SocialNote *SocNot)
{
char Query[256];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumUsrs;
unsigned NumUsr;
unsigned NumUsrsShown = 0;
struct UsrData UsrDat;
bool ShowPhoto;
char PhotoURL[PATH_MAX+1];
/* Show number of users who have shared this social note */
fprintf (Gbl.F.Out,"<span class=\"SOCIAL_NUM_SHARES\"> %u</span>",
SocNot->NumShared);
if (SocNot->NumShared)
{
/***** Get list of publishers from database (only the first) *****/
sprintf (Query,"SELECT PublisherCod"
" FROM social_timeline"
" WHERE NotCod='%ld' AND PublisherCod<>'%ld'"
" ORDER BY PubCod LIMIT %u",
SocNot->NotCod,SocNot->UsrCod,
Soc_MAX_NUM_SHARERS_SHOWN);
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get data of social publishing");
if (NumUsrs)
{
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** List users *****/
for (NumUsr = 0;
NumUsr < NumUsrs;
NumUsr++)
{
/***** Get user *****/
row = mysql_fetch_row (mysql_res);
/* Get user's code (row[0]) */
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
/***** Get user's data and show user's photo *****/
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat))
{
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_SHARER\">");
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (&UsrDat,PhotoURL);
Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL :
NULL,
"PHOTO18x24",Pho_ZOOM);
fprintf (Gbl.F.Out,"</div>");
NumUsrsShown++;
}
}
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
if (SocNot->NumShared > NumUsrsShown)
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_SHARER\">"
"<img src=\"%s/ellipsis32x32.gif\""
" alt=\"%u\" title=\"%u\""
" class=\"ICON20x20\" />"
"</div>",
Gbl.Prefs.IconsURL,
SocNot->NumShared - NumUsrsShown,
SocNot->NumShared - NumUsrsShown);
}
2016-01-04 11:58:36 +01:00
}
2015-12-31 18:40:45 +01:00
/*****************************************************************************/
/********* Get data of social publishing in timeline using its code **********/
2015-12-30 12:40:13 +01:00
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
static void Soc_GetDataOfSocialPublishingByCod (struct SocialPublishing *SocPub)
{
char Query[256];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
/***** Get data of social publishing from database *****/
2016-01-04 14:49:10 +01:00
sprintf (Query,"SELECT PubCod,NotCod,PublisherCod,AuthorCod,UNIX_TIMESTAMP(TimePublish)"
2015-12-31 18:40:45 +01:00
" FROM social_timeline"
" WHERE PubCod='%ld'",
SocPub->PubCod);
2016-01-02 14:36:34 +01:00
if (DB_QuerySELECT (Query,&mysql_res,"can not get data of social publishing"))
2015-12-31 18:40:45 +01:00
{
/***** Get social note *****/
row = mysql_fetch_row (mysql_res);
Soc_GetDataOfSocialPublishingFromRow (row,SocPub);
}
else
/***** Reset fields of social publishing *****/
2016-01-05 04:54:00 +01:00
Soc_ResetSocialPublishing (SocPub);
2015-12-31 18:40:45 +01:00
}
/*****************************************************************************/
/**************** Get data of social note using its code *********************/
/*****************************************************************************/
static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *SocNot)
2015-12-30 12:40:13 +01:00
{
char Query[256];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2015-12-31 14:25:28 +01:00
/***** Get data of social note from database *****/
2016-01-03 17:34:06 +01:00
sprintf (Query,"SELECT NotCod,NoteType,UsrCod,HieCod,Cod,Unavailable,UNIX_TIMESTAMP(TimeNote)"
2015-12-31 14:25:28 +01:00
" FROM social_notes"
2015-12-31 14:47:22 +01:00
" WHERE NotCod='%ld'",
2015-12-31 18:40:45 +01:00
SocNot->NotCod);
2015-12-31 14:25:28 +01:00
if (DB_QuerySELECT (Query,&mysql_res,"can not get data of social note"))
2015-12-30 12:40:13 +01:00
{
2016-01-04 11:58:36 +01:00
/***** Get data of social note *****/
2015-12-30 12:40:13 +01:00
row = mysql_fetch_row (mysql_res);
2015-12-31 18:40:45 +01:00
Soc_GetDataOfSocialNoteFromRow (row,SocNot);
2016-01-04 11:58:36 +01:00
/***** Get number of times this social note has been shared *****/
2016-01-05 21:30:10 +01:00
Soc_UpdateNumTimesANoteHasBeenShared (SocNot);
2015-12-30 12:40:13 +01:00
}
else
2015-12-31 14:25:28 +01:00
/***** Reset fields of social note *****/
2016-01-05 04:54:00 +01:00
Soc_ResetSocialNote (SocNot);
2015-12-30 12:40:13 +01:00
}
2015-12-30 16:33:36 +01:00
/*****************************************************************************/
2016-01-08 01:53:37 +01:00
/*************** Get data of social comment using its code *******************/
/*****************************************************************************/
static void Soc_GetDataOfSocialCommentByCod (struct SocialComment *SocCom)
{
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
/***** Get data of social comment from database *****/
sprintf (Query,"SELECT social_comments.ComCod,social_comments.UsrCod,"
"social_comments.NotCod,"
"UNIX_TIMESTAMP(social_comments.TimeComment),"
"social_comments_content.Content"
" FROM social_comments,social_comments_content"
" WHERE social_comments.ComCod='%ld'"
" AND social_comments.ComCod=social_comments_content.ComCod",
SocCom->ComCod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get data of social comment"))
{
/***** Get data of social comment *****/
row = mysql_fetch_row (mysql_res);
Soc_GetDataOfSocialCommentFromRow (row,SocCom);
}
else
/***** Reset fields of social comment *****/
Soc_ResetSocialComment (SocCom);
}
/*****************************************************************************/
/************** Get data of social publishing using its code *****************/
/*****************************************************************************/
static void Soc_GetDataOfSocialPublishingFromRow (MYSQL_ROW row,struct SocialPublishing *SocPub)
{
/* Get code of social publishing (row[0]) */
SocPub->PubCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get social note code (row[1]) */
SocPub->NotCod = Str_ConvertStrCodToLongCod (row[1]);
/* Get publisher's code (row[2]) */
SocPub->PublisherCod = Str_ConvertStrCodToLongCod (row[2]);
/* Get author's code (row[3]) */
SocPub->AuthorCod = Str_ConvertStrCodToLongCod (row[3]);
/* Get time of the note (row[4]) */
SocPub->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[4]);
}
/*****************************************************************************/
/******************** Get data of social note from row ***********************/
2015-12-30 16:33:36 +01:00
/*****************************************************************************/
2015-12-31 18:40:45 +01:00
static void Soc_GetDataOfSocialNoteFromRow (MYSQL_ROW row,struct SocialNote *SocNot)
2015-12-30 16:33:36 +01:00
{
/* Get social code (row[0]) */
2016-01-02 14:36:34 +01:00
SocNot->NotCod = Str_ConvertStrCodToLongCod (row[0]);
2015-12-30 16:33:36 +01:00
2015-12-31 14:25:28 +01:00
/* Get note type (row[1]) */
2016-01-04 11:58:36 +01:00
SocNot->NoteType = Soc_GetNoteTypeFromStr ((const char *) row[1]);
2015-12-30 16:33:36 +01:00
/* Get (from) user code (row[2]) */
2016-01-02 14:36:34 +01:00
SocNot->UsrCod = Str_ConvertStrCodToLongCod (row[2]);
2015-12-30 16:33:36 +01:00
2016-01-02 13:21:25 +01:00
/* Get hierarchy code (row[3]) */
2016-01-02 14:36:34 +01:00
SocNot->HieCod = Str_ConvertStrCodToLongCod (row[3]);
2015-12-30 16:33:36 +01:00
2016-01-02 13:21:25 +01:00
/* Get file/post... code (row[4]) */
2016-01-02 14:36:34 +01:00
SocNot->Cod = Str_ConvertStrCodToLongCod (row[4]);
2015-12-30 16:33:36 +01:00
2016-01-03 17:34:06 +01:00
/* File/post... unavailable (row[5]) */
SocNot->Unavailable = (Str_ConvertToUpperLetter (row[5][0]) == 'Y');
/* Get time of the note (row[6]) */
SocNot->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[6]);
2015-12-31 18:40:45 +01:00
}
/*****************************************************************************/
/****** Get social note type from string number coming from database *********/
/*****************************************************************************/
2016-01-04 11:58:36 +01:00
static Soc_NoteType_t Soc_GetNoteTypeFromStr (const char *Str)
2015-12-31 18:40:45 +01:00
{
unsigned UnsignedNum;
if (sscanf (Str,"%u",&UnsignedNum) == 1)
if (UnsignedNum < Soc_NUM_SOCIAL_NOTES)
return (Soc_NoteType_t) UnsignedNum;
return Soc_NOTE_UNKNOWN;
2015-12-30 16:33:36 +01:00
}
2016-01-05 04:54:00 +01:00
2016-01-08 01:53:37 +01:00
/*****************************************************************************/
/****************** Get data of social comment from row **********************/
/*****************************************************************************/
static void Soc_GetDataOfSocialCommentFromRow (MYSQL_ROW row,struct SocialComment *SocCom)
{
/* Get code of social comment (row[0]) */
SocCom->ComCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get (from) user code (row[1]) */
SocCom->UsrCod = Str_ConvertStrCodToLongCod (row[1]);
/* Get code of social note (row[2]) */
SocCom->NotCod = Str_ConvertStrCodToLongCod (row[2]);
/* Get time of the note (row[3]) */
SocCom->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[3]);
/* Get content (row[4]) */
strncpy (SocCom->Content,row[4],Cns_MAX_BYTES_LONG_TEXT);
SocCom->Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
}
2016-01-05 04:54:00 +01:00
/*****************************************************************************/
/******************** Reset fields of social publishing **********************/
/*****************************************************************************/
static void Soc_ResetSocialPublishing (struct SocialPublishing *SocPub)
{
SocPub->NotCod = -1L;
SocPub->PublisherCod = -1L;
SocPub->AuthorCod = -1L;
SocPub->DateTimeUTC = (time_t) 0;
}
/*****************************************************************************/
/*********************** Reset fields of social note *************************/
/*****************************************************************************/
static void Soc_ResetSocialNote (struct SocialNote *SocNot)
{
SocNot->NoteType = Soc_NOTE_UNKNOWN;
SocNot->UsrCod = -1L;
SocNot->HieCod = -1L;
SocNot->Cod = -1L;
SocNot->Unavailable = false;
SocNot->DateTimeUTC = (time_t) 0;
SocNot->NumShared = 0;
}
2016-01-08 01:53:37 +01:00
/*****************************************************************************/
/********************** Reset fields of social comment ***********************/
/*****************************************************************************/
static void Soc_ResetSocialComment (struct SocialComment *SocCom)
{
SocCom->UsrCod = -1L;
SocCom->NotCod = -1L;
SocCom->DateTimeUTC = (time_t) 0;
SocCom->Content[0] = '\0';
}