[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/help/controller/ -> PhabricatorHelpEditorProtocolController.php (source)

   1  <?php
   2  
   3  final class PhabricatorHelpEditorProtocolController
   4    extends PhabricatorHelpController {
   5  
   6    public function shouldAllowPublic() {
   7      return true;
   8    }
   9  
  10    public function processRequest() {
  11      $request = $this->getRequest();
  12      $viewer = $request->getUser();
  13  
  14      $dialog = id(new AphrontDialogView())
  15        ->setUser($viewer)
  16        ->setMethod('GET')
  17        ->setSubmitURI('/settings/panel/display/')
  18        ->setTitle(pht('Unsupported Editor Protocol'))
  19        ->appendParagraph(
  20          pht(
  21            'Your configured editor URI uses an unsupported protocol. Change '.
  22            'your settings to use a supported protocol, or ask your '.
  23            'administrator to add support for the chosen protocol by '.
  24            'configuring: %s',
  25            phutil_tag('tt', array(), 'uri.allowed-editor-protocols')))
  26        ->addSubmitButton(pht('Change Settings'))
  27        ->addCancelButton('/');
  28  
  29      return id(new AphrontDialogResponse())
  30        ->setDialog($dialog);
  31    }
  32  
  33    public static function hasAllowedProtocol($uri) {
  34      $uri = new PhutilURI($uri);
  35      $editor_protocol = $uri->getProtocol();
  36      if (!$editor_protocol) {
  37        // The URI must have a protocol.
  38        return false;
  39      }
  40  
  41      $allowed_key = 'uri.allowed-editor-protocols';
  42      $allowed_protocols = PhabricatorEnv::getEnvConfig($allowed_key);
  43      if (empty($allowed_protocols[$editor_protocol])) {
  44        // The protocol must be on the allowed protocol whitelist.
  45        return false;
  46      }
  47  
  48      return true;
  49    }
  50  
  51  
  52  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1