Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editengine/PhabricatorEditEngine.php
Show First 20 Lines • Show All 402 Lines • ▼ Show 20 Lines | $query = $this->newConfigurationQuery() | ||||
->withIsDefault(true) | ->withIsDefault(true) | ||||
->withIsDisabled(false); | ->withIsDisabled(false); | ||||
return $this->loadEditEngineConfigurationWithQuery( | return $this->loadEditEngineConfigurationWithQuery( | ||||
$query, | $query, | ||||
'getCreateSortKey'); | 'getCreateSortKey'); | ||||
} | } | ||||
public function loadDefaultEditConfiguration() { | public function loadDefaultEditConfiguration($object) { | ||||
$query = $this->newConfigurationQuery() | $query = $this->newConfigurationQuery() | ||||
->withIsEdit(true) | ->withIsEdit(true) | ||||
->withIsDisabled(false); | ->withIsDisabled(false); | ||||
// If this object supports subtyping, we edit it with a form of the same | |||||
// subtype: so "bug" tasks get edited with "bug" forms. | |||||
if ($object instanceof PhabricatorEditEngineSubtypeInterface) { | |||||
$query->withSubtypes( | |||||
array( | |||||
$object->getEditEngineSubtype(), | |||||
)); | |||||
} | |||||
return $this->loadEditEngineConfigurationWithQuery( | return $this->loadEditEngineConfigurationWithQuery( | ||||
$query, | $query, | ||||
'getEditSortKey'); | 'getEditSortKey'); | ||||
} | } | ||||
final public function getBuiltinEngineConfigurations() { | final public function getBuiltinEngineConfigurations() { | ||||
$configurations = $this->newBuiltinEngineConfigurations(); | $configurations = $this->newBuiltinEngineConfigurations(); | ||||
▲ Show 20 Lines • Show All 462 Lines • ▼ Show 20 Lines | if ($use_default) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
if ($id && !$config->getIsEdit()) { | if ($id && !$config->getIsEdit()) { | ||||
return $this->buildNotEditFormRespose($object, $config); | return $this->buildNotEditFormRespose($object, $config); | ||||
} | } | ||||
} else { | } else { | ||||
if ($id) { | if ($id) { | ||||
$config = $this->loadDefaultEditConfiguration(); | $config = $this->loadDefaultEditConfiguration($object); | ||||
if (!$config) { | if (!$config) { | ||||
return $this->buildNoEditResponse($object); | return $this->buildNoEditResponse($object); | ||||
} | } | ||||
} else { | } else { | ||||
$config = $this->loadDefaultCreateConfiguration(); | $config = $this->loadDefaultCreateConfiguration(); | ||||
if (!$config) { | if (!$config) { | ||||
return $this->buildNoCreateResponse($object); | return $this->buildNoCreateResponse($object); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 462 Lines • ▼ Show 20 Lines | /* -( Responding to Web Requests )----------------------------------------- */ | ||||
* current object, just if they have access to the related field. | * current object, just if they have access to the related field. | ||||
* | * | ||||
* @param const Transaction type to test for. | * @param const Transaction type to test for. | ||||
* @return bool True if the user could "Edit" to apply the transaction type. | * @return bool True if the user could "Edit" to apply the transaction type. | ||||
*/ | */ | ||||
final public function hasEditAccessToTransaction($xaction_type) { | final public function hasEditAccessToTransaction($xaction_type) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$config = $this->loadDefaultEditConfiguration(); | |||||
if (!$config) { | |||||
return false; | |||||
} | |||||
$object = $this->getTargetObject(); | $object = $this->getTargetObject(); | ||||
if (!$object) { | if (!$object) { | ||||
$object = $this->newEditableObject(); | $object = $this->newEditableObject(); | ||||
} | } | ||||
$config = $this->loadDefaultEditConfiguration($object); | |||||
if (!$config) { | |||||
return false; | |||||
} | |||||
$fields = $this->buildEditFields($object); | $fields = $this->buildEditFields($object); | ||||
$field = null; | $field = null; | ||||
foreach ($fields as $form_field) { | foreach ($fields as $form_field) { | ||||
$field_xaction_type = $form_field->getTransactionType(); | $field_xaction_type = $form_field->getTransactionType(); | ||||
if ($field_xaction_type === $xaction_type) { | if ($field_xaction_type === $xaction_type) { | ||||
$field = $form_field; | $field = $form_field; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | if (!$configs) { | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
return $specs; | return $specs; | ||||
} | } | ||||
final public function buildEditEngineCommentView($object) { | final public function buildEditEngineCommentView($object) { | ||||
$config = $this->loadDefaultEditConfiguration(); | $config = $this->loadDefaultEditConfiguration($object); | ||||
if (!$config) { | if (!$config) { | ||||
// TODO: This just nukes the entire comment form if you don't have access | // TODO: This just nukes the entire comment form if you don't have access | ||||
// to any edit forms. We might want to tailor this UX a bit. | // to any edit forms. We might want to tailor this UX a bit. | ||||
return id(new PhabricatorApplicationTransactionCommentView()) | return id(new PhabricatorApplicationTransactionCommentView()) | ||||
->setNoPermission(true); | ->setNoPermission(true); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | private function buildCommentResponse($object) { | ||||
$controller = $this->getController(); | $controller = $this->getController(); | ||||
$request = $controller->getRequest(); | $request = $controller->getRequest(); | ||||
if (!$request->isFormPost()) { | if (!$request->isFormPost()) { | ||||
return new Aphront400Response(); | return new Aphront400Response(); | ||||
} | } | ||||
$config = $this->loadDefaultEditConfiguration(); | $config = $this->loadDefaultEditConfiguration($object); | ||||
if (!$config) { | if (!$config) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$fields = $this->buildEditFields($object); | $fields = $this->buildEditFields($object); | ||||
$is_preview = $request->isPreviewRequest(); | $is_preview = $request->isPreviewRequest(); | ||||
$view_uri = $this->getEffectiveObjectViewURI($object); | $view_uri = $this->getEffectiveObjectViewURI($object); | ||||
▲ Show 20 Lines • Show All 568 Lines • Show Last 20 Lines |