Differential D14093 Diff 34066 src/applications/owners/controller/PhabricatorOwnersEditController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/controller/PhabricatorOwnersEditController.php
Show All 30 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$e_name = true; | $e_name = true; | ||||
$v_name = $package->getName(); | $v_name = $package->getName(); | ||||
$v_owners = mpull($package->getOwners(), 'getUserPHID'); | $v_owners = mpull($package->getOwners(), 'getUserPHID'); | ||||
$v_auditing = $package->getAuditingEnabled(); | $v_auditing = $package->getAuditingEnabled(); | ||||
$v_description = $package->getDescription(); | $v_description = $package->getDescription(); | ||||
$v_status = $package->getStatus(); | $v_status = $package->getStatus(); | ||||
$field_list = PhabricatorCustomField::getObjectFields( | |||||
$package, | |||||
PhabricatorCustomField::ROLE_EDIT); | |||||
$field_list->setViewer($viewer); | |||||
$field_list->readFieldsFromStorage($package); | |||||
$errors = array(); | $errors = array(); | ||||
if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
$xactions = array(); | $xactions = array(); | ||||
$v_name = $request->getStr('name'); | $v_name = $request->getStr('name'); | ||||
$v_owners = $request->getArr('owners'); | $v_owners = $request->getArr('owners'); | ||||
$v_auditing = ($request->getStr('auditing') == 'enabled'); | $v_auditing = ($request->getStr('auditing') == 'enabled'); | ||||
Show All 23 Lines | if ($request->isFormPost()) { | ||||
->setNewValue($v_description); | ->setNewValue($v_description); | ||||
if (!$is_new) { | if (!$is_new) { | ||||
$xactions[] = id(new PhabricatorOwnersPackageTransaction()) | $xactions[] = id(new PhabricatorOwnersPackageTransaction()) | ||||
->setTransactionType($type_status) | ->setTransactionType($type_status) | ||||
->setNewValue($v_status); | ->setNewValue($v_status); | ||||
} | } | ||||
$field_xactions = $field_list->buildFieldTransactionsFromRequest( | |||||
new PhabricatorOwnersPackageTransaction(), | |||||
$request); | |||||
$xactions = array_merge($xactions, $field_xactions); | |||||
$editor = id(new PhabricatorOwnersPackageTransactionEditor()) | $editor = id(new PhabricatorOwnersPackageTransactionEditor()) | ||||
->setActor($viewer) | ->setActor($viewer) | ||||
->setContentSourceFromRequest($request) | ->setContentSourceFromRequest($request) | ||||
->setContinueOnNoEffect(true); | ->setContinueOnNoEffect(true); | ||||
try { | try { | ||||
$editor->applyTransactions($package, $xactions); | $editor->applyTransactions($package, $xactions); | ||||
Show All 35 Lines | $form = id(new AphrontFormView()) | ||||
->setError($e_name)) | ->setError($e_name)) | ||||
->appendControl( | ->appendControl( | ||||
id(new AphrontFormTokenizerControl()) | id(new AphrontFormTokenizerControl()) | ||||
->setDatasource(new PhabricatorProjectOrUserDatasource()) | ->setDatasource(new PhabricatorProjectOrUserDatasource()) | ||||
->setLabel(pht('Owners')) | ->setLabel(pht('Owners')) | ||||
->setName('owners') | ->setName('owners') | ||||
->setValue($v_owners)); | ->setValue($v_owners)); | ||||
if (!$is_new) { | if (!$is_new) { | ||||
$form->appendChild( | $form->appendChild( | ||||
id(new AphrontFormSelectControl()) | id(new AphrontFormSelectControl()) | ||||
->setLabel(pht('Status')) | ->setLabel(pht('Status')) | ||||
->setName('status') | ->setName('status') | ||||
->setValue($v_status) | ->setValue($v_status) | ||||
->setOptions($package->getStatusNameMap())); | ->setOptions($package->getStatusNameMap())); | ||||
} | } | ||||
$form->appendChild( | $form->appendChild( | ||||
id(new AphrontFormSelectControl()) | id(new AphrontFormSelectControl()) | ||||
->setName('auditing') | ->setName('auditing') | ||||
->setLabel(pht('Auditing')) | ->setLabel(pht('Auditing')) | ||||
->setCaption( | ->setCaption( | ||||
pht( | pht( | ||||
'With auditing enabled, all future commits that touch '. | 'With auditing enabled, all future commits that touch '. | ||||
'this package will be reviewed to make sure an owner '. | 'this package will be reviewed to make sure an owner '. | ||||
'of the package is involved and the commit message has '. | 'of the package is involved and the commit message has '. | ||||
'a valid revision, reviewed by, and author.')) | 'a valid revision, reviewed by, and author.')) | ||||
->setOptions( | ->setOptions( | ||||
array( | array( | ||||
'disabled' => pht('Disabled'), | 'disabled' => pht('Disabled'), | ||||
'enabled' => pht('Enabled'), | 'enabled' => pht('Enabled'), | ||||
)) | )) | ||||
->setValue(($v_auditing ? 'enabled' : 'disabled'))) | ->setValue(($v_auditing ? 'enabled' : 'disabled'))) | ||||
->appendChild( | ->appendChild( | ||||
id(new PhabricatorRemarkupControl()) | id(new PhabricatorRemarkupControl()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setLabel(pht('Description')) | ->setLabel(pht('Description')) | ||||
->setName('description') | ->setName('description') | ||||
->setValue($v_description)) | ->setValue($v_description)); | ||||
->appendChild( | |||||
$field_list->appendFieldsToForm($form); | |||||
$form->appendChild( | |||||
id(new AphrontFormSubmitControl()) | id(new AphrontFormSubmitControl()) | ||||
->addCancelButton($cancel_uri) | ->addCancelButton($cancel_uri) | ||||
->setValue($button_text)); | ->setValue($button_text)); | ||||
$form_box = id(new PHUIObjectBoxView()) | $form_box = id(new PHUIObjectBoxView()) | ||||
->setHeaderText($title) | ->setHeaderText($title) | ||||
->setFormErrors($errors) | ->setFormErrors($errors) | ||||
->setForm($form); | ->setForm($form); | ||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
if ($package->getID()) { | if ($package->getID()) { | ||||
Show All 19 Lines |