From 948b7fbaaa58c0a825938f7e8bda9a07ec39239b Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 18 Feb 2017 10:11:07 -0500 Subject: Add mandatory argument "project_id" to API method "updateSwimlane()" --- app/Api/Procedure/SwimlaneProcedure.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'app/Api/Procedure') 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) -- cgit v1.2.3