protected function execute(ConduitAPIRequest $conduit_request) { $revision_phids = $conduit_request->getValue('revisionPHIDs'); $requested_commit_phids = $conduit_request->getValue('requestedCommitPHIDs'); $result = array(); if (!$revision_phids && !$requested_commit_phids) { return $result; } $query = new ReleephRequestQuery(); $query->setViewer($conduit_request->getUser()); if ($revision_phids) { $query->withRequestedObjectPHIDs($revision_phids); } else { if ($requested_commit_phids) { $query->withRequestedCommitPHIDs($requested_commit_phids); } } $releeph_requests = $query->execute(); foreach ($releeph_requests as $releeph_request) { $branch = $releeph_request->getBranch(); $request_commit_phid = $releeph_request->getRequestCommitPHID(); $object = $releeph_request->getRequestedObject(); if ($object instanceof DifferentialRevision) { $object_phid = $object->getPHID(); } else { $object_phid = null; } $status = $releeph_request->getStatus(); $status_name = ReleephRequestStatus::getStatusDescriptionFor($status); $url = PhabricatorEnv::getProductionURI('/RQ' . $releeph_request->getID()); $result[] = array('branchBasename' => $branch->getBasename(), 'branchSymbolic' => $branch->getSymbolicName(), 'requestID' => $releeph_request->getID(), 'revisionPHID' => $object_phid, 'status' => $status, 'status_name' => $status_name, 'url' => $url); } return $result; }
public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $append = $request->getURIData('append'); $main_domain_uri = PhabricatorEnv::getProductionURI('/u/' . $append); return id(new AphrontRedirectResponse())->setIsExternal(true)->setURI($main_domain_uri); }
private function buildPropertyView(PhameBlog $blog) { $viewer = $this->getViewer(); require_celerity_resource('aphront-tooltip-css'); Javelin::initBehavior('phabricator-tooltips'); $properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($blog); $domain = $blog->getDomain(); if (!$domain) { $domain = phutil_tag('em', array(), pht('No external domain')); } $properties->addProperty(pht('Domain'), $domain); $feed_uri = PhabricatorEnv::getProductionURI($this->getApplicationURI('blog/feed/' . $blog->getID() . '/')); $properties->addProperty(pht('Atom URI'), javelin_tag('a', array('href' => $feed_uri, 'sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Atom URI does not support custom domains.'), 'size' => 320)), $feed_uri)); $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $blog); $properties->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]); $engine = id(new PhabricatorMarkupEngine())->setViewer($viewer)->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)->process(); $properties->invokeWillRenderEvent(); $description = $blog->getDescription(); if (strlen($description)) { $description = new PHUIRemarkupView($viewer, $description); $properties->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY); $properties->addTextContent($description); } return $properties; }
protected function buildMailBody(PhabricatorLiskDAO $object, array $xactions) { $body = parent::buildMailBody($object, $xactions); $detail_uri = PhabricatorEnv::getProductionURI($object->getURI()); $body->addLinkSection(pht('PACKAGE DETAIL'), $detail_uri); return $body; }
public function execute(PhutilArgumentParser $args) { $viewer = $this->getViewer(); $names = $args->getArg('buildable'); if (count($names) != 1) { throw new PhutilArgumentUsageException(pht('Specify exactly one buildable object, by object name.')); } $name = head($names); $buildable = id(new PhabricatorObjectQuery())->setViewer($viewer)->withNames($names)->executeOne(); if (!$buildable) { throw new PhutilArgumentUsageException(pht('No such buildable "%s"!', $name)); } if (!$buildable instanceof HarbormasterBuildableInterface) { throw new PhutilArgumentUsageException(pht('Object "%s" is not a buildable!', $name)); } $plan_id = $args->getArg('plan'); if (!$plan_id) { throw new PhutilArgumentUsageException(pht('Use --plan to specify a build plan to run.')); } $plan = id(new HarbormasterBuildPlanQuery())->setViewer($viewer)->withIDs(array($plan_id))->executeOne(); if (!$plan) { throw new PhutilArgumentUsageException(pht('Build plan "%s" does not exist.', $plan_id)); } $console = PhutilConsole::getConsole(); $buildable = HarbormasterBuildable::initializeNewBuildable($viewer)->setIsManualBuildable(true)->setBuildablePHID($buildable->getHarbormasterBuildablePHID())->setContainerPHID($buildable->getHarbormasterContainerPHID())->save(); $console->writeOut("%s\n", pht('Applying plan %s to new buildable %s...', $plan->getID(), 'B' . $buildable->getID())); $console->writeOut("\n %s\n\n", PhabricatorEnv::getProductionURI('/B' . $buildable->getID())); PhabricatorWorker::setRunAllTasksInProcess(true); $buildable->applyPlan($plan); $console->writeOut("%s\n", pht('Done.')); return 0; }
/** * Makes sure a given custom blog uri is properly configured in DNS * to point at this Phabricator instance. If there is an error in * the configuration, return a string describing the error and how * to fix it. If there is no error, return an empty string. * * @return string */ public function validateCustomDomain($custom_domain) { $example_domain = 'blog.example.com'; $label = pht('Invalid'); // note this "uri" should be pretty busted given the desired input // so just use it to test if there's a protocol specified $uri = new PhutilURI($custom_domain); if ($uri->getProtocol()) { return array($label, pht('The custom domain should not include a protocol. Just provide ' . 'the bare domain name (for example, "%s").', $example_domain)); } if ($uri->getPort()) { return array($label, pht('The custom domain should not include a port number. Just provide ' . 'the bare domain name (for example, "%s").', $example_domain)); } if (strpos($custom_domain, '/') !== false) { return array($label, pht('The custom domain should not specify a path (hosting a Phame ' . 'blog at a path is currently not supported). Instead, just provide ' . 'the bare domain name (for example, "%s").', $example_domain)); } if (strpos($custom_domain, '.') === false) { return array($label, pht('The custom domain should contain at least one dot (.) because ' . 'some browsers fail to set cookies on domains without a dot. ' . 'Instead, use a normal looking domain name like "%s".', $example_domain)); } if (!PhabricatorEnv::getEnvConfig('policy.allow-public')) { $href = PhabricatorEnv::getProductionURI('/config/edit/policy.allow-public/'); return array(pht('Fix Configuration'), pht('For custom domains to work, this Phabricator instance must be ' . 'configured to allow the public access policy. Configure this ' . 'setting %s, or ask an administrator to configure this setting. ' . 'The domain can be specified later once this setting has been ' . 'changed.', phutil_tag('a', array('href' => $href), pht('here')))); } return null; }
protected function processReceivedMail(PhabricatorMetaMTAReceivedMail $mail, PhabricatorUser $sender) { $title = $mail->getSubject(); if (!$title) { $title = pht('Email Paste'); } $file = PhabricatorPasteEditor::initializeFileForPaste($sender, $title, $mail->getCleanTextBody()); $xactions = array(); $xactions[] = id(new PhabricatorPasteTransaction())->setTransactionType(PhabricatorPasteTransaction::TYPE_CONTENT)->setNewValue($file->getPHID()); $xactions[] = id(new PhabricatorPasteTransaction())->setTransactionType(PhabricatorPasteTransaction::TYPE_TITLE)->setNewValue($title); $xactions[] = id(new PhabricatorPasteTransaction())->setTransactionType(PhabricatorPasteTransaction::TYPE_LANGUAGE)->setNewValue(''); // auto-detect $paste = PhabricatorPaste::initializeNewPaste($sender); $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_EMAIL, array('id' => $mail->getID())); $editor = id(new PhabricatorPasteEditor())->setActor($sender)->setContentSource($content_source)->setContinueOnNoEffect(true); $xactions = $editor->applyTransactions($paste, $xactions); $mail->setRelatedPHID($paste->getPHID()); $subject_prefix = PhabricatorEnv::getEnvConfig('metamta.paste.subject-prefix'); $subject = pht('You successfully created a paste.'); $paste_uri = PhabricatorEnv::getProductionURI($paste->getURI()); $body = new PhabricatorMetaMTAMailBody(); $body->addRawSection($subject); $body->addTextSection(pht('PASTE LINK'), $paste_uri); id(new PhabricatorMetaMTAMail())->addTos(array($sender->getPHID()))->setSubject($subject)->setSubjectPrefix($subject_prefix)->setFrom($sender->getPHID())->setRelatedPHID($paste->getPHID())->setBody($body->render())->saveAndSend(); }
public function markupDocumentLink($matches) { $link = trim($matches[1]); $name = trim(idx($matches, 2, $link)); if (empty($matches[2])) { $name = explode('/', trim($name, '/')); $name = end($name); } $uri = new PhutilURI($link); $slug = $uri->getPath(); $fragment = $uri->getFragment(); $slug = PhabricatorSlug::normalize($slug); $slug = PhrictionDocument::getSlugURI($slug); $href = (string) id(new PhutilURI($slug))->setFragment($fragment); if ($this->getEngine()->getState('toc')) { $text = $name; } else { if ($this->getEngine()->isTextMode()) { return PhabricatorEnv::getProductionURI($href); } else { $text = $this->newTag('a', array('href' => $href, 'class' => 'phriction-link'), $name); } } return $this->getEngine()->storeText($text); }
protected function execute(ConduitAPIRequest $request) { $name = $request->getValue('name'); $name_prefix = $request->getValue('namePrefix'); $language = $request->getValue('language'); $type = $request->getValue('type'); $query = new DiffusionSymbolQuery(); if ($name !== null) { $query->setName($name); } if ($name_prefix !== null) { $query->setNamePrefix($name_prefix); } if ($language !== null) { $query->setLanguage($language); } if ($type !== null) { $query->setType($type); } $query->needPaths(true); $query->needArcanistProjects(true); $query->needRepositories(true); $results = $query->execute(); $response = array(); foreach ($results as $result) { $response[] = array('name' => $result->getSymbolName(), 'type' => $result->getSymbolType(), 'language' => $result->getSymbolLanguage(), 'path' => $result->getPath(), 'line' => $result->getLineNumber(), 'uri' => PhabricatorEnv::getProductionURI($result->getURI())); } return $response; }
protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $query = id(new ReleephProductQuery())->setViewer($viewer); $ids = $request->getValue('ids'); if ($ids !== null) { $query->withIDs($ids); } $phids = $request->getValue('phids'); if ($phids !== null) { $query->withPHIDs($phids); } $repository_phids = $request->getValue('repositoryPHIDs'); if ($repository_phids !== null) { $query->withRepositoryPHIDs($repository_phids); } $is_active = $request->getValue('isActive'); if ($is_active !== null) { $query->withActive($is_active); } $pager = $this->newPager($request); $products = $query->executeWithCursorPager($pager); $data = array(); foreach ($products as $product) { $id = $product->getID(); $uri = '/releeph/product/' . $id . '/'; $uri = PhabricatorEnv::getProductionURI($uri); $data[] = array('id' => $id, 'phid' => $product->getPHID(), 'uri' => $uri, 'name' => $product->getName(), 'isActive' => (bool) $product->getIsActive(), 'repositoryPHID' => $product->getRepositoryPHID()); } return $this->addPagerResults(array('data' => $data), $pager); }
protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $query = id(new ReleephBranchQuery())->setViewer($viewer); $ids = $request->getValue('ids'); if ($ids !== null) { $query->withIDs($ids); } $phids = $request->getValue('phids'); if ($phids !== null) { $query->withPHIDs($phids); } $product_phids = $request->getValue('productPHIDs'); if ($product_phids !== null) { $query->withProductPHIDs($product_phids); } $pager = $this->newPager($request); $branches = $query->executeWithCursorPager($pager); $data = array(); foreach ($branches as $branch) { $id = $branch->getID(); $uri = '/releeph/branch/' . $id . '/'; $uri = PhabricatorEnv::getProductionURI($uri); $data[] = array('id' => $id, 'phid' => $branch->getPHID(), 'uri' => $uri, 'name' => $branch->getName(), 'productPHID' => $branch->getProduct()->getPHID()); } return $this->addPagerResults(array('data' => $data), $pager); }
protected function execute(ConduitAPIRequest $request) { $query = new PhabricatorFlagQuery(); $owner_phids = $request->getValue('ownerPHIDs', array()); if ($owner_phids) { $query->withOwnerPHIDs($owner_phids); } $object_phids = $request->getValue('objectPHIDs', array()); if ($object_phids) { $query->withObjectPHIDs($object_phids); } $types = $request->getValue('types', array()); if ($types) { $query->withTypes($types); } $query->needHandles(true); $query->setOffset($request->getValue('offset', 0)); $query->setLimit($request->getValue('limit', 100)); $flags = $query->execute(); $results = array(); foreach ($flags as $flag) { $color = $flag->getColor(); $uri = PhabricatorEnv::getProductionURI($flag->getHandle()->getURI()); $results[] = array('id' => $flag->getID(), 'ownerPHID' => $flag->getOwnerPHID(), 'type' => $flag->getType(), 'objectPHID' => $flag->getObjectPHID(), 'reasonPHID' => $flag->getReasonPHID(), 'color' => $color, 'colorName' => PhabricatorFlagColor::getColorName($color), 'note' => $flag->getNote(), 'handle' => array('uri' => $uri, 'name' => $flag->getHandle()->getName()), 'dateCreated' => $flag->getDateCreated(), 'dateModified' => $flag->getDateModified()); } return $results; }
protected function doWork() { $data = $this->getTaskData(); $viewer = PhabricatorUser::getOmnipotentUser(); $address = idx($data, 'address'); $author_phid = idx($data, 'authorPHID'); $author = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withPHIDs(array($author_phid))->executeOne(); if (!$author) { throw new PhabricatorWorkerPermanentFailureException(pht('Invite has invalid author PHID ("%s").', $author_phid)); } $invite = id(new PhabricatorAuthInviteQuery())->setViewer($viewer)->withEmailAddresses(array($address))->executeOne(); if ($invite) { // If we're inviting a user who has already been invited, we just // regenerate their invite code. $invite->regenerateVerificationCode(); } else { // Otherwise, we're creating a new invite. $invite = id(new PhabricatorAuthInvite())->setEmailAddress($address); } // Whether this is a new invite or not, tag this most recent author as // the invite author. $invite->setAuthorPHID($author_phid); $code = $invite->getVerificationCode(); $invite_uri = '/auth/invite/' . $code . '/'; $invite_uri = PhabricatorEnv::getProductionURI($invite_uri); $template = idx($data, 'template'); $template = str_replace('{$INVITE_URI}', $invite_uri, $template); $invite->save(); $mail = id(new PhabricatorMetaMTAMail())->addRawTos(array($invite->getEmailAddress()))->setForceDelivery(true)->setSubject(pht('[Phabricator] %s has invited you to join Phabricator', $author->getFullName()))->setBody($template)->saveAndSend(); }
protected final function buildDocumentContentDictionary(PhrictionDocument $doc, PhrictionContent $content) { $uri = PhrictionDocument::getSlugURI($content->getSlug()); $uri = PhabricatorEnv::getProductionURI($uri); $doc_status = $doc->getStatus(); return array('phid' => $doc->getPHID(), 'uri' => $uri, 'slug' => $content->getSlug(), 'version' => $content->getVersion(), 'authorPHID' => $content->getAuthorPHID(), 'title' => $content->getTitle(), 'content' => $content->getContent(), 'status' => PhrictionDocumentStatus::getConduitConstant($doc_status), 'description' => $content->getDescription(), 'dateCreated' => $content->getDateCreated()); }
public function render() { $handle = $this->handle; $type_name = nonempty($handle->getTypeName(), 'Document'); require_celerity_resource('phabricator-search-results-css'); $link = phutil_render_tag('a', array('href' => $handle->getURI()), PhabricatorEnv::getProductionURI($handle->getURI())); $img = $handle->getImageURI(); if ($img) { $img = phutil_render_tag('div', array('class' => 'result-image', 'style' => "background-image: url('{$img}');"), ''); } switch ($handle->getType()) { case PhabricatorPHIDConstants::PHID_TYPE_CMIT: $object_name = $handle->getName(); if ($this->object) { $data = $this->object->getCommitData(); $summary = $data->getSummary(); if (strlen($summary)) { $object_name = $handle->getName() . ': ' . $data->getSummary(); } } break; default: $object_name = $handle->getFullName(); break; } return '<div class="phabricator-search-result">' . $img . '<div class="result-desc">' . phutil_render_tag('a', array('class' => 'result-name', 'href' => $handle->getURI()), $this->emboldenQuery($object_name)) . '<div class="result-type">' . $type_name . ' · ' . $link . '</div>' . '</div>' . '<div style="clear: both;"></div>' . '</div>'; }
protected function execute(ConduitAPIRequest $request) { $need_messages = $request->getValue('needMessages'); $bypass_cache = $request->getValue('bypassCache'); $query = id(new DiffusionCommitQuery())->setViewer($request->getUser())->needCommitData(true); $repository_phid = $request->getValue('repositoryPHID'); if ($repository_phid) { $repository = id(new PhabricatorRepositoryQuery())->setViewer($request->getUser())->withPHIDs(array($repository_phid))->executeOne(); if ($repository) { $query->withRepository($repository); } } $names = $request->getValue('names'); if ($names) { $query->withIdentifiers($names); } $ids = $request->getValue('ids'); if ($ids) { $query->withIDs($ids); } $phids = $request->getValue('phids'); if ($phids) { $query->withPHIDs($phids); } $pager = $this->newPager($request); $commits = $query->executeWithCursorPager($pager); $map = $query->getIdentifierMap(); $map = mpull($map, 'getPHID'); $data = array(); foreach ($commits as $commit) { $commit_data = $commit->getCommitData(); $callsign = $commit->getRepository()->getCallsign(); $identifier = $commit->getCommitIdentifier(); $uri = '/r' . $callsign . $identifier; $uri = PhabricatorEnv::getProductionURI($uri); $dict = array('id' => $commit->getID(), 'phid' => $commit->getPHID(), 'repositoryPHID' => $commit->getRepository()->getPHID(), 'identifier' => $identifier, 'epoch' => $commit->getEpoch(), 'uri' => $uri, 'isImporting' => !$commit->isImported(), 'summary' => $commit->getSummary(), 'authorPHID' => $commit->getAuthorPHID(), 'committerPHID' => $commit_data->getCommitDetail('committerPHID'), 'author' => $commit_data->getAuthorName(), 'authorName' => $commit_data->getCommitDetail('authorName'), 'authorEmail' => $commit_data->getCommitDetail('authorEmail'), 'committer' => $commit_data->getCommitDetail('committer'), 'committerName' => $commit_data->getCommitDetail('committerName'), 'committerEmail' => $commit_data->getCommitDetail('committerEmail'), 'hashes' => array()); if ($bypass_cache) { $lowlevel_commitref = id(new DiffusionLowLevelCommitQuery())->setRepository($commit->getRepository())->withIdentifier($commit->getCommitIdentifier())->execute(); $dict['author'] = $lowlevel_commitref->getAuthor(); $dict['authorName'] = $lowlevel_commitref->getAuthorName(); $dict['authorEmail'] = $lowlevel_commitref->getAuthorEmail(); $dict['committer'] = $lowlevel_commitref->getCommitter(); $dict['committerName'] = $lowlevel_commitref->getCommitterName(); $dict['committerEmail'] = $lowlevel_commitref->getCommitterEmail(); if ($need_messages) { $dict['message'] = $lowlevel_commitref->getMessage(); } foreach ($lowlevel_commitref->getHashes() as $hash) { $dict['hashes'][] = array('type' => $hash->getHashType(), 'value' => $hash->getHashValue()); } } if ($need_messages && !$bypass_cache) { $dict['message'] = $commit_data->getCommitMessage(); } $data[$commit->getPHID()] = $dict; } $result = array('data' => $data, 'identifierMap' => nonempty($map, (object) array())); return $this->addPagerResults($result, $pager); }
public function testFieldParser() { $this->assertEqual(null, $this->parse('123')); $this->assertEqual(null, $this->parse('D123')); // NOTE: We expect foreign, validly-formatted URIs to be ignored. $this->assertEqual(null, $this->parse('http://phabricator.example.com/D123')); $this->assertEqual(123, $this->parse(PhabricatorEnv::getProductionURI('/D123'))); }
/** * Add a Herald section with a rule management URI and a transcript URI. * * @param string URI to rule management. * @param string URI to rule transcripts. * @return this * @task compose */ public function addHeraldSection($rules_uri, $xscript_uri) { if (!PhabricatorEnv::getEnvConfig('metamta.herald.show-hints')) { return $this; } $this->addTextSection(pht('MANAGE HERALD RULES'), PhabricatorEnv::getProductionURI($rules_uri)); $this->addTextSection(pht('WHY DID I GET THIS EMAIL?'), PhabricatorEnv::getProductionURI($xscript_uri)); return $this; }
protected function buildPasteInfoDictionary(PhabricatorPaste $paste) { $content = null; $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $paste->getFilePHID()); if ($file) { $content = $file->loadFileData(); } return array('id' => $paste->getID(), 'objectName' => 'P' . $paste->getID(), 'phid' => $paste->getPHID(), 'authorPHID' => $paste->getAuthorPHID(), 'filePHID' => $paste->getFilePHID(), 'title' => $paste->getTitle(), 'dateCreated' => $paste->getDateCreated(), 'language' => $paste->getLanguage(), 'uri' => PhabricatorEnv::getProductionURI('/P' . $paste->getID()), 'parentPHID' => $paste->getParentPHID(), 'content' => $content); }
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); } }
protected function execute(ConduitAPIRequest $request) { $paste_id = $request->getValue('paste_id'); $paste = id(new PhabricatorPaste())->load($paste_id); if (!$paste) { throw new ConduitException('ERR_BAD_PASTE'); } $result = array('id' => $paste->getID(), 'phid' => $paste->getPHID(), 'authorPHID' => $paste->getAuthorPHID(), 'filePHID' => $paste->getFilePHID(), 'title' => $paste->getTitle(), 'dateCreated' => $paste->getDateCreated(), 'language' => $paste->getLanguage(), 'uri' => PhabricatorEnv::getProductionURI('/P' . $paste->getID())); return $result; }
protected function execute(ConduitAPIRequest $request) { $task_id = $request->getValue('task_id'); $task = id(new ManiphestTask())->load($task_id); if (!$task) { throw new ConduitException('ERR_BAD_TASK'); } $result = array('id' => $task->getID(), 'phid' => $task->getPHID(), 'authorPHID' => $task->getAuthorPHID(), 'ownerPHID' => $task->getAuthorPHID(), 'ccPHIDs' => $task->getCCPHIDs(), 'status' => $task->getStatus(), 'priority' => ManiphestTaskPriority::getTaskPriorityName($task->getPriority()), 'title' => $task->getTitle(), 'description' => $task->getDescription(), 'projectPHIDs' => $task->getProjectPHIDs(), 'uri' => PhabricatorEnv::getProductionURI('/T' . $task->getID())); return $result; }
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 execute(ConduitAPIRequest $request) { $poll_id = $request->getValue('poll_id'); $poll = id(new PhabricatorSlowvotePoll())->load($poll_id); if (!$poll) { throw new ConduitException('ERR_BAD_POLL'); } $result = array('id' => $poll->getID(), 'phid' => $poll->getPHID(), 'authorPHID' => $poll->getAuthorPHID(), 'question' => $poll->getQuestion(), 'uri' => PhabricatorEnv::getProductionURI('/V' . $poll->getID())); return $result; }
public function processAddFactorForm(AphrontFormView $form, AphrontRequest $request, PhabricatorUser $user) { $totp_token_type = PhabricatorAuthTOTPKeyTemporaryTokenType::TOKENTYPE; $key = $request->getStr('totpkey'); if (strlen($key)) { // If the user is providing a key, make sure it's a key we generated. // This raises the barrier to theoretical attacks where an attacker might // provide a known key (such attacks are already prevented by CSRF, but // this is a second barrier to overcome). // (We store and verify the hash of the key, not the key itself, to limit // how useful the data in the table is to an attacker.) $temporary_token = id(new PhabricatorAuthTemporaryTokenQuery())->setViewer($user)->withTokenResources(array($user->getPHID()))->withTokenTypes(array($totp_token_type))->withExpired(false)->withTokenCodes(array(PhabricatorHash::digest($key)))->executeOne(); if (!$temporary_token) { // If we don't have a matching token, regenerate the key below. $key = null; } } if (!strlen($key)) { $key = self::generateNewTOTPKey(); // Mark this key as one we generated, so the user is allowed to submit // a response for it. $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); id(new PhabricatorAuthTemporaryToken())->setTokenResource($user->getPHID())->setTokenType($totp_token_type)->setTokenExpires(time() + phutil_units('1 hour in seconds'))->setTokenCode(PhabricatorHash::digest($key))->save(); unset($unguarded); } $code = $request->getStr('totpcode'); $e_code = true; if ($request->getExists('totp')) { $okay = self::verifyTOTPCode($user, new PhutilOpaqueEnvelope($key), $code); if ($okay) { $config = $this->newConfigForUser($user)->setFactorName(pht('Mobile App (TOTP)'))->setFactorSecret($key); return $config; } else { if (!strlen($code)) { $e_code = pht('Required'); } else { $e_code = pht('Invalid'); } } } $form->addHiddenInput('totp', true); $form->addHiddenInput('totpkey', $key); $form->appendRemarkupInstructions(pht('First, download an authenticator application on your phone. Two ' . 'applications which work well are **Authy** and **Google ' . 'Authenticator**, but any other TOTP application should also work.')); $form->appendInstructions(pht('Launch the application on your phone, and add a new entry for ' . 'this Phabricator install. When prompted, scan the QR code or ' . 'manually enter the key shown below into the application.')); $prod_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/')); $issuer = $prod_uri->getDomain(); $uri = urisprintf('otpauth://totp/%s:%s?secret=%s&issuer=%s', $issuer, $user->getUsername(), $key, $issuer); $qrcode = $this->renderQRCode($uri); $form->appendChild($qrcode); $form->appendChild(id(new AphrontFormStaticControl())->setLabel(pht('Key'))->setValue(phutil_tag('strong', array(), $key))); $form->appendInstructions(pht('(If given an option, select that this key is "Time Based", not ' . '"Counter Based".)')); $form->appendInstructions(pht('After entering the key, the application should display a numeric ' . 'code. Enter that code below to confirm that you have configured ' . 'the authenticator correctly:')); $form->appendChild(id(new PHUIFormNumberControl())->setLabel(pht('TOTP Code'))->setName('totpcode')->setValue($code)->setError($e_code)); }
protected final function renderSummarySection() { $package = $this->getPackage(); $handles = $this->getHandles(); $section = array(); $section[] = $handles[$package->getActorPHID()]->getName() . ' ' . strtolower($this->getVerb()) . ' ' . $this->renderPackageTitle() . '.'; $section[] = ''; $section[] = 'PACKAGE DETAIL'; $section[] = ' ' . PhabricatorEnv::getProductionURI('/owners/package/' . $package->getID() . '/'); return implode("\n", $section); }
protected function renderObjectEmbed($object, $handle, $options) { $name = $handle->getFullName(); $href = $handle->getURI(); $status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED; if ($this->getEngine()->isTextMode()) { return $name . ' <' . PhabricatorEnv::getProductionURI($href) . '>'; } $attr = array('phid' => $handle->getPHID(), 'closed' => $handle->getStatus() == $status_closed); return $this->renderHovertag($name, $href, $attr); }
public function getViewURI() { // go for the pretty uri if we can $domain = $this->blog ? $this->blog->getDomain() : ''; if ($domain) { $phame_title = PhabricatorSlug::normalize($this->getPhameTitle()); return 'http://' . $domain . '/post/' . $phame_title; } $uri = '/phame/post/view/' . $this->getID() . '/'; return PhabricatorEnv::getProductionURI($uri); }
protected function buildMailBody(PhabricatorLiskDAO $object, array $xactions) { $body = parent::buildMailBody($object, $xactions); // If the user just gave the answer, add the answer text. foreach ($xactions as $xaction) { $type = $xaction->getTransactionType(); $new = $xaction->getNewValue(); if ($type == PonderAnswerTransaction::TYPE_CONTENT) { $body->addRawSection($new); } } $body->addTextSection(pht('ANSWER DETAIL'), PhabricatorEnv::getProductionURI($object->getURI())); return $body; }
protected function renderObjectEmbedForAnyMedia($object, PhabricatorObjectHandle $handle, $options) { $name = $handle->getFullName(); $href = $handle->getURI(); if ($this->getEngine()->isTextMode()) { return $name . ' <' . PhabricatorEnv::getProductionURI($href) . '>'; } else { if ($this->getEngine()->isHTMLMailMode()) { $href = PhabricatorEnv::getProductionURI($href); return $this->renderObjectTagForMail($name, $href, $handle); } } return $this->renderObjectEmbed($object, $handle, $options); }