diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index e82f1055ea..c82f070a3b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -337,7 +337,6 @@ phutil_register_library_map(array( 'PhabricatorDisabledUserController' => 'applications/auth/controller/disabled', 'PhabricatorDraft' => 'applications/draft/storage/draft', 'PhabricatorDraftDAO' => 'applications/draft/storage/base', - 'PhabricatorEditPreferencesController' => 'applications/preferences/controller/edit', 'PhabricatorEmailLoginController' => 'applications/auth/controller/email', 'PhabricatorEmailTokenController' => 'applications/auth/controller/emailtoken', 'PhabricatorEnv' => 'infrastructure/env', @@ -456,8 +455,6 @@ phutil_register_library_map(array( 'PhabricatorPeopleListController' => 'applications/people/controller/list', 'PhabricatorPeopleLogsController' => 'applications/people/controller/logs', 'PhabricatorPeopleProfileController' => 'applications/people/controller/profile', - 'PhabricatorPeopleProfileEditController' => 'applications/people/controller/profileedit', - 'PhabricatorPreferencesController' => 'applications/preferences/controller/base', 'PhabricatorProfileView' => 'view/layout/profile', 'PhabricatorProject' => 'applications/project/storage/project', 'PhabricatorProjectAffiliation' => 'applications/project/storage/affiliation', @@ -577,6 +574,7 @@ phutil_register_library_map(array( 'PhabricatorUserPreferenceSettingsPanelController' => 'applications/people/controller/settings/panels/preferences', 'PhabricatorUserPreferences' => 'applications/people/storage/preferences', 'PhabricatorUserProfile' => 'applications/people/storage/profile', + 'PhabricatorUserProfileSettingsPanelController' => 'applications/people/controller/settings/panels/profile', 'PhabricatorUserSSHKey' => 'applications/people/storage/usersshkey', 'PhabricatorUserSSHKeysSettingsPanelController' => 'applications/people/controller/settings/panels/sshkeys', 'PhabricatorUserSettingsController' => 'applications/people/controller/settings', @@ -892,7 +890,6 @@ phutil_register_library_map(array( 'PhabricatorDisabledUserController' => 'PhabricatorAuthController', 'PhabricatorDraft' => 'PhabricatorDraftDAO', 'PhabricatorDraftDAO' => 'PhabricatorLiskDAO', - 'PhabricatorEditPreferencesController' => 'PhabricatorPreferencesController', 'PhabricatorEmailLoginController' => 'PhabricatorAuthController', 'PhabricatorEmailTokenController' => 'PhabricatorAuthController', 'PhabricatorFeedController' => 'PhabricatorController', @@ -990,8 +987,6 @@ phutil_register_library_map(array( 'PhabricatorPeopleListController' => 'PhabricatorPeopleController', 'PhabricatorPeopleLogsController' => 'PhabricatorPeopleController', 'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController', - 'PhabricatorPeopleProfileEditController' => 'PhabricatorPeopleController', - 'PhabricatorPreferencesController' => 'PhabricatorController', 'PhabricatorProfileView' => 'AphrontView', 'PhabricatorProject' => 'PhabricatorProjectDAO', 'PhabricatorProjectAffiliation' => 'PhabricatorProjectDAO', @@ -1098,6 +1093,7 @@ phutil_register_library_map(array( 'PhabricatorUserPreferenceSettingsPanelController' => 'PhabricatorUserSettingsPanelController', 'PhabricatorUserPreferences' => 'PhabricatorUserDAO', 'PhabricatorUserProfile' => 'PhabricatorUserDAO', + 'PhabricatorUserProfileSettingsPanelController' => 'PhabricatorUserSettingsPanelController', 'PhabricatorUserSSHKey' => 'PhabricatorUserDAO', 'PhabricatorUserSSHKeysSettingsPanelController' => 'PhabricatorUserSettingsPanelController', 'PhabricatorUserSettingsController' => 'PhabricatorPeopleController', diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index 0e4ec268ee..0b1400533d 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -72,8 +72,6 @@ class AphrontDefaultApplicationConfiguration '/people/' => array( '$' => 'PhabricatorPeopleListController', 'logs/$' => 'PhabricatorPeopleLogsController', - 'edit/(?:(?P\d+)/(?:(?P\w+)/)?)?$' - => 'PhabricatorPeopleEditController', ), '/p/(?P\w+)/(?:(?P\w+)/)?$' => 'PhabricatorPeopleProfileController', diff --git a/src/applications/people/controller/profile/PhabricatorPeopleProfileController.php b/src/applications/people/controller/profile/PhabricatorPeopleProfileController.php index ca2e2c51de..95ec181952 100644 --- a/src/applications/people/controller/profile/PhabricatorPeopleProfileController.php +++ b/src/applications/people/controller/profile/PhabricatorPeopleProfileController.php @@ -50,7 +50,7 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController { $links[] = phutil_render_tag( 'a', array( - 'href' => '/profile/edit/', + 'href' => '/settings/page/profile/', ), 'Edit Profile'); } diff --git a/src/applications/people/controller/settings/PhabricatorUserSettingsController.php b/src/applications/people/controller/settings/PhabricatorUserSettingsController.php index 29af81f4ac..acc107b519 100644 --- a/src/applications/people/controller/settings/PhabricatorUserSettingsController.php +++ b/src/applications/people/controller/settings/PhabricatorUserSettingsController.php @@ -33,6 +33,7 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController { $this->pages = array( 'account' => 'Account', + 'profile' => 'Profile', 'email' => 'Email', 'preferences' => 'Preferences', 'conduit' => 'Conduit Certificate', @@ -60,6 +61,9 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController { case 'account': $delegate = new PhabricatorUserAccountSettingsPanelController($request); break; + case 'profile': + $delegate = new PhabricatorUserProfileSettingsPanelController($request); + break; case 'email': $delegate = new PhabricatorUserEmailSettingsPanelController($request); break; diff --git a/src/applications/people/controller/settings/__init__.php b/src/applications/people/controller/settings/__init__.php index 4a8c7d81c6..ec95b76f5a 100644 --- a/src/applications/people/controller/settings/__init__.php +++ b/src/applications/people/controller/settings/__init__.php @@ -14,6 +14,7 @@ phutil_require_module('phabricator', 'applications/people/controller/settings/pa phutil_require_module('phabricator', 'applications/people/controller/settings/panels/email'); phutil_require_module('phabricator', 'applications/people/controller/settings/panels/oauth'); phutil_require_module('phabricator', 'applications/people/controller/settings/panels/preferences'); +phutil_require_module('phabricator', 'applications/people/controller/settings/panels/profile'); phutil_require_module('phabricator', 'applications/people/controller/settings/panels/sshkeys'); phutil_require_module('phabricator', 'view/layout/sidenav'); diff --git a/src/applications/people/controller/settings/panels/account/PhabricatorUserAccountSettingsPanelController.php b/src/applications/people/controller/settings/panels/account/PhabricatorUserAccountSettingsPanelController.php index a6f20909d7..5786e71358 100644 --- a/src/applications/people/controller/settings/panels/account/PhabricatorUserAccountSettingsPanelController.php +++ b/src/applications/people/controller/settings/panels/account/PhabricatorUserAccountSettingsPanelController.php @@ -25,45 +25,18 @@ class PhabricatorUserAccountSettingsPanelController $user = $request->getUser(); $editable = $this->getAccountEditable(); - $e_realname = true; + $e_realname = $editable ? true : null; $errors = array(); if ($request->isFormPost()) { - if (!$editable) { - return new Aphront400Response(); - } - if (!empty($_FILES['profile'])) { - $err = idx($_FILES['profile'], 'error'); - if ($err != UPLOAD_ERR_NO_FILE) { - $file = PhabricatorFile::newFromPHPUpload( - $_FILES['profile'], - array( - 'authorPHID' => $user->getPHID(), - )); - $okay = $file->isTransformableImage(); - if ($okay) { - $xformer = new PhabricatorImageTransformer(); - $xformed = $xformer->executeProfileTransform( - $file, - $width = 50, - $min_height = 50, - $max_height = 50); - $user->setProfileImagePHID($xformed->getPHID()); - } else { - $errors[] = - 'Only valid image files (jpg, jpeg, png or gif) '. - 'will be accepted.'; - } + if ($editable) { + $user->setRealName($request->getStr('realname')); + if (!strlen($user->getRealName())) { + $errors[] = 'Real name must be nonempty.'; + $e_realname = 'Required'; } } - $user->setRealName($request->getStr('realname')); - - if (!strlen($user->getRealName())) { - $errors[] = 'Real name must be nonempty.'; - $e_realname = 'Required'; - } - $new_timezone = $request->getStr('timezone'); if (in_array($new_timezone, DateTimeZone::listIdentifiers(), true)) { $user->setTimezoneIdentifier($new_timezone); @@ -78,9 +51,6 @@ class PhabricatorUserAccountSettingsPanelController } } - $img_src = PhabricatorFileURI::getViewURIForPHID( - $user->getProfileImagePHID()); - $notice = null; if (!$errors) { if ($request->getStr('saved')) { @@ -97,6 +67,9 @@ class PhabricatorUserAccountSettingsPanelController $notice = $notice->render(); } + $timezone_ids = DateTimeZone::listIdentifiers(); + $timezone_id_map = array_combine($timezone_ids, $timezone_ids); + $form = new AphrontFormView(); $form ->setUser($user) @@ -113,46 +86,17 @@ class PhabricatorUserAccountSettingsPanelController ->setValue($user->getRealName()) ->setDisabled(!$editable)) ->appendChild( - id(new AphrontFormMarkupControl()) - ->setValue('
')) + id(new AphrontFormSelectControl()) + ->setLabel('Timezone') + ->setName('timezone') + ->setOptions($timezone_id_map) + ->setValue($user->getTimezoneIdentifier())) ->appendChild( - id(new AphrontFormMarkupControl()) - ->setLabel('Profile Image') - ->setValue( - phutil_render_tag( - 'img', - array( - 'src' => $img_src, - )))); - - if ($editable) { - $timezone_ids = DateTimeZone::listIdentifiers(); - $timezone_id_map = array_combine($timezone_ids, $timezone_ids); - - $form - ->appendChild( - id(new AphrontFormFileControl()) - ->setLabel('Change Image') - ->setName('profile')) - ->appendChild( - id(new AphrontFormMarkupControl()) - ->setValue('
')) - ->appendChild( - id(new AphrontFormSelectControl()) - ->setLabel('Timezone') - ->setName('timezone') - ->setOptions($timezone_id_map) - ->setValue($user->getTimezoneIdentifier())) - ->appendChild( - id(new AphrontFormMarkupControl()) - ->setValue('
')) - ->appendChild( - id(new AphrontFormSubmitControl()) - ->setValue('Save')); - } + id(new AphrontFormSubmitControl()) + ->setValue('Save')); $panel = new AphrontPanelView(); - $panel->setHeader('Profile Settings'); + $panel->setHeader('Account Settings'); $panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->appendChild($form); diff --git a/src/applications/people/controller/settings/panels/account/__init__.php b/src/applications/people/controller/settings/panels/account/__init__.php index eb7b21e092..a70e1289e4 100644 --- a/src/applications/people/controller/settings/panels/account/__init__.php +++ b/src/applications/people/controller/settings/panels/account/__init__.php @@ -6,15 +6,9 @@ -phutil_require_module('phabricator', 'aphront/response/400'); phutil_require_module('phabricator', 'aphront/response/redirect'); -phutil_require_module('phabricator', 'applications/files/storage/file'); -phutil_require_module('phabricator', 'applications/files/transform'); -phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'applications/people/controller/settings/panels/base'); phutil_require_module('phabricator', 'view/form/base'); -phutil_require_module('phabricator', 'view/form/control/file'); -phutil_require_module('phabricator', 'view/form/control/markup'); phutil_require_module('phabricator', 'view/form/control/select'); phutil_require_module('phabricator', 'view/form/control/static'); phutil_require_module('phabricator', 'view/form/control/submit'); @@ -23,7 +17,6 @@ phutil_require_module('phabricator', 'view/form/error'); phutil_require_module('phabricator', 'view/layout/panel'); phutil_require_module('phabricator', 'view/null'); -phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/people/controller/profileedit/PhabricatorPeopleProfileEditController.php b/src/applications/people/controller/settings/panels/profile/PhabricatorUserProfileSettingsPanelController.php similarity index 61% rename from src/applications/people/controller/profileedit/PhabricatorPeopleProfileEditController.php rename to src/applications/people/controller/settings/panels/profile/PhabricatorUserProfileSettingsPanelController.php index 8ec1e222a3..c427008351 100644 --- a/src/applications/people/controller/profileedit/PhabricatorPeopleProfileEditController.php +++ b/src/applications/people/controller/settings/panels/profile/PhabricatorUserProfileSettingsPanelController.php @@ -16,8 +16,8 @@ * limitations under the License. */ -class PhabricatorPeopleProfileEditController - extends PhabricatorPeopleController { +class PhabricatorUserProfileSettingsPanelController + extends PhabricatorUserSettingsPanelController { public function processRequest() { @@ -48,12 +48,22 @@ class PhabricatorPeopleProfileEditController $okay = $file->isTransformableImage(); if ($okay) { $xformer = new PhabricatorImageTransformer(); - $xformed = $xformer->executeProfileTransform( + + // Generate the large picture for the profile page. + $large_xformed = $xformer->executeProfileTransform( $file, $width = 280, $min_height = 140, $max_height = 420); - $profile->setProfileImagePHID($xformed->getPHID()); + $profile->setProfileImagePHID($large_xformed->getPHID()); + + // Generate the small picture for comments, etc. + $small_xformed = $xformer->executeProfileTransform( + $file, + $width = 50, + $min_height = 50, + $max_height = 50); + $user->setProfileImagePHID($small_xformed->getPHID()); } else { $errors[] = 'Only valid image files (jpg, jpeg, png or gif) '. @@ -63,9 +73,10 @@ class PhabricatorPeopleProfileEditController } if (!$errors) { + $user->save(); $profile->save(); $response = id(new AphrontRedirectResponse()) - ->setURI('/p/'.$user->getUsername().'/'); + ->setURI('/settings/page/profile/?saved=true'); return $response; } } @@ -75,12 +86,24 @@ class PhabricatorPeopleProfileEditController $error_view = new AphrontErrorView(); $error_view->setTitle('Form Errors'); $error_view->setErrors($errors); + } else { + if ($request->getStr('saved')) { + $error_view = new AphrontErrorView(); + $error_view->setSeverity(AphrontErrorView::SEVERITY_NOTICE); + $error_view->setTitle('Changes Saved'); + $error_view->appendChild('

Your changes have been saved.

'); + $error_view = $error_view->render(); + } } + $img_src = PhabricatorFileURI::getViewURIForPHID( + $user->getProfileImagePHID()); + $profile_uri = PhabricatorEnv::getURI('/p/'.$user->getUsername().'/'); + $form = new AphrontFormView(); $form ->setUser($request->getUser()) - ->setAction('/profile/edit/') + ->setAction('/settings/page/profile/') ->setEncType('multipart/form-data') ->appendChild( id(new AphrontFormTextControl()) @@ -88,21 +111,38 @@ class PhabricatorPeopleProfileEditController ->setName('title') ->setValue($profile->getTitle()) ->setCaption('Serious business title.')) + ->appendChild( + id(new AphrontFormMarkupControl()) + ->setLabel('Profile URI') + ->setValue( + phutil_render_tag( + 'a', + array( + 'href' => $profile_uri, + ), + phutil_escape_html($profile_uri)))) ->appendChild( '

Write something about yourself! '. 'Make sure to include important information like '. - 'your favorite pokemon and which '. - 'Starcraft race you play.

') + 'your favorite pokemon and which Starcraft race you play.

') ->appendChild( id(new AphrontFormTextAreaControl()) ->setLabel('Blurb') ->setName('blurb') ->setValue($profile->getBlurb())) + ->appendChild( + id(new AphrontFormMarkupControl()) + ->setLabel('Profile Image') + ->setValue( + phutil_render_tag( + 'img', + array( + 'src' => $img_src, + )))) ->appendChild( id(new AphrontFormFileControl()) ->setLabel('Change Image') - ->setName('image') - ->setCaption('Upload a 280px-wide image.')) + ->setName('image')) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue('Save') @@ -113,14 +153,12 @@ class PhabricatorPeopleProfileEditController $panel->appendChild($form); $panel->setWidth(AphrontPanelView::WIDTH_FORM); - return $this->buildStandardPageResponse( - array( - $error_view, - $panel, - ), - array( - 'title' => 'Edit Profile', - )); + return id(new AphrontNullView()) + ->appendChild( + array( + $error_view, + $panel, + )); } } diff --git a/src/applications/people/controller/profileedit/__init__.php b/src/applications/people/controller/settings/panels/profile/__init__.php similarity index 70% rename from src/applications/people/controller/profileedit/__init__.php rename to src/applications/people/controller/settings/panels/profile/__init__.php index fdfc29408f..2b1c76b08e 100644 --- a/src/applications/people/controller/profileedit/__init__.php +++ b/src/applications/people/controller/settings/panels/profile/__init__.php @@ -9,17 +9,22 @@ phutil_require_module('phabricator', 'aphront/response/redirect'); phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/files/transform'); -phutil_require_module('phabricator', 'applications/people/controller/base'); +phutil_require_module('phabricator', 'applications/files/uri'); +phutil_require_module('phabricator', 'applications/people/controller/settings/panels/base'); phutil_require_module('phabricator', 'applications/people/storage/profile'); +phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'view/form/base'); phutil_require_module('phabricator', 'view/form/control/file'); +phutil_require_module('phabricator', 'view/form/control/markup'); phutil_require_module('phabricator', 'view/form/control/submit'); phutil_require_module('phabricator', 'view/form/control/text'); phutil_require_module('phabricator', 'view/form/control/textarea'); phutil_require_module('phabricator', 'view/form/error'); phutil_require_module('phabricator', 'view/layout/panel'); +phutil_require_module('phabricator', 'view/null'); +phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'utils'); -phutil_require_source('PhabricatorPeopleProfileEditController.php'); +phutil_require_source('PhabricatorUserProfileSettingsPanelController.php');