Differential D14705 Diff 35574 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 { | ||||
public function shouldAllowPublic() { | public function shouldAllowPublic() { | ||||
return true; | return true; | ||||
} | } | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$id = $request->getURIData('id'); | $id = $request->getURIData('id'); | ||||
$e_title = null; | |||||
$priority_map = ManiphestTaskPriority::getTaskPriorityMap(); | |||||
$task = id(new ManiphestTaskQuery()) | $task = id(new ManiphestTaskQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withIDs(array($id)) | ->withIDs(array($id)) | ||||
->needSubscriberPHIDs(true) | ->needSubscriberPHIDs(true) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$task) { | if (!$task) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$workflow = $request->getStr('workflow'); | |||||
$parent_task = null; | |||||
if ($workflow && is_numeric($workflow)) { | |||||
$parent_task = id(new ManiphestTaskQuery()) | |||||
->setViewer($viewer) | |||||
->withIDs(array($workflow)) | |||||
->executeOne(); | |||||
} | |||||
$field_list = PhabricatorCustomField::getObjectFields( | $field_list = PhabricatorCustomField::getObjectFields( | ||||
$task, | $task, | ||||
PhabricatorCustomField::ROLE_VIEW); | PhabricatorCustomField::ROLE_VIEW); | ||||
$field_list | $field_list | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->readFieldsFromStorage($task); | ->readFieldsFromStorage($task); | ||||
$e_commit = ManiphestTaskHasCommitEdgeType::EDGECONST; | $e_commit = ManiphestTaskHasCommitEdgeType::EDGECONST; | ||||
Show All 17 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$edges = idx($query->execute(), $phid); | $edges = idx($query->execute(), $phid); | ||||
$phids = array_fill_keys($query->getDestinationPHIDs(), true); | $phids = array_fill_keys($query->getDestinationPHIDs(), true); | ||||
if ($task->getOwnerPHID()) { | if ($task->getOwnerPHID()) { | ||||
$phids[$task->getOwnerPHID()] = true; | $phids[$task->getOwnerPHID()] = true; | ||||
} | } | ||||
$phids[$task->getAuthorPHID()] = true; | $phids[$task->getAuthorPHID()] = true; | ||||
$attached = $task->getAttached(); | |||||
foreach ($attached as $type => $list) { | |||||
foreach ($list as $phid => $info) { | |||||
$phids[$phid] = true; | |||||
} | |||||
} | |||||
if ($parent_task) { | |||||
$phids[$parent_task->getPHID()] = true; | |||||
} | |||||
$phids = array_keys($phids); | $phids = array_keys($phids); | ||||
$handles = $viewer->loadHandles($phids); | $handles = $viewer->loadHandles($phids); | ||||
$info_view = null; | $engine = id(new PhabricatorMarkupEngine()) | ||||
if ($parent_task) { | ->setViewer($viewer) | ||||
$info_view = new PHUIInfoView(); | ->setContextObject($task) | ||||
$info_view->setSeverity(PHUIInfoView::SEVERITY_NOTICE); | ->addObject($task, ManiphestTask::MARKUP_FIELD_DESCRIPTION); | ||||
$info_view->addButton( | |||||
id(new PHUIButtonView()) | |||||
->setTag('a') | |||||
->setHref('/maniphest/task/create/?parent='.$parent_task->getID()) | |||||
->setText(pht('Create Another Subtask'))); | |||||
$info_view->appendChild(hsprintf( | |||||
'Created a subtask of <strong>%s</strong>.', | |||||
$handles->renderHandle($parent_task->getPHID()))); | |||||
} else if ($workflow == 'create') { | |||||
$info_view = new PHUIInfoView(); | |||||
$info_view->setSeverity(PHUIInfoView::SEVERITY_NOTICE); | |||||
$info_view->addButton( | |||||
id(new PHUIButtonView()) | |||||
->setTag('a') | |||||
->setHref('/maniphest/task/create/?template='.$task->getID()) | |||||
->setText(pht('Similar Task'))); | |||||
$info_view->addButton( | |||||
id(new PHUIButtonView()) | |||||
->setTag('a') | |||||
->setHref('/maniphest/task/create/') | |||||
->setText(pht('Empty Task'))); | |||||
$info_view->appendChild(pht('New task created. Create another?')); | |||||
} | |||||
$engine = new PhabricatorMarkupEngine(); | |||||
$engine->setViewer($viewer); | |||||
$engine->setContextObject($task); | |||||
$engine->addObject($task, ManiphestTask::MARKUP_FIELD_DESCRIPTION); | |||||
$timeline = $this->buildTransactionTimeline( | $timeline = $this->buildTransactionTimeline( | ||||
$task, | $task, | ||||
new ManiphestTransactionQuery(), | new ManiphestTransactionQuery(), | ||||
$engine); | $engine); | ||||
$actions = $this->buildActionView($task); | $actions = $this->buildActionView($task); | ||||
Show All 27 Lines | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
->setPageObjectPHIDs( | ->setPageObjectPHIDs( | ||||
array( | array( | ||||
$task->getPHID(), | $task->getPHID(), | ||||
)) | )) | ||||
->appendChild( | ->appendChild( | ||||
array( | array( | ||||
$info_view, | |||||
$object_box, | $object_box, | ||||
$timeline, | $timeline, | ||||
$comment_view, | $comment_view, | ||||
)); | )); | ||||
} | } | ||||
private function buildHeaderView(ManiphestTask $task) { | private function buildHeaderView(ManiphestTask $task) { | ||||
$view = id(new PHUIHeaderView()) | $view = id(new PHUIHeaderView()) | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | private function buildPropertyView( | ||||
} | } | ||||
if ($revisions_commits) { | if ($revisions_commits) { | ||||
$view->addProperty( | $view->addProperty( | ||||
pht('Commits'), | pht('Commits'), | ||||
phutil_implode_html(phutil_tag('br'), $revisions_commits)); | phutil_implode_html(phutil_tag('br'), $revisions_commits)); | ||||
} | } | ||||
$attached = $task->getAttached(); | |||||
if (!is_array($attached)) { | |||||
$attached = array(); | |||||
} | |||||
$file_infos = idx($attached, PhabricatorFileFilePHIDType::TYPECONST); | |||||
if ($file_infos) { | |||||
$file_phids = array_keys($file_infos); | |||||
// TODO: These should probably be handles or something; clean this up | |||||
// as we sort out file attachments. | |||||
$files = id(new PhabricatorFileQuery()) | |||||
->setViewer($viewer) | |||||
->withPHIDs($file_phids) | |||||
->execute(); | |||||
$file_view = new PhabricatorFileLinkListView(); | |||||
$file_view->setFiles($files); | |||||
$view->addProperty( | |||||
pht('Files'), | |||||
$file_view->render()); | |||||
} | |||||
$view->invokeWillRenderEvent(); | $view->invokeWillRenderEvent(); | ||||
$field_list->appendFieldsToPropertyList( | $field_list->appendFieldsToPropertyList( | ||||
$task, | $task, | ||||
$viewer, | $viewer, | ||||
$view); | $view); | ||||
return $view; | return $view; | ||||
Show All 25 Lines |