1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-28 09:42:41 +01:00
phorge-phorge/src/applications/help/controller/PhabricatorHelpEditorProtocolController.php
Chad Little deb06727ea Update Help for handleRequest
Summary: Updates Help for handleRequest

Test Plan: Launch help dialog, close dialog

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D13772
2015-08-01 15:40:03 -07:00

51 lines
1.4 KiB
PHP

<?php
final class PhabricatorHelpEditorProtocolController
extends PhabricatorHelpController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$dialog = id(new AphrontDialogView())
->setUser($viewer)
->setMethod('GET')
->setSubmitURI('/settings/panel/display/')
->setTitle(pht('Unsupported Editor Protocol'))
->appendParagraph(
pht(
'Your configured editor URI uses an unsupported protocol. Change '.
'your settings to use a supported protocol, or ask your '.
'administrator to add support for the chosen protocol by '.
'configuring: %s',
phutil_tag('tt', array(), 'uri.allowed-editor-protocols')))
->addSubmitButton(pht('Change Settings'))
->addCancelButton('/');
return id(new AphrontDialogResponse())
->setDialog($dialog);
}
public static function hasAllowedProtocol($uri) {
$uri = new PhutilURI($uri);
$editor_protocol = $uri->getProtocol();
if (!$editor_protocol) {
// The URI must have a protocol.
return false;
}
$allowed_key = 'uri.allowed-editor-protocols';
$allowed_protocols = PhabricatorEnv::getEnvConfig($allowed_key);
if (empty($allowed_protocols[$editor_protocol])) {
// The protocol must be on the allowed protocol whitelist.
return false;
}
return true;
}
}