Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / people / controller / PhabricatorPeopleProfileTasksController.php
blobbc4e1432f10c48230cb44923a0c0586ba5b93ac4
1 <?php
3 final class PhabricatorPeopleProfileTasksController
4 extends PhabricatorPeopleProfileController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
8 $id = $request->getURIData('id');
10 $user = id(new PhabricatorPeopleQuery())
11 ->setViewer($viewer)
12 ->withIDs(array($id))
13 ->needProfile(true)
14 ->needProfileImage(true)
15 ->needAvailability(true)
16 ->executeOne();
17 if (!$user) {
18 return new Aphront404Response();
21 $class = 'PhabricatorManiphestApplication';
22 if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
23 return new Aphront404Response();
26 $this->setUser($user);
27 $title = array(pht('Assigned Tasks'), $user->getUsername());
28 $header = $this->buildProfileHeader();
29 $tasks = $this->buildTasksView($user);
31 $crumbs = $this->buildApplicationCrumbs();
32 $crumbs->addTextCrumb(pht('Assigned Tasks'));
33 $crumbs->setBorder(true);
35 $nav = $this->newNavigation(
36 $user,
37 PhabricatorPeopleProfileMenuEngine::ITEM_TASKS);
39 $view = id(new PHUITwoColumnView())
40 ->setHeader($header)
41 ->addClass('project-view-home')
42 ->addClass('project-view-people-home')
43 ->setFooter(array(
44 $tasks,
45 ));
47 return $this->newPage()
48 ->setTitle($title)
49 ->setCrumbs($crumbs)
50 ->setNavigation($nav)
51 ->appendChild($view);
54 private function buildTasksView(PhabricatorUser $user) {
55 $viewer = $this->getViewer();
57 $open = ManiphestTaskStatus::getOpenStatusConstants();
59 $tasks = id(new ManiphestTaskQuery())
60 ->setViewer($viewer)
61 ->withOwners(array($user->getPHID()))
62 ->withStatuses($open)
63 ->needProjectPHIDs(true)
64 ->setLimit(100)
65 ->setGroupBy(ManiphestTaskQuery::GROUP_PRIORITY)
66 ->execute();
68 $handles = ManiphestTaskListView::loadTaskHandles($viewer, $tasks);
70 $list = id(new ManiphestTaskListView())
71 ->setUser($viewer)
72 ->setHandles($handles)
73 ->setTasks($tasks)
74 ->setNoDataString(pht('No open, assigned tasks.'));
76 $view = id(new PHUIObjectBoxView())
77 ->setHeaderText(pht('Assigned Tasks'))
78 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
79 ->appendChild($list);
81 return $view;