From ced90826dbe9ed609a34541f652ab9f4361d7d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 7 Jan 2016 14:57:35 +0100 Subject: [PATCH] Version 15.101 --- sql/cambios.sql | 8 ++++++-- sql/swad.sql | 22 +++++++++++++++++++++- swad_changelog.h | 21 ++++++++++++++++++++- swad_database.c | 40 ++++++++++++++++++++++++++++++++++++++++ swad_social.c | 20 ++++++++++++-------- 5 files changed, 99 insertions(+), 12 deletions(-) diff --git a/sql/cambios.sql b/sql/cambios.sql index 84d755d38..5f27dbcc7 100644 --- a/sql/cambios.sql +++ b/sql/cambios.sql @@ -11213,6 +11213,10 @@ 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; - - CREATE TABLE IF NOT EXISTS social_timeline_new (PubCod BIGINT NOT NULL AUTO_INCREMENT, NotCod BIGINT NOT NULL, PublisherCod INT NOT NULL, AuthorCod INT NOT NULL, TimePublish DATETIME NOT NULL, UNIQUE INDEX(PubCod), UNIQUE INDEX(NotCod,PublisherCod), INDEX(PublisherCod), INDEX(AuthorCod), INDEX(TimePublish)) SELECT PubCod,NotCod,PublisherCod,AuthorCod,TimePublish FROM social_timeline ORDER BY PubCod; + +----- SWAD 15.100.5 (2016/01/07) ----- + +CREATE TABLE IF NOT EXISTS social_comments (ComCod BIGINT NOT NULL AUTO_INCREMENT,UsrCod INT NOT NULL,NotCod INT NOT NULL,TimeComment DATETIME NOT NULL,UNIQUE INDEX(ComCod),INDEX(UsrCod),INDEX(NotCod,TimeComment),INDEX(TimeComment)); + +CREATE TABLE IF NOT EXISTS social_comments_content (ComCod BIGINT NOT NULL,Content LONGTEXT NOT NULL,UNIQUE INDEX(ComCod),FULLTEXT(Content)) ENGINE = MYISAM; diff --git a/sql/swad.sql b/sql/swad.sql index 3b93006cf..344d74921 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -913,7 +913,27 @@ CREATE TABLE IF NOT EXISTS sessions ( UNIQUE INDEX(SessionId), INDEX(UsrCod)); -- --- Table social: stores social notes +-- Table social_comments: stores the comments to social notes +-- +CREATE TABLE IF NOT EXISTS social_comments ( + ComCod BIGINT NOT NULL AUTO_INCREMENT, + UsrCod INT NOT NULL, + NotCod INT NOT NULL, + TimeComment DATETIME NOT NULL, + UNIQUE INDEX(ComCod), + INDEX(UsrCod), + INDEX(NotCod,TimeComment), + INDEX(TimeComment)); +-- +-- Table social_notes: stores the content of comments to social notes +-- +CREATE TABLE IF NOT EXISTS social_comments_content ( + ComCod BIGINT NOT NULL, + Content LONGTEXT NOT NULL, + UNIQUE INDEX(ComCod), + FULLTEXT(Content)) ENGINE = MYISAM; +-- +-- Table social_notes: stores social notes -- CREATE TABLE IF NOT EXISTS social_notes ( NotCod BIGINT NOT NULL AUTO_INCREMENT, diff --git a/swad_changelog.h b/swad_changelog.h index 6f042e591..6f1c20387 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -124,13 +124,32 @@ En definitiva, se estar /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.100.4 (2016-01-07)" +#define Log_PLATFORM_VERSION "SWAD 15.101 (2016-01-07)" #define CSS_FILE "swad15.100.2.css" #define JS_FILE "swad15.100.2.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.101: Jan 07, 2016 Store social comment in database. (191091 lines) + 16 changes necessary in database: +CREATE TABLE IF NOT EXISTS social_comments (ComCod BIGINT NOT NULL AUTO_INCREMENT,UsrCod INT NOT NULL,NotCod INT NOT NULL,TimeComment DATETIME NOT NULL,UNIQUE INDEX(ComCod),INDEX(UsrCod),INDEX(NotCod,TimeComment),INDEX(TimeComment)); +CREATE TABLE IF NOT EXISTS social_comments_content (ComCod BIGINT NOT NULL,Content LONGTEXT NOT NULL,UNIQUE INDEX(ComCod),FULLTEXT(Content)) ENGINE = MYISAM; +UPDATE actions SET Txt='Redactar public. social (global)' WHERE ActCod='1491' AND Language='es'; +UPDATE actions SET Txt='Crear public. social (global)' WHERE ActCod='1492' AND Language='es'; +UPDATE actions SET Txt='Eliminar public. social (global)' WHERE ActCod='1493' AND Language='es'; +UPDATE actions SET Txt='Solicitar elim. public. social (global)' WHERE ActCod='1494' AND Language='es'; +UPDATE actions SET Txt='Compartir public. social (global)' WHERE ActCod='1495' AND Language='es'; +UPDATE actions SET Txt='Dejar de compartir public. social (global)' WHERE ActCod='1496' AND Language='es'; +UPDATE actions SET Txt='Redactar public. social (usuario)' WHERE ActCod='1497' AND Language='es'; +UPDATE actions SET Txt='Crear public. social (usuario)' WHERE ActCod='1498' AND Language='es'; +UPDATE actions SET Txt='Compartir public. social (usuario)' WHERE ActCod='1499' AND Language='es'; +UPDATE actions SET Txt='Dejar de compartir public. social (usuario)' WHERE ActCod='1500' AND Language='es'; +UPDATE actions SET Txt='Solicitar elim. public. social (usuario)' WHERE ActCod='1501' AND Language='es'; +UPDATE actions SET Txt='Eliminar public. social (usuario)' WHERE ActCod='1502' AND Language='es'; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1503','es','N','Crear comentario social (global)'); +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1504','es','N','Crear comentario social (usuario)'); + Version 15.100.4: Jan 07, 2016 Fixed bug when sharing a social note. Receive social comment. (191012 lines) Version 15.100.3: Jan 07, 2016 Fixed bug when sharing and unsharing a social note. (190999 lines) diff --git a/swad_database.c b/swad_database.c index 3c32658f1..96560167b 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1935,6 +1935,46 @@ mysql> DESCRIBE sessions; "UNIQUE INDEX(SessionId)," "INDEX(UsrCod))"); + /***** Table social_comments *****/ +/* +mysql> DESCRIBE social_comments; ++-------------+------------+------+-----+---------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++-------------+------------+------+-----+---------+----------------+ +| ComCod | bigint(20) | NO | PRI | NULL | auto_increment | +| UsrCod | int(11) | NO | MUL | NULL | | +| NotCod | int(11) | NO | MUL | NULL | | +| TimeComment | datetime | NO | MUL | NULL | | ++-------------+------------+------+-----+---------+----------------+ +4 rows in set (0.00 sec) +*/ + DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_comments (" + "ComCod BIGINT NOT NULL AUTO_INCREMENT," + "UsrCod INT NOT NULL," + "NotCod INT NOT NULL," + "TimeComment DATETIME NOT NULL," + "UNIQUE INDEX(ComCod)," + "INDEX(UsrCod)," + "INDEX(NotCod,TimeComment)," + "INDEX(TimeComment));"); + + /***** Table social_comments_content *****/ +/* +mysql> DESCRIBE social_comments_content; ++---------+------------+------+-----+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++---------+------------+------+-----+---------+-------+ +| ComCod | bigint(20) | NO | PRI | NULL | | +| Content | longtext | NO | MUL | NULL | | ++---------+------------+------+-----+---------+-------+ +2 rows in set (0.00 sec) +*/ + DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_comments_content (" + "ComCod BIGINT NOT NULL," + "Content LONGTEXT NOT NULL," + "UNIQUE INDEX(ComCod)," + "FULLTEXT(Content)) ENGINE = MYISAM;"); + /***** Table social_notes *****/ /* mysql> DESCRIBE social_notes; diff --git a/swad_social.c b/swad_social.c index 8ae03bf84..87b2b3b02 100644 --- a/swad_social.c +++ b/swad_social.c @@ -1408,10 +1408,10 @@ void Soc_ReceiveCommentUsr (void) static void Soc_ReceiveComment (void) { char Content[Cns_MAX_BYTES_LONG_TEXT+1]; - // char Query[128+Cns_MAX_BYTES_LONG_TEXT]; + char Query[128+Cns_MAX_BYTES_LONG_TEXT]; struct SocialNote SocNot; char ParamName[32]; - // long ComCod; + long ComCod; /***** Get and store new comment *****/ /* Get the code of the social note */ @@ -1422,13 +1422,17 @@ static void Soc_ReceiveComment (void) Par_GetParAndChangeFormat (ParamName,Content,Cns_MAX_BYTES_LONG_TEXT, Str_TO_RIGOROUS_HTML,true); - /* Insert post content in the database */ - /* - sprintf (Query,"INSERT INTO social_comments (SocNot,UsrCod,Content,TimeComment)" - " VALUES ('%ld','%s',NOW())", - SocNot.NotCod,Content); + /* Insert comment in the database */ + sprintf (Query,"INSERT INTO social_comments (NotCod,UsrCod,TimeComment)" + " VALUES ('%ld','%ld',NOW())", + SocNot.NotCod,Gbl.Usrs.Me.UsrDat.UsrCod); ComCod = DB_QueryINSERTandReturnCode (Query,"can not create comment"); - */ + + /* Insert comment content in the database */ + sprintf (Query,"INSERT INTO social_comments_content (ComCod,Content)" + " VALUES ('%ld','%s')", + ComCod,Content); + DB_QueryINSERT (Query,"can not store comment content"); Lay_ShowAlert (Lay_INFO,Content); }