Version 15.77.1

This commit is contained in:
Antonio Cañas Vargas 2015-12-28 20:46:48 +01:00
parent 6110c5750a
commit 1b8da4590f
8 changed files with 99 additions and 34 deletions

View File

@ -1341,6 +1341,7 @@ a:hover img.CENTRE_PHOTO_SHOW
.PHOTO21x28 {width: 21px; height: 28px; vertical-align:middle; border-radius:2px;}
.PHOTO30x40 {width: 30px; height: 40px; vertical-align:middle; border-radius:2px;}
.PHOTO45x60 {width: 45px; height: 60px; vertical-align:middle; border-radius:3px;}
.PHOTO60x80 {width: 60px; height: 80px; vertical-align:middle; border-radius:3px;}
.PHOTO93x124 {width: 93px; height:124px; vertical-align:middle; border-radius:4px;}
.PHOTO186x248 {width:186px; height:248px; vertical-align:middle; border-radius:8px;}
.IMG_USR

View File

@ -11188,4 +11188,4 @@ SELECT COUNT(DISTINCT crs_usr.UsrCod) FROM institutions,centres,degrees,courses,
----- SWAD 15.77 (2015/12/28) -----
CREATE TABLE IF NOT EXISTS social (SocCod BIGINT NOT NULL AUTO_INCREMENT,SocialEvent TINYINT NOT NULL,UsrCod INT NOT NULL,CtyCod INT NOT NULL DEFAULT -1,InsCod INT NOT NULL DEFAULT -1,CtrCod INT NOT NULL DEFAULT -1,DegCod INT NOT NULL DEFAULT -1,CrsCod INT NOT NULL DEFAULT -1,Cod INT NOT NULL DEFAULT -1,TimeEvent DATETIME NOT NULL,Status TINYINT NOT NULL DEFAULT 0,UNIQUE INDEX(SocCod),INDEX(SocialEvent),INDEX(UsrCod),INDEX(TimeEvent));
ALTER TABLE social DROP COLUMN Status;

View File

@ -926,7 +926,6 @@ CREATE TABLE IF NOT EXISTS social (
CrsCod INT NOT NULL DEFAULT -1,
Cod INT NOT NULL DEFAULT -1,
TimeEvent DATETIME NOT NULL,
Status TINYINT NOT NULL DEFAULT 0,
UNIQUE INDEX(SocCod),
INDEX(SocialEvent),
INDEX(UsrCod),

View File

@ -114,15 +114,16 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.77 (2015-12-28)"
#define Log_PLATFORM_VERSION "SWAD 15.77.1 (2015-12-28)"
#define CSS_FILE "swad15.75.css"
// 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.77.1: Dec 28, 2015 Insert social event when posting in a global forum. (188342 lines)
Version 15.77: Dec 28, 2015 New table in database for social activity. (188287 lines)
2 changes necessary in database:
CREATE TABLE IF NOT EXISTS social (SocCod BIGINT NOT NULL AUTO_INCREMENT,SocialEvent TINYINT NOT NULL,UsrCod INT NOT NULL,CtyCod INT NOT NULL DEFAULT -1,InsCod INT NOT NULL DEFAULT -1,CtrCod INT NOT NULL DEFAULT -1,DegCod INT NOT NULL DEFAULT -1,CrsCod INT NOT NULL DEFAULT -1,Cod INT NOT NULL DEFAULT -1,TimeEvent DATETIME NOT NULL,Status TINYINT NOT NULL DEFAULT 0,UNIQUE INDEX(SocCod),INDEX(SocialEvent),INDEX(UsrCod),INDEX(TimeEvent));
CREATE TABLE IF NOT EXISTS social (SocCod BIGINT NOT NULL AUTO_INCREMENT,SocialEvent TINYINT NOT NULL,UsrCod INT NOT NULL,CtyCod INT NOT NULL DEFAULT -1,InsCod INT NOT NULL DEFAULT -1,CtrCod INT NOT NULL DEFAULT -1,DegCod INT NOT NULL DEFAULT -1,CrsCod INT NOT NULL DEFAULT -1,Cod INT NOT NULL DEFAULT -1,TimeEvent DATETIME NOT NULL,UNIQUE INDEX(SocCod),INDEX(SocialEvent),INDEX(UsrCod),INDEX(TimeEvent));
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1490','es','N','Ver actividad social (timeline)');
Version 15.76.1: Dec 28, 2015 Refactoring in swad_database. (187926 lines)

View File

@ -1951,9 +1951,8 @@ mysql> DESCRIBE social;
| CrsCod | int(11) | NO | | -1 | |
| Cod | int(11) | NO | | -1 | |
| TimeEvent | datetime | NO | MUL | NULL | |
| Status | tinyint(4) | NO | | 0 | |
+-------------+------------+------+-----+---------+----------------+
11 rows in set (0.00 sec)
10 rows in set (0.00 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS social ("
"SocCod BIGINT NOT NULL AUTO_INCREMENT,"
@ -1966,7 +1965,6 @@ mysql> DESCRIBE social;
"CrsCod INT NOT NULL DEFAULT -1,"
"Cod INT NOT NULL DEFAULT -1,"
"TimeEvent DATETIME NOT NULL,"
"Status TINYINT NOT NULL DEFAULT 0,"
"UNIQUE INDEX(SocCod),"
"INDEX(SocialEvent),"
"INDEX(UsrCod),"

View File

@ -41,6 +41,7 @@
#include "swad_notification.h"
#include "swad_parameter.h"
#include "swad_profile.h"
#include "swad_social.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
@ -3829,6 +3830,17 @@ void For_RecForumPst (void)
Ntf_ShowAlertNumUsrsToBeNotifiedByEMail (NumUsrsToBeNotifiedByEMail);
}
/***** Insert post into public social activity *****/
switch (Gbl.Forum.ForumType) // Only if forum is public for any logged user
{
case For_FORUM_GLOBAL_USRS:
case For_FORUM_SWAD_USRS:
Soc_StoreSocialEvent (Soc_EVENT_FORUM_POST,PstCod);
break;
default:
break;
}
/***** Show again the posts of this thread of the forum *****/
For_ShowForumLevel2 (ThrCod);
}

View File

@ -25,25 +25,15 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
// #include <linux/stddef.h> // For NULL
#include <linux/limits.h> // For PATH_MAX
#include <stdlib.h> // For malloc and free
#include <sys/types.h> // For time_t
#include "swad_constant.h"
// #include "swad_config.h"
#include "swad_database.h"
// #include "swad_follow.h"
#include "swad_global.h"
#include "swad_layout.h"
// #include "swad_nickname.h"
// #include "swad_parameter.h"
// #include "swad_privacy.h"
// #include "swad_profile.h"
// #include "swad_role.h"
#include "swad_social.h"
// #include "swad_text.h"
// #include "swad_theme.h"
// #include "swad_user.h"
/*****************************************************************************/
/****************************** Public constants *****************************/
@ -108,7 +98,7 @@ void Soc_ShowSocialActivity (void)
time_t DateTimeUTC; // Date-time of the event
bool ShowPhoto = false;
char PhotoURL[PATH_MAX+1];
char SummaryStr[Soc_MAX_BYTES_SUMMARY+1];
char *SummaryStr;
/***** Get my timeline from database *****/
sprintf (Query,"SELECT SocialEvent,UsrCod,"
@ -124,12 +114,16 @@ void Soc_ShowSocialActivity (void)
/***** 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);
/***** List start *****/
Lay_StartRoundFrame (NULL,Txt_Public_activity);
fprintf (Gbl.F.Out,"<ul>");
fprintf (Gbl.F.Out,"<ul class=\"LIST_LEFT\">");
/***** List events one by one *****/
for (NumEvent = 0;
@ -192,20 +186,27 @@ void Soc_ShowSocialActivity (void)
fprintf (Gbl.F.Out,"<li>");
/* Write author of the event */
fprintf (Gbl.F.Out,"<div style=\"display:inline-block; vertical-align:top; width:64px; height:90px;\">");
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (&UsrDat,PhotoURL);
Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL :
NULL,
"PHOTO30x40",Pho_ZOOM);
"PHOTO60x80",Pho_ZOOM);
fprintf (Gbl.F.Out,"</div>");
fprintf (Gbl.F.Out,"<span class=\"DAT\">%s</span>",
UsrDat.FullName);
fprintf (Gbl.F.Out,"<div style=\"display:inline-block;\">");
/* Write event type */
fprintf (Gbl.F.Out,"<span class=\"DAT\">%u</span>",
fprintf (Gbl.F.Out,"<div class=\"DAT LEFT_TOP\""
" style=\"display:inline-block; width:300px;\">"
"<strong>%s</strong> @%s</div>",
UsrDat.FullName,UsrDat.Nickname);
/* Write date and time */
Soc_WriteEventDate (DateTimeUTC);
/* Write event type and location */
fprintf (Gbl.F.Out,"<div class=\"DAT\" style=\"display:block;\">%u: ",
(unsigned) SocialEvent);
/* Write location */
fprintf (Gbl.F.Out,"<span class=\"DAT\">");
if (SocialEvent == Soc_EVENT_FORUM_POST)
fprintf (Gbl.F.Out,"%s: %s",Txt_Forum,ForumName);
else if (Crs.CrsCod > 0)
@ -218,15 +219,14 @@ void Soc_ShowSocialActivity (void)
fprintf (Gbl.F.Out,"%s: %s",Txt_Institution,Ins.ShortName);
else if (Cty.CtyCod > 0)
fprintf (Gbl.F.Out,"%s: %s",Txt_Country,Cty.Name[Gbl.Prefs.Language]);
fprintf (Gbl.F.Out,"</span>");
/* Write date and time */
Soc_WriteEventDate (DateTimeUTC);
fprintf (Gbl.F.Out,"</div>");
/***** Write content of the event *****/
Soc_GetEventSummary (SocialEvent,Cod,
SummaryStr,Soc_MAX_BYTES_SUMMARY);
fprintf (Gbl.F.Out,"<span class=\"DAT\">%s</span>",SummaryStr);
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s</div>",SummaryStr);
fprintf (Gbl.F.Out,"</div>");
}
/***** List end *****/
@ -235,6 +235,9 @@ void Soc_ShowSocialActivity (void)
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
/***** Free summary *****/
free ((void *) SummaryStr);
}
else
Lay_ShowAlert (Lay_INFO,"No events."); // Need translation!!!!
@ -270,7 +273,8 @@ static void Soc_WriteEventDate (time_t TimeUTC)
UniqueId++;
/***** Start cell *****/
fprintf (Gbl.F.Out,"<span id=\"date_%u\" class=\"DAT\">",
fprintf (Gbl.F.Out,"<div id=\"date_%u\" class=\"DAT_LIGHT RIGHT_TOP\""
" style=\"display:inline-block;\">",
UniqueId);
/***** Write date and time *****/
@ -280,7 +284,7 @@ static void Soc_WriteEventDate (time_t TimeUTC)
UniqueId,(long) TimeUTC);
/***** End cell *****/
fprintf (Gbl.F.Out,"</span>");
fprintf (Gbl.F.Out,"</div>");
}
/*****************************************************************************/
@ -365,3 +369,51 @@ static void Soc_GetEventSummary (Soc_SocialEvent_t SocialEvent,long Cod,
break;
}
}
/*****************************************************************************/
/********************* Store a social event into database ********************/
/*****************************************************************************/
void Soc_StoreSocialEvent (Soc_SocialEvent_t SocialEvent,long Cod)
{
char Query[512];
long CtyCod;
long InsCod;
long CtrCod;
long DegCod;
long CrsCod;
if (SocialEvent == Soc_EVENT_FORUM_POST)
{
// CtyCod = Gbl.Forum.Cty.CtyCod;
// InsCod = Gbl.Forum.Ins.InsCod;
// CtrCod = Gbl.Forum.Ctr.CtrCod;
// DegCod = Gbl.Forum.Deg.DegCod;
// CrsCod = Gbl.Forum.Crs.CrsCod;
CtyCod = -1L;
InsCod = -1L;
CtrCod = -1L;
DegCod = -1L;
CrsCod = -1L;
}
else
{
CtyCod = Gbl.CurrentCty.Cty.CtyCod;
InsCod = Gbl.CurrentIns.Ins.InsCod;
CtrCod = Gbl.CurrentCtr.Ctr.CtrCod;
DegCod = Gbl.CurrentDeg.Deg.DegCod;
CrsCod = Gbl.CurrentCrs.Crs.CrsCod;
}
/***** Store notify event *****/
sprintf (Query,"INSERT INTO social (SocialEvent,UsrCod,"
"CtyCod,InsCod,CtrCod,DegCod,CrsCod,"
"Cod,TimeEvent)"
" VALUES ('%u','%ld',"
"'%ld','%ld','%ld','%ld','%ld',"
"'%ld',NOW())",
(unsigned) SocialEvent,Gbl.Usrs.Me.UsrDat.UsrCod,
CtyCod,InsCod,CtrCod,DegCod,CrsCod,
Cod);
DB_QueryINSERT (Query,"can not create new social event");
}

View File

@ -84,4 +84,6 @@ typedef enum
void Soc_ShowSocialActivity (void);
void Soc_StoreSocialEvent (Soc_SocialEvent_t SocialEvent,long Cod);
#endif