Add date_modification to comments (PR #2950)
This commit is contained in:
committed by
Frédéric Guillot
parent
67aca3c664
commit
8e18c39db9
@@ -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));
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user