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