コード例 #1
0
 protected function renderObjectRef($object, PhabricatorObjectHandle $handle, $anchor, $id)
 {
     if ($this->getEngine()->isTextMode()) {
         return '#' . $id;
     }
     $tag = $handle->renderTag();
     $tag->setPHID($handle->getPHID());
     return $tag;
 }
コード例 #2
0
 public static function newFromHandle(PhabricatorObjectHandle $handle)
 {
     $token = id(new PhabricatorTypeaheadTokenView())->setKey($handle->getPHID())->setValue($handle->getFullName())->setIcon($handle->getIcon());
     if ($handle->isDisabled() || $handle->getStatus() == PhabricatorObjectHandle::STATUS_CLOSED) {
         $token->setTokenType(self::TYPE_DISABLED);
     } else {
         $token->setColor($handle->getTagColor());
     }
     return $token;
 }
コード例 #3
0
 public static function newFromPolicyAndHandle($policy_identifier, PhabricatorObjectHandle $handle = null)
 {
     $is_global = PhabricatorPolicyQuery::isGlobalPolicy($policy_identifier);
     if ($is_global) {
         return PhabricatorPolicyQuery::getGlobalPolicy($policy_identifier);
     }
     $policy = PhabricatorPolicyQuery::getObjectPolicy($policy_identifier);
     if ($policy) {
         return $policy;
     }
     if (!$handle) {
         throw new Exception(pht("Policy identifier is an object PHID ('%s'), but no object handle " . "was provided. A handle must be provided for object policies.", $policy_identifier));
     }
     $handle_phid = $handle->getPHID();
     if ($policy_identifier != $handle_phid) {
         throw new Exception(pht("Policy identifier is an object PHID ('%s'), but the provided " . "handle has a different PHID ('%s'). The handle must correspond " . "to the policy identifier.", $policy_identifier, $handle_phid));
     }
     $policy = id(new PhabricatorPolicy())->setPHID($policy_identifier)->setHref($handle->getURI());
     $phid_type = phid_get_type($policy_identifier);
     switch ($phid_type) {
         case PhabricatorProjectProjectPHIDType::TYPECONST:
             $policy->setType(PhabricatorPolicyType::TYPE_PROJECT);
             $policy->setName($handle->getName());
             break;
         case PhabricatorPeopleUserPHIDType::TYPECONST:
             $policy->setType(PhabricatorPolicyType::TYPE_USER);
             $policy->setName($handle->getFullName());
             break;
         case PhabricatorPolicyPHIDTypePolicy::TYPECONST:
             // TODO: This creates a weird handle-based version of a rule policy.
             // It behaves correctly, but can't be applied since it doesn't have
             // any rules. It is used to render transactions, and might need some
             // cleanup.
             break;
         default:
             $policy->setType(PhabricatorPolicyType::TYPE_MASKED);
             $policy->setName($handle->getFullName());
             break;
     }
     $policy->makeEphemeral();
     return $policy;
 }
コード例 #4
0
 protected function renderObjectEmbed($object, PhabricatorObjectHandle $handle, $options)
 {
     $name = $handle->getFullName();
     $href = $handle->getURI();
     $status_closed = PhabricatorObjectHandle::STATUS_CLOSED;
     $attr = array('phid' => $handle->getPHID(), 'closed' => $handle->getStatus() == $status_closed);
     return $this->renderHovertag($name, $href, $attr);
 }
コード例 #5
0
 protected function getDefaultPrivateReplyHandlerEmailAddress(PhabricatorObjectHandle $handle, $prefix)
 {
     if ($handle->getType() != PhabricatorPHIDConstants::PHID_TYPE_USER) {
         // You must be a real user to get a private reply handler address.
         return null;
     }
     $receiver = $this->getMailReceiver();
     $receiver_id = $receiver->getID();
     $user_id = $handle->getAlternateID();
     $hash = PhabricatorMetaMTAReceivedMail::computeMailHash($receiver->getMailKey(), $handle->getPHID());
     $domain = $this->getReplyHandlerDomain();
     $address = "{$prefix}{$receiver_id}+{$user_id}+{$hash}@{$domain}";
     return $this->getSingleReplyHandlerPrefix($address);
 }
コード例 #6
0
 protected function getDefaultPrivateReplyHandlerEmailAddress(PhabricatorObjectHandle $handle, $prefix)
 {
     if ($handle->getType() != PhabricatorPeopleUserPHIDType::TYPECONST) {
         // You must be a real user to get a private reply handler address.
         return null;
     }
     $user = id(new PhabricatorPeopleQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs(array($handle->getPHID()))->executeOne();
     if (!$user) {
         // This may happen if a user was subscribed to something, and was then
         // deleted.
         return null;
     }
     $receiver = $this->getMailReceiver();
     $receiver_id = $receiver->getID();
     $user_id = $user->getID();
     $hash = PhabricatorObjectMailReceiver::computeMailHash($receiver->getMailKey(), $handle->getPHID());
     $domain = $this->getReplyHandlerDomain();
     $address = "{$prefix}{$receiver_id}+{$user_id}+{$hash}@{$domain}";
     return $this->getSingleReplyHandlerPrefix($address);
 }
コード例 #7
0
 private function buildCommitView(PhabricatorObjectHandle $handle = null)
 {
     $request = $this->getRequest();
     $query = new PhabricatorAuditCommitQuery();
     $query->needCommitData(true);
     $use_pager = $this->filter != 'active';
     if ($use_pager) {
         $pager = new AphrontPagerView();
         $pager->setURI($request->getRequestURI(), 'offset');
         $pager->setOffset($request->getInt('offset'));
         $query->setOffset($pager->getOffset());
         $query->setLimit($pager->getPageSize() + 1);
     }
     switch ($this->filter) {
         case 'active':
         case 'author':
             $query->withAuthorPHIDs(array($handle->getPHID()));
             break;
         case 'packagecommits':
             $query->withPackagePHIDs(array($handle->getPHID()));
             break;
     }
     switch ($this->filter) {
         case 'active':
             $query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
             break;
         case 'author':
         case 'packagecommits':
             switch ($this->filterStatus) {
                 case 'open':
                     $query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
                     break;
             }
             break;
     }
     if ($handle) {
         $handle_name = phutil_escape_html($handle->getName());
     } else {
         $handle_name = null;
     }
     switch ($this->filter) {
         case 'active':
             $header = 'Problem Commits';
             $nodata = 'None of your commits have open concerns.';
             break;
         case 'author':
             $header = "Commits by {$handle_name}";
             $nodata = "No matching commits by {$handle_name}.";
             break;
         case 'commits':
             $header = "Commits";
             $nodata = "No matching commits.";
             break;
         case 'packagecommits':
             $header = "Commits in Package '{$handle_name}'";
             $nodata = "No matching commits in package '{$handle_name}'.";
             break;
     }
     $commits = $query->execute();
     if ($use_pager) {
         $commits = $pager->sliceResults($commits);
     }
     $view = new PhabricatorAuditCommitListView();
     $view->setUser($request->getUser());
     $view->setCommits($commits);
     $view->setNoDataString($nodata);
     $phids = $view->getRequiredHandlePHIDs();
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $view->setHandles($handles);
     $panel = new AphrontPanelView();
     $panel->setHeader($header);
     $panel->appendChild($view);
     if ($use_pager) {
         $panel->appendChild($pager);
     }
     return $panel;
 }
コード例 #8
0
 public function addButton(PhabricatorObjectHandle $handle, $button)
 {
     $this->buttons[$handle->getPHID()][] = $button;
     return $this;
 }
コード例 #9
0
 protected function buildHandleInformationDictionary(PhabricatorObjectHandle $handle)
 {
     return array('phid' => $handle->getPHID(), 'uri' => PhabricatorEnv::getProductionURI($handle->getURI()), 'typeName' => $handle->getTypeName(), 'type' => $handle->getType(), 'name' => $handle->getName(), 'fullName' => $handle->getFullName(), 'status' => $handle->getStatus());
 }