Ejemplo n.º 1
0
 protected function buildUserInformationDictionary(PhabricatorUser $user, PhabricatorUserStatus $current_status = null)
 {
     $roles = array();
     if ($user->getIsDisabled()) {
         $roles[] = 'disabled';
     }
     if ($user->getIsSystemAgent()) {
         $roles[] = 'agent';
     }
     if ($user->getIsAdmin()) {
         $roles[] = 'admin';
     }
     $primary = $user->loadPrimaryEmail();
     if ($primary && $primary->getIsVerified()) {
         $roles[] = 'verified';
     } else {
         $roles[] = 'unverified';
     }
     $return = array('phid' => $user->getPHID(), 'userName' => $user->getUserName(), 'realName' => $user->getRealName(), 'image' => $user->loadProfileImageURI(), 'uri' => PhabricatorEnv::getURI('/p/' . $user->getUsername() . '/'), 'roles' => $roles);
     if ($current_status) {
         $return['currentStatus'] = $current_status->getTextStatus();
         $return['currentStatusUntil'] = $current_status->getDateTo();
     }
     return $return;
 }
 protected function execute(ConduitAPIRequest $request)
 {
     $diff = null;
     $revision_id = $request->getValue('revision_id');
     $revision = id(new DifferentialRevision())->load($revision_id);
     if (!$revision) {
         throw new ConduitException('ERR_BAD_REVISION');
     }
     $revision->loadRelationships();
     $reviewer_phids = array_values($revision->getReviewers());
     $diffs = $revision->loadDiffs();
     $diff_dicts = array();
     foreach ($diffs as $diff) {
         $diff->attachChangesets($diff->loadChangesets());
         // TODO: We could batch this to improve performance.
         foreach ($diff->getChangesets() as $changeset) {
             $changeset->attachHunks($changeset->loadHunks());
         }
         $diff_dicts[] = $diff->getDiffDict();
     }
     $commit_dicts = array();
     $commit_phids = $revision->loadCommitPHIDs();
     $handles = id(new PhabricatorObjectHandleData($commit_phids))->loadHandles();
     foreach ($commit_phids as $commit_phid) {
         $commit_dicts[] = array('fullname' => $handles[$commit_phid]->getFullName(), 'dateCommitted' => $handles[$commit_phid]->getTimestamp());
     }
     $auxiliary_fields = $this->loadAuxiliaryFields($revision);
     $dict = array('id' => $revision->getID(), 'phid' => $revision->getPHID(), 'authorPHID' => $revision->getAuthorPHID(), 'uri' => PhabricatorEnv::getURI('/D' . $revision->getID()), 'title' => $revision->getTitle(), 'status' => $revision->getStatus(), 'statusName' => ArcanistDifferentialRevisionStatus::getNameForRevisionStatus($revision->getStatus()), 'summary' => $revision->getSummary(), 'testPlan' => $revision->getTestPlan(), 'lineCount' => $revision->getLineCount(), 'reviewerPHIDs' => $reviewer_phids, 'diffs' => $diff_dicts, 'commits' => $commit_dicts, 'auxiliary' => $auxiliary_fields);
     return $dict;
 }
 protected function execute(ConduitAPIRequest $request)
 {
     $viewer = $request->getUser();
     $revision = id(new DifferentialRevisionQuery())->setViewer($viewer)->withIDs(array($request->getValue('revision_id')))->needReviewerStatus(true)->needReviewerAuthority(true)->executeOne();
     if (!$revision) {
         throw new ConduitException('ERR_BAD_REVISION');
     }
     $xactions = array();
     $action = $request->getValue('action');
     if ($action && $action != 'comment' && $action != 'none') {
         $xactions[] = id(new DifferentialTransaction())->setTransactionType(DifferentialTransaction::TYPE_ACTION)->setNewValue($action);
     }
     $content = $request->getValue('message');
     if (strlen($content)) {
         $xactions[] = id(new DifferentialTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new DifferentialTransactionComment())->setContent($content));
     }
     if ($request->getValue('attach_inlines')) {
         $type_inline = DifferentialTransaction::TYPE_INLINE;
         $inlines = DifferentialTransactionQuery::loadUnsubmittedInlineComments($viewer, $revision);
         foreach ($inlines as $inline) {
             $xactions[] = id(new DifferentialTransaction())->setTransactionType($type_inline)->attachComment($inline);
         }
     }
     $editor = id(new DifferentialTransactionEditor())->setActor($viewer)->setDisableEmail($request->getValue('silent'))->setContentSource($request->newContentSource())->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
     $editor->applyTransactions($revision, $xactions);
     return array('revisionid' => $revision->getID(), 'uri' => PhabricatorEnv::getURI('/D' . $revision->getID()));
 }
 protected function execute(ConduitAPIRequest $request)
 {
     $diff = id(new DifferentialDiff())->load($request->getValue('diffid'));
     if (!$diff) {
         throw new ConduitException('ERR_BAD_DIFF');
     }
     $revision = id(new DifferentialRevision())->load($request->getValue('id'));
     if (!$revision) {
         throw new ConduitException('ERR_BAD_REVISION');
     }
     if ($request->getUser()->getPHID() !== $revision->getAuthorPHID()) {
         throw new ConduitException('ERR_WRONG_USER');
     }
     if ($revision->getStatus() == ArcanistDifferentialRevisionStatus::CLOSED) {
         throw new ConduitException('ERR_CLOSED');
     }
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_CONDUIT, array());
     $editor = new DifferentialRevisionEditor($revision, $revision->getAuthorPHID());
     $editor->setContentSource($content_source);
     $fields = $request->getValue('fields');
     $editor->copyFieldsFromConduit($fields);
     $editor->addDiff($diff, $request->getValue('message'));
     $editor->save();
     return array('revisionid' => $revision->getID(), 'uri' => PhabricatorEnv::getURI('/D' . $revision->getID()));
 }
 public function renderText()
 {
     $author = null;
     if ($this->getAuthorPHID()) {
         $author = $this->getHandle($this->getAuthorPHID())->getLinkName();
     } else {
         $author = $this->getValue('authorName');
     }
     $committer = null;
     if ($this->getValue('committerPHID')) {
         $committer_handle = $this->getHandle($this->getValue('committerPHID'));
         $committer = $committer_handle->getLinkName();
     } else {
         if ($this->getValue('committerName')) {
             $committer = $this->getValue('committerName');
         }
     }
     $commit_handle = $this->getHandle($this->getPrimaryObjectPHID());
     $commit_uri = PhabricatorEnv::getURI($commit_handle->getURI());
     $commit_name = $commit_handle->getLinkName();
     if (!$committer) {
         $committer = $author;
         $author = null;
     }
     if ($author) {
         $text = pht('%s committed %s (authored by %s).', $committer, $commit_name, $author);
     } else {
         $text = pht('%s committed %s.', $committer, $commit_name);
     }
     return $text;
 }
 protected function getProviderConfigurationHelp()
 {
     $config = $this->getProviderConfig();
     $base_uri = rtrim($config->getProperty(self::PROPERTY_PHABRICATOR_URI), '/');
     $login_uri = PhabricatorEnv::getURI($this->getLoginURI());
     return pht("**Step 2 of 2 - Configure Phabricator OAuth Instance**\n\n" . "To configure Phabricator OAuth, create a new application here:" . "\n\n" . "%s/oauthserver/client/create/" . "\n\n" . "When creating your application, use these settings:" . "\n\n" . "  - **Redirect URI:** Set this to: `%s`" . "\n\n" . "After completing configuration, copy the **Client ID** and " . "**Client Secret** to the fields above. (You may need to generate the " . "client secret by clicking 'New Secret' first.)", $base_uri, $login_uri);
 }
 public function renderText()
 {
     $author_handle = $this->getHandle($this->getPrimaryObjectPHID());
     $author_name = $author_handle->getLinkName();
     $author_uri = PhabricatorEnv::getURI($author_handle->getURI());
     $text = pht('% updated their status %s', $author_name, $author_uri);
     return $text;
 }
 protected function getObjectHref($object, PhabricatorObjectHandle $handle, $id)
 {
     $uri = $handle->getURI();
     if ($this->getEngine()->getConfig('uri.full')) {
         $uri = PhabricatorEnv::getURI($uri);
     }
     return $uri;
 }
 protected function configureAdapter(PhutilOAuthAuthAdapter $adapter)
 {
     $config = $this->getProviderConfig();
     $adapter->setClientID($config->getProperty(self::PROPERTY_APP_ID));
     $adapter->setClientSecret(new PhutilOpaqueEnvelope($config->getProperty(self::PROPERTY_APP_SECRET)));
     $adapter->setRedirectURI(PhabricatorEnv::getURI($this->getLoginURI()));
     return $adapter;
 }
 protected function getProviderConfigurationHelp()
 {
     if ($this->isSetup()) {
         return pht("**Step 1 of 2**: Provide the name and URI for your JIRA install.\n\n" . "In the next step, you will configure JIRA.");
     } else {
         $login_uri = PhabricatorEnv::getURI($this->getLoginURI());
         return pht("**Step 2 of 2**: In this step, you will configure JIRA.\n\n" . "**Create a JIRA Application**: Log into JIRA and go to " . "**Administration**, then **Add-ons**, then **Application Links**. " . "Click the button labeled **Add Application Link**, and use these " . "settings to create an application:\n\n" . "  - **Server URL**: `%s`\n" . "  - Then, click **Next**. On the second page:\n" . "  - **Application Name**: `Phabricator`\n" . "  - **Application Type**: `Generic Application`\n" . "  - Then, click **Create**.\n\n" . "**Configure Your Application**: Find the application you just " . "created in the table, and click the **Configure** link under " . "**Actions**. Select **Incoming Authentication** and click the " . "**OAuth** tab (it may be selected by default). Then, use these " . "settings:\n\n" . "  - **Consumer Key**: Set this to the \"Consumer Key\" value in the " . "form above.\n" . "  - **Consumer Name**: `Phabricator`\n" . "  - **Public Key**: Set this to the \"Public Key\" value in the " . "form above.\n" . "  - **Consumer Callback URL**: `%s`\n" . "Click **Save** in JIRA. Authentication should now be configured, " . "and this provider should work correctly.", PhabricatorEnv::getProductionURI('/'), $login_uri);
     }
 }
 public function renderText()
 {
     $author_name = $this->getHandle($this->getAuthorPHID())->getLinkName();
     $commit_path = $this->getHandle($this->getPrimaryObjectPHID())->getURI();
     $commit_uri = PhabricatorEnv::getURI($commit_path);
     $action = $this->getValue('action');
     $verb = PhabricatorAuditActionConstants::getActionPastTenseVerb($action);
     $text = "{$author_name} {$verb} commit {$commit_uri}";
     return $text;
 }
 protected function execute(ConduitAPIRequest $request)
 {
     $fields = $request->getValue('fields');
     $diff = id(new DifferentialDiff())->load($request->getValue('diffid'));
     if (!$diff) {
         throw new ConduitException('ERR_BAD_DIFF');
     }
     $revision = DifferentialRevisionEditor::newRevisionFromConduitWithDiff($fields, $diff, $request->getUser()->getPHID());
     return array('revisionid' => $revision->getID(), 'uri' => PhabricatorEnv::getURI('/D' . $revision->getID()));
 }
 protected function getProviderConfigurationHelp()
 {
     $login_uri = PhabricatorEnv::getURI($this->getLoginURI());
     $uri = new PhutilURI(PhabricatorEnv::getProductionURI('/'));
     $https_note = null;
     if ($uri->getProtocol() !== 'https') {
         $https_note = pht('NOTE: Amazon **requires** HTTPS, but your Phabricator install does ' . 'not use HTTPS. **You will not be able to add Amazon as an ' . 'authentication provider until you configure HTTPS on this install**.');
     }
     return pht("%s\n\n" . "To configure Amazon OAuth, create a new 'API Project' here:" . "\n\n" . "http://login.amazon.com/manageApps" . "\n\n" . "Use these settings:" . "\n\n" . "  - **Allowed Return URLs:** Add this: `%s`" . "\n\n" . "After completing configuration, copy the **Client ID** and " . "**Client Secret** to the fields above.", $https_note, $login_uri);
 }
 protected function getProviderConfigurationHelp()
 {
     $login_uri = PhabricatorEnv::getURI($this->getLoginURI());
     if ($this->isSetup()) {
         return pht("**Step 1 of 2**: Provide the name and URI for your MediaWiki install.\n\n" . "In the next step, you will create an auth consumer in MediaWiki to be used by Phabricator oauth.");
     } else {
         $wiki_uri = $this->getWikiURI();
         return pht("**Step 2 of 2**: Create a MediaWiki auth consumer for this Phabricator instance." . "\n\n" . "NOTE: Propose a consumer with the form at this url: %s" . "\n\n" . "Provide the following settings on the consumer registration:\n\n" . "  - **Callback URL:** Set this to: `%s`\n" . "  - **Grants:** `Basic Rights` is all that is needed for authentication.\n" . "\n\n" . "After you register the consumer, a **Consumer Key** and " . "**Consumer Secret** will be provided to you by MediaWiki. " . "To complete configuration of phabricator, copy the provided keys into " . "the corresponding fields above." . "\n\n" . "NOTE: Before Phabricator can successfully authenticate to your MediaWiki," . " a wiki admin must approve the oauth consumer registration using the form" . " which can be found at the following url: %s", $wiki_uri . '/index.php?title=Special:OAuthConsumerRegistration/propose', $login_uri, $wiki_uri . '/index.php?title=Special:OAuthManageConsumers/proposed');
     }
 }
Ejemplo n.º 15
0
 protected function buildUserInformationDictionary(PhabricatorUser $user)
 {
     $src_phid = $user->getProfileImagePHID();
     $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid);
     if ($file) {
         $picture = $file->getBestURI();
     } else {
         $picture = null;
     }
     return array('phid' => $user->getPHID(), 'userName' => $user->getUserName(), 'realName' => $user->getRealName(), 'email' => $user->getEmail(), 'image' => $picture, 'uri' => PhabricatorEnv::getURI('/p/' . $user->getUsername() . '/'));
 }
 protected function configureAdapter(PhutilOAuth1AuthAdapter $adapter)
 {
     $config = $this->getProviderConfig();
     $adapter->setConsumerKey($config->getProperty(self::PROPERTY_CONSUMER_KEY));
     $secret = $config->getProperty(self::PROPERTY_CONSUMER_SECRET);
     if (strlen($secret)) {
         $adapter->setConsumerSecret(new PhutilOpaqueEnvelope($secret));
     }
     $adapter->setCallbackURI(PhabricatorEnv::getURI($this->getLoginURI()));
     return $adapter;
 }
 protected function execute(ConduitAPIRequest $request)
 {
     $viewer = $request->getUser();
     $diff = id(new DifferentialDiffQuery())->setViewer($viewer)->withIDs(array($request->getValue('diffid')))->executeOne();
     if (!$diff) {
         throw new ConduitException('ERR_BAD_DIFF');
     }
     $revision = DifferentialRevision::initializeNewRevision($viewer);
     $revision->attachReviewerStatus(array());
     $this->applyFieldEdit($request, $revision, $diff, $request->getValue('fields', array()), $message = null);
     return array('revisionid' => $revision->getID(), 'uri' => PhabricatorEnv::getURI('/D' . $revision->getID()));
 }
 public function renderText()
 {
     $author_handle = $this->getHandle($this->getAuthorPHID());
     $author_name = $author_handle->getName();
     $document_handle = $this->getHandle($this->getPrimaryObjectPHID());
     $document_title = $document_handle->getLinkName();
     $document_uri = PhabricatorEnv::getURI($document_handle->getURI());
     $action = $this->getValue('action');
     $verb = PhrictionActionConstants::getActionPastTenseVerb($action);
     $text = "{$author_name} {$verb} the document" . " {$document_title} {$document_uri}";
     return $text;
 }
Ejemplo n.º 19
0
 protected function getObjectHref($object, PhabricatorObjectHandle $handle, $id)
 {
     $href = $handle->getURI();
     // If the ID has a `M123/456` component, link to that specific image.
     $id = explode('/', $id);
     if (isset($id[1])) {
         $href = $href . '/' . $id[1] . '/';
     }
     if ($this->getEngine()->getConfig('uri.full')) {
         $href = PhabricatorEnv::getURI($href);
     }
     return $href;
 }
 protected function execute(ConduitAPIRequest $request)
 {
     $revision = id(new DifferentialRevision())->load($request->getValue('revision_id'));
     if (!$revision) {
         throw new ConduitException('ERR_BAD_REVISION');
     }
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_CONDUIT, array());
     $editor = new DifferentialCommentEditor($revision, $request->getUser()->getPHID(), DifferentialAction::ACTION_COMMENT);
     $editor->setContentSource($content_source);
     $editor->setMessage($request->getValue('message'));
     $editor->save();
     return array('revisionid' => $revision->getID(), 'uri' => PhabricatorEnv::getURI('/D' . $revision->getID()));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $diff = id(new DifferentialDiff())->load($this->id);
     if (!$diff) {
         return new Aphront404Response();
     }
     if ($diff->getRevisionID()) {
         $top_panel = new AphrontPanelView();
         $top_panel->setWidth(AphrontPanelView::WIDTH_WIDE);
         $link = phutil_render_tag('a', array('href' => PhabricatorEnv::getURI('/D' . $diff->getRevisionID())), phutil_escape_html('D' . $diff->getRevisionID()));
         $top_panel->appendChild("<h1>This diff belongs to revision {$link}</h1>");
     } else {
         $action_panel = new AphrontPanelView();
         $action_panel->setHeader('Preview Diff');
         $action_panel->setWidth(AphrontPanelView::WIDTH_WIDE);
         $action_panel->appendChild('<p class="aphront-panel-instructions">Review the diff for ' . 'correctness. When you are satisfied, either <strong>create a new ' . 'revision</strong> or <strong>update an existing revision</strong>.');
         // TODO: implmenent optgroup support in AphrontFormSelectControl?
         $select = array();
         $select[] = '<optgroup label="Create New Revision">';
         $select[] = '<option value="">Create a new Revision...</option>';
         $select[] = '</optgroup>';
         $revision_data = new DifferentialRevisionListData(DifferentialRevisionListData::QUERY_OPEN_OWNED, array($request->getUser()->getPHID()));
         $revisions = $revision_data->loadRevisions();
         if ($revisions) {
             $select[] = '<optgroup label="Update Existing Revision">';
             foreach ($revisions as $revision) {
                 $select[] = phutil_render_tag('option', array('value' => $revision->getID()), phutil_escape_html($revision->getTitle()));
             }
             $select[] = '</optgroup>';
         }
         $select = '<select name="revisionID">' . implode("\n", $select) . '</select>';
         $action_form = new AphrontFormView();
         $action_form->setUser($request->getUser())->setAction('/differential/revision/edit/')->addHiddenInput('diffID', $diff->getID())->addHiddenInput('viaDiffView', 1)->appendChild(id(new AphrontFormMarkupControl())->setLabel('Attach To')->setValue($select))->appendChild(id(new AphrontFormSubmitControl())->setValue('Continue'));
         $action_panel->appendChild($action_form);
         $top_panel = $action_panel;
     }
     $changesets = $diff->loadChangesets();
     $changesets = msort($changesets, 'getSortKey');
     $table_of_contents = id(new DifferentialDiffTableOfContentsView())->setChangesets($changesets);
     $refs = array();
     foreach ($changesets as $changeset) {
         $refs[$changeset->getID()] = $changeset->getID();
     }
     $details = id(new DifferentialChangesetListView())->setChangesets($changesets)->setRenderingReferences($refs);
     return $this->buildStandardPageResponse(id(new DifferentialPrimaryPaneView())->setLineWidthFromChangesets($changesets)->appendChild(array($top_panel->render(), $table_of_contents->render(), $details->render())), array('title' => 'Diff View'));
 }
 protected function execute(ConduitAPIRequest $request)
 {
     $viewer = $request->getUser();
     $diff = id(new DifferentialDiffQuery())->setViewer($viewer)->withIDs(array($request->getValue('diffid')))->executeOne();
     if (!$diff) {
         throw new ConduitException('ERR_BAD_DIFF');
     }
     $revision = id(new DifferentialRevisionQuery())->setViewer($request->getUser())->withIDs(array($request->getValue('id')))->needReviewerStatus(true)->needActiveDiffs(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$revision) {
         throw new ConduitException('ERR_BAD_REVISION');
     }
     if ($revision->getStatus() == ArcanistDifferentialRevisionStatus::CLOSED) {
         throw new ConduitException('ERR_CLOSED');
     }
     $this->applyFieldEdit($request, $revision, $diff, $request->getValue('fields', array()), $request->getValue('message'));
     return array('revisionid' => $revision->getID(), 'uri' => PhabricatorEnv::getURI('/D' . $revision->getID()));
 }
Ejemplo n.º 23
0
 protected function buildUserInformationDictionary(PhabricatorUser $user, $with_email = false, $with_availability = false)
 {
     $roles = array();
     if ($user->getIsDisabled()) {
         $roles[] = 'disabled';
     }
     if ($user->getIsSystemAgent()) {
         $roles[] = 'agent';
     }
     if ($user->getIsMailingList()) {
         $roles[] = 'list';
     }
     if ($user->getIsAdmin()) {
         $roles[] = 'admin';
     }
     $primary = $user->loadPrimaryEmail();
     if ($primary && $primary->getIsVerified()) {
         $email = $primary->getAddress();
         $roles[] = 'verified';
     } else {
         $email = null;
         $roles[] = 'unverified';
     }
     if ($user->getIsApproved()) {
         $roles[] = 'approved';
     }
     if ($user->isUserActivated()) {
         $roles[] = 'activated';
     }
     $return = array('phid' => $user->getPHID(), 'userName' => $user->getUserName(), 'realName' => $user->getRealName(), 'image' => $user->getProfileImageURI(), 'uri' => PhabricatorEnv::getURI('/p/' . $user->getUsername() . '/'), 'roles' => $roles);
     if ($with_email) {
         $return['primaryEmail'] = $email;
     }
     if ($with_availability) {
         // TODO: Modernize this once we have a more long-term view of what the
         // data looks like.
         $until = $user->getAwayUntil();
         if ($until) {
             $return['currentStatus'] = 'away';
             $return['currentStatusUntil'] = $until;
         }
     }
     return $return;
 }
 protected function execute(ConduitAPIRequest $request)
 {
     $diff = id(new DifferentialDiff())->load($request->getValue('diffid'));
     if (!$diff) {
         throw new ConduitException('ERR_BAD_DIFF');
     }
     $revision = id(new DifferentialRevision())->load($request->getValue('id'));
     if ($request->getUser()->getPHID() !== $revision->getAuthorPHID()) {
         throw new ConduitException('ERR_WRONG_USER');
     }
     if ($revision->getStatus() == DifferentialRevisionStatus::COMMITTED) {
         throw new ConduitException('ERR_COMMITTED');
     }
     $editor = new DifferentialRevisionEditor($revision, $revision->getAuthorPHID());
     $fields = $request->getValue('fields');
     $editor->copyFieldsFromConduit($fields);
     $editor->addDiff($diff, $request->getValue('message'));
     $editor->save();
     return array('revisionid' => $revision->getID(), 'uri' => PhabricatorEnv::getURI('/D' . $revision->getID()));
 }
Ejemplo n.º 25
0
 protected function validateHost($host)
 {
     if (!$host) {
         // If the client doesn't send a host key, don't complain. We should in
         // the future, but this change isn't severe enough to bump the protocol
         // version.
         // TODO: Remove this once the protocol version gets bumped past 2 (i.e.,
         // require the host key be present and valid).
         return;
     }
     // NOTE: Compare domains only so we aren't sensitive to port specification
     // or omission.
     $host = new PhutilURI($host);
     $host = $host->getDomain();
     $self = new PhutilURI(PhabricatorEnv::getURI('/'));
     $self = $self->getDomain();
     if ($self !== $host) {
         throw new Exception("Your client is connecting to this install as '{$host}', but it is " . "configured as '{$self}'. The client and server must use the exact " . "same URI to identify the install. Edit your .arcconfig or " . "phabricator/conf so they agree on the URI for the install.");
     }
 }
 protected function execute(ConduitAPIRequest $request)
 {
     $diff = null;
     $revision_id = $request->getValue('revision_id');
     $revision = id(new DifferentialRevisionQuery())->withIDs(array($revision_id))->setViewer($request->getUser())->needRelationships(true)->needReviewerStatus(true)->executeOne();
     if (!$revision) {
         throw new ConduitException('ERR_BAD_REVISION');
     }
     $reviewer_phids = array_values($revision->getReviewers());
     $diffs = id(new DifferentialDiffQuery())->setViewer($request->getUser())->withRevisionIDs(array($revision_id))->needChangesets(true)->needArcanistProjects(true)->execute();
     $diff_dicts = mpull($diffs, 'getDiffDict');
     $commit_dicts = array();
     $commit_phids = $revision->loadCommitPHIDs();
     $handles = id(new PhabricatorHandleQuery())->setViewer($request->getUser())->withPHIDs($commit_phids)->execute();
     foreach ($commit_phids as $commit_phid) {
         $commit_dicts[] = array('fullname' => $handles[$commit_phid]->getFullName(), 'dateCommitted' => $handles[$commit_phid]->getTimestamp());
     }
     $field_data = $this->loadCustomFieldsForRevisions($request->getUser(), array($revision));
     $dict = array('id' => $revision->getID(), 'phid' => $revision->getPHID(), 'authorPHID' => $revision->getAuthorPHID(), 'uri' => PhabricatorEnv::getURI('/D' . $revision->getID()), 'title' => $revision->getTitle(), 'status' => $revision->getStatus(), 'statusName' => ArcanistDifferentialRevisionStatus::getNameForRevisionStatus($revision->getStatus()), 'summary' => $revision->getSummary(), 'testPlan' => $revision->getTestPlan(), 'lineCount' => $revision->getLineCount(), 'reviewerPHIDs' => $reviewer_phids, 'diffs' => $diff_dicts, 'commits' => $commit_dicts, 'auxiliary' => idx($field_data, $revision->getPHID(), array()));
     return $dict;
 }
 protected function executeChecks()
 {
     $methods = id(new PhabricatorConduitMethodQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIsDeprecated(true)->execute();
     if (!$methods) {
         return;
     }
     $methods = mpull($methods, null, 'getAPIMethodName');
     $method_names = mpull($methods, 'getAPIMethodName');
     $table = new PhabricatorConduitMethodCallLog();
     $conn_r = $table->establishConnection('r');
     $calls = queryfx_all($conn_r, 'SELECT DISTINCT method FROM %T WHERE dateCreated > %d
     AND method IN (%Ls)', $table->getTableName(), time() - 60 * 60 * 24 * 30, $method_names);
     $calls = ipull($calls, 'method', 'method');
     foreach ($calls as $method_name) {
         $method = $methods[$method_name];
         $summary = pht('Deprecated Conduit method `%s` was called in the last 30 days. ' . 'You should migrate away from use of this method: it will be ' . 'removed in a future version of Phabricator.', $method_name);
         $uri = PhabricatorEnv::getURI('/conduit/log/?methods=' . $method_name);
         $description = $method->getMethodStatusDescription();
         $message = pht('Deprecated Conduit method %s was called in the last 30 days. ' . 'You should migrate away from use of this method: it will be ' . 'removed in a future version of Phabricator.' . "\n\n" . "%s: %s" . "\n\n" . 'If you have already migrated all callers away from this method, ' . 'you can safely ignore this setup issue.', phutil_tag('tt', array(), $method_name), phutil_tag('tt', array(), $method_name), $description);
         $this->newIssue('conduit.deprecated.' . $method_name)->setShortName(pht('Deprecated Conduit Method'))->setName(pht('Deprecated Conduit Method "%s" In Use', $method_name))->setSummary($summary)->setMessage($message)->addLink($uri, pht('View Method Call Logs'));
     }
 }
 public function processLoginRequest(PhabricatorAuthLoginController $controller)
 {
     $request = $controller->getRequest();
     $adapter = $this->getAdapter();
     $account = null;
     $response = null;
     if (!$request->isAjax()) {
         throw new Exception(pht('Expected this request to come via Ajax.'));
     }
     $assertion = $request->getStr('assertion');
     if (!$assertion) {
         throw new Exception(pht('Expected identity assertion.'));
     }
     $adapter->setAssertion($assertion);
     $adapter->setAudience(PhabricatorEnv::getURI('/'));
     try {
         $account_id = $adapter->getAccountID();
     } catch (Exception $ex) {
         // TODO: Handle this in a more user-friendly way.
         throw $ex;
     }
     return array($this->loadOrCreateAccount($account_id), $response);
 }
 private function buildPropertySection(PhabricatorCalendarExport $export)
 {
     $viewer = $this->getViewer();
     $properties = id(new PHUIPropertyListView())->setUser($viewer);
     $mode = $export->getPolicyMode();
     $policy_icon = PhabricatorCalendarExport::getPolicyModeIcon($mode);
     $policy_name = PhabricatorCalendarExport::getPolicyModeName($mode);
     $policy_desc = PhabricatorCalendarExport::getPolicyModeDescription($mode);
     $policy_color = PhabricatorCalendarExport::getPolicyModeColor($mode);
     $policy_view = id(new PHUIStatusListView())->addItem(id(new PHUIStatusItemView())->setIcon($policy_icon, $policy_color)->setTarget($policy_name)->setNote($policy_desc));
     $properties->addProperty(pht('Mode'), $policy_view);
     $query_key = $export->getQueryKey();
     $query_link = phutil_tag('a', array('href' => $this->getApplicationURI("/query/{$query_key}/")), $query_key);
     $properties->addProperty(pht('Query'), $query_link);
     $ics_uri = $export->getICSURI();
     $ics_uri = PhabricatorEnv::getURI($ics_uri);
     if ($export->getIsDisabled()) {
         $ics_href = phutil_tag('em', array(), $ics_uri);
     } else {
         $ics_href = phutil_tag('a', array('href' => $ics_uri), $ics_uri);
     }
     $properties->addProperty(pht('ICS URI'), $ics_href);
     return $properties;
 }
 public final function getControllerURI($action, array $params = array(), $local = false)
 {
     $id = $this->getProviderConfig()->getID();
     $app = PhabricatorApplication::getByClass('PhabricatorPhortuneApplication');
     $path = $app->getBaseURI() . 'provider/' . $id . '/' . $action . '/';
     $uri = new PhutilURI($path);
     $uri->setQueryParams($params);
     if ($local) {
         return $uri;
     } else {
         return PhabricatorEnv::getURI((string) $uri);
     }
 }