Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / almanac / controller / AlmanacNetworkViewController.php
blob271ae1a0fbfdff72a88e533d22840aa55f089631
1 <?php
3 final class AlmanacNetworkViewController
4 extends AlmanacNetworkController {
6 public function shouldAllowPublic() {
7 return true;
10 public function handleRequest(AphrontRequest $request) {
11 $viewer = $request->getViewer();
13 $id = $request->getURIData('id');
14 $network = id(new AlmanacNetworkQuery())
15 ->setViewer($viewer)
16 ->withIDs(array($id))
17 ->executeOne();
18 if (!$network) {
19 return new Aphront404Response();
22 $title = pht('Network %s', $network->getName());
24 $curtain = $this->buildCurtain($network);
26 $header = id(new PHUIHeaderView())
27 ->setUser($viewer)
28 ->setHeader($network->getName())
29 ->setHeaderIcon('fa-globe')
30 ->setPolicyObject($network);
32 $crumbs = $this->buildApplicationCrumbs();
33 $crumbs->addTextCrumb($network->getName());
34 $crumbs->setBorder(true);
36 $timeline = $this->buildTransactionTimeline(
37 $network,
38 new AlmanacNetworkTransactionQuery());
39 $timeline->setShouldTerminate(true);
41 $view = id(new PHUITwoColumnView())
42 ->setHeader($header)
43 ->setCurtain($curtain)
44 ->setMainColumn(array(
45 $timeline,
46 ));
48 return $this->newPage()
49 ->setTitle($title)
50 ->setCrumbs($crumbs)
51 ->appendChild(
52 array(
53 $view,
54 ));
58 private function buildCurtain(AlmanacNetwork $network) {
59 $viewer = $this->getViewer();
61 $can_edit = PhabricatorPolicyFilter::hasCapability(
62 $viewer,
63 $network,
64 PhabricatorPolicyCapability::CAN_EDIT);
66 $id = $network->getID();
67 $edit_uri = $this->getApplicationURI("network/edit/{$id}/");
69 $curtain = $this->newCurtainView($network);
71 $curtain->addAction(
72 id(new PhabricatorActionView())
73 ->setIcon('fa-pencil')
74 ->setName(pht('Edit Network'))
75 ->setHref($edit_uri)
76 ->setWorkflow(!$can_edit)
77 ->setDisabled(!$can_edit));
79 return $curtain;