From: Zach Copley Date: Sat, 6 Sep 2008 07:06:51 +0000 (-0400) Subject: Moved avatar upload down below timezone on profile settings X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4f19a9462c7f3b0f21204bfe9e3e196c99aa7d73;p=quix0rs-gnu-social.git Moved avatar upload down below timezone on profile settings darcs-hash:20080906070651-7b5ce-23c17932cc9c474dfbeb530d29b1bd1adb3a4260.gz --- diff --git a/actions/profilesettings.php b/actions/profilesettings.php index 10ab2cd0f6..f34101ba97 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -29,48 +29,33 @@ class ProfilesettingsAction extends SettingsAction { } function show_form($msg=NULL, $success=false) { - $user = common_current_user(); - $profile = $user->getProfile(); $this->form_header(_('Profile settings'), $msg, $success); + $this->show_settings_form(); + $this->show_avatar_form(); + common_show_footer(); + } - common_element('h2', NULL, _('Avatar')); + function handle_post() { - $original = $profile->getOriginalAvatar(); + # CSRF protection - if ($original) { - common_element('img', array('src' => $original->url, - 'class' => 'avatar original', - 'width' => $original->width, - 'height' => $original->height, - 'alt' => $user->nickname)); + $token = $this->trimmed('token'); + if (!$token || $token != common_session_token()) { + $this->show_form(_('There was a problem with your session token. Try again, please.')); + return; } - $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); - - if ($avatar) { - common_element('img', array('src' => $avatar->url, - 'class' => 'avatar profile', - 'width' => AVATAR_PROFILE_SIZE, - 'height' => AVATAR_PROFILE_SIZE, - 'alt' => $user->nickname)); + if ($this->arg('save')) { + $this->save_profile(); + } else if ($this->arg('upload')) { + $this->upload_avatar(); } + } - common_element_start('form', array('enctype' => 'multipart/form-data', - 'method' => 'POST', - 'id' => 'profilesettings', - 'action' => - common_local_url('profilesettings'))); - common_hidden('token', common_session_token()); + function show_settings_form() { - common_element('input', array('name' => 'MAX_FILE_SIZE', - 'type' => 'hidden', - 'id' => 'MAX_FILE_SIZE', - 'value' => MAX_AVATAR_SIZE)); - common_element('input', array('name' => 'avatarfile', - 'type' => 'file', - 'id' => 'avatarfile')); - common_submit('upload', _('Upload')); - common_element_end('form'); + $user = common_current_user(); + $profile = $user->getProfile(); common_element_start('form', array('method' => 'POST', 'id' => 'profilesettings', @@ -78,7 +63,6 @@ class ProfilesettingsAction extends SettingsAction { common_local_url('profilesettings'))); common_hidden('token', common_session_token()); - common_element('h2', NULL, _('Profile Settings')); # too much common patterns here... abstractable? @@ -112,24 +96,58 @@ class ProfilesettingsAction extends SettingsAction { common_submit('save', _('Save')); common_element_end('form'); - common_show_footer(); + + } - function handle_post() { + function show_avatar_form() { - # CSRF protection + $user = common_current_user(); + $profile = $user->getProfile(); - $token = $this->trimmed('token'); - if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); - return; + $original = $profile->getOriginalAvatar(); + + + common_element_start('form', array('enctype' => 'multipart/form-data', + 'method' => 'POST', + 'id' => 'profilesettings', + 'action' => + common_local_url('profilesettings'))); + common_hidden('token', common_session_token()); + + common_element_start('p'); + common_element('label', array('for' => 'avatar'), 'Avatar'); + + if ($original) { + common_element('img', array('src' => $original->url, + 'class' => 'avatar original', + 'width' => $original->width, + 'height' => $original->height, + 'alt' => $user->nickname)); } - if ($this->arg('save')) { - $this->save_profile(); - } else if ($this->arg('upload')) { - $this->upload_avatar(); + $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); + + if ($avatar) { + common_element('img', array('src' => $avatar->url, + 'class' => 'avatar profile', + 'width' => AVATAR_PROFILE_SIZE, + 'height' => AVATAR_PROFILE_SIZE, + 'alt' => $user->nickname)); } + + common_element_end('p'); + + common_element('input', array('name' => 'MAX_FILE_SIZE', + 'type' => 'hidden', + 'id' => 'MAX_FILE_SIZE', + 'value' => MAX_AVATAR_SIZE)); + common_element('input', array('name' => 'avatarfile', + 'type' => 'file', + 'id' => 'avatarfile')); + common_submit('upload', _('Upload')); + common_element_end('form'); + } function save_profile() {