diff options
author | Cullen Walsh <ckwalsh@cullenwalsh.com> | 2011-06-18 21:12:29 -0700 |
---|---|---|
committer | Cullen Walsh <ckwalsh@cullenwalsh.com> | 2012-03-18 22:21:36 +0000 |
commit | 6deadc3acf302e9fd15adfd6bff5f0fe525240c7 (patch) | |
tree | e886c36bff237fa32201618cfc0f812962d4394a | |
parent | 22c864cb3a945b52fe9b91765d247abfe00b50bc (diff) | |
download | forums-6deadc3acf302e9fd15adfd6bff5f0fe525240c7.tar forums-6deadc3acf302e9fd15adfd6bff5f0fe525240c7.tar.gz forums-6deadc3acf302e9fd15adfd6bff5f0fe525240c7.tar.bz2 forums-6deadc3acf302e9fd15adfd6bff5f0fe525240c7.tar.xz forums-6deadc3acf302e9fd15adfd6bff5f0fe525240c7.zip |
[feature/avatars] Rework UCP to be simpler/more consistent
Redesigning the UCP avatar page to use javascript to make use less
confusing. This design is also more easily transfered to the ACP for
group avatars, which will give better consistency in the long run.
PHPBB3-10018
-rw-r--r-- | phpBB/includes/avatar/driver/remote.php | 2 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_profile.php | 69 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/ucp_avatar_options.html | 49 |
3 files changed, 94 insertions, 26 deletions
diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index 32f93c7928..c28eed93da 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -72,6 +72,8 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver $url = 'http://' . $url; } + require_once($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx); + $error = array_merge($error, validate_data(array( 'url' => $url, ), array( diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index bcafd3d636..d5f3ec4b81 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -554,31 +554,60 @@ class ucp_profile { $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver()); - if (isset($_POST['av_delete'])) + $avatar_drivers = $avatar_manager->get_valid_drivers(); + sort($avatar_drivers); + + if ($submit) { if (check_form_key('ucp_avatar')) { - $result = array( - 'user_avatar' => '', - 'user_avatar_type' => '', - 'user_avatar_width' => 0, - 'user_avatar_height' => 0, - ); - - if ($driver = $avatar_manager->get_driver($user->data['user_avatar_type'])) + $driver = request_var('avatar_driver', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$driver"]) { - $driver->delete($user->data); + $avatar = $avatar_manager->get_driver($driver); + $result = $avatar->process_form($template, $user->data, $error); + + if ($result && empty($error)) + { + // Success! Lets save the result in the database + $result['user_avatar_type'] = $driver; + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $result) . ' + WHERE user_id = ' . $user->data['user_id']; + + $db->sql_query($sql); + + meta_refresh(3, $this->u_action); + $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); + trigger_error($message); + } } - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $result) . ' - WHERE user_id = ' . $user->data['user_id']; + else + { + // They are removing their avatar or are trying to play games with us + if ($avatar = $avatar_manager->get_driver($user->data['user_avatar_type'])) + { + $avatar->delete($user->data); + } - $db->sql_query($sql); + $result = array( + 'user_avatar' => '', + 'user_avatar_type' => '', + 'user_avatar_width' => 0, + 'user_avatar_height' => 0, + ); - meta_refresh(3, $this->u_action); - $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); - trigger_error($message); + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $result) . ' + WHERE user_id = ' . $user->data['user_id']; + + $db->sql_query($sql); + + meta_refresh(3, $this->u_action); + $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); + trigger_error($message); + } } else { @@ -586,9 +615,6 @@ class ucp_profile } } - $avatar_drivers = $avatar_manager->get_valid_drivers(); - sort($avatar_drivers); - foreach ($avatar_drivers as $driver) { if ($config["allow_avatar_$driver"]) @@ -636,6 +662,7 @@ class ucp_profile 'L_EXPLAIN' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_EXPLAIN'), 'DRIVER' => $driver, + 'SELECTED' => ($driver == $user->data['user_avatar_type']), 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options.html b/phpBB/styles/prosilver/template/ucp_avatar_options.html index f05e96410d..eb78e9f77c 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options.html @@ -10,22 +10,61 @@ <dl> <dt><label>{L_CURRENT_IMAGE}:</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt> <dd><!-- IF AVATAR -->{AVATAR}<!-- ELSE --><img src="{T_THEME_PATH}/images/no_avatar.gif" alt="" /><!-- ENDIF --></dd> - <!-- IF AVATAR && S_AVATARS_ENABLED --><dd><input type="submit" name="av_delete" id="av_delete" value="{LA_DELETE_AVATAR}" /></dd><!-- ENDIF --> </dl> </fieldset> - + <h3>{L_AVATAR_SELECT_NEW}</h3> + <fieldset> + <dl> + <dt><label>{L_AVATAR_TYPE}</label></dt> + <dd><select name="avatar_driver" id="avatar_driver"> + <option value="">{L_NO_AVATAR}</option> + <!-- BEGIN avatar_drivers --> + <option value="{avatar_drivers.DRIVER}"<!-- IF avatar_drivers.SELECTED --> selected="selected"<!-- ENDIF -->>{avatar_drivers.L_TITLE}</option> + <!-- END avatar_drivers --> + </select></dd> + </fieldset> + <div id="av_options"> <!-- BEGIN avatar_drivers --> - <h3>{avatar_drivers.L_TITLE}</h3> + <div id="av_option_{avatar_drivers.DRIVER}"> + <noscript> + <h3 class="avatar_section_header">{avatar_drivers.L_TITLE}</h3> + </noscript> <p>{avatar_drivers.L_EXPLAIN}</p> <fieldset> {avatar_drivers.OUTPUT} </fieldset> + </div> +<!-- END avatar_drivers --> + </div> <fieldset class="submit-buttons"> <input type="reset" value="{L_RESET}" name="reset" class="button2" /> - <input type="submit" name="submit_av_{avatar_drivers.DRIVER}" value="{L_SUBMIT}" class="button1" /> + <input type="submit" name="submit" value="{L_SUBMIT}" class="button1" /> </fieldset> -<!-- END avatar_drivers --> + + <script type="text/javascript"> + // <![CDATA[ + function avatar_simplify() { + var node = document.getElementById('av_options'); + for (var i = 0; i < node.children.length; i++) { + child = node.children[i]; + child.style.display = 'none'; + } + + var selected = document.getElementById('avatar_driver').value; + var id = 'av_option_' + selected; + node = document.getElementById(id); + if (node != null) { + node.style.display = 'block'; + } + } + + avatar_simplify(); + document.getElementById('avatar_driver').onchange = avatar_simplify; + // ]]> + </script> <span class="corners-bottom"><span></span></span></div> </div> +<script type="text/javascript"> +</script> |