From 2bb39132492619c6f2d12733f125d2d0ef46fbba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sun, 3 Jan 2016 17:34:06 +0100 Subject: [PATCH] Version 15.93.4 --- sql/swad.sql | 1 + swad_changelog.h | 5 ++++- swad_database.c | 23 ++++++++++++----------- swad_social.c | 19 ++++++++++++------- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/sql/swad.sql b/sql/swad.sql index 0af5560cb..cc765c82f 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -921,6 +921,7 @@ CREATE TABLE IF NOT EXISTS social_notes ( UsrCod INT NOT NULL, HieCod INT NOT NULL DEFAULT -1, Cod INT NOT NULL DEFAULT -1, + Unavailable ENUM('N','Y') NOT NULL DEFAULT 'N', TimeNote DATETIME NOT NULL, UNIQUE INDEX(NotCod), INDEX(SocialNote), diff --git a/swad_changelog.h b/swad_changelog.h index a08a6bea2..8f5e3ffe7 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -125,7 +125,10 @@ // 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.93.4: Jan 03, 2016 Changes in links to actions in social timeline. (190345 lines) + Version 15.93.4: Jan 03, 2016 Changes in links to actions in social timeline. (190353 lines) + 1 change necessary in database: +ALTER TABLE social_notes ADD COLUMN Unavailable ENUM('N','Y') NOT NULL DEFAULT 'N' AFTER Cod; + Version 15.93.3: Jan 03, 2016 Code refactoring in file browser related with file metadata. (190345 lines) Version 15.93.2: Jan 03, 2016 To show a file in social timeline, file code is passed as parameter instead of path. (190360 lines) Version 15.93.1: Jan 03, 2016 Show text indicating document not available in social note. (190358 lines) diff --git a/swad_database.c b/swad_database.c index 5b115b9a2..c9eab8502 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1938,17 +1938,17 @@ mysql> DESCRIBE sessions; /***** Table social_notes *****/ /* mysql> DESCRIBE social_notes; -+----------+------------+------+-----+---------+----------------+ -| Field | Type | Null | Key | Default | Extra | -+----------+------------+------+-----+---------+----------------+ -| NotCod | bigint(20) | NO | PRI | NULL | auto_increment | -| NoteType | tinyint(4) | NO | MUL | NULL | | -| UsrCod | int(11) | NO | MUL | NULL | | -| HieCod | int(11) | NO | | -1 | | -| DegCod | int(11) | NO | | -1 | | -| Cod | int(11) | NO | | -1 | | -| TimeNote | datetime | NO | MUL | NULL | | -+----------+------------+------+-----+---------+----------------+ ++-------------+---------------+------+-----+---------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++-------------+---------------+------+-----+---------+----------------+ +| NotCod | bigint(20) | NO | PRI | NULL | auto_increment | +| NoteType | tinyint(4) | NO | MUL | NULL | | +| UsrCod | int(11) | NO | MUL | NULL | | +| HieCod | int(11) | NO | | -1 | | +| Cod | int(11) | NO | | -1 | | +| Unavailable | enum('N','Y') | NO | | N | | +| TimeNote | datetime | NO | MUL | NULL | | ++-------------+---------------+------+-----+---------+----------------+ 7 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_notes (" @@ -1957,6 +1957,7 @@ mysql> DESCRIBE social_notes; "UsrCod INT NOT NULL," "HieCod INT NOT NULL DEFAULT -1," "Cod INT NOT NULL DEFAULT -1," + "Unavailable ENUM('N','Y') NOT NULL DEFAULT 'N'," "TimeNote DATETIME NOT NULL," "UNIQUE INDEX(NotCod)," "INDEX(NoteType)," diff --git a/swad_social.c b/swad_social.c index 5d31c4ac8..803c42ca5 100644 --- a/swad_social.c +++ b/swad_social.c @@ -109,8 +109,9 @@ struct SocialNote long NotCod; Soc_NoteType_t NoteType; long UsrCod; - long HieCod; // Hierarchy code (institution/centre/degree/course) - long Cod; // Code of file, forum post, notice,... + long HieCod; // Hierarchy code (institution/centre/degree/course) + long Cod; // Code of file, forum post, notice,... + bool Unavailable; // File, forum post, notice,... unavailable (removed) time_t DateTimeUTC; }; @@ -767,8 +768,8 @@ void Soc_StoreAndPublishSocialNote (Soc_NoteType_t NoteType,long Cod) /***** Store social note *****/ sprintf (Query,"INSERT INTO social_notes" - " (NoteType,UsrCod,HieCod,Cod,TimeNote)" - " VALUES ('%u','%ld','%ld','%ld',NOW())", + " (NoteType,UsrCod,HieCod,Cod,Unavailable,TimeNote)" + " VALUES ('%u','%ld','%ld','%ld','N',NOW())", (unsigned) NoteType,Gbl.Usrs.Me.UsrDat.UsrCod,HieCod,Cod); SocPub.NotCod = DB_QueryINSERTandReturnCode (Query,"can not create new social note"); @@ -1489,7 +1490,7 @@ static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *SocNot) MYSQL_ROW row; /***** Get data of social note from database *****/ - sprintf (Query,"SELECT NotCod,NoteType,UsrCod,HieCod,Cod,UNIX_TIMESTAMP(TimeNote)" + sprintf (Query,"SELECT NotCod,NoteType,UsrCod,HieCod,Cod,Unavailable,UNIX_TIMESTAMP(TimeNote)" " FROM social_notes" " WHERE NotCod='%ld'", SocNot->NotCod); @@ -1506,6 +1507,7 @@ static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *SocNot) SocNot->UsrCod = -1L; SocNot->HieCod = -1L; SocNot->Cod = -1L; + SocNot->Unavailable = false; SocNot->DateTimeUTC = (time_t) 0; } } @@ -1531,8 +1533,11 @@ static void Soc_GetDataOfSocialNoteFromRow (MYSQL_ROW row,struct SocialNote *Soc /* Get file/post... code (row[4]) */ SocNot->Cod = Str_ConvertStrCodToLongCod (row[4]); - /* Get time of the note (row[5]) */ - SocNot->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[5]); + /* 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]); } /*****************************************************************************/