summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Model/CommentModel.php7
-rw-r--r--app/Schema/Mysql.php10
-rw-r--r--app/Schema/Postgres.php10
-rw-r--r--app/Schema/Sql/mysql.sql3
-rw-r--r--app/Schema/Sql/postgres.sql3
-rw-r--r--app/Schema/Sqlite.php10
-rw-r--r--app/Template/comment/show.php4
-rw-r--r--tests/integration/CommentProcedureTest.php3
-rw-r--r--tests/units.postgres.xml2
-rw-r--r--tests/units/Model/CommentModelTest.php3
10 files changed, 46 insertions, 9 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">
diff --git a/tests/integration/CommentProcedureTest.php b/tests/integration/CommentProcedureTest.php
index 881d938c..0a969420 100644
--- a/tests/integration/CommentProcedureTest.php
+++ b/tests/integration/CommentProcedureTest.php
@@ -35,10 +35,12 @@ class CommentProcedureTest extends BaseProcedureTest
$this->assertNotEmpty($comment);
$this->assertEquals(1, $comment['user_id']);
$this->assertEquals('foobar', $comment['comment']);
+ $this->assertEquals($comment['date_creation'], $comment['date_modification']);
}
public function assertUpdateComment()
{
+ sleep(1); // Integration test fails because its too fast
$this->assertTrue($this->app->execute('updateComment', array(
'id' => $this->commentId,
'content' => 'test',
@@ -46,6 +48,7 @@ class CommentProcedureTest extends BaseProcedureTest
$comment = $this->app->getComment($this->commentId);
$this->assertEquals('test', $comment['comment']);
+ $this->assertNotEquals($comment['date_creation'], $comment['date_modification']);
}
public function assertGetAllComments()
diff --git a/tests/units.postgres.xml b/tests/units.postgres.xml
index 3442db1c..cf538a82 100644
--- a/tests/units.postgres.xml
+++ b/tests/units.postgres.xml
@@ -10,4 +10,4 @@
<const name="DB_PASSWORD" value="" />
<const name="DB_NAME" value="kanboard_unit_test" />
</php>
-</phpunit> \ No newline at end of file
+</phpunit>
diff --git a/tests/units/Model/CommentModelTest.php b/tests/units/Model/CommentModelTest.php
index 4178a839..c75401cc 100644
--- a/tests/units/Model/CommentModelTest.php
+++ b/tests/units/Model/CommentModelTest.php
@@ -26,6 +26,7 @@ class CommentModelTest extends Base
$this->assertEquals(1, $comment['user_id']);
$this->assertEquals('admin', $comment['username']);
$this->assertEquals(time(), $comment['date_creation'], '', 3);
+ $this->assertEquals(time(), $comment['date_modification'], '', 3);
$comment = $commentModel->getById(2);
$this->assertNotEmpty($comment);
@@ -34,6 +35,7 @@ class CommentModelTest extends Base
$this->assertEquals(0, $comment['user_id']);
$this->assertEquals('', $comment['username']);
$this->assertEquals(time(), $comment['date_creation'], '', 3);
+ $this->assertEquals(time(), $comment['date_modification'], '', 3);
}
public function testGetAll()
@@ -73,6 +75,7 @@ class CommentModelTest extends Base
$comment = $commentModel->getById(1);
$this->assertNotEmpty($comment);
$this->assertEquals('bla', $comment['comment']);
+ $this->assertEquals(time(), $comment['date_modification'], '', 3);
}
public function testRemove()