Version 18.53

This commit is contained in:
Antonio Cañas Vargas 2019-02-21 20:04:05 +01:00
parent 1c98d3828e
commit f53f29fac9
7 changed files with 111 additions and 22 deletions

View File

@ -1407,6 +1407,7 @@ CREATE TABLE IF NOT EXISTS usr_last (
LastTab TINYINT NOT NULL, LastTab TINYINT NOT NULL,
LastTime DATETIME NOT NULL, LastTime DATETIME NOT NULL,
LastAccNotif DATETIME NOT NULL, LastAccNotif DATETIME NOT NULL,
TimelineUsrs TINYINT NOT NULL DEFAULT 0,
UNIQUE INDEX(UsrCod), UNIQUE INDEX(UsrCod),
INDEX(LastTime)); INDEX(LastTime));
-- --

View File

@ -429,11 +429,15 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 18.52.4 (2019-02-21)" #define Log_PLATFORM_VERSION "SWAD 18.53 (2019-02-21)"
#define CSS_FILE "swad18.52.4.css" #define CSS_FILE "swad18.52.4.css"
#define JS_FILE "swad18.51.js" #define JS_FILE "swad18.51.js"
/* /*
Version 18.52.4: Feb 21, 2019 Changes in pink theme. (? lines) Version 18.53: Feb 21, 2019 Last selection of users scope in timeline is saved in database. (237538 lines)
1 change necessary in database:
ALTER TABLE usr_last ADD COLUMN TimelineUsrs TINYINT NOT NULL DEFAULT 0 AFTER LastAccNotif;
Version 18.52.4: Feb 21, 2019 Changes in pink theme. (237459 lines)
Version 18.52.3: Feb 21, 2019 Fixed bug in removing of old temporary files. (237458 lines) Version 18.52.3: Feb 21, 2019 Fixed bug in removing of old temporary files. (237458 lines)
Version 18.52.2: Feb 20, 2019 Fixed bug in reception of images. (237458 lines) Version 18.52.2: Feb 20, 2019 Fixed bug in reception of images. (237458 lines)
Version 18.52.1: Feb 20, 2019 Messages to debug problem with files. (237425 lines) Version 18.52.1: Feb 20, 2019 Messages to debug problem with files. (237425 lines)

View File

@ -2969,8 +2969,9 @@ mysql> DESCRIBE usr_last;
| LastTab | tinyint(4) | NO | | NULL | | | LastTab | tinyint(4) | NO | | NULL | |
| LastTime | datetime | NO | MUL | NULL | | | LastTime | datetime | NO | MUL | NULL | |
| LastAccNotif | datetime | NO | | NULL | | | LastAccNotif | datetime | NO | | NULL | |
| TimelineUsrs | tinyint(4) | NO | | 0 | |
+--------------+------------+------+-----+---------+-------+ +--------------+------------+------+-----+---------+-------+
6 rows in set (0.00 sec) 7 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS usr_last (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS usr_last ("
"UsrCod INT NOT NULL," "UsrCod INT NOT NULL,"
@ -2979,6 +2980,7 @@ mysql> DESCRIBE usr_last;
"LastTab TINYINT NOT NULL," "LastTab TINYINT NOT NULL,"
"LastTime DATETIME NOT NULL," "LastTime DATETIME NOT NULL,"
"LastAccNotif DATETIME NOT NULL," "LastAccNotif DATETIME NOT NULL,"
"TimelineUsrs TINYINT NOT NULL DEFAULT 0,"
"UNIQUE INDEX(UsrCod)," "UNIQUE INDEX(UsrCod),"
"INDEX(LastTime))"); "INDEX(LastTime))");

View File

@ -287,7 +287,8 @@ void Sch_GetParamWhatToSearch (void)
Sch_NUM_WHAT_TO_SEARCH - 1, Sch_NUM_WHAT_TO_SEARCH - 1,
(unsigned long) Sch_SEARCH_UNKNOWN); (unsigned long) Sch_SEARCH_UNKNOWN);
// If parameter WhatToSearch is not present, use parameter from session /***** If parameter WhatToSearch is not present,
use parameter from session *****/
if (WhatToSearch != Sch_SEARCH_UNKNOWN) if (WhatToSearch != Sch_SEARCH_UNKNOWN)
Gbl.Search.WhatToSearch = WhatToSearch; Gbl.Search.WhatToSearch = WhatToSearch;
} }

View File

@ -148,6 +148,8 @@ static void Soc_FormStart (Act_Action_t ActionGbl,Act_Action_t ActionUsr);
static void Soc_PutFormWhichUsrs (void); static void Soc_PutFormWhichUsrs (void);
static void Soc_PutParamWhichUsrs (void); static void Soc_PutParamWhichUsrs (void);
static void Soc_GetParamsWhichUsrs (void); static void Soc_GetParamsWhichUsrs (void);
static Soc_WhichUsrs_t Soc_GetWhichUsrsFromDB (void);
static void Soc_SaveWhichUsersInDB (void);
static void Soc_ShowWarningYouDontFollowAnyUser (void); static void Soc_ShowWarningYouDontFollowAnyUser (void);
@ -277,6 +279,10 @@ void Soc_ShowTimelineGbl1 (void)
/***** Get which users *****/ /***** Get which users *****/
Soc_GetParamsWhichUsrs (); Soc_GetParamsWhichUsrs ();
/***** Save which users in database *****/
if (Gbl.Action.Act == ActSeeSocTmlGbl) // Only in action to see global timeline
Soc_SaveWhichUsersInDB ();
} }
void Soc_ShowTimelineGbl2 (void) void Soc_ShowTimelineGbl2 (void)
@ -572,7 +578,7 @@ static void Soc_BuildQueryToGetTimeline (char **Query,
case Soc_TIMELINE_GBL: // Show the global timeline case Soc_TIMELINE_GBL: // Show the global timeline
switch (Gbl.Social.WhichUsrs) switch (Gbl.Social.WhichUsrs)
{ {
case Soc_FOLLOWED: // Show the timeline of the users I follow case Soc_USRS_FOLLOWED: // Show the timeline of the users I follow
DB_Query ("can not create temporary table", DB_Query ("can not create temporary table",
"CREATE TEMPORARY TABLE publishers " "CREATE TEMPORARY TABLE publishers "
"(UsrCod INT NOT NULL,UNIQUE INDEX(UsrCod)) ENGINE=MEMORY" "(UsrCod INT NOT NULL,UNIQUE INDEX(UsrCod)) ENGINE=MEMORY"
@ -585,9 +591,12 @@ static void Soc_BuildQueryToGetTimeline (char **Query,
sprintf (SubQueryPublishers,"social_pubs.PublisherCod=publishers.UsrCod AND "); sprintf (SubQueryPublishers,"social_pubs.PublisherCod=publishers.UsrCod AND ");
break; break;
case Soc_ALL_USRS: // Show the timeline of all users case Soc_USRS_ALL: // Show the timeline of all users
SubQueryPublishers[0] = '\0'; SubQueryPublishers[0] = '\0';
break; break;
default:
Lay_ShowErrorAndExit ("Wrong parameter which users.");
break;
} }
break; break;
} }
@ -700,12 +709,15 @@ static void Soc_BuildQueryToGetTimeline (char **Query,
case Soc_TIMELINE_GBL: // Show the global timeline case Soc_TIMELINE_GBL: // Show the global timeline
switch (Gbl.Social.WhichUsrs) switch (Gbl.Social.WhichUsrs)
{ {
case Soc_FOLLOWED: // Show the timeline of the users I follow case Soc_USRS_FOLLOWED: // Show the timeline of the users I follow
sprintf (SubQueryRangeBottom,"social_pubs.PubCod>%ld AND ",RangePubsToGet.Bottom); sprintf (SubQueryRangeBottom,"social_pubs.PubCod>%ld AND ",RangePubsToGet.Bottom);
break; break;
case Soc_ALL_USRS: // Show the timeline of all users case Soc_USRS_ALL: // Show the timeline of all users
sprintf (SubQueryRangeBottom,"PubCod>%ld AND ",RangePubsToGet.Bottom); sprintf (SubQueryRangeBottom,"PubCod>%ld AND ",RangePubsToGet.Bottom);
break; break;
default:
Lay_ShowErrorAndExit ("Wrong parameter which users.");
break;
} }
break; break;
} }
@ -721,12 +733,15 @@ static void Soc_BuildQueryToGetTimeline (char **Query,
case Soc_TIMELINE_GBL: // Show the global timeline case Soc_TIMELINE_GBL: // Show the global timeline
switch (Gbl.Social.WhichUsrs) switch (Gbl.Social.WhichUsrs)
{ {
case Soc_FOLLOWED: // Show the timeline of the users I follow case Soc_USRS_FOLLOWED: // Show the timeline of the users I follow
sprintf (SubQueryRangeTop,"social_pubs.PubCod<%ld AND ",RangePubsToGet.Top); sprintf (SubQueryRangeTop,"social_pubs.PubCod<%ld AND ",RangePubsToGet.Top);
break; break;
case Soc_ALL_USRS: // Show the timeline of all users case Soc_USRS_ALL: // Show the timeline of all users
sprintf (SubQueryRangeTop,"PubCod<%ld AND ",RangePubsToGet.Top); sprintf (SubQueryRangeTop,"PubCod<%ld AND ",RangePubsToGet.Top);
break; break;
default:
Lay_ShowErrorAndExit ("Wrong parameter which users.");
break;
} }
break; break;
} }
@ -750,7 +765,7 @@ static void Soc_BuildQueryToGetTimeline (char **Query,
case Soc_TIMELINE_GBL: // Show the global timeline case Soc_TIMELINE_GBL: // Show the global timeline
switch (Gbl.Social.WhichUsrs) switch (Gbl.Social.WhichUsrs)
{ {
case Soc_FOLLOWED: // Show the timeline of the users I follow case Soc_USRS_FOLLOWED: // Show the timeline of the users I follow
NumPubs = NumPubs =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get publishing", (unsigned) DB_QuerySELECT (&mysql_res,"can not get publishing",
"SELECT PubCod,NotCod FROM social_pubs,publishers" "SELECT PubCod,NotCod FROM social_pubs,publishers"
@ -760,7 +775,7 @@ static void Soc_BuildQueryToGetTimeline (char **Query,
SubQueryPublishers, SubQueryPublishers,
SubQueryAlreadyExists); SubQueryAlreadyExists);
break; break;
case Soc_ALL_USRS: // Show the timeline of all users case Soc_USRS_ALL: // Show the timeline of all users
NumPubs = NumPubs =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get publishing", (unsigned) DB_QuerySELECT (&mysql_res,"can not get publishing",
"SELECT PubCod,NotCod FROM social_pubs" "SELECT PubCod,NotCod FROM social_pubs"
@ -769,6 +784,9 @@ static void Soc_BuildQueryToGetTimeline (char **Query,
SubQueryRangeBottom,SubQueryRangeTop, SubQueryRangeBottom,SubQueryRangeTop,
SubQueryAlreadyExists); SubQueryAlreadyExists);
break; break;
default:
Lay_ShowErrorAndExit ("Wrong parameter which users.");
break;
} }
break; break;
} }
@ -1057,7 +1075,7 @@ static void Soc_PutFormWhichUsrs (void)
fprintf (Gbl.F.Out,"<div class=\"SEL_BELOW_TITLE\">" fprintf (Gbl.F.Out,"<div class=\"SEL_BELOW_TITLE\">"
"<ul>"); "<ul>");
for (WhichUsrs = (Soc_WhichUsrs_t) 0; for (WhichUsrs = (Soc_WhichUsrs_t) 1;
WhichUsrs < Soc_NUM_WHICH_USRS; WhichUsrs < Soc_NUM_WHICH_USRS;
WhichUsrs++) WhichUsrs++)
{ {
@ -1079,7 +1097,7 @@ static void Soc_PutFormWhichUsrs (void)
Frm_EndForm (); Frm_EndForm ();
/***** Show warning if I do not follow anyone *****/ /***** Show warning if I do not follow anyone *****/
if (Gbl.Social.WhichUsrs == Soc_FOLLOWED) if (Gbl.Social.WhichUsrs == Soc_USRS_FOLLOWED)
Soc_ShowWarningYouDontFollowAnyUser (); Soc_ShowWarningYouDontFollowAnyUser ();
} }
@ -1101,9 +1119,68 @@ static void Soc_GetParamsWhichUsrs (void)
/***** Get which users I want to see *****/ /***** Get which users I want to see *****/
Gbl.Social.WhichUsrs = (Soc_WhichUsrs_t) Gbl.Social.WhichUsrs = (Soc_WhichUsrs_t)
Par_GetParToUnsignedLong ("WhichUsrs", Par_GetParToUnsignedLong ("WhichUsrs",
0, 1,
Soc_NUM_WHICH_USRS - 1, Soc_NUM_WHICH_USRS - 1,
(unsigned long) Soc_DEFAULT_WHICH_USRS); (unsigned long) Soc_USRS_UNKNOWN);
/***** If parameter WhichUsrs is not present, get it from database *****/
if (Gbl.Social.WhichUsrs == Soc_USRS_UNKNOWN)
Gbl.Social.WhichUsrs = Soc_GetWhichUsrsFromDB ();
/***** If parameter WhichUsrs is unknown, set it to default *****/
if (Gbl.Social.WhichUsrs == Soc_USRS_UNKNOWN)
Gbl.Social.WhichUsrs = Soc_DEFAULT_WHICH_USRS;
}
/*****************************************************************************/
/********** Get user's last data from database giving a user's code **********/
/*****************************************************************************/
static Soc_WhichUsrs_t Soc_GetWhichUsrsFromDB (void)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned UnsignedNum;
Soc_WhichUsrs_t WhichUsrs = Soc_USRS_UNKNOWN;
/***** Get which users from database *****/
if (DB_QuerySELECT (&mysql_res,"can not get timeline users from user's last data",
"SELECT TimelineUsrs" // row[0]
" FROM usr_last WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod) == 1)
{
row = mysql_fetch_row (mysql_res);
/* Get which users */
if (sscanf (row[0],"%u",&UnsignedNum) == 1)
if (UnsignedNum < Soc_NUM_WHICH_USRS)
WhichUsrs = (Soc_WhichUsrs_t) UnsignedNum;
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return WhichUsrs;
}
/*****************************************************************************/
/********************** Save which users into database ***********************/
/*****************************************************************************/
static void Soc_SaveWhichUsersInDB (void)
{
if (Gbl.Usrs.Me.Logged)
{
if (Gbl.Social.WhichUsrs == Soc_USRS_UNKNOWN)
Gbl.Social.WhichUsrs = Soc_DEFAULT_WHICH_USRS;
/***** Update which users in database *****/
// WhichUsrs is stored in usr_last for next time I log in
DB_QueryUPDATE ("can not update timeline users in user's last data",
"UPDATE usr_last SET TimelineUsrs=%u WHERE UsrCod=%ld",
(unsigned) Gbl.Social.WhichUsrs,
Gbl.Usrs.Me.UsrDat.UsrCod);
}
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -43,13 +43,14 @@
/******************************** Public types *******************************/ /******************************** Public types *******************************/
/*****************************************************************************/ /*****************************************************************************/
#define Soc_NUM_WHICH_USRS 2 #define Soc_NUM_WHICH_USRS 3
typedef enum typedef enum
{ {
Soc_FOLLOWED = 0, Soc_USRS_UNKNOWN = 0,
Soc_ALL_USRS = 1, Soc_USRS_FOLLOWED = 1,
Soc_USRS_ALL = 2,
} Soc_WhichUsrs_t; // Which users I want to see: only users I follow or all users } Soc_WhichUsrs_t; // Which users I want to see: only users I follow or all users
#define Soc_DEFAULT_WHICH_USRS Soc_ALL_USRS #define Soc_DEFAULT_WHICH_USRS Soc_USRS_ALL
#define Soc_NUM_PUB_TYPES 4 #define Soc_NUM_PUB_TYPES 4
// If the numbers assigned to each event type change, // If the numbers assigned to each event type change,

View File

@ -49054,7 +49054,10 @@ const char *Txt_Timeline_OF_A_USER = // Warning: it is very important to include
const char *Txt_TIMELINE_WHICH_USERS[Soc_NUM_WHICH_USRS] = const char *Txt_TIMELINE_WHICH_USERS[Soc_NUM_WHICH_USRS] =
{ {
// Soc_FOLLOWED // Soc_USRS_UNKNOWN
NULL
,
// Soc_USRS_FOLLOWED
#if L==1 // ca #if L==1 // ca
"Usuaris que segueixo" "Usuaris que segueixo"
#elif L==2 // de #elif L==2 // de
@ -49075,7 +49078,7 @@ const char *Txt_TIMELINE_WHICH_USERS[Soc_NUM_WHICH_USRS] =
"Usu&aacute;rios que estou seguindo" "Usu&aacute;rios que estou seguindo"
#endif #endif
, ,
// Soc_ALL_USRS // Soc_USRS_ALL
#if L==1 // ca #if L==1 // ca
"Tots els usuaris" "Tots els usuaris"
#elif L==2 // de #elif L==2 // de