Differential D13773 Diff 33266 src/applications/maniphest/controller/ManiphestTaskDetailController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/controller/ManiphestTaskDetailController.php
<?php | <?php | ||||
final class ManiphestTaskDetailController extends ManiphestController { | final class ManiphestTaskDetailController extends ManiphestController { | ||||
private $id; | |||||
public function shouldAllowPublic() { | public function shouldAllowPublic() { | ||||
return true; | return true; | ||||
} | } | ||||
public function willProcessRequest(array $data) { | public function handleRequest(AphrontRequest $request) { | ||||
$this->id = $data['id']; | $viewer = $this->getViewer(); | ||||
} | $id = $request->getURIData('id'); | ||||
public function processRequest() { | |||||
$request = $this->getRequest(); | |||||
$user = $request->getUser(); | |||||
$e_title = null; | $e_title = null; | ||||
$priority_map = ManiphestTaskPriority::getTaskPriorityMap(); | $priority_map = ManiphestTaskPriority::getTaskPriorityMap(); | ||||
$task = id(new ManiphestTaskQuery()) | $task = id(new ManiphestTaskQuery()) | ||||
->setViewer($user) | ->setViewer($viewer) | ||||
->withIDs(array($this->id)) | ->withIDs(array($id)) | ||||
->needSubscriberPHIDs(true) | ->needSubscriberPHIDs(true) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$task) { | if (!$task) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$workflow = $request->getStr('workflow'); | $workflow = $request->getStr('workflow'); | ||||
$parent_task = null; | $parent_task = null; | ||||
if ($workflow && is_numeric($workflow)) { | if ($workflow && is_numeric($workflow)) { | ||||
$parent_task = id(new ManiphestTaskQuery()) | $parent_task = id(new ManiphestTaskQuery()) | ||||
->setViewer($user) | ->setViewer($viewer) | ||||
->withIDs(array($workflow)) | ->withIDs(array($workflow)) | ||||
->executeOne(); | ->executeOne(); | ||||
} | } | ||||
$field_list = PhabricatorCustomField::getObjectFields( | $field_list = PhabricatorCustomField::getObjectFields( | ||||
$task, | $task, | ||||
PhabricatorCustomField::ROLE_VIEW); | PhabricatorCustomField::ROLE_VIEW); | ||||
$field_list | $field_list | ||||
->setViewer($user) | ->setViewer($viewer) | ||||
->readFieldsFromStorage($task); | ->readFieldsFromStorage($task); | ||||
$e_commit = ManiphestTaskHasCommitEdgeType::EDGECONST; | $e_commit = ManiphestTaskHasCommitEdgeType::EDGECONST; | ||||
$e_dep_on = ManiphestTaskDependsOnTaskEdgeType::EDGECONST; | $e_dep_on = ManiphestTaskDependsOnTaskEdgeType::EDGECONST; | ||||
$e_dep_by = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST; | $e_dep_by = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST; | ||||
$e_rev = ManiphestTaskHasRevisionEdgeType::EDGECONST; | $e_rev = ManiphestTaskHasRevisionEdgeType::EDGECONST; | ||||
$e_mock = ManiphestTaskHasMockEdgeType::EDGECONST; | $e_mock = ManiphestTaskHasMockEdgeType::EDGECONST; | ||||
Show All 24 Lines | foreach ($attached as $type => $list) { | ||||
} | } | ||||
} | } | ||||
if ($parent_task) { | if ($parent_task) { | ||||
$phids[$parent_task->getPHID()] = true; | $phids[$parent_task->getPHID()] = true; | ||||
} | } | ||||
$phids = array_keys($phids); | $phids = array_keys($phids); | ||||
$handles = $user->loadHandles($phids); | $handles = $viewer->loadHandles($phids); | ||||
$info_view = null; | $info_view = null; | ||||
if ($parent_task) { | if ($parent_task) { | ||||
$info_view = new PHUIInfoView(); | $info_view = new PHUIInfoView(); | ||||
$info_view->setSeverity(PHUIInfoView::SEVERITY_NOTICE); | $info_view->setSeverity(PHUIInfoView::SEVERITY_NOTICE); | ||||
$info_view->addButton( | $info_view->addButton( | ||||
id(new PHUIButtonView()) | id(new PHUIButtonView()) | ||||
->setTag('a') | ->setTag('a') | ||||
Show All 15 Lines | if ($parent_task) { | ||||
id(new PHUIButtonView()) | id(new PHUIButtonView()) | ||||
->setTag('a') | ->setTag('a') | ||||
->setHref('/maniphest/task/create/') | ->setHref('/maniphest/task/create/') | ||||
->setText(pht('Empty Task'))); | ->setText(pht('Empty Task'))); | ||||
$info_view->appendChild(pht('New task created. Create another?')); | $info_view->appendChild(pht('New task created. Create another?')); | ||||
} | } | ||||
$engine = new PhabricatorMarkupEngine(); | $engine = new PhabricatorMarkupEngine(); | ||||
$engine->setViewer($user); | $engine->setViewer($viewer); | ||||
$engine->setContextObject($task); | $engine->setContextObject($task); | ||||
$engine->addObject($task, ManiphestTask::MARKUP_FIELD_DESCRIPTION); | $engine->addObject($task, ManiphestTask::MARKUP_FIELD_DESCRIPTION); | ||||
$timeline = $this->buildTransactionTimeline( | $timeline = $this->buildTransactionTimeline( | ||||
$task, | $task, | ||||
new ManiphestTransactionQuery(), | new ManiphestTransactionQuery(), | ||||
$engine); | $engine); | ||||
Show All 37 Lines | public function handleRequest(AphrontRequest $request) { | ||||
// Don't show owner/priority changes for closed tasks, as they don't make | // Don't show owner/priority changes for closed tasks, as they don't make | ||||
// much sense. | // much sense. | ||||
if ($task->isClosed()) { | if ($task->isClosed()) { | ||||
unset($transaction_types[ManiphestTransaction::TYPE_PRIORITY]); | unset($transaction_types[ManiphestTransaction::TYPE_PRIORITY]); | ||||
unset($transaction_types[ManiphestTransaction::TYPE_OWNER]); | unset($transaction_types[ManiphestTransaction::TYPE_OWNER]); | ||||
} | } | ||||
$default_claim = array( | $default_claim = array( | ||||
$user->getPHID() => $user->getUsername().' ('.$user->getRealName().')', | $viewer->getPHID() => $viewer->getUsername(). | ||||
' ('.$viewer->getRealName().')', | |||||
); | ); | ||||
$draft = id(new PhabricatorDraft())->loadOneWhere( | $draft = id(new PhabricatorDraft())->loadOneWhere( | ||||
'authorPHID = %s AND draftKey = %s', | 'authorPHID = %s AND draftKey = %s', | ||||
$user->getPHID(), | $viewer->getPHID(), | ||||
$task->getPHID()); | $task->getPHID()); | ||||
if ($draft) { | if ($draft) { | ||||
$draft_text = $draft->getDraft(); | $draft_text = $draft->getDraft(); | ||||
} else { | } else { | ||||
$draft_text = null; | $draft_text = null; | ||||
} | } | ||||
$projects_source = new PhabricatorProjectDatasource(); | $projects_source = new PhabricatorProjectDatasource(); | ||||
$users_source = new PhabricatorPeopleDatasource(); | $users_source = new PhabricatorPeopleDatasource(); | ||||
$mailable_source = new PhabricatorMetaMTAMailableDatasource(); | $mailable_source = new PhabricatorMetaMTAMailableDatasource(); | ||||
$comment_form = new AphrontFormView(); | $comment_form = new AphrontFormView(); | ||||
$comment_form | $comment_form | ||||
->setUser($user) | ->setUser($viewer) | ||||
->setWorkflow(true) | ->setWorkflow(true) | ||||
->setAction('/maniphest/transaction/save/') | ->setAction('/maniphest/transaction/save/') | ||||
->setEncType('multipart/form-data') | ->setEncType('multipart/form-data') | ||||
->addHiddenInput('taskID', $task->getID()) | ->addHiddenInput('taskID', $task->getID()) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormSelectControl()) | id(new AphrontFormSelectControl()) | ||||
->setLabel(pht('Action')) | ->setLabel(pht('Action')) | ||||
->setName('action') | ->setName('action') | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | $comment_form | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormFileControl()) | id(new AphrontFormFileControl()) | ||||
->setLabel(pht('File')) | ->setLabel(pht('File')) | ||||
->setName('file') | ->setName('file') | ||||
->setControlID('file') | ->setControlID('file') | ||||
->setControlStyle('display: none')) | ->setControlStyle('display: none')) | ||||
->appendChild( | ->appendChild( | ||||
id(new PhabricatorRemarkupControl()) | id(new PhabricatorRemarkupControl()) | ||||
->setUser($user) | ->setUser($viewer) | ||||
->setLabel(pht('Comments')) | ->setLabel(pht('Comments')) | ||||
->setName('comments') | ->setName('comments') | ||||
->setValue($draft_text) | ->setValue($draft_text) | ||||
->setID('transaction-comments') | ->setID('transaction-comments') | ||||
->setUser($user)) | ->setUser($viewer)) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormSubmitControl()) | id(new AphrontFormSubmitControl()) | ||||
->setValue(pht('Submit'))); | ->setValue(pht('Submit'))); | ||||
$control_map = array( | $control_map = array( | ||||
ManiphestTransaction::TYPE_STATUS => 'resolution', | ManiphestTransaction::TYPE_STATUS => 'resolution', | ||||
ManiphestTransaction::TYPE_OWNER => 'assign_to', | ManiphestTransaction::TYPE_OWNER => 'assign_to', | ||||
PhabricatorTransactions::TYPE_SUBSCRIBERS => 'ccs', | PhabricatorTransactions::TYPE_SUBSCRIBERS => 'ccs', | ||||
Show All 17 Lines | $tokenizer_map = array( | ||||
PhabricatorTransactions::TYPE_SUBSCRIBERS => array( | PhabricatorTransactions::TYPE_SUBSCRIBERS => array( | ||||
'id' => 'cc-tokenizer', | 'id' => 'cc-tokenizer', | ||||
'src' => $mailable_source->getDatasourceURI(), | 'src' => $mailable_source->getDatasourceURI(), | ||||
'placeholder' => $mailable_source->getPlaceholderText(), | 'placeholder' => $mailable_source->getPlaceholderText(), | ||||
), | ), | ||||
); | ); | ||||
// TODO: Initializing these behaviors for logged out users fatals things. | // TODO: Initializing these behaviors for logged out users fatals things. | ||||
if ($user->isLoggedIn()) { | if ($viewer->isLoggedIn()) { | ||||
Javelin::initBehavior('maniphest-transaction-controls', array( | Javelin::initBehavior('maniphest-transaction-controls', array( | ||||
'select' => 'transaction-action', | 'select' => 'transaction-action', | ||||
'controlMap' => $control_map, | 'controlMap' => $control_map, | ||||
'tokenizers' => $tokenizer_map, | 'tokenizers' => $tokenizer_map, | ||||
)); | )); | ||||
Javelin::initBehavior('maniphest-transaction-preview', array( | Javelin::initBehavior('maniphest-transaction-preview', array( | ||||
'uri' => '/maniphest/transaction/preview/'.$task->getID().'/', | 'uri' => '/maniphest/transaction/preview/'.$task->getID().'/', | ||||
Show All 25 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$crumbs = $this->buildApplicationCrumbs() | $crumbs = $this->buildApplicationCrumbs() | ||||
->addTextCrumb($object_name, '/'.$object_name); | ->addTextCrumb($object_name, '/'.$object_name); | ||||
$header = $this->buildHeaderView($task); | $header = $this->buildHeaderView($task); | ||||
$properties = $this->buildPropertyView( | $properties = $this->buildPropertyView( | ||||
$task, $field_list, $edges, $actions, $handles); | $task, $field_list, $edges, $actions, $handles); | ||||
$description = $this->buildDescriptionView($task, $engine); | $description = $this->buildDescriptionView($task, $engine); | ||||
if (!$user->isLoggedIn()) { | if (!$viewer->isLoggedIn()) { | ||||
// TODO: Eventually, everything should run through this. For now, we're | // TODO: Eventually, everything should run through this. For now, we're | ||||
// only using it to get a consistent "Login to Comment" button. | // only using it to get a consistent "Login to Comment" button. | ||||
$comment_box = id(new PhabricatorApplicationTransactionCommentView()) | $comment_box = id(new PhabricatorApplicationTransactionCommentView()) | ||||
->setUser($user) | ->setUser($viewer) | ||||
->setRequestURI($request->getRequestURI()); | ->setRequestURI($request->getRequestURI()); | ||||
$preview_panel = null; | $preview_panel = null; | ||||
} else { | } else { | ||||
$comment_box = id(new PHUIObjectBoxView()) | $comment_box = id(new PHUIObjectBoxView()) | ||||
->setFlush(true) | ->setFlush(true) | ||||
->setHeaderText($comment_header) | ->setHeaderText($comment_header) | ||||
->setForm($comment_form); | ->setForm($comment_form); | ||||
$timeline->setQuoteTargetID('transaction-comments'); | $timeline->setQuoteTargetID('transaction-comments'); | ||||
▲ Show 20 Lines • Show All 243 Lines • Show Last 20 Lines |