diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index db32e7d6b0..7ef1e0236c 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1496,7 +1496,6 @@ phutil_register_library_map(array( 'PhabricatorSettingsPanelExternalAccounts' => 'applications/settings/panel/PhabricatorSettingsPanelExternalAccounts.php', 'PhabricatorSettingsPanelHomePreferences' => 'applications/settings/panel/PhabricatorSettingsPanelHomePreferences.php', 'PhabricatorSettingsPanelPassword' => 'applications/settings/panel/PhabricatorSettingsPanelPassword.php', - 'PhabricatorSettingsPanelProfile' => 'applications/settings/panel/PhabricatorSettingsPanelProfile.php', 'PhabricatorSettingsPanelSSHKeys' => 'applications/settings/panel/PhabricatorSettingsPanelSSHKeys.php', 'PhabricatorSettingsPanelSearchPreferences' => 'applications/settings/panel/PhabricatorSettingsPanelSearchPreferences.php', 'PhabricatorSetupCheck' => 'applications/config/check/PhabricatorSetupCheck.php', @@ -3448,7 +3447,6 @@ phutil_register_library_map(array( 'PhabricatorSettingsPanelExternalAccounts' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelHomePreferences' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelPassword' => 'PhabricatorSettingsPanel', - 'PhabricatorSettingsPanelProfile' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelSSHKeys' => 'PhabricatorSettingsPanel', 'PhabricatorSettingsPanelSearchPreferences' => 'PhabricatorSettingsPanel', 'PhabricatorSetupCheckAPC' => 'PhabricatorSetupCheck', diff --git a/src/applications/settings/panel/PhabricatorSettingsPanelAccount.php b/src/applications/settings/panel/PhabricatorSettingsPanelAccount.php index 81049f39b0..94a56887b1 100644 --- a/src/applications/settings/panel/PhabricatorSettingsPanelAccount.php +++ b/src/applications/settings/panel/PhabricatorSettingsPanelAccount.php @@ -26,6 +26,17 @@ final class PhabricatorSettingsPanelAccount $errors[] = pht('The selected timezone is not a valid timezone.'); } + $sex = $request->getStr('sex'); + $sexes = array(PhutilPerson::SEX_MALE, PhutilPerson::SEX_FEMALE); + if (in_array($sex, $sexes)) { + $user->setSex($sex); + } else { + $user->setSex(null); + } + + // Checked in runtime. + $user->setTranslation($request->getStr('translation')); + if (!$errors) { $user->save(); return id(new AphrontRedirectResponse()) @@ -45,30 +56,60 @@ final class PhabricatorSettingsPanelAccount } } else { $notice = new AphrontErrorView(); - $notice->setTitle(pht('Form Errors')); $notice->setErrors($errors); - $notice = $notice->render(); } $timezone_ids = DateTimeZone::listIdentifiers(); $timezone_id_map = array_fuse($timezone_ids); + $sexes = array( + PhutilPerson::SEX_UNKNOWN => pht('Unspecified'), + PhutilPerson::SEX_MALE => pht('Male'), + PhutilPerson::SEX_FEMALE => pht('Female'), + ); + + $translations = array(); + $symbols = id(new PhutilSymbolLoader()) + ->setType('class') + ->setAncestorClass('PhabricatorTranslation') + ->setConcreteOnly(true) + ->selectAndLoadSymbols(); + foreach ($symbols as $symbol) { + $class = $symbol['name']; + $translations[$class] = newv($class, array())->getName(); + } + asort($translations); + $default = PhabricatorEnv::newObjectFromConfig('translation.provider'); + $translations = array( + '' => pht('Server Default (%s)', $default->getName()), + ) + $translations; + + $form = new AphrontFormView(); $form ->setUser($user) - ->appendChild( - id(new AphrontFormStaticControl()) - ->setLabel(pht('Username')) - ->setValue($user->getUsername())) + ->setFlexible(true) ->appendChild( id(new AphrontFormSelectControl()) ->setLabel(pht('Timezone')) ->setName('timezone') ->setOptions($timezone_id_map) ->setValue($user->getTimezoneIdentifier())) + ->appendChild( + id(new AphrontFormSelectControl()) + ->setOptions($sexes) + ->setLabel(pht('Sex')) + ->setName('sex') + ->setValue($user->getSex())) + ->appendChild( + id(new AphrontFormSelectControl()) + ->setOptions($translations) + ->setLabel(pht('Translation')) + ->setName('translation') + ->setValue($user->getTranslation())) ->appendChild( id(new AphrontFormSubmitControl()) - ->setValue(pht('Save'))); + ->setValue(pht('Save Account Settings'))); $header = new PhabricatorHeaderView(); $header->setHeader(pht('Account Settings')); diff --git a/src/applications/settings/panel/PhabricatorSettingsPanelProfile.php b/src/applications/settings/panel/PhabricatorSettingsPanelProfile.php deleted file mode 100644 index e4a71a5106..0000000000 --- a/src/applications/settings/panel/PhabricatorSettingsPanelProfile.php +++ /dev/null @@ -1,112 +0,0 @@ -getUser(); - - $errors = array(); - if ($request->isFormPost()) { - $sex = $request->getStr('sex'); - $sexes = array(PhutilPerson::SEX_MALE, PhutilPerson::SEX_FEMALE); - if (in_array($sex, $sexes)) { - $user->setSex($sex); - } else { - $user->setSex(null); - } - - // Checked in runtime. - $user->setTranslation($request->getStr('translation')); - - if (!$errors) { - $user->save(); - $response = id(new AphrontRedirectResponse()) - ->setURI($this->getPanelURI('?saved=true')); - return $response; - } - } - - $error_view = null; - if ($errors) { - $error_view = new AphrontErrorView(); - $error_view->setTitle(pht('Form Errors')); - $error_view->setErrors($errors); - } else { - if ($request->getStr('saved')) { - $error_view = new AphrontErrorView(); - $error_view->setSeverity(AphrontErrorView::SEVERITY_NOTICE); - $error_view->setTitle(pht('Changes Saved')); - $error_view->appendChild( - phutil_tag('p', array(), pht('Your changes have been saved.'))); - $error_view = $error_view->render(); - } - } - - $profile_uri = PhabricatorEnv::getURI('/p/'.$user->getUsername().'/'); - - $sexes = array( - PhutilPerson::SEX_UNKNOWN => pht('Unknown'), - PhutilPerson::SEX_MALE => pht('Male'), - PhutilPerson::SEX_FEMALE => pht('Female'), - ); - - $translations = array(); - $symbols = id(new PhutilSymbolLoader()) - ->setType('class') - ->setAncestorClass('PhabricatorTranslation') - ->setConcreteOnly(true) - ->selectAndLoadSymbols(); - foreach ($symbols as $symbol) { - $class = $symbol['name']; - $translations[$class] = newv($class, array())->getName(); - } - asort($translations); - $default = PhabricatorEnv::newObjectFromConfig('translation.provider'); - $translations = array( - '' => pht('Server Default (%s)', $default->getName()), - ) + $translations; - - $form = new AphrontFormView(); - $form - ->setUser($request->getUser()) - ->appendChild( - id(new AphrontFormSelectControl()) - ->setOptions($sexes) - ->setLabel(pht('Sex')) - ->setName('sex') - ->setValue($user->getSex())) - ->appendChild( - id(new AphrontFormSelectControl()) - ->setOptions($translations) - ->setLabel(pht('Translation')) - ->setName('translation') - ->setValue($user->getTranslation())); - - $form->appendChild( - id(new AphrontFormSubmitControl()) - ->setValue(pht('Save'))); - - $header = new PhabricatorHeaderView(); - $header->setHeader(pht('Edit Profile Details')); - - return array( - $error_view, - $header, - $form, - ); - } - -}