diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-03-24 20:03:18 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-03-24 20:03:18 -0400 |
commit | 725b7d2a551c782b40e69ab1bdc701b5ee899646 (patch) | |
tree | e948f34762d48631a1d58b1ad2190c8a7478c2bf /app/Model | |
parent | 3a5f5abda2735f3ecf0e02bab3ee5fc11ed3e5bd (diff) | |
parent | 194fbe263e2a862d3bb341ccbadd724f8d8b79e4 (diff) |
Merge pull-request #1993
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/Metadata.php | 12 | ||||
-rw-r--r-- | app/Model/Setting.php | 6 |
2 files changed, 10 insertions, 8 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)); } } |