1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 03:02:43 +01:00
phorge-phorge/src/applications/people/controller/settings/PhabricatorUserSettingsController.php

103 lines
2.9 KiB
PHP
Raw Normal View History

2011-02-06 07:36:21 +01:00
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorUserSettingsController extends PhabricatorPeopleController {
private $page;
private $pages;
2011-02-06 07:36:21 +01:00
public function willProcessRequest(array $data) {
$this->page = idx($data, 'page');
}
public function processRequest() {
$request = $this->getRequest();
$this->pages = array(
'account' => 'Account',
'email' => 'Email',
2011-02-06 07:36:21 +01:00
// 'password' => 'Password',
'conduit' => 'Conduit Certificate',
2011-02-06 07:36:21 +01:00
);
$oauth_providers = PhabricatorOAuthProvider::getAllProviders();
foreach ($oauth_providers as $provider) {
if (!$provider->isProviderEnabled()) {
continue;
}
$key = $provider->getProviderKey();
$name = $provider->getProviderName();
$this->pages[$key] = $name.' Account';
}
if (empty($this->pages[$this->page])) {
$this->page = key($this->pages);
2011-02-06 07:36:21 +01:00
}
switch ($this->page) {
2011-02-06 08:56:06 +01:00
case 'account':
$delegate = new PhabricatorUserAccountSettingsPanelController($request);
2011-02-06 08:56:06 +01:00
break;
case 'email':
$delegate = new PhabricatorUserEmailSettingsPanelController($request);
break;
case 'conduit':
$delegate = new PhabricatorUserConduitSettingsPanelController($request);
break;
2011-02-06 07:36:21 +01:00
default:
if (empty($this->pages[$this->page])) {
return new Aphront404Response();
}
$delegate = new PhabricatorUserOAuthSettingsPanelController($request);
$delegate->setOAuthProvider($oauth_providers[$this->page]);
2011-02-06 07:36:21 +01:00
}
$response = $this->delegateToController($delegate);
2011-02-06 07:36:21 +01:00
if ($response instanceof AphrontView) {
$sidenav = $this->renderSideNav();
$sidenav->appendChild($response);
return $this->buildStandardPageResponse(
$sidenav,
array(
'title' => 'Account Settings',
));
} else {
return $response;
}
}
private function renderSideNav() {
2011-02-06 07:36:21 +01:00
$sidenav = new AphrontSideNavView();
foreach ($this->pages as $page => $name) {
2011-02-06 07:36:21 +01:00
$sidenav->addNavItem(
phutil_render_tag(
'a',
array(
'href' => '/settings/page/'.$page.'/',
'class' => ($page == $this->page)
? 'aphront-side-nav-selected'
: null,
),
phutil_escape_html($name)));
}
return $sidenav;
}
}