1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Move profile-related "settings" and "account" panel information to "edit profile"

Summary: Ref T1703. Put this stuff on Profile -> Edit Profile instead of spread across Settings -> Account and Settings -> Profile. Makes it custom-field driven.

Test Plan: {F49333} {F49334}

Reviewers: chad, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1703

Differential Revision: https://secure.phabricator.com/D6397
This commit is contained in:
epriestley 2013-07-09 16:23:45 -07:00
parent c5f2e617d8
commit 62ab1dcc62
4 changed files with 29 additions and 61 deletions

View file

@ -104,23 +104,31 @@ final class PhabricatorPeopleProfileController
}
}
$nav->appendChild($header);
$nav->appendChild($content);
$actions = id(new PhabricatorActionListView())
->setUser($viewer);
if ($user->getPHID() == $viewer->getPHID()) {
$nav->addFilter(
null,
pht('Edit Profile...'),
'/settings/panel/profile/');
}
$can_edit = ($user->getPHID() == $viewer->getPHID());
$actions->addAction(
id(new PhabricatorActionView())
->setIcon('edit')
->setName(pht('Edit Profile'))
->setHref($this->getApplicationURI('editprofile/'.$user->getID().'/'))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
if ($viewer->getIsAdmin()) {
$nav->addFilter(
null,
pht('Administrate User...'),
'/people/edit/'.$user->getID().'/');
$actions->addAction(
id(new PhabricatorActionView())
->setIcon('blame')
->setName(pht('Administrate User'))
->setHref($this->getApplicationURI('edit/'.$user->getID().'/')));
}
$nav->appendChild($header);
$nav->appendChild($actions);
$nav->appendChild($content);
return $this->buildApplicationPage(
$nav,
array(

View file

@ -26,6 +26,9 @@ final class PhabricatorUserRealNameField
}
public function getNewValueForApplicationTransactions() {
if (!$this->isEditable()) {
return $this->getObject()->getRealName();
}
return $this->value;
}
@ -42,7 +45,12 @@ final class PhabricatorUserRealNameField
return id(new AphrontFormTextControl())
->setName($this->getFieldKey())
->setValue($this->value)
->setLabel($this->getFieldName());
->setLabel($this->getFieldName())
->setDisabled(!$this->isEditable());
}
private function isEditable() {
return PhabricatorEnv::getEnvConfig('account.editable');
}
}

View file

@ -17,20 +17,8 @@ final class PhabricatorSettingsPanelAccount
public function processRequest(AphrontRequest $request) {
$user = $request->getUser();
$editable = PhabricatorEnv::getEnvConfig('account.editable');
$e_realname = $editable ? true : null;
$errors = array();
if ($request->isFormPost()) {
if ($editable) {
$user->setRealName($request->getStr('realname'));
if (!strlen($user->getRealName())) {
$errors[] = pht('Real name must be nonempty.');
$e_realname = pht('Required');
}
}
$new_timezone = $request->getStr('timezone');
if (in_array($new_timezone, DateTimeZone::listIdentifiers(), true)) {
$user->setTimezoneIdentifier($new_timezone);
@ -72,13 +60,6 @@ final class PhabricatorSettingsPanelAccount
id(new AphrontFormStaticControl())
->setLabel(pht('Username'))
->setValue($user->getUsername()))
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Real Name'))
->setName('realname')
->setError($e_realname)
->setValue($user->getRealName())
->setDisabled(!$editable))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Timezone'))

View file

@ -25,9 +25,6 @@ final class PhabricatorSettingsPanelProfile
$e_image = null;
$errors = array();
if ($request->isFormPost()) {
$profile->setTitle($request->getStr('title'));
$profile->setBlurb($request->getStr('blurb'));
$sex = $request->getStr('sex');
$sexes = array(PhutilPerson::SEX_MALE, PhutilPerson::SEX_FEMALE);
if (in_array($sex, $sexes)) {
@ -148,12 +145,6 @@ final class PhabricatorSettingsPanelProfile
$form
->setUser($request->getUser())
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Title'))
->setName('title')
->setValue($profile->getTitle())
->setCaption(pht('Serious business title.')))
->appendChild(
id(new AphrontFormSelectControl())
->setOptions($sexes)
@ -166,26 +157,6 @@ final class PhabricatorSettingsPanelProfile
->setLabel(pht('Translation'))
->setName('translation')
->setValue($user->getTranslation()))
->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Profile URI'))
->setValue(
phutil_tag(
'a',
array(
'href' => $profile_uri,
),
$profile_uri)))
->appendChild(hsprintf(
'<p class="aphront-form-instructions">%s</p>',
pht('Write something about yourself! Make sure to include important ' .
'information like your favorite Pokemon and which Starcraft race ' .
'you play.')))
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel(pht('Blurb'))
->setName('blurb')
->setValue($profile->getBlurb()))
->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Profile Image'))