diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Model/Metadata.php | 12 | ||||
-rw-r--r-- | app/Model/Setting.php | 6 | ||||
-rw-r--r-- | app/Schema/Mysql.php | 18 | ||||
-rw-r--r-- | app/Schema/Postgres.php | 18 | ||||
-rw-r--r-- | app/Schema/Sqlite.php | 19 |
5 files changed, 62 insertions, 11 deletions
diff --git a/app/Model/Metadata.php b/app/Model/Metadata.php index cb66c717..9b26e404 100644 --- a/app/Model/Metadata.php +++ b/app/Model/Metadata.php @@ -81,19 +81,19 @@ abstract class Metadata extends Base public function save($entity_id, array $values) { $results = array(); - + $user_id = $this->userSession->getId(); + $timestamp = time(); + $this->db->startTransaction(); - + foreach ($values as $key => $value) { if ($this->exists($entity_id, $key)) { - $results[] = $this->db->table(static::TABLE)->eq($this->getEntityKey(), $entity_id)->eq('name', $key)->update(array('value' => $value)); + $results[] = $this->db->table(static::TABLE)->eq($this->getEntityKey(), $entity_id)->eq('name', $key)->update(array('value' => $value, 'changed_on' => $timestamp, 'changed_by' => $user_id)); } else { - $results[] = $this->db->table(static::TABLE)->insert(array('name' => $key, 'value' => $value, $this->getEntityKey() => $entity_id)); + $results[] = $this->db->table(static::TABLE)->insert(array('name' => $key, 'value' => $value, $this->getEntityKey() => $entity_id, 'changed_on' => $timestamp, 'changed_by' => $user_id)); } } - $this->db->closeTransaction(); - return ! in_array(false, $results, true); } diff --git a/app/Model/Setting.php b/app/Model/Setting.php index 6d29c6ec..4e1c1b0b 100644 --- a/app/Model/Setting.php +++ b/app/Model/Setting.php @@ -81,14 +81,16 @@ abstract class Setting extends Base { $results = array(); $values = $this->prepare($values); + $user_id = $this->userSession->getId(); + $timestamp = time(); $this->db->startTransaction(); foreach ($values as $option => $value) { if ($this->exists($option)) { - $results[] = $this->db->table(self::TABLE)->eq('option', $option)->update(array('value' => $value)); + $results[] = $this->db->table(self::TABLE)->eq('option', $option)->update(array('value' => $value, 'changed_on' => $timestamp, 'changed_by' => $user_id)); } else { - $results[] = $this->db->table(self::TABLE)->insert(array('option' => $option, 'value' => $value)); + $results[] = $this->db->table(self::TABLE)->insert(array('option' => $option, 'value' => $value, 'changed_on' => $timestamp, 'changed_by' => $user_id)); } } diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index 9a551e99..bf41ba29 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -6,7 +6,23 @@ use PDO; use Kanboard\Core\Security\Token; use Kanboard\Core\Security\Role; -const VERSION = 107; +const VERSION = 108; + +function version_108(PDO $pdo) +{ + //user_has_metadata + $pdo->exec("ALTER TABLE user_has_metadata ADD COLUMN changed_by INT DEFAULT 0 NOT NULL"); + $pdo->exec("ALTER TABLE user_has_metadata ADD COLUMN changed_on INT DEFAULT 0 NOT NULL"); + //project_has_metadata + $pdo->exec("ALTER TABLE project_has_metadata ADD COLUMN changed_by INT DEFAULT 0 NOT NULL"); + $pdo->exec("ALTER TABLE project_has_metadata ADD COLUMN changed_on INT DEFAULT 0 NOT NULL"); + //task_has_metadata + $pdo->exec("ALTER TABLE task_has_metadata ADD COLUMN changed_by INT DEFAULT 0 NOT NULL"); + $pdo->exec("ALTER TABLE task_has_metadata ADD COLUMN changed_on INT DEFAULT 0 NOT NULL"); + //settings + $pdo->exec("ALTER TABLE settings ADD COLUMN changed_by INT DEFAULT 0 NOT NULL"); + $pdo->exec("ALTER TABLE settings ADD COLUMN changed_on INT DEFAULT 0 NOT NULL"); +} function version_107(PDO $pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index 6aed1491..1b1996b4 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -6,7 +6,23 @@ use PDO; use Kanboard\Core\Security\Token; use Kanboard\Core\Security\Role; -const VERSION = 87; +const VERSION = 88; + +function version_88(PDO $pdo) +{ + //user_has_metadata + $pdo->exec("ALTER TABLE user_has_metadata ADD COLUMN changed_by INTEGER DEFAULT 0 NOT NULL"); + $pdo->exec("ALTER TABLE user_has_metadata ADD COLUMN changed_on INTEGER DEFAULT 0 NOT NULL"); + //project_has_metadata + $pdo->exec("ALTER TABLE project_has_metadata ADD COLUMN changed_by INTEGER DEFAULT 0 NOT NULL"); + $pdo->exec("ALTER TABLE project_has_metadata ADD COLUMN changed_on INTEGER DEFAULT 0 NOT NULL"); + //task_has_metadata + $pdo->exec("ALTER TABLE task_has_metadata ADD COLUMN changed_by INTEGER DEFAULT 0 NOT NULL"); + $pdo->exec("ALTER TABLE task_has_metadata ADD COLUMN changed_on INTEGER DEFAULT 0 NOT NULL"); + //settings + $pdo->exec("ALTER TABLE settings ADD COLUMN changed_by INTEGER DEFAULT 0 NOT NULL"); + $pdo->exec("ALTER TABLE settings ADD COLUMN changed_on INTEGER DEFAULT 0 NOT NULL"); +} function version_87(PDO $pdo) { diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index 8bcad291..c846eb5e 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -6,7 +6,24 @@ use Kanboard\Core\Security\Token; use Kanboard\Core\Security\Role; use PDO; -const VERSION = 99; +const VERSION = 100; + +function version_100(PDO $pdo) +{ + //user_has_metadata + $pdo->exec("ALTER TABLE user_has_metadata ADD COLUMN changed_by INTEGER DEFAULT 0 NOT NULL"); + $pdo->exec("ALTER TABLE user_has_metadata ADD COLUMN changed_on INTEGER DEFAULT 0 NOT NULL"); + //project_has_metadata + $pdo->exec("ALTER TABLE project_has_metadata ADD COLUMN changed_by INTEGER DEFAULT 0 NOT NULL"); + $pdo->exec("ALTER TABLE project_has_metadata ADD COLUMN changed_on INTEGER DEFAULT 0 NOT NULL"); + //task_has_metadata + $pdo->exec("ALTER TABLE task_has_metadata ADD COLUMN changed_by INTEGER DEFAULT 0 NOT NULL"); + $pdo->exec("ALTER TABLE task_has_metadata ADD COLUMN changed_on INTEGER DEFAULT 0 NOT NULL"); + //settings + $pdo->exec("ALTER TABLE settings ADD COLUMN changed_by INTEGER DEFAULT 0 NOT NULL"); + $pdo->exec("ALTER TABLE settings ADD COLUMN changed_on INTEGER DEFAULT 0 NOT NULL"); + +} function version_99(PDO $pdo) { |