diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Api/Procedure/SwimlaneProcedure.php | 21 | ||||
-rw-r--r-- | app/Controller/SwimlaneController.php | 2 | ||||
-rw-r--r-- | app/Model/SwimlaneModel.php | 10 |
3 files changed, 25 insertions, 8 deletions
diff --git a/app/Api/Procedure/SwimlaneProcedure.php b/app/Api/Procedure/SwimlaneProcedure.php index 25b1efb0..edc1e006 100644 --- a/app/Api/Procedure/SwimlaneProcedure.php +++ b/app/Api/Procedure/SwimlaneProcedure.php @@ -49,15 +49,28 @@ class SwimlaneProcedure extends BaseProcedure return $this->swimlaneModel->create($project_id, $name, $description); } - public function updateSwimlane($swimlane_id, $name, $description = null) + public function updateSwimlane($project_id, $swimlane_id, $name, $description = null) { - $values = array('id' => $swimlane_id, 'name' => $name); + ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateSwimlane', $project_id); - if (!is_null($description)) { + $values = array( + 'project_id' => $project_id, + 'id' => $swimlane_id, + 'name' => $name, + ); + + if (! is_null($description)) { $values['description'] = $description; } - return $this->swimlaneModel->update($values); + list($valid, $errors) = $this->swimlaneValidator->validateModification($values); + + if (! $valid) { + $this->logger->debug(__METHOD__.': Validation error: '.var_export($errors, true)); + return false; + } + + return $this->swimlaneModel->update($swimlane_id, $values); } public function removeSwimlane($project_id, $swimlane_id) diff --git a/app/Controller/SwimlaneController.php b/app/Controller/SwimlaneController.php index 93d19188..d99cfa7a 100644 --- a/app/Controller/SwimlaneController.php +++ b/app/Controller/SwimlaneController.php @@ -125,7 +125,7 @@ class SwimlaneController extends BaseController list($valid, $errors) = $this->swimlaneValidator->validateModification($values); if ($valid) { - if ($this->swimlaneModel->update($values)) { + if ($this->swimlaneModel->update($values['id'], $values)) { $this->flash->success(t('Swimlane updated successfully.')); return $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id']))); } else { diff --git a/app/Model/SwimlaneModel.php b/app/Model/SwimlaneModel.php index 785a1054..30012096 100644 --- a/app/Model/SwimlaneModel.php +++ b/app/Model/SwimlaneModel.php @@ -216,14 +216,18 @@ class SwimlaneModel extends Base * Update a swimlane * * @access public - * @param array $values Form values + * @param integer $swimlaneId + * @param array $values * @return bool */ - public function update(array $values) + public function update($swimlaneId, array $values) { + unset($values['id']); + unset($values['project_id']); + return $this->db ->table(self::TABLE) - ->eq('id', $values['id']) + ->eq('id', $swimlaneId) ->update($values); } |