本文整理汇总了PHP中AphrontRequest::isDialogFormPost方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontRequest::isDialogFormPost方法的具体用法?PHP AphrontRequest::isDialogFormPost怎么用?PHP AphrontRequest::isDialogFormPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AphrontRequest
的用法示例。
在下文中一共展示了AphrontRequest::isDialogFormPost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$dblob = $request->getURIData('dblob');
$fragment = id(new PhragmentFragmentQuery())->setViewer($viewer)->withPaths(array($dblob))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if ($fragment === null) {
return new Aphront404Response();
}
$version = id(new PhragmentFragmentVersionQuery())->setViewer($viewer)->withFragmentPHIDs(array($fragment->getPHID()))->withIDs(array($id))->executeOne();
if ($version === null) {
return new Aphront404Response();
}
if ($request->isDialogFormPost()) {
$file_phid = $version->getFilePHID();
$file = null;
if ($file_phid !== null) {
$file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($file_phid))->executeOne();
if ($file === null) {
throw new Exception(pht('The file associated with this version was not found.'));
}
}
if ($file === null) {
$fragment->deleteFile($viewer);
} else {
$fragment->updateFromFile($viewer, $file);
}
return id(new AphrontRedirectResponse())->setURI($this->getApplicationURI('/history/' . $dblob));
}
return $this->createDialog($fragment, $version);
}
示例2: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$phid = $request->getURIData('phid');
$xaction = id(new PhabricatorObjectQuery())->withPHIDs(array($phid))->setViewer($viewer)->executeOne();
if (!$xaction) {
return new Aphront404Response();
}
if (!$xaction->getComment()) {
return new Aphront404Response();
}
if ($xaction->getComment()->getIsRemoved()) {
// You can't remove an already-removed comment.
return new Aphront400Response();
}
$obj_phid = $xaction->getObjectPHID();
$obj_handle = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($obj_phid))->executeOne();
if ($request->isDialogFormPost()) {
$comment = $xaction->getApplicationTransactionCommentObject()->setContent('')->setIsRemoved(true);
$editor = id(new PhabricatorApplicationTransactionCommentEditor())->setActor($viewer)->setContentSource(PhabricatorContentSource::newFromRequest($request))->applyEdit($xaction, $comment);
if ($request->isAjax()) {
return id(new AphrontAjaxResponse())->setContent(array());
} else {
return id(new AphrontReloadResponse())->setURI($obj_handle->getURI());
}
}
$form = id(new AphrontFormView())->setUser($viewer);
$dialog = $this->newDialog()->setTitle(pht('Remove Comment'));
$dialog->addHiddenInput('anchor', $request->getStr('anchor'))->appendParagraph(pht("Removing a comment prevents anyone (including you) from reading " . "it. Removing a comment also hides the comment's edit history " . "and prevents it from being edited."))->appendParagraph(pht('Really remove this comment?'));
$dialog->addSubmitButton(pht('Remove Comment'))->addCancelButton($obj_handle->getURI());
return $dialog;
}
开发者ID:pugong,项目名称:phabricator,代码行数:32,代码来源:PhabricatorApplicationTransactionCommentRemoveController.php
示例3: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$e_file = true;
$errors = array();
if ($request->isDialogFormPost()) {
$file_phids = $request->getStrList('filePHIDs');
if ($file_phids) {
$files = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs($file_phids)->setRaisePolicyExceptions(true)->execute();
} else {
$files = array();
}
if ($files) {
$results = array();
foreach ($files as $file) {
$results[] = $file->getDragAndDropDictionary();
}
$content = array('files' => $results);
return id(new AphrontAjaxResponse())->setContent($content);
} else {
$e_file = pht('Required');
$errors[] = pht('You must choose a file to upload.');
}
}
if ($request->getURIData('single')) {
$allow_multiple = false;
} else {
$allow_multiple = true;
}
$form = id(new AphrontFormView())->appendChild(id(new PHUIFormFileControl())->setName('filePHIDs')->setLabel(pht('Upload File'))->setAllowMultiple($allow_multiple)->setError($e_file));
return $this->newDialog()->setTitle(pht('File'))->setErrors($errors)->appendForm($form)->addSubmitButton(pht('Upload'))->addCancelButton('/');
}
示例4: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$cancel_uri = $this->getApplicationURI('cache/');
$opcode_cache = PhabricatorOpcodeCacheSpec::getActiveCacheSpec();
$data_cache = PhabricatorDataCacheSpec::getActiveCacheSpec();
$opcode_clearable = $opcode_cache->getClearCacheCallback();
$data_clearable = $data_cache->getClearCacheCallback();
if (!$opcode_clearable && !$data_clearable) {
return $this->newDialog()->setTitle(pht('No Caches to Reset'))->appendParagraph(pht('None of the caches on this page can be cleared.'))->addCancelButton($cancel_uri);
}
if ($request->isDialogFormPost()) {
if ($opcode_clearable) {
call_user_func($opcode_cache->getClearCacheCallback());
}
if ($data_clearable) {
call_user_func($data_cache->getClearCacheCallback());
}
return id(new AphrontRedirectResponse())->setURI($cancel_uri);
}
$caches = id(new PHUIPropertyListView())->setUser($viewer);
if ($opcode_clearable) {
$caches->addProperty(pht('Opcode'), $opcode_cache->getName());
}
if ($data_clearable) {
$caches->addProperty(pht('Data'), $data_cache->getName());
}
return $this->newDialog()->setTitle(pht('Really Clear Cache?'))->setShortTitle(pht('Really Clear Cache'))->appendParagraph(pht('This will only affect the current web ' . 'frontend. Daemons and any other web frontends may continue ' . 'to use older, cached code from their opcache.'))->appendParagraph(pht('The following caches will be cleared:'))->appendChild($caches)->addSubmitButton(pht('Clear Cache'))->addCancelButton($cancel_uri);
}
示例5: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$phid = head($request->getArr('macro'));
$above = $request->getStr('above');
$below = $request->getStr('below');
$e_macro = true;
$errors = array();
if ($request->isDialogFormPost()) {
if (!$phid) {
$e_macro = pht('Required');
$errors[] = pht('Macro name is required.');
} else {
$macro = id(new PhabricatorMacroQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
if (!$macro) {
$e_macro = pht('Invalid');
$errors[] = pht('No such macro.');
}
}
if (!$errors) {
$options = new PhutilSimpleOptions();
$data = array('src' => $macro->getName(), 'above' => $above, 'below' => $below);
$string = $options->unparse($data, $escape = '}');
$result = array('text' => "{meme, {$string}}");
return id(new AphrontAjaxResponse())->setContent($result);
}
}
$view = id(new AphrontFormView())->setUser($viewer)->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Macro'))->setName('macro')->setLimit(1)->setDatasource(new PhabricatorMacroDatasource())->setError($e_macro))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Above'))->setName('above')->setValue($above))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Below'))->setName('below')->setValue($below));
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Create Meme'))->appendForm($view)->addCancelButton('/')->addSubmitButton(pht('Llama Diorama'));
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例6: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$chrono_key = $request->getStr('chronoKey');
if ($request->isDialogFormPost()) {
$table = new PhabricatorFeedStoryNotification();
queryfx($table->establishConnection('w'), 'UPDATE %T SET hasViewed = 1 ' . 'WHERE userPHID = %s AND hasViewed = 0 and chronologicalKey <= %s', $table->getTableName(), $viewer->getPHID(), $chrono_key);
PhabricatorUserCache::clearCache(PhabricatorUserNotificationCountCacheType::KEY_COUNT, $viewer->getPHID());
return id(new AphrontReloadResponse())->setURI('/notification/');
}
$dialog = new AphrontDialogView();
$dialog->setUser($viewer);
$dialog->addCancelButton('/notification/');
if ($chrono_key) {
$dialog->setTitle(pht('Really mark all notifications as read?'));
$dialog->addHiddenInput('chronoKey', $chrono_key);
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
if ($is_serious) {
$dialog->appendChild(pht('All unread notifications will be marked as read. You can not ' . 'undo this action.'));
} else {
$dialog->appendChild(pht("You can't ignore your problems forever, you know."));
}
$dialog->addSubmitButton(pht('Mark All Read'));
} else {
$dialog->setTitle(pht('No notifications to mark as read.'));
$dialog->appendChild(pht('You have no unread notifications.'));
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例7: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$issue = $request->getURIData('key');
$verb = $request->getURIData('verb');
$issue_uri = $this->getApplicationURI('issue/' . $issue . '/');
if ($request->isDialogFormPost()) {
$this->manageApplication($issue);
return id(new AphrontRedirectResponse())->setURI($issue_uri);
}
if ($verb == 'ignore') {
$title = pht('Really ignore this setup issue?');
$submit_title = pht('Ignore');
$body = pht("You can ignore an issue if you don't want to fix it, or plan to " . "fix it later. Ignored issues won't appear on every page but will " . "still be shown in the list of open issues.");
} else {
if ($verb == 'unignore') {
$title = pht('Unignore this setup issue?');
$submit_title = pht('Unignore');
$body = pht('This issue will no longer be suppressed, and will return to its ' . 'rightful place as a global setup warning.');
} else {
throw new Exception(pht('Unrecognized verb: %s', $verb));
}
}
$dialog = id(new AphrontDialogView())->setUser($request->getUser())->setTitle($title)->appendChild($body)->addSubmitButton($submit_title)->addCancelButton($issue_uri);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例8: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$revision_id = $request->getURIData('id');
$strategy_class = $request->getURIData('strategy');
$revision = id(new DifferentialRevisionQuery())->withIDs(array($revision_id))->setViewer($viewer)->executeOne();
if (!$revision) {
return new Aphront404Response();
}
if (is_subclass_of($strategy_class, 'DifferentialLandingStrategy')) {
$this->pushStrategy = newv($strategy_class, array());
} else {
throw new Exception(pht("Strategy type must be a valid class name and must subclass " . "%s. '%s' is not a subclass of %s", 'DifferentialLandingStrategy', $strategy_class, 'DifferentialLandingStrategy'));
}
if ($request->isDialogFormPost()) {
$response = null;
$text = '';
try {
$response = $this->attemptLand($revision, $request);
$title = pht('Success!');
$text = pht('Revision was successfully landed.');
} catch (Exception $ex) {
$title = pht('Failed to land revision');
if ($ex instanceof PhutilProxyException) {
$text = hsprintf('%s:<br><pre>%s</pre>', $ex->getMessage(), $ex->getPreviousException()->getMessage());
} else {
$text = phutil_tag('pre', array(), $ex->getMessage());
}
$text = id(new PHUIInfoView())->appendChild($text);
}
if ($response instanceof AphrontDialogView) {
$dialog = $response;
} else {
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle($title)->appendChild(phutil_tag('p', array(), $text))->addCancelButton('/D' . $revision_id, pht('Done'));
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$is_disabled = $this->pushStrategy->isActionDisabled($viewer, $revision, $revision->getRepository());
if ($is_disabled) {
if (is_string($is_disabled)) {
$explain = $is_disabled;
} else {
$explain = pht('This action is not currently enabled.');
}
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht("Can't land revision"))->appendChild($explain)->addCancelButton('/D' . $revision_id);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$prompt = hsprintf('%s<br><br>%s', pht('This will squash and rebase revision %s, and push it to ' . 'the default / master branch.', $revision_id), pht('It is an experimental feature and may not work.'));
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Land Revision %s?', $revision_id))->appendChild($prompt)->setSubmitURI($request->getRequestURI())->addSubmitButton(pht('Land it!'))->addCancelButton('/D' . $revision_id);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例9: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$key = $request->getURIData('queryKey');
$engine_class = $request->getURIData('engine');
$base_class = 'PhabricatorApplicationSearchEngine';
if (!is_subclass_of($engine_class, $base_class)) {
return new Aphront400Response();
}
$engine = newv($engine_class, array());
$engine->setViewer($viewer);
$named_query = id(new PhabricatorNamedQueryQuery())->setViewer($viewer)->withEngineClassNames(array($engine_class))->withQueryKeys(array($key))->withUserPHIDs(array($viewer->getPHID()))->executeOne();
if (!$named_query && $engine->isBuiltinQuery($key)) {
$named_query = $engine->getBuiltinQuery($key);
}
if (!$named_query) {
return new Aphront404Response();
}
$builtin = null;
if ($engine->isBuiltinQuery($key)) {
$builtin = $engine->getBuiltinQuery($key);
}
$return_uri = $engine->getQueryManagementURI();
if ($request->isDialogFormPost()) {
if ($named_query->getIsBuiltin()) {
$named_query->setIsDisabled((int) (!$named_query->getIsDisabled()));
$named_query->save();
} else {
$named_query->delete();
}
return id(new AphrontRedirectResponse())->setURI($return_uri);
}
if ($named_query->getIsBuiltin()) {
if ($named_query->getIsDisabled()) {
$title = pht('Enable Query?');
$desc = pht('Enable the built-in query "%s"? It will appear in your menu again.', $builtin->getQueryName());
$button = pht('Enable Query');
} else {
$title = pht('Disable Query?');
$desc = pht('This built-in query can not be deleted, but you can disable it so ' . 'it does not appear in your query menu. You can enable it again ' . 'later. Disable built-in query "%s"?', $builtin->getQueryName());
$button = pht('Disable Query');
}
} else {
$title = pht('Really Delete Query?');
$desc = pht('Really delete the query "%s"? You can not undo this. Remember ' . 'all the great times you had filtering results together?', $named_query->getQueryName());
$button = pht('Delete Query');
}
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle($title)->appendChild($desc)->addCancelButton($return_uri)->addSubmitButton($button);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例10: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$action = $request->getURIData('action');
$project = id(new PhabricatorProjectQuery())->setViewer($viewer)->withIDs(array($id))->needMembers(true)->needWatchers(true)->executeOne();
if (!$project) {
return new Aphront404Response();
}
$project_uri = $this->getApplicationURI('profile/' . $project->getID() . '/');
// You must be a member of a project to
if (!$project->isUserMember($viewer->getPHID())) {
return new Aphront400Response();
}
if ($request->isDialogFormPost()) {
$edge_action = null;
switch ($action) {
case 'watch':
$edge_action = '+';
$force_subscribe = true;
break;
case 'unwatch':
$edge_action = '-';
$force_subscribe = false;
break;
}
$type_member = PhabricatorObjectHasWatcherEdgeType::EDGECONST;
$member_spec = array($edge_action => array($viewer->getPHID() => $viewer->getPHID()));
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $type_member)->setNewValue($member_spec);
$editor = id(new PhabricatorProjectTransactionEditor($project))->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($project, $xactions);
return id(new AphrontRedirectResponse())->setURI($project_uri);
}
$dialog = null;
switch ($action) {
case 'watch':
$title = pht('Watch Project?');
$body = pht('Watching a project will let you monitor it closely. You will ' . 'receive email and notifications about changes to every object ' . 'associated with projects you watch.');
$submit = pht('Watch Project');
break;
case 'unwatch':
$title = pht('Unwatch Project?');
$body = pht('You will no longer receive email or notifications about every ' . 'object associated with this project.');
$submit = pht('Unwatch Project');
break;
default:
return new Aphront404Response();
}
return $this->newDialog()->setTitle($title)->appendParagraph($body)->addCancelButton($project_uri)->addSubmitButton($submit);
}
示例11: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$snapshot = id(new PhragmentSnapshotQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($id))->executeOne();
if ($snapshot === null) {
return new Aphront404Response();
}
if ($request->isDialogFormPost()) {
$fragment_uri = $snapshot->getPrimaryFragment()->getURI();
$snapshot->delete();
return id(new AphrontRedirectResponse())->setURI($fragment_uri);
}
return $this->createDialog();
}
示例12: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$id = $request->getURIData('id');
$step = id(new HarbormasterBuildStepQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$step) {
return new Aphront404Response();
}
$plan_id = $step->getBuildPlan()->getID();
$done_uri = $this->getApplicationURI('plan/' . $plan_id . '/');
if ($request->isDialogFormPost()) {
$step->delete();
return id(new AphrontRedirectResponse())->setURI($done_uri);
}
return $this->newDialog()->setTitle(pht('Really Delete Step?'))->appendParagraph(pht("Are you sure you want to delete this step? " . "This can't be undone!"))->addCancelButton($done_uri)->addSubmitButton(pht('Delete Build Step'));
}
示例13: processRequest
public function processRequest(AphrontRequest $request)
{
$user = $request->getUser();
if ($request->isFormPost()) {
if (!$request->isDialogFormPost()) {
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle('Really regenerate session?');
$dialog->setSubmitURI($this->getPanelURI());
$dialog->addSubmitButton('Regenerate');
$dialog->addCancelbutton($this->getPanelURI());
$dialog->appendChild('<p>Really destroy the old certificate? Any established ' . 'sessions will be terminated.');
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$conn = $user->establishConnection('w');
queryfx($conn, 'DELETE FROM %T WHERE userPHID = %s AND type LIKE %>', PhabricatorUser::SESSION_TABLE, $user->getPHID(), 'conduit');
// This implicitly regenerates the certificate.
$user->setConduitCertificate(null);
$user->save();
return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?regenerated=true'));
}
if ($request->getStr('regenerated')) {
$notice = new AphrontErrorView();
$notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$notice->setTitle('Certificate Regenerated');
$notice->appendChild('<p>Your old certificate has been destroyed and you have been issued ' . 'a new certificate. Sessions established under the old certificate ' . 'are no longer valid.</p>');
$notice = $notice->render();
} else {
$notice = null;
}
$cert_form = new AphrontFormView();
$cert_form->setUser($user)->appendChild('<p class="aphront-form-instructions">This certificate allows you to ' . 'authenticate over Conduit, the Phabricator API. Normally, you just ' . 'run <tt>arc install-certificate</tt> to install it.')->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Certificate')->setHeight(AphrontFormTextAreaControl::HEIGHT_SHORT)->setValue($user->getConduitCertificate()));
$cert = new AphrontPanelView();
$cert->setHeader('Arcanist Certificate');
$cert->appendChild($cert_form);
$cert->setWidth(AphrontPanelView::WIDTH_FORM);
$regen_form = new AphrontFormView();
$regen_form->setUser($user)->setAction($this->getPanelURI())->setWorkflow(true)->appendChild('<p class="aphront-form-instructions">You can regenerate this ' . 'certificate, which will invalidate the old certificate and create ' . 'a new one.</p>')->appendChild(id(new AphrontFormSubmitControl())->setValue('Regenerate Certificate'));
$regen = new AphrontPanelView();
$regen->setHeader('Regenerate Certificate');
$regen->appendChild($regen_form);
$regen->setWidth(AphrontPanelView::WIDTH_FORM);
return array($notice, $cert, $regen);
}
示例14: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$phid = $request->getURIData('phid');
$handle = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
if (!$handle->isComplete()) {
return new Aphront404Response();
}
$flag = PhabricatorFlagQuery::loadUserFlag($viewer, $phid);
if (!$flag) {
$flag = new PhabricatorFlag();
$flag->setOwnerPHID($viewer->getPHID());
$flag->setType($handle->getType());
$flag->setObjectPHID($handle->getPHID());
$flag->setReasonPHID($viewer->getPHID());
}
if ($request->isDialogFormPost()) {
$flag->setColor($request->getInt('color'));
$flag->setNote($request->getStr('note'));
$flag->save();
return id(new AphrontReloadResponse())->setURI('/flag/');
}
$type_name = $handle->getTypeName();
$dialog = new AphrontDialogView();
$dialog->setUser($viewer);
$dialog->setTitle(pht('Flag %s', $type_name));
require_celerity_resource('phabricator-flag-css');
$form = new PHUIFormLayoutView();
$is_new = !$flag->getID();
if ($is_new) {
$form->appendChild(hsprintf('<p>%s</p><br />', pht('You can flag this %s if you want to remember to look ' . 'at it later.', $type_name)));
}
$radio = new AphrontFormRadioButtonControl();
foreach (PhabricatorFlagColor::getColorNameMap() as $color => $text) {
$class = 'phabricator-flag-radio phabricator-flag-color-' . $color;
$radio->addButton($color, $text, '', $class);
}
$form->appendChild($radio->setName('color')->setLabel(pht('Flag Color'))->setValue($flag->getColor()))->appendChild(id(new AphrontFormTextAreaControl())->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)->setName('note')->setLabel(pht('Note'))->setValue($flag->getNote()));
$dialog->appendChild($form);
$dialog->addCancelButton($handle->getURI());
$dialog->addSubmitButton($is_new ? pht('Create Flag') : pht('Save'));
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例15: handleRequest
public function handleRequest(AphrontRequest $request)
{
$this->requireApplicationCapability(AuthManageProvidersCapability::CAPABILITY);
$viewer = $request->getUser();
$config_id = $request->getURIData('id');
$action = $request->getURIData('action');
$config = id(new PhabricatorAuthProviderConfigQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($config_id))->executeOne();
if (!$config) {
return new Aphront404Response();
}
$is_enable = $action === 'enable';
if ($request->isDialogFormPost()) {
$xactions = array();
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())->setTransactionType(PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE)->setNewValue((int) $is_enable);
$editor = id(new PhabricatorAuthProviderConfigEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->applyTransactions($config, $xactions);
return id(new AphrontRedirectResponse())->setURI($this->getApplicationURI());
}
if ($is_enable) {
$title = pht('Enable Provider?');
if ($config->getShouldAllowRegistration()) {
$body = pht('Do you want to enable this provider? Users will be able to use ' . 'their existing external accounts to register new Phabricator ' . 'accounts and log in using linked accounts.');
} else {
$body = pht('Do you want to enable this provider? Users will be able to log ' . 'in to Phabricator using linked accounts.');
}
$button = pht('Enable Provider');
} else {
// TODO: We could tailor this a bit more. In particular, we could
// check if this is the last provider and either prevent if from
// being disabled or force the user through like 35 prompts. We could
// also check if it's the last provider linked to the acting user's
// account and pop a warning like "YOU WILL NO LONGER BE ABLE TO LOGIN
// YOU GOOF, YOU PROBABLY DO NOT MEAN TO DO THIS". None of this is
// critical and we can wait to see how users manage to shoot themselves
// in the feet. Shortly, `bin/auth` will be able to recover from these
// types of mistakes.
$title = pht('Disable Provider?');
$body = pht('Do you want to disable this provider? Users will not be able to ' . 'register or log in using linked accounts. If there are any users ' . 'without other linked authentication mechanisms, they will no longer ' . 'be able to log in. If you disable all providers, no one will be ' . 'able to log in.');
$button = pht('Disable Provider');
}
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle($title)->appendChild($body)->addCancelButton($this->getApplicationURI())->addSubmitButton($button);
return id(new AphrontDialogResponse())->setDialog($dialog);
}