Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / spaces / controller / PhabricatorSpacesViewController.php
blobba55ba90a75c2da74e51fcc6fd94ab76762ea9d5
1 <?php
3 final class PhabricatorSpacesViewController
4 extends PhabricatorSpacesController {
6 public function shouldAllowPublic() {
7 return true;
10 public function handleRequest(AphrontRequest $request) {
11 $viewer = $this->getViewer();
13 $space = id(new PhabricatorSpacesNamespaceQuery())
14 ->setViewer($viewer)
15 ->withIDs(array($request->getURIData('id')))
16 ->executeOne();
17 if (!$space) {
18 return new Aphront404Response();
21 $curtain = $this->buildCurtain($space);
22 $property_list = $this->buildPropertyListView($space);
23 $title = array($space->getMonogram(), $space->getNamespaceName());
25 $xactions = id(new PhabricatorSpacesNamespaceTransactionQuery())
26 ->setViewer($viewer)
27 ->withObjectPHIDs(array($space->getPHID()))
28 ->execute();
30 $timeline = $this->buildTransactionTimeline(
31 $space,
32 new PhabricatorSpacesNamespaceTransactionQuery());
33 $timeline->setShouldTerminate(true);
35 $header = id(new PHUIHeaderView())
36 ->setUser($viewer)
37 ->setHeader($space->getNamespaceName())
38 ->setPolicyObject($space)
39 ->setHeaderIcon('fa-th-large');
41 if ($space->getIsArchived()) {
42 $header->setStatus('fa-ban', 'indigo', pht('Archived'));
43 } else {
44 $header->setStatus('fa-check', 'bluegrey', pht('Active'));
47 $box = id(new PHUIObjectBoxView())
48 ->setHeaderText(pht('Details'))
49 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
50 ->addPropertyList($property_list);
52 $crumbs = $this->buildApplicationCrumbs();
53 $crumbs->addTextCrumb($space->getMonogram());
54 $crumbs->setBorder(true);
56 $view = id(new PHUITwoColumnView())
57 ->setHeader($header)
58 ->setMainColumn(array(
59 $box,
60 $timeline,
62 ->setCurtain($curtain);
64 return $this->newPage()
65 ->setTitle($title)
66 ->setCrumbs($crumbs)
67 ->appendChild($view);
71 private function buildPropertyListView(PhabricatorSpacesNamespace $space) {
72 $viewer = $this->getRequest()->getUser();
74 $list = id(new PHUIPropertyListView())
75 ->setUser($viewer);
77 $list->addProperty(
78 pht('Default Space'),
79 $space->getIsDefaultNamespace()
80 ? pht('Yes')
81 : pht('No'));
83 $description = $space->getDescription();
84 if (strlen($description)) {
85 $description = new PHUIRemarkupView($viewer, $description);
86 $list->addSectionHeader(
87 pht('Description'),
88 PHUIPropertyListView::ICON_SUMMARY);
89 $list->addTextContent($description);
92 return $list;
95 private function buildCurtain(PhabricatorSpacesNamespace $space) {
96 $viewer = $this->getRequest()->getUser();
98 $curtain = $this->newCurtainView($space);
100 $can_edit = PhabricatorPolicyFilter::hasCapability(
101 $viewer,
102 $space,
103 PhabricatorPolicyCapability::CAN_EDIT);
105 $curtain->addAction(
106 id(new PhabricatorActionView())
107 ->setName(pht('Edit Space'))
108 ->setIcon('fa-pencil')
109 ->setHref($this->getApplicationURI('edit/'.$space->getID().'/'))
110 ->setWorkflow(!$can_edit)
111 ->setDisabled(!$can_edit));
113 $id = $space->getID();
115 if ($space->getIsArchived()) {
116 $curtain->addAction(
117 id(new PhabricatorActionView())
118 ->setName(pht('Activate Space'))
119 ->setIcon('fa-check')
120 ->setHref($this->getApplicationURI("activate/{$id}/"))
121 ->setDisabled(!$can_edit)
122 ->setWorkflow(true));
123 } else {
124 $curtain->addAction(
125 id(new PhabricatorActionView())
126 ->setName(pht('Archive Space'))
127 ->setIcon('fa-ban')
128 ->setHref($this->getApplicationURI("archive/{$id}/"))
129 ->setDisabled(!$can_edit)
130 ->setWorkflow(true));
133 return $curtain;