1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-20 13:52:40 +01:00

Add email to settings. Disable arbitrary user editing.

Summary:

Test Plan:

Reviewers:

CC:
This commit is contained in:
epriestley 2011-02-19 16:46:14 -08:00
parent 2aece70eaf
commit 490280e6eb
3 changed files with 55 additions and 8 deletions

View file

@ -26,6 +26,8 @@ class PhabricatorPeopleEditController extends PhabricatorPeopleController {
public function processRequest() {
return new Aphront404Response();
if ($this->username) {
$user = id(new PhabricatorUser())->loadOneWhere(
'userName = %s',

View file

@ -35,6 +35,7 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController {
'href' => '/p/'.$user->getUsername().'/',
),
'View Profile'),
/*
phutil_render_tag(
'a',
array(
@ -42,6 +43,7 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController {
'href' => '/people/edit/'.$user->getUsername().'/',
),
'Edit'),
*/
);
}
@ -52,7 +54,7 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController {
'Username',
'Real Name',
'',
'',
// '',
));
$table->setColumnClasses(
array(
@ -60,13 +62,13 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController {
null,
'wide',
'action',
'action',
// 'action',
));
$panel = new AphrontPanelView();
$panel->appendChild($table);
$panel->setHeader('People');
$panel->setCreateButton('Create New User', '/people/edit/');
// $panel->setCreateButton('Create New User', '/people/edit/');
return $this->buildStandardPageResponse($panel, array(
'title' => 'People',

View file

@ -31,6 +31,7 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
$pages = array(
'account' => 'Account',
'email' => 'Email',
// 'password' => 'Password',
// 'facebook' => 'Facebook Account',
'arcanist' => 'Arcanist Certificate',
@ -42,6 +43,11 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
if ($request->isFormPost()) {
switch ($this->page) {
case 'email':
$user->setEmail($request->getStr('email'));
$user->save();
return id(new AphrontRedirectResponse())
->setURI('/settings/page/email/?saved=true');
case 'arcanist':
if (!$request->isDialogFormPost()) {
@ -93,6 +99,9 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
case 'account':
$content = $this->renderAccountForm();
break;
case 'email':
$content = $this->renderEmailForm();
break;
default:
$content = 'derp derp';
break;
@ -195,10 +204,6 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
id(new AphrontFormStaticControl())
->setLabel('Username')
->setValue($user->getUsername()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Email')
->setValue($user->getEmail()))
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Real Name')
@ -235,4 +240,42 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
return $panel->render();
}
private function renderEmailForm() {
$request = $this->getRequest();
$user = $request->getUser();
if ($request->getStr('saved')) {
$notice = new AphrontErrorView();
$notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$notice->setTitle('Changed Saved');
$notice->appendChild('<p>Your changes have been saved.</p>');
$notice = $notice->render();
} else {
$notice = null;
}
$form = new AphrontFormView();
$form
->setUser($user)
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Email')
->setName('email')
->setCaption(
'Note: there is no email validation yet; double-check your '.
'typing.')
->setValue($user->getEmail()))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Save'));
$panel = new AphrontPanelView();
$panel->setHeader('Email Settings');
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->appendChild($form);
return $notice.$panel->render();
}
}