mirror of https://github.com/acanas/swad-core.git
Version 15.82.1
This commit is contained in:
parent
021c777bc9
commit
9bb1b6d63e
|
@ -116,13 +116,14 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.82 (2015-12-29)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.82.1 (2015-12-29)"
|
||||
#define CSS_FILE "swad15.80.css"
|
||||
#define JS_FILE "swad15.77.7.js"
|
||||
|
||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
||||
/*
|
||||
Version 15.82.1: Dec 29, 2015 Public social posts are displayed in timeline. (189176 lines)
|
||||
Version 15.82: Dec 29, 2015 Public social post is received and stored in a new database table. (189136 lines)
|
||||
1 change necessary in database:
|
||||
CREATE TABLE IF NOT EXISTS social_post (PstCod INT NOT NULL AUTO_INCREMENT,Content LONGTEXT NOT NULL,UNIQUE INDEX(PstCod),FULLTEXT(Content)) ENGINE = MYISAM;
|
||||
|
|
|
@ -2347,14 +2347,19 @@ void Msg_GetDistinctCoursesInMyMessages (Msg_TypeOfMessages_t TypeOfMessages)
|
|||
switch (TypeOfMessages)
|
||||
{
|
||||
case Msg_MESSAGES_RECEIVED:
|
||||
sprintf (Query,"SELECT DISTINCT courses.CrsCod,courses.ShortName FROM msg_rcv,msg_snt,courses"
|
||||
" WHERE msg_rcv.UsrCod='%ld' AND msg_rcv.MsgCod=msg_snt.MsgCod AND msg_snt.CrsCod=courses.CrsCod"
|
||||
sprintf (Query,"SELECT DISTINCT courses.CrsCod,courses.ShortName"
|
||||
" FROM msg_rcv,msg_snt,courses"
|
||||
" WHERE msg_rcv.UsrCod='%ld'"
|
||||
" AND msg_rcv.MsgCod=msg_snt.MsgCod"
|
||||
" AND msg_snt.CrsCod=courses.CrsCod"
|
||||
" ORDER BY courses.ShortName",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
break;
|
||||
case Msg_MESSAGES_SENT:
|
||||
sprintf (Query,"SELECT DISTINCT courses.CrsCod,courses.ShortName FROM msg_snt,courses"
|
||||
" WHERE msg_snt.UsrCod='%ld' AND msg_snt.CrsCod=courses.CrsCod"
|
||||
sprintf (Query,"SELECT DISTINCT courses.CrsCod,courses.ShortName"
|
||||
" FROM msg_snt,courses"
|
||||
" WHERE msg_snt.UsrCod='%ld'"
|
||||
" AND msg_snt.CrsCod=courses.CrsCod"
|
||||
" ORDER BY courses.ShortName",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
break;
|
||||
|
@ -2588,13 +2593,14 @@ void Msg_GetMsgSubject (long MsgCod,char *Subject)
|
|||
|
||||
static void Msg_GetMsgContent (long MsgCod,char *Content)
|
||||
{
|
||||
char Query[512];
|
||||
char Query[128];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
||||
/***** Get content of message from database *****/
|
||||
sprintf (Query,"SELECT Content FROM msg_content WHERE MsgCod='%ld'",MsgCod);
|
||||
sprintf (Query,"SELECT Content FROM msg_content WHERE MsgCod='%ld'",
|
||||
MsgCod);
|
||||
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get the content of a message");
|
||||
|
||||
/***** Result should have a unique row *****/
|
||||
|
@ -2604,7 +2610,7 @@ static void Msg_GetMsgContent (long MsgCod,char *Content)
|
|||
/***** Get number of rows *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/****** Get location (row[0]) *****/
|
||||
/****** Get content (row[0]) *****/
|
||||
strncpy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT);
|
||||
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <linux/limits.h> // For PATH_MAX
|
||||
#include <stdlib.h> // For malloc and free
|
||||
#include <string.h> // For string functions
|
||||
#include <sys/types.h> // For time_t
|
||||
|
||||
#include "swad_constant.h"
|
||||
|
@ -105,6 +106,8 @@ extern struct Globals Gbl;
|
|||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Soc_GetAndWriteSocialPost (long PstCod);
|
||||
|
||||
static unsigned long Soc_ShowTimeline (const char *Query);
|
||||
static Soc_SocialEvent_t Soc_GetSocialEventFromDB (const char *Str);
|
||||
static void Soc_WriteEventDate (time_t TimeUTC);
|
||||
|
@ -166,6 +169,43 @@ void Soc_ReceiveSocialPost (void)
|
|||
Soc_StoreSocialEvent (Soc_EVENT_SOCIAL_POST,PstCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** 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_post 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);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Show social activity (timeline) of a selected user **************/
|
||||
/*****************************************************************************/
|
||||
|
@ -248,7 +288,7 @@ static unsigned long Soc_ShowTimeline (const char *Query)
|
|||
time_t DateTimeUTC; // Date-time of the event
|
||||
bool ShowPhoto = false;
|
||||
char PhotoURL[PATH_MAX+1];
|
||||
char *SummaryStr;
|
||||
char SummaryStr[Cns_MAX_BYTES_TEXT+1];
|
||||
|
||||
/***** Get timeline from database *****/
|
||||
NumEvents = DB_QuerySELECT (Query,&mysql_res,"can not get your notifications");
|
||||
|
@ -256,10 +296,6 @@ static unsigned long Soc_ShowTimeline (const char *Query)
|
|||
/***** List my timeline *****/
|
||||
if (NumEvents) // Events found
|
||||
{
|
||||
/***** Allocate memory for the summary of the notification *****/
|
||||
if ((SummaryStr = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
|
||||
Lay_ShowErrorAndExit ("Not enough memory to store the summary of the notification.");
|
||||
|
||||
/***** Initialize structure with user's data *****/
|
||||
Usr_UsrDataConstructor (&UsrDat);
|
||||
|
||||
|
@ -349,9 +385,15 @@ static unsigned long Soc_ShowTimeline (const char *Query)
|
|||
/* Write date and time */
|
||||
Soc_WriteEventDate (DateTimeUTC);
|
||||
|
||||
/* Write event type and location */
|
||||
if (SocialEvent != Soc_EVENT_SOCIAL_POST)
|
||||
if (SocialEvent == Soc_EVENT_SOCIAL_POST)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">");
|
||||
Soc_GetAndWriteSocialPost (Cod);
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Write event type and location */
|
||||
fprintf (Gbl.F.Out,"<div>");
|
||||
Soc_StartFormGoToAction (SocialEvent,Crs.CrsCod,Cod);
|
||||
Act_LinkFormSubmit (Txt_SOCIAL_EVENT[SocialEvent],
|
||||
|
@ -379,12 +421,12 @@ static unsigned long Soc_ShowTimeline (const char *Query)
|
|||
else if (Cty.CtyCod > 0)
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
|
||||
Txt_Country,Cty.Name[Gbl.Prefs.Language]);
|
||||
}
|
||||
|
||||
/* Write content of the event */
|
||||
Soc_GetEventSummary (SocialEvent,Cod,
|
||||
SummaryStr,Soc_MAX_BYTES_SUMMARY);
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s</div>",SummaryStr);
|
||||
/* Write content of the event */
|
||||
Soc_GetEventSummary (SocialEvent,Cod,
|
||||
SummaryStr,Soc_MAX_BYTES_SUMMARY);
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s</div>",SummaryStr);
|
||||
}
|
||||
|
||||
/* End of right part */
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
@ -399,9 +441,6 @@ static unsigned long Soc_ShowTimeline (const char *Query)
|
|||
|
||||
/***** Free memory used for user's data *****/
|
||||
Usr_UsrDataDestructor (&UsrDat);
|
||||
|
||||
/***** Free summary *****/
|
||||
free ((void *) SummaryStr);
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
|
Loading…
Reference in New Issue