summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--app/Api/Procedure/SwimlaneProcedure.php21
-rw-r--r--app/Controller/SwimlaneController.php2
-rw-r--r--app/Model/SwimlaneModel.php10
-rw-r--r--doc/en_US/api-swimlane-procedures.markdown2
-rw-r--r--tests/integration/SwimlaneProcedureTest.php2
-rw-r--r--tests/units/Model/SwimlaneModelTest.php3
7 files changed, 30 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index dfcc054f..7ab888c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@ Breaking changes:
* Previous default swimlanes are migrated to an independent swimlane
* Columns "default_swimlane" and "show_default_swimlane" from "projects" table are not used anymore
* Remove API method "getDefaultSwimlane()"
+* Add mandatory argument "project_id" to API method "updateSwimlane()"
Bug fixes:
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);
}
diff --git a/doc/en_US/api-swimlane-procedures.markdown b/doc/en_US/api-swimlane-procedures.markdown
index 1e3296df..cad1ddf7 100644
--- a/doc/en_US/api-swimlane-procedures.markdown
+++ b/doc/en_US/api-swimlane-procedures.markdown
@@ -239,6 +239,7 @@ Response example:
- Purpose: **Update swimlane properties**
- Parameters:
+ - **project_id** (integer, required)
- **swimlane_id** (integer, required)
- **name** (string, required)
- **description** (string, optional)
@@ -254,6 +255,7 @@ Request example:
"id": 87102426,
"params": [
"1",
+ "1",
"Another swimlane"
]
}
diff --git a/tests/integration/SwimlaneProcedureTest.php b/tests/integration/SwimlaneProcedureTest.php
index afd2b3b4..a3c2397a 100644
--- a/tests/integration/SwimlaneProcedureTest.php
+++ b/tests/integration/SwimlaneProcedureTest.php
@@ -37,7 +37,7 @@ class SwimlaneProcedureTest extends BaseProcedureTest
public function assertUpdateSwimlane()
{
- $this->assertTrue($this->app->updateSwimlane($this->swimlaneId, 'Another swimlane'));
+ $this->assertTrue($this->app->updateSwimlane($this->projectId, $this->swimlaneId, 'Another swimlane'));
$swimlane = $this->app->getSwimlaneById($this->swimlaneId);
$this->assertEquals('Another swimlane', $swimlane['name']);
diff --git a/tests/units/Model/SwimlaneModelTest.php b/tests/units/Model/SwimlaneModelTest.php
index 73cc9e09..7da93f9c 100644
--- a/tests/units/Model/SwimlaneModelTest.php
+++ b/tests/units/Model/SwimlaneModelTest.php
@@ -4,7 +4,6 @@ require_once __DIR__.'/../Base.php';
use Kanboard\Model\ProjectModel;
use Kanboard\Model\TaskCreationModel;
-use Kanboard\Model\TaskFinderModel;
use Kanboard\Model\SwimlaneModel;
class SwimlaneModelTest extends Base
@@ -86,7 +85,7 @@ class SwimlaneModelTest extends Base
$this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
$this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
- $this->assertTrue($swimlaneModel->update(array('id' => 2, 'name' => 'foobar')));
+ $this->assertTrue($swimlaneModel->update(2, array('name' => 'foobar')));
$swimlane = $swimlaneModel->getById(2);
$this->assertEquals('foobar', $swimlane['name']);