protected function loadRelationship($object)
 {
     $request = $this->getRequest();
     $viewer = $this->getViewer();
     $relationship_key = $request->getURIData('relationshipKey');
     $list = PhabricatorObjectRelationshipList::newForObject($viewer, $object);
     return $list->getRelationship($relationship_key);
 }
 private function buildCurtainView(PholioMock $mock)
 {
     $viewer = $this->getViewer();
     $curtain = $this->newCurtainView($mock);
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $mock, PhabricatorPolicyCapability::CAN_EDIT);
     $curtain->addAction(id(new PhabricatorActionView())->setIcon('fa-pencil')->setName(pht('Edit Mock'))->setHref($this->getApplicationURI('/edit/' . $mock->getID() . '/'))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     if ($mock->isClosed()) {
         $curtain->addAction(id(new PhabricatorActionView())->setIcon('fa-check')->setName(pht('Open Mock'))->setHref($this->getApplicationURI('/archive/' . $mock->getID() . '/'))->setDisabled(!$can_edit)->setWorkflow(true));
     } else {
         $curtain->addAction(id(new PhabricatorActionView())->setIcon('fa-ban')->setName(pht('Close Mock'))->setHref($this->getApplicationURI('/archive/' . $mock->getID() . '/'))->setDisabled(!$can_edit)->setWorkflow(true));
     }
     $relationship_list = PhabricatorObjectRelationshipList::newForObject($viewer, $mock);
     $relationship_submenu = $relationship_list->newActionMenu();
     if ($relationship_submenu) {
         $curtain->addAction($relationship_submenu);
     }
     if ($this->getManiphestTaskPHIDs()) {
         $curtain->newPanel()->setHeaderText(pht('Maniphest Tasks'))->appendChild($viewer->renderHandleList($this->getManiphestTaskPHIDs()));
     }
     $curtain->newPanel()->setHeaderText(pht('Authored By'))->appendChild($this->buildAuthorPanel($mock));
     return $curtain;
 }
 private function buildCurtain(ManiphestTask $task, PhabricatorEditEngine $edit_engine)
 {
     $viewer = $this->getViewer();
     $id = $task->getID();
     $phid = $task->getPHID();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $task, PhabricatorPolicyCapability::CAN_EDIT);
     $curtain = $this->newCurtainView($task);
     $curtain->addAction(id(new PhabricatorActionView())->setName(pht('Edit Task'))->setIcon('fa-pencil')->setHref($this->getApplicationURI("/task/edit/{$id}/"))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $edit_config = $edit_engine->loadDefaultEditConfiguration();
     $can_create = (bool) $edit_config;
     $can_reassign = $edit_engine->hasEditAccessToTransaction(ManiphestTransaction::TYPE_OWNER);
     if ($can_create) {
         $form_key = $edit_config->getIdentifier();
         $edit_uri = id(new PhutilURI("/task/edit/form/{$form_key}/"))->setQueryParam('parent', $id)->setQueryParam('template', $id)->setQueryParam('status', ManiphestTaskStatus::getDefaultStatus());
         $edit_uri = $this->getApplicationURI($edit_uri);
     } else {
         // TODO: This will usually give us a somewhat-reasonable error page, but
         // could be a bit cleaner.
         $edit_uri = "/task/edit/{$id}/";
         $edit_uri = $this->getApplicationURI($edit_uri);
     }
     $subtask_item = id(new PhabricatorActionView())->setName(pht('Create Subtask'))->setHref($edit_uri)->setIcon('fa-level-down')->setDisabled(!$can_create)->setWorkflow(!$can_create);
     $relationship_list = PhabricatorObjectRelationshipList::newForObject($viewer, $task);
     $submenu_actions = array($subtask_item, ManiphestTaskHasParentRelationship::RELATIONSHIPKEY, ManiphestTaskHasSubtaskRelationship::RELATIONSHIPKEY, ManiphestTaskMergeInRelationship::RELATIONSHIPKEY, ManiphestTaskCloseAsDuplicateRelationship::RELATIONSHIPKEY);
     $task_submenu = $relationship_list->newActionSubmenu($submenu_actions)->setName(pht('Edit Related Tasks...'))->setIcon('fa-anchor');
     $curtain->addAction($task_submenu);
     $relationship_submenu = $relationship_list->newActionMenu();
     if ($relationship_submenu) {
         $curtain->addAction($relationship_submenu);
     }
     $owner_phid = $task->getOwnerPHID();
     $author_phid = $task->getAuthorPHID();
     $handles = $viewer->loadHandles(array($owner_phid, $author_phid));
     if ($owner_phid) {
         $image_uri = $handles[$owner_phid]->getImageURI();
         $image_href = $handles[$owner_phid]->getURI();
         $owner = $viewer->renderHandle($owner_phid)->render();
         $content = phutil_tag('strong', array(), $owner);
         $assigned_to = id(new PHUIHeadThingView())->setImage($image_uri)->setImageHref($image_href)->setContent($content);
     } else {
         $assigned_to = phutil_tag('em', array(), pht('None'));
     }
     $curtain->newPanel()->setHeaderText(pht('Assigned To'))->appendChild($assigned_to);
     $author_uri = $handles[$author_phid]->getImageURI();
     $author_href = $handles[$author_phid]->getURI();
     $author = $viewer->renderHandle($author_phid)->render();
     $content = phutil_tag('strong', array(), $author);
     $date = phabricator_date($task->getDateCreated(), $viewer);
     $content = pht('%s, %s', $content, $date);
     $authored_by = id(new PHUIHeadThingView())->setImage($author_uri)->setImageHref($author_href)->setContent($content);
     $curtain->newPanel()->setHeaderText(pht('Authored By'))->appendChild($authored_by);
     return $curtain;
 }
 private function buildCurtain(DifferentialRevision $revision)
 {
     $viewer = $this->getViewer();
     $revision_id = $revision->getID();
     $revision_phid = $revision->getPHID();
     $curtain = $this->newCurtainView($revision);
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $revision, PhabricatorPolicyCapability::CAN_EDIT);
     $curtain->addAction(id(new PhabricatorActionView())->setIcon('fa-pencil')->setHref("/differential/revision/edit/{$revision_id}/")->setName(pht('Edit Revision'))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $curtain->addAction(id(new PhabricatorActionView())->setIcon('fa-upload')->setHref("/differential/revision/update/{$revision_id}/")->setName(pht('Update Diff'))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $request_uri = $this->getRequest()->getRequestURI();
     $curtain->addAction(id(new PhabricatorActionView())->setIcon('fa-download')->setName(pht('Download Raw Diff'))->setHref($request_uri->alter('download', 'true')));
     $relationship_list = PhabricatorObjectRelationshipList::newForObject($viewer, $revision);
     $revision_actions = array(DifferentialRevisionHasParentRelationship::RELATIONSHIPKEY, DifferentialRevisionHasChildRelationship::RELATIONSHIPKEY);
     $revision_submenu = $relationship_list->newActionSubmenu($revision_actions)->setName(pht('Edit Related Revisions...'))->setIcon('fa-cog');
     $curtain->addAction($revision_submenu);
     $relationship_submenu = $relationship_list->newActionMenu();
     if ($relationship_submenu) {
         $curtain->addAction($relationship_submenu);
     }
     return $curtain;
 }
 private function buildCurtain(PhabricatorRepositoryCommit $commit, PhabricatorRepository $repository)
 {
     $request = $this->getRequest();
     $viewer = $this->getViewer();
     $curtain = $this->newCurtainView($commit);
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $commit, PhabricatorPolicyCapability::CAN_EDIT);
     $identifier = $commit->getCommitIdentifier();
     $uri = $repository->getPathURI("commit/{$identifier}/edit/");
     $action = id(new PhabricatorActionView())->setName(pht('Edit Commit'))->setHref($uri)->setIcon('fa-pencil')->setDisabled(!$can_edit)->setWorkflow(!$can_edit);
     $curtain->addAction($action);
     $action = id(new PhabricatorActionView())->setName(pht('Download Raw Diff'))->setHref($request->getRequestURI()->alter('diff', true))->setIcon('fa-download');
     $curtain->addAction($action);
     $relationship_list = PhabricatorObjectRelationshipList::newForObject($viewer, $commit);
     $relationship_submenu = $relationship_list->newActionMenu();
     if ($relationship_submenu) {
         $curtain->addAction($relationship_submenu);
     }
     return $curtain;
 }