1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Modernize People

Summary: Adds Crumbs, pht's, and checkout out mobile.

Test Plan: Added, removed people. Changed roles, checked iOS and Chrome.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5052
This commit is contained in:
Chad Little 2013-02-21 14:10:22 -08:00
parent e6281c3db0
commit 3d6500823c
6 changed files with 261 additions and 196 deletions

View file

@ -29,7 +29,7 @@ final class PhabricatorEmailVerificationController
array( array(
'href' => '/', 'href' => '/',
), ),
'Continue to Phabricator'); pht('Continue to Phabricator'));
$home_link = hsprintf( $home_link = hsprintf(
'<br /><p><strong>%s</strong></p>', '<br /><p><strong>%s</strong></p>',
$home_link); $home_link);
@ -39,26 +39,28 @@ final class PhabricatorEmailVerificationController
array( array(
'href' => '/settings/panel/email/', 'href' => '/settings/panel/email/',
), ),
'Return to Email Settings'); pht('Return to Email Settings'));
$settings_link = hsprintf( $settings_link = hsprintf(
'<br /><p><strong>%s</strong></p>', '<br /><p><strong>%s</strong></p>',
$settings_link); $settings_link);
if (!$email) { if (!$email) {
$content = id(new AphrontErrorView()) $content = id(new AphrontErrorView())
->setTitle('Unable To Verify') ->setTitle(pht('Unable To Verify'))
->appendChild(phutil_tag( ->appendChild(phutil_tag(
'p', 'p',
array(), array(),
'The verification code is incorrect, the email address has been '. pht('The verification code is incorrect, the email address has been '.
'removed, or the email address is owned by another user. Make '. 'removed, or the email address is owned by another user. Make '.
'sure you followed the link in the email correctly.')); 'sure you followed the link in the email correctly.')));
} else if ($email->getIsVerified()) { } else if ($email->getIsVerified()) {
$inst = pht('This email address has already been verified.');
$content = id(new AphrontErrorView()) $content = id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_NOTICE) ->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
->setTitle('Address Already Verified') ->setTitle(pht('Address Already Verified'))
->appendChild(hsprintf( ->appendChild(hsprintf(
'<p>This email address has already been verified.</p>%s', '<p>%s</p>%s',
$inst,
$settings_link)); $settings_link));
} else { } else {
@ -67,11 +69,13 @@ final class PhabricatorEmailVerificationController
$email->save(); $email->save();
unset($guard); unset($guard);
$inst = pht('This email address has now been verified. Thanks!');
$content = id(new AphrontErrorView()) $content = id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_NOTICE) ->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
->setTitle('Address Verified') ->setTitle(pht('Address Verified'))
->appendChild(hsprintf( ->appendChild(hsprintf(
'<p>This email address has now been verified. Thanks!</p>%s%s', '<p>%s</p>%s%s',
$inst,
$home_link, $home_link,
$settings_link)); $settings_link));
} }
@ -79,7 +83,8 @@ final class PhabricatorEmailVerificationController
return $this->buildApplicationPage( return $this->buildApplicationPage(
$content, $content,
array( array(
'title' => 'Verify Email', 'title' => pht('Verify Email'),
'device' => true,
)); ));
} }

View file

@ -9,22 +9,42 @@ abstract class PhabricatorPeopleController extends PhabricatorController {
$is_admin = $this->getRequest()->getUser()->getIsAdmin(); $is_admin = $this->getRequest()->getUser()->getIsAdmin();
if ($is_admin) { if ($is_admin) {
$nav->addLabel('Create Users'); $nav->addLabel(pht('User Administration'));
$nav->addFilter('edit', 'Create New User'); $nav->addFilter('edit', pht('Create New User'));
if (PhabricatorEnv::getEnvConfig('ldap.auth-enabled') === true) { if (PhabricatorEnv::getEnvConfig('ldap.auth-enabled') === true) {
$nav->addFilter('ldap', 'Import from LDAP'); $nav->addFilter('ldap', pht('Import from LDAP'));
} }
} }
$nav->addLabel('Directory'); $nav->addFilter('people',
$nav->addFilter('people', 'User Directory', $this->getApplicationURI()); pht('User Directory'),
$this->getApplicationURI());
if ($is_admin) { if ($is_admin) {
$nav->addLabel('Logs'); $nav->addFilter('logs', pht('Activity Logs'));
$nav->addFilter('logs', 'Activity Logs');
} }
return $nav; return $nav;
} }
public function buildApplicationMenu() {
return $this->buildSideNavView()->getMenu();
}
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
// I'm sure this copypasty is wrong.
$is_admin = $this->getRequest()->getUser()->getIsAdmin();
if ($is_admin) {
$crumbs->addAction(
id(new PhabricatorMenuItemView())
->setName(pht('Create New User'))
->setHref($this->getApplicationURI('edit'))
->setIcon('create'));
}
return $crumbs;
}
} }

View file

@ -20,27 +20,41 @@ final class PhabricatorPeopleEditController
$request = $this->getRequest(); $request = $this->getRequest();
$admin = $request->getUser(); $admin = $request->getUser();
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
if ($this->id) { if ($this->id) {
$user = id(new PhabricatorUser())->load($this->id); $user = id(new PhabricatorUser())->load($this->id);
if (!$user) { if (!$user) {
return new Aphront404Response(); return new Aphront404Response();
} }
$base_uri = '/people/edit/'.$user->getID().'/'; $base_uri = '/people/edit/'.$user->getID().'/';
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht('Edit User'))
->setHref('/people/edit/'));
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName($user->getFullName())
->setHref($base_uri));
} else { } else {
$user = new PhabricatorUser(); $user = new PhabricatorUser();
$base_uri = '/people/edit/'; $base_uri = '/people/edit/';
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht('Create New User'))
->setHref($base_uri));
} }
$nav = new AphrontSideNavFilterView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($base_uri)); $nav->setBaseURI(new PhutilURI($base_uri));
$nav->addLabel('User Information'); $nav->addLabel(pht('User Information'));
$nav->addFilter('basic', 'Basic Information'); $nav->addFilter('basic', pht('Basic Information'));
$nav->addFilter('role', 'Edit Roles'); $nav->addFilter('role', pht('Edit Roles'));
$nav->addFilter('cert', 'Conduit Certificate'); $nav->addFilter('cert', pht('Conduit Certificate'));
$nav->addFilter('profile', 'View Profile', '/p/'.$user->getUsername().'/'); $nav->addFilter('profile',
$nav->addLabel('Special'); pht('View Profile'), '/p/'.$user->getUsername().'/');
$nav->addFilter('rename', 'Change Username'); $nav->addLabel(pht('Special'));
$nav->addFilter('delete', 'Delete User'); $nav->addFilter('rename', pht('Change Username'));
$nav->addFilter('delete', pht('Delete User'));
if (!$user->getID()) { if (!$user->getID()) {
$this->view = 'basic'; $this->view = 'basic';
@ -53,9 +67,9 @@ final class PhabricatorPeopleEditController
if ($request->getStr('saved')) { if ($request->getStr('saved')) {
$notice = new AphrontErrorView(); $notice = new AphrontErrorView();
$notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE); $notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$notice->setTitle('Changes Saved'); $notice->setTitle(pht('Changes Saved'));
$notice->appendChild( $notice->appendChild(
phutil_tag('p', array(), 'Your changes were saved.')); phutil_tag('p', array(), pht('Your changes were saved.')));
$content[] = $notice; $content[] = $notice;
} }
@ -93,10 +107,12 @@ final class PhabricatorPeopleEditController
$nav->appendChild($content); $nav->appendChild($content);
} }
$nav->setCrumbs($crumbs);
return $this->buildApplicationPage( return $this->buildApplicationPage(
$nav, $nav,
array( array(
'title' => 'Edit User', 'title' => pht('Edit User'),
'device' => true,
)); ));
} }
@ -123,10 +139,10 @@ final class PhabricatorPeopleEditController
$new_email = $request->getStr('email'); $new_email = $request->getStr('email');
if (!strlen($new_email)) { if (!strlen($new_email)) {
$errors[] = 'Email is required.'; $errors[] = pht('Email is required.');
$e_email = 'Required'; $e_email = pht('Required');
} else if (!PhabricatorUserEmail::isAllowedAddress($new_email)) { } else if (!PhabricatorUserEmail::isAllowedAddress($new_email)) {
$e_email = 'Invalid'; $e_email = pht('Invalid');
$errors[] = PhabricatorUserEmail::describeAllowedAddresses(); $errors[] = PhabricatorUserEmail::describeAllowedAddresses();
} else { } else {
$e_email = null; $e_email = null;
@ -136,18 +152,18 @@ final class PhabricatorPeopleEditController
$user->setRealName($request->getStr('realname')); $user->setRealName($request->getStr('realname'));
if (!strlen($user->getUsername())) { if (!strlen($user->getUsername())) {
$errors[] = "Username is required."; $errors[] = pht("Username is required.");
$e_username = 'Required'; $e_username = pht('Required');
} else if (!PhabricatorUser::validateUsername($user->getUsername())) { } else if (!PhabricatorUser::validateUsername($user->getUsername())) {
$errors[] = PhabricatorUser::describeValidUsername(); $errors[] = PhabricatorUser::describeValidUsername();
$e_username = 'Invalid'; $e_username = pht('Invalid');
} else { } else {
$e_username = null; $e_username = null;
} }
if (!strlen($user->getRealName())) { if (!strlen($user->getRealName())) {
$errors[] = 'Real name is required.'; $errors[] = pht('Real name is required.');
$e_realname = 'Required'; $e_realname = pht('Required');
} else { } else {
$e_realname = null; $e_realname = null;
} }
@ -184,7 +200,7 @@ final class PhabricatorPeopleEditController
->setURI('/people/edit/'.$user->getID().'/?saved=true'); ->setURI('/people/edit/'.$user->getID().'/?saved=true');
return $response; return $response;
} catch (AphrontQueryDuplicateKeyException $ex) { } catch (AphrontQueryDuplicateKeyException $ex) {
$errors[] = 'Username and email must be unique.'; $errors[] = pht('Username and email must be unique.');
$same_username = id(new PhabricatorUser()) $same_username = id(new PhabricatorUser())
->loadOneWhere('username = %s', $user->getUsername()); ->loadOneWhere('username = %s', $user->getUsername());
@ -192,11 +208,11 @@ final class PhabricatorPeopleEditController
->loadOneWhere('address = %s', $new_email); ->loadOneWhere('address = %s', $new_email);
if ($same_username) { if ($same_username) {
$e_username = 'Duplicate'; $e_username = pht('Duplicate');
} }
if ($same_email) { if ($same_email) {
$e_email = 'Duplicate'; $e_email = pht('Duplicate');
} }
} }
} }
@ -205,7 +221,7 @@ final class PhabricatorPeopleEditController
$error_view = null; $error_view = null;
if ($errors) { if ($errors) {
$error_view = id(new AphrontErrorView()) $error_view = id(new AphrontErrorView())
->setTitle('Form Errors') ->setTitle(pht('Form Errors'))
->setErrors($errors); ->setErrors($errors);
} }
@ -226,14 +242,14 @@ final class PhabricatorPeopleEditController
$form $form
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Username') ->setLabel(pht('Username'))
->setName('username') ->setName('username')
->setValue($user->getUsername()) ->setValue($user->getUsername())
->setError($e_username) ->setError($e_username)
->setDisabled($is_immutable)) ->setDisabled($is_immutable))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Real Name') ->setLabel(pht('Real Name'))
->setName('realname') ->setName('realname')
->setValue($user->getRealName()) ->setValue($user->getRealName())
->setError($e_realname)); ->setError($e_realname));
@ -241,7 +257,7 @@ final class PhabricatorPeopleEditController
if (!$user->getID()) { if (!$user->getID()) {
$form->appendChild( $form->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Email') ->setLabel(pht('Email'))
->setName('email') ->setName('email')
->setDisabled($is_immutable) ->setDisabled($is_immutable)
->setValue($new_email) ->setValue($new_email)
@ -250,14 +266,15 @@ final class PhabricatorPeopleEditController
} else { } else {
$email = $user->loadPrimaryEmail(); $email = $user->loadPrimaryEmail();
if ($email) { if ($email) {
$status = $email->getIsVerified() ? 'Verified' : 'Unverified'; $status = $email->getIsVerified() ?
pht('Verified') : pht('Unverified');
} else { } else {
$status = 'No Email Address'; $status = pht('No Email Address');
} }
$form->appendChild( $form->appendChild(
id(new AphrontFormStaticControl()) id(new AphrontFormStaticControl())
->setLabel('Email') ->setLabel(pht('Email'))
->setValue($status)); ->setValue($status));
$form->appendChild( $form->appendChild(
@ -265,7 +282,7 @@ final class PhabricatorPeopleEditController
->addCheckbox( ->addCheckbox(
'welcome', 'welcome',
1, 1,
'Re-send "Welcome to Phabricator" email.', pht('Re-send "Welcome to Phabricator" email.'),
false)); false));
} }
@ -276,39 +293,39 @@ final class PhabricatorPeopleEditController
$form $form
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setLabel('Role') ->setLabel(pht('Role'))
->setName('role') ->setName('role')
->setValue('user') ->setValue('user')
->setOptions( ->setOptions(
array( array(
'user' => 'Normal User', 'user' => pht('Normal User'),
'agent' => 'System Agent', 'agent' => pht('System Agent'),
)) ))
->setCaption( ->setCaption(
'You can create a "system agent" account for bots, scripts, '. pht('You can create a "system agent" account for bots, '.
'etc.')) 'scripts, etc.')))
->appendChild( ->appendChild(
id(new AphrontFormCheckboxControl()) id(new AphrontFormCheckboxControl())
->addCheckbox( ->addCheckbox(
'welcome', 'welcome',
1, 1,
'Send "Welcome to Phabricator" email.', pht('Send "Welcome to Phabricator" email.'),
$welcome_checked)); $welcome_checked));
} else { } else {
$roles = array(); $roles = array();
if ($user->getIsSystemAgent()) { if ($user->getIsSystemAgent()) {
$roles[] = 'System Agent'; $roles[] = pht('System Agent');
} }
if ($user->getIsAdmin()) { if ($user->getIsAdmin()) {
$roles[] = 'Admin'; $roles[] = pht('Admin');
} }
if ($user->getIsDisabled()) { if ($user->getIsDisabled()) {
$roles[] = 'Disabled'; $roles[] = pht('Disabled');
} }
if (!$roles) { if (!$roles) {
$roles[] = 'Normal User'; $roles[] = pht('Normal User');
} }
$roles = implode(', ', $roles); $roles = implode(', ', $roles);
@ -322,16 +339,17 @@ final class PhabricatorPeopleEditController
$form $form
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Save')); ->setValue(pht('Save')));
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
if ($user->getID()) { if ($user->getID()) {
$panel->setHeader('Edit User'); $panel->setHeader(pht('Edit User'));
} else { } else {
$panel->setHeader('Create New User'); $panel->setHeader(pht('Create New User'));
} }
$panel->appendChild($form); $panel->appendChild($form);
$panel->setNoBackground();
$panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->setWidth(AphrontPanelView::WIDTH_FORM);
return array($error_view, $panel); return array($error_view, $panel);
@ -355,7 +373,7 @@ final class PhabricatorPeopleEditController
$logs = array(); $logs = array();
if ($is_self) { if ($is_self) {
$errors[] = "You can not edit your own role."; $errors[] = pht("You can not edit your own role.");
} else { } else {
$new_admin = (bool)$request->getBool('is_admin'); $new_admin = (bool)$request->getBool('is_admin');
$old_admin = (bool)$user->getIsAdmin(); $old_admin = (bool)$user->getIsAdmin();
@ -383,7 +401,7 @@ final class PhabricatorPeopleEditController
$error_view = null; $error_view = null;
if ($errors) { if ($errors) {
$error_view = id(new AphrontErrorView()) $error_view = id(new AphrontErrorView())
->setTitle('Form Errors') ->setTitle(pht('Form Errors'))
->setErrors($errors); ->setErrors($errors);
} }
@ -393,9 +411,9 @@ final class PhabricatorPeopleEditController
->setAction($request->getRequestURI()->alter('saved', null)); ->setAction($request->getRequestURI()->alter('saved', null));
if ($is_self) { if ($is_self) {
$inst = pht('NOTE: You can not edit your own role.');
$form->appendChild(hsprintf( $form->appendChild(hsprintf(
'<p class="aphront-form-instructions">NOTE: You can not edit your own '. '<p class="aphront-form-instructions">%s</p>', $inst));
'role.</p>'));
} }
$form $form
@ -405,7 +423,7 @@ final class PhabricatorPeopleEditController
->addCheckbox( ->addCheckbox(
'is_admin', 'is_admin',
1, 1,
'Administrator', pht('Administrator'),
$user->getIsAdmin()) $user->getIsAdmin())
->setDisabled($is_self)) ->setDisabled($is_self))
->appendChild( ->appendChild(
@ -413,7 +431,7 @@ final class PhabricatorPeopleEditController
->addCheckbox( ->addCheckbox(
'is_disabled', 'is_disabled',
1, 1,
'Disabled', pht('Disabled'),
$user->getIsDisabled()) $user->getIsDisabled())
->setDisabled($is_self)) ->setDisabled($is_self))
->appendChild( ->appendChild(
@ -421,7 +439,7 @@ final class PhabricatorPeopleEditController
->addCheckbox( ->addCheckbox(
'is_agent', 'is_agent',
1, 1,
'System Agent (Bot/Script User)', pht('System Agent (Bot/Script User)'),
$user->getIsSystemAgent()) $user->getIsSystemAgent())
->setDisabled(true)); ->setDisabled(true));
@ -429,12 +447,13 @@ final class PhabricatorPeopleEditController
$form $form
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Edit Role')); ->setValue(pht('Edit Role')));
} }
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->setHeader('Edit Role'); $panel->setHeader(pht('Edit Role'));
$panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->setNoBackground();
$panel->appendChild($form); $panel->appendChild($form);
return array($error_view, $panel); return array($error_view, $panel);
@ -444,37 +463,38 @@ final class PhabricatorPeopleEditController
$request = $this->getRequest(); $request = $this->getRequest();
$admin = $request->getUser(); $admin = $request->getUser();
$inst = pht('You can use this certificate '.
'to write scripts or bots which interface with Phabricator over '.
'Conduit.');
$form = new AphrontFormView(); $form = new AphrontFormView();
$form $form
->setUser($admin) ->setUser($admin)
->setAction($request->getRequestURI()) ->setAction($request->getRequestURI())
->appendChild(hsprintf( ->appendChild(hsprintf(
'<p class="aphront-form-instructions">You can use this certificate '. '<p class="aphront-form-instructions">%s</p>', $inst));
'to write scripts or bots which interface with Phabricator over '.
'Conduit.</p>'));
if ($user->getIsSystemAgent()) { if ($user->getIsSystemAgent()) {
$form $form
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Username') ->setLabel(pht('Username'))
->setValue($user->getUsername())) ->setValue($user->getUsername()))
->appendChild( ->appendChild(
id(new AphrontFormTextAreaControl()) id(new AphrontFormTextAreaControl())
->setLabel('Certificate') ->setLabel(pht('Certificate'))
->setValue($user->getConduitCertificate())); ->setValue($user->getConduitCertificate()));
} else { } else {
$form->appendChild( $form->appendChild(
id(new AphrontFormStaticControl()) id(new AphrontFormStaticControl())
->setLabel('Certificate') ->setLabel(pht('Certificate'))
->setValue( ->setValue(
'You may only view the certificates of System Agents.')); pht('You may only view the certificates of System Agents.')));
} }
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->setHeader('Conduit Certificate'); $panel->setHeader(pht('Conduit Certificate'));
$panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->setNoBackground();
$panel->appendChild($form); $panel->appendChild($form);
return array($panel); return array($panel);
@ -492,13 +512,13 @@ final class PhabricatorPeopleEditController
$username = $request->getStr('username'); $username = $request->getStr('username');
if (!strlen($username)) { if (!strlen($username)) {
$e_username = 'Required'; $e_username = pht('Required');
$errors[] = 'New username is required.'; $errors[] = pht('New username is required.');
} else if ($username == $user->getUsername()) { } else if ($username == $user->getUsername()) {
$e_username = 'Invalid'; $e_username = pht('Invalid');
$errors[] = 'New username must be different from old username.'; $errors[] = pht('New username must be different from old username.');
} else if (!PhabricatorUser::validateUsername($username)) { } else if (!PhabricatorUser::validateUsername($username)) {
$e_username = 'Invalid'; $e_username = pht('Invalid');
$errors[] = PhabricatorUser::describeValidUsername(); $errors[] = PhabricatorUser::describeValidUsername();
} }
@ -512,61 +532,67 @@ final class PhabricatorPeopleEditController
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI($request->getRequestURI()->alter('saved', true)); ->setURI($request->getRequestURI()->alter('saved', true));
} catch (AphrontQueryDuplicateKeyException $ex) { } catch (AphrontQueryDuplicateKeyException $ex) {
$e_username = 'Not Unique'; $e_username = pht('Not Unique');
$errors[] = 'Another user already has that username.'; $errors[] = pht('Another user already has that username.');
} }
} }
} }
if ($errors) { if ($errors) {
$errors = id(new AphrontErrorView()) $errors = id(new AphrontErrorView())
->setTitle('Form Errors') ->setTitle(pht('Form Errors'))
->setErrors($errors); ->setErrors($errors);
} else { } else {
$errors = null; $errors = null;
} }
$inst1 = pht('Be careful when renaming users!');
$inst2 = pht('The old username will no longer be tied to the user, so '.
'anything which uses it (like old commit messages) will no longer '.
'associate correctly. And if you give a user a username which some '.
'other user used to have, username lookups will begin returning '.
'the wrong user.');
$inst3 = pht('It is generally safe to rename newly created users (and '.
'test users and so on), but less safe to rename established users '.
'and unsafe to reissue a username.');
$inst4 = pht('Users who rely on password auth will need to reset their '.
'passwordafter their username is changed (their username is part '.
'of the salt in the password hash). They will receive an email '.
'with instructions on how to do this.');
$form = new AphrontFormView(); $form = new AphrontFormView();
$form $form
->setUser($admin) ->setUser($admin)
->setAction($request->getRequestURI()) ->setAction($request->getRequestURI())
->appendChild(hsprintf( ->appendChild(hsprintf(
'<p class="aphront-form-instructions">'. '<p class="aphront-form-instructions">'.
'<strong>Be careful when renaming users!</strong> '. '<strong>%s</strong> '.
'The old username will no longer be tied to the user, so anything '. '%s'.
'which uses it (like old commit messages) will no longer associate '.
'correctly. And if you give a user a username which some other user '.
'used to have, username lookups will begin returning the wrong '.
'user.'.
'</p>'. '</p>'.
'<p class="aphront-form-instructions">'. '<p class="aphront-form-instructions">'.
'It is generally safe to rename newly created users (and test users '. '%s'.
'and so on), but less safe to rename established users and unsafe '.
'to reissue a username.'.
'</p>'. '</p>'.
'<p class="aphront-form-instructions">'. '<p class="aphront-form-instructions">'.
'Users who rely on password auth will need to reset their password '. '%s'.
'after their username is changed (their username is part of the '. '</p>', $inst1, $inst2, $inst3, $inst4))
'salt in the password hash). They will receive an email with '.
'instructions on how to do this.'.
'</p>'))
->appendChild( ->appendChild(
id(new AphrontFormStaticControl()) id(new AphrontFormStaticControl())
->setLabel('Old Username') ->setLabel(pht('Old Username'))
->setValue($user->getUsername())) ->setValue($user->getUsername()))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('New Username') ->setLabel(pht('New Username'))
->setValue($username) ->setValue($username)
->setName('username') ->setName('username')
->setError($e_username)) ->setError($e_username))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Change Username')); ->setValue(pht('Change Username')));
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->setHeader('Change Username'); $panel->setHeader(pht('Change Username'));
$panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->setNoBackground();
$panel->appendChild($form); $panel->appendChild($form);
return array($errors, $panel); return array($errors, $panel);
@ -576,13 +602,15 @@ final class PhabricatorPeopleEditController
$request = $this->getRequest(); $request = $this->getRequest();
$admin = $request->getUser(); $admin = $request->getUser();
$far1 = pht('As you stare into the gaping maw of the abyss, something '.
'hold you back.');
$far2 = pht('You can not delete your own account.');
if ($user->getPHID() == $admin->getPHID()) { if ($user->getPHID() == $admin->getPHID()) {
$error = new AphrontErrorView(); $error = new AphrontErrorView();
$error->setTitle('You Shall Journey No Farther'); $error->setTitle(pht('You Shall Journey No Farther'));
$error->appendChild(hsprintf( $error->appendChild(hsprintf(
'<p>As you stare into the gaping maw of the abyss, something holds '. '<p>%s</p><p>%s</p>', $far1, $far2));
'you back.</p>'.
'<p>You can not delete your own account.</p>'));
return $error; return $error;
} }
@ -594,11 +622,11 @@ final class PhabricatorPeopleEditController
$username = $request->getStr('username'); $username = $request->getStr('username');
if (!strlen($username)) { if (!strlen($username)) {
$e_username = 'Required'; $e_username = pht('Required');
$errors[] = 'You must type the username to confirm deletion.'; $errors[] = pht('You must type the username to confirm deletion.');
} else if ($username != $user->getUsername()) { } else if ($username != $user->getUsername()) {
$e_username = 'Invalid'; $e_username = pht('Invalid');
$errors[] = 'You must type the username correctly.'; $errors[] = pht('You must type the username correctly.');
} }
if (!$errors) { if (!$errors) {
@ -612,49 +640,53 @@ final class PhabricatorPeopleEditController
if ($errors) { if ($errors) {
$errors = id(new AphrontErrorView()) $errors = id(new AphrontErrorView())
->setTitle('Form Errors') ->setTitle(pht('Form Errors'))
->setErrors($errors); ->setErrors($errors);
} else { } else {
$errors = null; $errors = null;
} }
$str1 = pht('Be careful when deleting users!');
$str2 = pht('If this user interacted with anything, it is generally '.
'better to disable them, not delete them. If you delete them, it will '.
'no longer be possible to search for their objects, for example, '.
'and you will lose other information about their history. Disabling '.
'them instead will prevent them from logging in but not destroy '.
'any of their data.');
$str3 = pht('It is generally safe to delete newly created users (and '.
'test users and so on), but less safe to delete established users. '.
'If possible, disable them instead.');
$form = new AphrontFormView(); $form = new AphrontFormView();
$form $form
->setUser($admin) ->setUser($admin)
->setAction($request->getRequestURI()) ->setAction($request->getRequestURI())
->appendChild(hsprintf( ->appendChild(hsprintf(
'<p class="aphront-form-instructions">'. '<p class="aphront-form-instructions">'.
'<strong>Be careful when deleting users!</strong> '. '<strong>%s</strong> %s'.
'If this user interacted with anything, it is generally better '.
'to disable them, not delete them. If you delete them, it will '.
'no longer be possible to search for their objects, for example, '.
'and you will lose other information about their history. Disabling '.
'them instead will prevent them from logging in but not destroy '.
'any of their data.'.
'</p>'. '</p>'.
'<p class="aphront-form-instructions">'. '<p class="aphront-form-instructions">'.
'It is generally safe to delete newly created users (and test users '. '%s'.
'and so on), but less safe to delete established users. If '. '</p>', $str1, $str2, $str3))
'possible, disable them instead.'.
'</p>'))
->appendChild( ->appendChild(
id(new AphrontFormStaticControl()) id(new AphrontFormStaticControl())
->setLabel('Username') ->setLabel(pht('Username'))
->setValue($user->getUsername())) ->setValue($user->getUsername()))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Confirm') ->setLabel(pht('Confirm'))
->setValue($username) ->setValue($username)
->setName('username') ->setName('username')
->setCaption("Type the username again to confirm deletion.") ->setCaption(pht("Type the username again to confirm deletion."))
->setError($e_username)) ->setError($e_username))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Delete User')); ->setValue(pht('Delete User')));
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->setHeader('Delete User'); $panel->setHeader(pht('Delete User'));
$panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->setNoBackground();
$panel->appendChild($form); $panel->appendChild($form);
return array($errors, $panel); return array($errors, $panel);
@ -668,13 +700,13 @@ final class PhabricatorPeopleEditController
'article/User_Guide_Account_Roles.html'), 'article/User_Guide_Account_Roles.html'),
'target' => '_blank', 'target' => '_blank',
), ),
'User Guide: Account Roles'); pht('User Guide: Account Roles'));
return hsprintf( $inst = pht('For a detailed explanation of account roles, see %s.',
'<p class="aphront-form-instructions">'.
'For a detailed explanation of account roles, see %s.'.
'</p>',
$roles_link); $roles_link);
return hsprintf(
'<p class="aphront-form-instructions">%s</p>',
$inst);
} }
} }

View file

@ -22,23 +22,23 @@ final class PhabricatorPeopleLdapController
->setUser($admin) ->setUser($admin)
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('LDAP username') ->setLabel(pht('LDAP username'))
->setName('username')) ->setName('username'))
->appendChild( ->appendChild(
id(new AphrontFormPasswordControl()) id(new AphrontFormPasswordControl())
->setLabel('Password') ->setLabel(pht('Password'))
->setName('password')) ->setName('password'))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('LDAP query') ->setLabel(pht('LDAP query'))
->setCaption('A filter such as (objectClass=*)') ->setCaption(pht('A filter such as (objectClass=*)'))
->setName('query')) ->setName('query'))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Search')); ->setValue(pht('Search')));
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->setHeader('Import LDAP Users'); $panel->setHeader(pht('Import LDAP Users'));
$panel->appendChild($form); $panel->appendChild($form);
@ -59,7 +59,8 @@ final class PhabricatorPeopleLdapController
return $this->buildApplicationPage( return $this->buildApplicationPage(
$nav, $nav,
array( array(
'title' => 'Import Ldap Users', 'title' => pht('Import Ldap Users'),
'device' => true,
)); ));
} }
@ -71,8 +72,8 @@ final class PhabricatorPeopleLdapController
$panel = new AphrontErrorView(); $panel = new AphrontErrorView();
$panel->setSeverity(AphrontErrorView::SEVERITY_NOTICE); $panel->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$panel->setTitle("Import Successful"); $panel->setTitle(pht("Import Successful"));
$errors = array("Successfully imported users from LDAP"); $errors = array(pht("Successfully imported users from LDAP"));
foreach ($usernames as $username) { foreach ($usernames as $username) {
@ -92,9 +93,9 @@ final class PhabricatorPeopleLdapController
$ldap_info->setLDAPUsername($username); $ldap_info->setLDAPUsername($username);
$ldap_info->setUserID($user->getID()); $ldap_info->setUserID($user->getID());
$ldap_info->save(); $ldap_info->save();
$errors[] = 'Successfully added ' . $username; $errors[] = pht('Successfully added %s', $username);
} catch (Exception $ex) { } catch (Exception $ex) {
$errors[] = 'Failed to add ' . $username . ' ' . $ex->getMessage(); $errors[] = pht('Failed to add %s %s', $username, $ex->getMessage());
} }
} }
@ -127,23 +128,23 @@ final class PhabricatorPeopleLdapController
$table = new AphrontTableView($results); $table = new AphrontTableView($results);
$table->setHeaders( $table->setHeaders(
array( array(
'Username', pht('Username'),
'Email', pht('Email'),
'RealName', pht('Real Name'),
'Import?', pht('Import?'),
)); ));
$form->appendChild($table); $form->appendChild($table);
$form->setAction($request->getRequestURI() $form->setAction($request->getRequestURI()
->alter('import', 'true')->alter('search', null)) ->alter('import', 'true')->alter('search', null))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Import')); ->setValue(pht('Import')));
$panel->appendChild($form); $panel->appendChild($form);
} catch (Exception $ex) { } catch (Exception $ex) {
$error_view = new AphrontErrorView(); $error_view = new AphrontErrorView();
$error_view->setTitle('LDAP Search Failed'); $error_view->setTitle(pht('LDAP Search Failed'));
$error_view->setErrors(array($ex->getMessage())); $error_view->setErrors(array($ex->getMessage()));
return $error_view; return $error_view;
} }

View file

@ -29,20 +29,20 @@ final class PhabricatorPeopleListController
foreach ($users as $user) { foreach ($users as $user) {
$primary_email = $user->loadPrimaryEmail(); $primary_email = $user->loadPrimaryEmail();
if ($primary_email && $primary_email->getIsVerified()) { if ($primary_email && $primary_email->getIsVerified()) {
$email = 'Verified'; $email = pht('Verified');
} else { } else {
$email = 'Unverified'; $email = pht('Unverified');
} }
$status = array(); $status = array();
if ($user->getIsDisabled()) { if ($user->getIsDisabled()) {
$status[] = 'Disabled'; $status[] = pht('Disabled');
} }
if ($user->getIsAdmin()) { if ($user->getIsAdmin()) {
$status[] = 'Admin'; $status[] = pht('Admin');
} }
if ($user->getIsSystemAgent()) { if ($user->getIsSystemAgent()) {
$status[] = 'System Agent'; $status[] = pht('System Agent');
} }
$status = implode(', ', $status); $status = implode(', ', $status);
@ -64,19 +64,19 @@ final class PhabricatorPeopleListController
'class' => 'button grey small', 'class' => 'button grey small',
'href' => '/people/edit/'.$user->getID().'/', 'href' => '/people/edit/'.$user->getID().'/',
), ),
'Administrate User'), pht('Administrate User')),
); );
} }
$table = new AphrontTableView($rows); $table = new AphrontTableView($rows);
$table->setHeaders( $table->setHeaders(
array( array(
'Join Date', pht('Join Date'),
'Time', pht('Time'),
'Username', pht('Username'),
'Real Name', pht('Real Name'),
'Roles', pht('Roles'),
'Email', pht('Email'),
'', '',
)); ));
$table->setColumnClasses( $table->setColumnClasses(
@ -101,19 +101,12 @@ final class PhabricatorPeopleListController
)); ));
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->setHeader('People ('.number_format($count).')'); $panel->setHeader(pht('People (%d)', number_format($count)));
$panel->setNoBackground();
$panel->appendChild($table); $panel->appendChild($table);
$panel->appendChild($pager); $panel->appendChild($pager);
if ($is_admin) { if ($is_admin) {
$panel->addButton(
phutil_tag(
'a',
array(
'href' => '/people/edit/',
'class' => 'button green',
),
'Create New Account'));
if (PhabricatorEnv::getEnvConfig('ldap.auth-enabled')) { if (PhabricatorEnv::getEnvConfig('ldap.auth-enabled')) {
$panel->addButton( $panel->addButton(
phutil_tag( phutil_tag(
@ -122,18 +115,25 @@ final class PhabricatorPeopleListController
'href' => '/people/ldap/', 'href' => '/people/ldap/',
'class' => 'button green' 'class' => 'button green'
), ),
'Import from LDAP')); pht('Import from LDAP')));
} }
} }
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht('User Directory'))
->setHref('/people/'));
$nav = $this->buildSideNavView(); $nav = $this->buildSideNavView();
$nav->selectFilter('people'); $nav->selectFilter('people');
$nav->appendChild($panel); $nav->appendChild($panel);
$nav->setCrumbs($crumbs);
return $this->buildApplicationPage( return $this->buildApplicationPage(
$nav, $nav,
array( array(
'title' => 'People', 'title' => pht('People'),
'device' => true,
)); ));
} }
} }

View file

@ -44,44 +44,44 @@ final class PhabricatorPeopleLogsController
->setUser($user) ->setUser($user)
->appendChild( ->appendChild(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
->setLabel('Filter Actor') ->setLabel(pht('Filter Actor'))
->setName('actor') ->setName('actor')
->setLimit(1) ->setLimit(1)
->setValue($actor_value) ->setValue($actor_value)
->setDatasource('/typeahead/common/accounts/')) ->setDatasource('/typeahead/common/accounts/'))
->appendChild( ->appendChild(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
->setLabel('Filter User') ->setLabel(pht('Filter User'))
->setName('user') ->setName('user')
->setLimit(1) ->setLimit(1)
->setValue($user_value) ->setValue($user_value)
->setDatasource('/typeahead/common/accounts/')) ->setDatasource('/typeahead/common/accounts/'))
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setLabel('Show Activity') ->setLabel(pht('Show Activity'))
->setName('activity') ->setName('activity')
->setValue($filter_activity) ->setValue($filter_activity)
->setOptions( ->setOptions(
array( array(
'' => 'All Activity', '' => pht('All Activity'),
'admin' => 'Admin Activity', 'admin' => pht('Admin Activity'),
))) )))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Filter IP') ->setLabel(pht('Filter IP'))
->setName('ip') ->setName('ip')
->setValue($filter_ip) ->setValue($filter_ip)
->setCaption( ->setCaption(
'Enter an IP (or IP prefix) to show only activity by that remote '. pht('Enter an IP (or IP prefix) to show only activity by that '.
'address.')) 'remote address.')))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Filter Session') ->setLabel(pht('Filter Session'))
->setName('session') ->setName('session')
->setValue($filter_session)) ->setValue($filter_session))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Filter Logs')); ->setValue(pht('Filter Logs')));
$log_table = new PhabricatorUserLog(); $log_table = new PhabricatorUserLog();
$conn_r = $log_table->establishConnection('r'); $conn_r = $log_table->establishConnection('r');
@ -183,15 +183,15 @@ final class PhabricatorPeopleLogsController
$table = new AphrontTableView($rows); $table = new AphrontTableView($rows);
$table->setHeaders( $table->setHeaders(
array( array(
'Date', pht('Date'),
'Time', pht('Time'),
'Action', pht('Action'),
'Actor', pht('Actor'),
'User', pht('User'),
'Old', pht('Old'),
'New', pht('New'),
'IP', pht('IP'),
'Session', pht('Session'),
)); ));
$table->setColumnClasses( $table->setColumnClasses(
array( array(
@ -207,12 +207,18 @@ final class PhabricatorPeopleLogsController
)); ));
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->setHeader('Activity Logs'); $panel->setHeader(pht('Activity Logs'));
$panel->setNoBackground();
$panel->appendChild($table); $panel->appendChild($table);
$panel->appendChild($pager); $panel->appendChild($pager);
$filter = new AphrontListFilterView(); $filter = new AphrontListFilterView();
$filter->appendChild($form); $filter->appendChild($form);
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht('Activity Logs'))
->setHref('/people/logs/'));
$nav = $this->buildSideNavView(); $nav = $this->buildSideNavView();
$nav->selectFilter('logs'); $nav->selectFilter('logs');
@ -221,12 +227,13 @@ final class PhabricatorPeopleLogsController
$filter, $filter,
$panel, $panel,
)); ));
$nav->setCrumbs($crumbs);
return $this->buildApplicationPage( return $this->buildApplicationPage(
$nav, $nav,
array( array(
'title' => 'Activity Logs', 'title' => pht('Activity Logs'),
'device' => true,
)); ));
} }
} }