diff options
author | Lev Lazinskiy <lev@levlaz.org> | 2017-01-22 09:39:30 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2017-01-22 12:39:30 -0500 |
commit | 8e18c39db9dbb0d91e28006b972dbe331e6500b4 (patch) | |
tree | 5a2f6bb37d355aafcf48f635b91b543d326d2686 /app | |
parent | 67aca3c664dfe4a7616781216e868f9477f4963f (diff) |
Add date_modification to comments (PR #2950)
Diffstat (limited to 'app')
-rw-r--r-- | app/Model/CommentModel.php | 7 | ||||
-rw-r--r-- | app/Schema/Mysql.php | 10 | ||||
-rw-r--r-- | app/Schema/Postgres.php | 10 | ||||
-rw-r--r-- | app/Schema/Sql/mysql.sql | 3 | ||||
-rw-r--r-- | app/Schema/Sql/postgres.sql | 3 | ||||
-rw-r--r-- | app/Schema/Sqlite.php | 10 | ||||
-rw-r--r-- | app/Template/comment/show.php | 4 |
7 files changed, 39 insertions, 8 deletions
diff --git a/app/Model/CommentModel.php b/app/Model/CommentModel.php index a9e48bd3..e44a5ecd 100644 --- a/app/Model/CommentModel.php +++ b/app/Model/CommentModel.php @@ -60,6 +60,7 @@ class CommentModel extends Base ->columns( self::TABLE.'.id', self::TABLE.'.date_creation', + self::TABLE.'.date_modification', self::TABLE.'.task_id', self::TABLE.'.user_id', self::TABLE.'.comment', @@ -69,7 +70,7 @@ class CommentModel extends Base UserModel::TABLE.'.avatar_path' ) ->join(UserModel::TABLE, 'id', 'user_id') - ->orderBy(self::TABLE.'.date_creation', $sorting) + ->orderBy(self::TABLE.'.date_modification', $sorting) ->eq(self::TABLE.'.task_id', $task_id) ->findAll(); } @@ -90,6 +91,7 @@ class CommentModel extends Base self::TABLE.'.task_id', self::TABLE.'.user_id', self::TABLE.'.date_creation', + self::TABLE.'.date_modification', self::TABLE.'.comment', self::TABLE.'.reference', UserModel::TABLE.'.username', @@ -127,6 +129,7 @@ class CommentModel extends Base public function create(array $values) { $values['date_creation'] = time(); + $values['date_modification'] = time(); $comment_id = $this->db->table(self::TABLE)->persist($values); if ($comment_id !== false) { @@ -148,7 +151,7 @@ class CommentModel extends Base $result = $this->db ->table(self::TABLE) ->eq('id', $values['id']) - ->update(array('comment' => $values['comment'])); + ->update(array('comment' => $values['comment'], 'date_modification' => time())); if ($result) { $this->queueManager->push($this->commentEventJob->withParams($values['id'], self::EVENT_UPDATE)); diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index cc691d1f..6c1c9da6 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -6,7 +6,15 @@ use PDO; use Kanboard\Core\Security\Token; use Kanboard\Core\Security\Role; -const VERSION = 118; +const VERSION = 119; + +function version_119(PDO $pdo) +{ + $pdo->exec('ALTER TABLE `comments` ADD COLUMN `date_modification` BIGINT(20)'); + $pdo->exec('UPDATE `comments` + SET `date_modification` = `date_creation` + WHERE `date_modification` IS NULL'); +} function version_118(PDO $pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index 32a7a744..9c72141a 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -6,7 +6,15 @@ use PDO; use Kanboard\Core\Security\Token; use Kanboard\Core\Security\Role; -const VERSION = 97; +const VERSION = 98; + +function version_98(PDO $pdo) +{ + $pdo->exec('ALTER TABLE "comments" ADD COLUMN date_modification BIGINT'); + $pdo->exec('UPDATE "comments" + SET date_modificaiton = date_creation + WHERE date_modification IS NULL'); +} function version_97(PDO $pdo) { diff --git a/app/Schema/Sql/mysql.sql b/app/Schema/Sql/mysql.sql index 0ee88d88..03b6eca2 100644 --- a/app/Schema/Sql/mysql.sql +++ b/app/Schema/Sql/mysql.sql @@ -98,6 +98,7 @@ CREATE TABLE `comments` ( `task_id` int(11) NOT NULL, `user_id` int(11) DEFAULT '0', `date_creation` bigint(20) DEFAULT NULL, + `date_modification` bigint(20) DEFAULT NULL, `comment` text, `reference` varchar(50) DEFAULT '', PRIMARY KEY (`id`), @@ -768,4 +769,4 @@ UNLOCK TABLES; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$R1zYk04d96KcHRpd9.r5I.5I6mgKIgUdsaISZYmaDLPIJCUO0FFJG', 'app-admin');INSERT INTO schema_version VALUES ('118'); +INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$R1zYk04d96KcHRpd9.r5I.5I6mgKIgUdsaISZYmaDLPIJCUO0FFJG', 'app-admin');INSERT INTO schema_version VALUES ('119'); diff --git a/app/Schema/Sql/postgres.sql b/app/Schema/Sql/postgres.sql index 578b0c75..f37c37d3 100644 --- a/app/Schema/Sql/postgres.sql +++ b/app/Schema/Sql/postgres.sql @@ -195,6 +195,7 @@ CREATE TABLE "comments" ( "task_id" integer NOT NULL, "user_id" integer DEFAULT 0, "date_creation" bigint NOT NULL, + "date_modification" bigint NOT NULL, "comment" "text", "reference" character varying(50) DEFAULT ''::character varying ); @@ -2613,4 +2614,4 @@ SELECT pg_catalog.setval('links_id_seq', 11, true); -- PostgreSQL database dump complete -- -INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$0.8BJyhOEBHGqfwD3nIJHuxObqTlZGJ/KRNDVHfSu7RGd42rEbSa.', 'app-admin');INSERT INTO schema_version VALUES ('97'); +INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$0.8BJyhOEBHGqfwD3nIJHuxObqTlZGJ/KRNDVHfSu7RGd42rEbSa.', 'app-admin');INSERT INTO schema_version VALUES ('98'); diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index 11dcd537..d2a7899e 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -6,7 +6,15 @@ use Kanboard\Core\Security\Token; use Kanboard\Core\Security\Role; use PDO; -const VERSION = 108; +const VERSION = 109; + +function version_109(PDO $pdo) +{ + $pdo->exec('ALTER TABLE comments ADD COLUMN date_modification INTEGER'); + $pdo->exec('UPDATE comments + SET date_modification = date_creation + WHERE date_modification IS NULL;'); +} function version_108(PDO $pdo) { diff --git a/app/Template/comment/show.php b/app/Template/comment/show.php index caf28c3c..8a9c855b 100644 --- a/app/Template/comment/show.php +++ b/app/Template/comment/show.php @@ -7,7 +7,9 @@ <strong class="comment-username"><?= $this->text->e($comment['name'] ?: $comment['username']) ?></strong> <?php endif ?> - <small class="comment-date"><?= $this->dt->datetime($comment['date_creation']) ?></small> + <small class="comment-date"><?= t('Created At')?>: <?= $this->dt->datetime($comment['date_creation']) ?></small> + <small class="comment-date"><?= t('Updated At')?>: <?= $this->dt->datetime($comment['date_modification']) ?></small> + </div> <div class="comment-content"> |