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() { public function processRequest() {
return new Aphront404Response();
if ($this->username) { if ($this->username) {
$user = id(new PhabricatorUser())->loadOneWhere( $user = id(new PhabricatorUser())->loadOneWhere(
'userName = %s', 'userName = %s',

View file

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

View file

@ -30,7 +30,8 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
$user = $request->getUser(); $user = $request->getUser();
$pages = array( $pages = array(
'account' => 'Account', 'account' => 'Account',
'email' => 'Email',
// 'password' => 'Password', // 'password' => 'Password',
// 'facebook' => 'Facebook Account', // 'facebook' => 'Facebook Account',
'arcanist' => 'Arcanist Certificate', 'arcanist' => 'Arcanist Certificate',
@ -42,6 +43,11 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
if ($request->isFormPost()) { if ($request->isFormPost()) {
switch ($this->page) { switch ($this->page) {
case 'email':
$user->setEmail($request->getStr('email'));
$user->save();
return id(new AphrontRedirectResponse())
->setURI('/settings/page/email/?saved=true');
case 'arcanist': case 'arcanist':
if (!$request->isDialogFormPost()) { if (!$request->isDialogFormPost()) {
@ -93,6 +99,9 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
case 'account': case 'account':
$content = $this->renderAccountForm(); $content = $this->renderAccountForm();
break; break;
case 'email':
$content = $this->renderEmailForm();
break;
default: default:
$content = 'derp derp'; $content = 'derp derp';
break; break;
@ -195,10 +204,6 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
id(new AphrontFormStaticControl()) id(new AphrontFormStaticControl())
->setLabel('Username') ->setLabel('Username')
->setValue($user->getUsername())) ->setValue($user->getUsername()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Email')
->setValue($user->getEmail()))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Real Name') ->setLabel('Real Name')
@ -235,4 +240,42 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
return $panel->render(); 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();
}
} }