diff --git a/sql/cambios.sql b/sql/cambios.sql index 16dde9cbc..05a2541dd 100644 --- a/sql/cambios.sql +++ b/sql/cambios.sql @@ -11202,7 +11202,14 @@ INSERT INTO social_timeline (AuthorCod,PublisherCod,NotCod,TimePublish) SELECT U SELECT MIN(PubCod) FROM social_timeline WHERE PublisherCod IN (SELECT '1' UNION SELECT FollowedCod FROM usr_follow WHERE FollowerCod='1') GROUP BY NotCod; - - - + +----- SWAD 15.90 (2016/01/02) ----- + +ALTER TABLE social_notes ADD COLUMN HieCod INT NOT NULL DEFAULT -1 AFTER UsrCod; +UPDATE social_notes SET HieCod=InsCod WHERE NoteType IN ('1','2'); +UPDATE social_notes SET HieCod=CtrCod WHERE NoteType IN ('3','4'); +UPDATE social_notes SET HieCod=DegCod WHERE NoteType IN ('5','6'); +UPDATE social_notes SET HieCod=CrsCod WHERE NoteType IN ('7','8','9','12'); +ALTER TABLE social_notes DROP COLUMN CtyCod,DROP COLUMN InsCod,DROP COLUMN CtrCod,DROP COLUMN CrsCod; + \ No newline at end of file diff --git a/sql/swad.sql b/sql/swad.sql index 085e2da0a..0af5560cb 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -919,11 +919,7 @@ CREATE TABLE IF NOT EXISTS social_notes ( NotCod BIGINT NOT NULL AUTO_INCREMENT, NoteType 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, + HieCod INT NOT NULL DEFAULT -1, Cod INT NOT NULL DEFAULT -1, TimeNote DATETIME NOT NULL, UNIQUE INDEX(NotCod), diff --git a/swad_changelog.h b/swad_changelog.h index 1aa414965..370e95fe9 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -111,19 +111,28 @@ // TODO: Reply to all // TODO: Hour in exam announcement should start at six a.m. // TODO: When a file, notice, etc. is removed, it should be removed from social events? -// TODO: New database table used to store users who write or share social +// TODO: Cange "Actividad pública" to "Actividad de Antonio" in user's profile /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.89.2 (2016-01-02)" +#define Log_PLATFORM_VERSION "SWAD 15.90 (2016-01-02)" #define CSS_FILE "swad15.88.1.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.90: Jan 02, 2016 Change in fields of database table that stores social notes. (190122 lines) + 6 changes necessary in database: +ALTER TABLE social_notes ADD COLUMN HieCod INT NOT NULL DEFAULT -1 AFTER UsrCod; +UPDATE social_notes SET HieCod=InsCod WHERE NoteType IN ('1','2'); +UPDATE social_notes SET HieCod=CtrCod WHERE NoteType IN ('3','4'); +UPDATE social_notes SET HieCod=DegCod WHERE NoteType IN ('5','6'); +UPDATE social_notes SET HieCod=CrsCod WHERE NoteType IN ('7','8','9','12'); +ALTER TABLE social_notes DROP COLUMN CtyCod,DROP COLUMN InsCod,DROP COLUMN CtrCod,DROP COLUMN CrsCod; + Version 15.89.2: Jan 02, 2016 Change in layout of user profile. (190141 lines) Version 15.89.1: Jan 02, 2016 Change in layout of user profile. (190137 lines) Version 15.89: Jan 02, 2016 Social timeline can be updated from user profile. (190084 lines) diff --git a/swad_database.c b/swad_database.c index d9afa8455..5b115b9a2 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1938,31 +1938,24 @@ mysql> DESCRIBE sessions; /***** Table social_notes *****/ /* mysql> DESCRIBE social_notes; -+------------+------------+------+-----+---------+----------------+ -| Field | Type | Null | Key | Default | Extra | -+------------+------------+------+-----+---------+----------------+ -| NotCod | bigint(20) | NO | PRI | NULL | auto_increment | ++----------+------------+------+-----+---------+----------------+ +| 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 | | -| CtyCod | int(11) | NO | | -1 | | -| InsCod | int(11) | NO | | -1 | | -| CtrCod | int(11) | NO | | -1 | | -| DegCod | int(11) | NO | | -1 | | -| CrsCod | int(11) | NO | | -1 | | -| Cod | int(11) | NO | | -1 | | -| TimeNote | datetime | NO | MUL | NULL | | -+------------+------------+------+-----+---------+----------------+ -10 rows in set (0.00 sec) +| 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 | | ++----------+------------+------+-----+---------+----------------+ +7 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_notes (" "NotCod BIGINT NOT NULL AUTO_INCREMENT," "NoteType 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," + "HieCod INT NOT NULL DEFAULT -1," "Cod INT NOT NULL DEFAULT -1," "TimeNote DATETIME NOT NULL," "UNIQUE INDEX(NotCod)," diff --git a/swad_social.c b/swad_social.c index 8e7d6a87f..0ba855a60 100644 --- a/swad_social.c +++ b/swad_social.c @@ -108,12 +108,8 @@ struct SocialNote long NotCod; Soc_NoteType_t NoteType; long UsrCod; - long CtyCod; - long InsCod; - long CtrCod; - long DegCod; - long CrsCod; - long Cod; + long HieCod; // Hierarchy code (institution/centre/degree/course) + long Cod; // Code of file, forum post, notice,... time_t DateTimeUTC; }; @@ -367,8 +363,6 @@ static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub, extern const char *Txt_Degree; extern const char *Txt_Centre; extern const char *Txt_Institution; - extern const char *Txt_Country; - struct Country Cty; struct Institution Ins; struct Centre Ctr; struct Degree Deg; @@ -383,26 +377,6 @@ static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub, UsrDat->UsrCod = SocNot->UsrCod; Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (UsrDat); - /* Get country data */ - Cty.CtyCod = SocNot->CtyCod; - Cty_GetDataOfCountryByCod (&Cty,Cty_GET_BASIC_DATA); - - /* Get institution data */ - Ins.InsCod = SocNot->InsCod; - Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); - - /* Get centre data */ - Ctr.CtrCod = SocNot->CtrCod; - Ctr_GetDataOfCentreByCod (&Ctr); - - /* Get degree data */ - Deg.DegCod = SocNot->DegCod; - Deg_GetDataOfDegreeByCod (&Deg); - - /* Get course data */ - Crs.CrsCod = SocNot->CrsCod; - Crs_GetDataOfCourseByCod (&Crs); - /* Get forum type of the post */ if (SocNot->NoteType == Soc_NOTE_FORUM_POST) { @@ -473,7 +447,7 @@ static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub, } else { - /* Write note type and location */ + /* Write note type and location-hierarchy */ fprintf (Gbl.F.Out,"