Differential D7933 Diff 17951 src/applications/project/controller/PhabricatorProjectBoardEditController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/controller/PhabricatorProjectBoardEditController.php
Show All 26 Lines | public function processRequest() { | ||||
if (!$project) { | if (!$project) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$is_new = ($this->id ? false : true); | $is_new = ($this->id ? false : true); | ||||
if (!$is_new) { | if (!$is_new) { | ||||
// TODO: LATER! | $column = id(new PhabricatorProjectColumnQuery()) | ||||
throw new Exception("When I'm ready!"); | ->setViewer($viewer) | ||||
->withIDs(array($this->id)) | |||||
->executeOne(); | |||||
} else { | } else { | ||||
epriestleyUnsubmitted Not Done Inline Actions
epriestley: - Use `requireCapabilities()` to require CAN_EDIT.
- Add an `if (!$column) { return 404; }`… | |||||
miknAuthorUnsubmitted Not Done Inline ActionsThank you! mikn: Thank you! | |||||
$column = new PhabricatorProjectColumn(); | $column = new PhabricatorProjectColumn(); | ||||
} | } | ||||
$errors = array(); | $errors = array(); | ||||
$e_name = true; | $e_name = true; | ||||
$error_view = null; | $error_view = null; | ||||
$view_uri = $this->getApplicationURI('/board/'.$this->projectID.'/'); | $view_uri = $this->getApplicationURI('/board/'.$this->projectID.'/'); | ||||
if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
$new_name = $request->getStr('name'); | $new_name = $request->getStr('name'); | ||||
$column->setName($new_name); | $column->setName($new_name); | ||||
if (!strlen($column->getName())) { | if (!strlen($column->getName())) { | ||||
$errors[] = pht('Column name is required.'); | $errors[] = pht('Column name is required.'); | ||||
$e_name = pht('Required'); | $e_name = pht('Required'); | ||||
} else { | } else { | ||||
$e_name = null; | $e_name = null; | ||||
} | } | ||||
$column->setProjectPHID($project->getPHID()); | $column->setProjectPHID($project->getPHID()); | ||||
$column->attachProject($project); | $column->attachProject($project); | ||||
$column->setSequence(0); | |||||
$columns = id(new PhabricatorProjectColumnQuery()) | |||||
->setViewer($viewer) | |||||
->withProjectPHIDs(array($project->getPHID())) | |||||
->execute(); | |||||
$new_sequence = 1; | |||||
if ($columns) { | |||||
$values = mpull($columns, 'getSequence'); | |||||
$new_sequence = max($values) + 1; | |||||
} | |||||
$column->setSequence($new_sequence); | |||||
epriestleyUnsubmitted Not Done Inline ActionsThis should only be for new columns -- editing a column shouldn't change its sequence number. epriestley: This should only be for new columns -- editing a column shouldn't change its sequence number. | |||||
miknAuthorUnsubmitted Not Done Inline ActionsOh, god. I apologise for that. Embarassing! mikn: Oh, god. I apologise for that. Embarassing! | |||||
if (!$errors) { | if (!$errors) { | ||||
$column->save(); | $column->save(); | ||||
return id(new AphrontRedirectResponse())->setURI($view_uri); | return id(new AphrontRedirectResponse())->setURI($view_uri); | ||||
} | } | ||||
} | } | ||||
$form = new AphrontFormView(); | $form = new AphrontFormView(); | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |