Differential D14895 Diff 36003 src/applications/project/controller/PhabricatorProjectEditDetailsController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/controller/PhabricatorProjectEditDetailsController.php
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| $v_name = $project->getName(); | $v_name = $project->getName(); | ||||
| $project_slugs = $project->getSlugs(); | $project_slugs = $project->getSlugs(); | ||||
| $project_slugs = mpull($project_slugs, 'getSlug', 'getSlug'); | $project_slugs = mpull($project_slugs, 'getSlug', 'getSlug'); | ||||
| $v_primary_slug = $project->getPrimarySlug(); | $v_primary_slug = $project->getPrimarySlug(); | ||||
| unset($project_slugs[$v_primary_slug]); | unset($project_slugs[$v_primary_slug]); | ||||
| $v_slugs = $project_slugs; | $v_slugs = $project_slugs; | ||||
| $v_color = $project->getColor(); | $v_color = $project->getColor(); | ||||
| $v_icon = $project->getIcon(); | $v_icon = $project->getIcon(); | ||||
| $v_locked = $project->getIsMembershipLocked(); | |||||
| $validation_exception = null; | $validation_exception = null; | ||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| $e_name = null; | $e_name = null; | ||||
| $e_slugs = null; | $e_slugs = null; | ||||
| $v_name = $request->getStr('name'); | $v_name = $request->getStr('name'); | ||||
| $v_slugs = $request->getStrList('slugs'); | $v_slugs = $request->getStrList('slugs'); | ||||
| $v_view = $request->getStr('can_view'); | $v_view = $request->getStr('can_view'); | ||||
| $v_edit = $request->getStr('can_edit'); | $v_edit = $request->getStr('can_edit'); | ||||
| $v_join = $request->getStr('can_join'); | $v_join = $request->getStr('can_join'); | ||||
| $v_color = $request->getStr('color'); | $v_color = $request->getStr('color'); | ||||
| $v_icon = $request->getStr('icon'); | $v_icon = $request->getStr('icon'); | ||||
| $v_locked = $request->getInt('is_membership_locked', 0); | |||||
| $type_name = PhabricatorProjectTransaction::TYPE_NAME; | $type_name = PhabricatorProjectTransaction::TYPE_NAME; | ||||
| $type_slugs = PhabricatorProjectTransaction::TYPE_SLUGS; | $type_slugs = PhabricatorProjectTransaction::TYPE_SLUGS; | ||||
| $type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY; | $type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY; | ||||
| $type_icon = PhabricatorProjectTransaction::TYPE_ICON; | $type_icon = PhabricatorProjectTransaction::TYPE_ICON; | ||||
| $type_color = PhabricatorProjectTransaction::TYPE_COLOR; | $type_color = PhabricatorProjectTransaction::TYPE_COLOR; | ||||
| $type_locked = PhabricatorProjectTransaction::TYPE_LOCKED; | |||||
| $xactions = array(); | $xactions = array(); | ||||
| $xactions[] = id(new PhabricatorProjectTransaction()) | $xactions[] = id(new PhabricatorProjectTransaction()) | ||||
| ->setTransactionType($type_name) | ->setTransactionType($type_name) | ||||
| ->setNewValue($v_name); | ->setNewValue($v_name); | ||||
| $xactions[] = id(new PhabricatorProjectTransaction()) | $xactions[] = id(new PhabricatorProjectTransaction()) | ||||
| Show All 15 Lines | if ($request->isFormPost()) { | ||||
| $xactions[] = id(new PhabricatorProjectTransaction()) | $xactions[] = id(new PhabricatorProjectTransaction()) | ||||
| ->setTransactionType($type_icon) | ->setTransactionType($type_icon) | ||||
| ->setNewValue($v_icon); | ->setNewValue($v_icon); | ||||
| $xactions[] = id(new PhabricatorProjectTransaction()) | $xactions[] = id(new PhabricatorProjectTransaction()) | ||||
| ->setTransactionType($type_color) | ->setTransactionType($type_color) | ||||
| ->setNewValue($v_color); | ->setNewValue($v_color); | ||||
| $xactions[] = id(new PhabricatorProjectTransaction()) | |||||
| ->setTransactionType($type_locked) | |||||
| ->setNewValue($v_locked); | |||||
| $xactions = array_merge( | $xactions = array_merge( | ||||
| $xactions, | $xactions, | ||||
| $field_list->buildFieldTransactionsFromRequest( | $field_list->buildFieldTransactionsFromRequest( | ||||
| new PhabricatorProjectTransaction(), | new PhabricatorProjectTransaction(), | ||||
| $request)); | $request)); | ||||
| $editor = id(new PhabricatorProjectTransactionEditor()) | $editor = id(new PhabricatorProjectTransactionEditor()) | ||||
| ->setActor($viewer) | ->setActor($viewer) | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | $form = id(new AphrontFormView()) | ||||
| ->setLabel(pht('Name')) | ->setLabel(pht('Name')) | ||||
| ->setName('name') | ->setName('name') | ||||
| ->setValue($v_name) | ->setValue($v_name) | ||||
| ->setError($e_name)); | ->setError($e_name)); | ||||
| $field_list->appendFieldsToForm($form); | $field_list->appendFieldsToForm($form); | ||||
| $shades = PhabricatorProjectIconSet::getColorMap(); | $shades = PhabricatorProjectIconSet::getColorMap(); | ||||
| list($can_lock, $lock_message) = $this->explainApplicationCapability( | |||||
| ProjectCanLockProjectsCapability::CAPABILITY, | |||||
| pht('You can update the Lock Project setting.'), | |||||
| pht('You can not update the Lock Project setting.')); | |||||
| $form | $form | ||||
| ->appendChild( | ->appendChild( | ||||
| id(new PHUIFormIconSetControl()) | id(new PHUIFormIconSetControl()) | ||||
| ->setLabel(pht('Icon')) | ->setLabel(pht('Icon')) | ||||
| ->setName('icon') | ->setName('icon') | ||||
| ->setIconSet(new PhabricatorProjectIconSet()) | ->setIconSet(new PhabricatorProjectIconSet()) | ||||
| ->setValue($v_icon)) | ->setValue($v_icon)) | ||||
| ->appendChild( | ->appendChild( | ||||
| Show All 38 Lines | $form | ||||
| ->appendChild( | ->appendChild( | ||||
| id(new AphrontFormPolicyControl()) | id(new AphrontFormPolicyControl()) | ||||
| ->setUser($viewer) | ->setUser($viewer) | ||||
| ->setName('can_join') | ->setName('can_join') | ||||
| ->setCaption( | ->setCaption( | ||||
| pht('Users who can edit a project can always join a project.')) | pht('Users who can edit a project can always join a project.')) | ||||
| ->setPolicyObject($project) | ->setPolicyObject($project) | ||||
| ->setPolicies($policies) | ->setPolicies($policies) | ||||
| ->setCapability(PhabricatorPolicyCapability::CAN_JOIN)) | ->setCapability(PhabricatorPolicyCapability::CAN_JOIN)); | ||||
| ->appendChild( | |||||
| id(new AphrontFormCheckboxControl()) | |||||
| ->setLabel(pht('Lock Project')) | |||||
| ->setDisabled(!$can_lock) | |||||
| ->addCheckbox( | |||||
| 'is_membership_locked', | |||||
| 1, | |||||
| pht('Prevent members from leaving this project.'), | |||||
| $v_locked) | |||||
| ->setCaption($lock_message)); | |||||
| if ($request->isAjax()) { | if ($request->isAjax()) { | ||||
| $errors = array(); | $errors = array(); | ||||
| if ($validation_exception) { | if ($validation_exception) { | ||||
| $errors = mpull($ex->getErrors(), 'getMessage'); | $errors = mpull($ex->getErrors(), 'getMessage'); | ||||
| } | } | ||||
| $dialog = id(new AphrontDialogView()) | $dialog = id(new AphrontDialogView()) | ||||
| ->setUser($viewer) | ->setUser($viewer) | ||||
| Show All 34 Lines | |||||