diff options
40 files changed, 1485 insertions, 417 deletions
diff --git a/phpBB/adm/style/acp_avatar_options_local.html b/phpBB/adm/style/acp_avatar_options_local.html new file mode 100644 index 0000000000..d762fa9008 --- /dev/null +++ b/phpBB/adm/style/acp_avatar_options_local.html @@ -0,0 +1,27 @@ +<dl> + <dt><label for="category">{L_AVATAR_CATEGORY}:</label></dt> + <dd><select name="av_local_cat" id="category"> + <option value="">{L_NO_AVATAR_CATEGORY}</option> + <!-- BEGIN av_local_cats --> + <option value="{av_local_cats.NAME}"<!-- IF av_local_cats.SELECTED --> selected="selected"<!-- ENDIF -->>{av_local_cats.NAME}</option> + <!-- END av_local_cats --> + </select> <input type="submit" value="{L_GO}" name="av_local_go" class="button2" /></dd> +</dl> +<dl> + <!-- IF AV_LOCAL_SHOW --> + <table cellspacing="1"> + <!-- BEGIN av_local_row --> + <tr> + <!-- BEGIN av_local_col --> + <td class="row1" style="text-align: center;"><img src="{av_local_row.av_local_col.AVATAR_IMAGE}" alt="{av_local_row.av_local_col.AVATAR_NAME}" title="{av_local_row.av_local_col.AVATAR_NAME}"/></td> + <!-- END av_local_col --> + </tr> + <tr> + <!-- BEGIN av_local_col --> + <td class="row2" style="text-align: center;"><input type="radio" name="av_local_file" id="av-{av_local_row.av_local_col.S_ROW_COUNT}" value="{av_local_row.av_local_col.AVATAR_FILE}" /></td> + <!-- END av_local_col --> + </tr> + <!-- END av_local_row --> + </table> + <!-- ENDIF --> +</dl> diff --git a/phpBB/adm/style/acp_avatar_options_remote.html b/phpBB/adm/style/acp_avatar_options_remote.html new file mode 100644 index 0000000000..02704c5be8 --- /dev/null +++ b/phpBB/adm/style/acp_avatar_options_remote.html @@ -0,0 +1,11 @@ +<dl> + <dt><label for="av_remote_url">{L_LINK_REMOTE_AVATAR}:</label><br /><span>{L_LINK_REMOTE_AVATAR_EXPLAIN}</span></dt> + <dd><input type="text" name="av_remote_url" id="av_remote_url" value="{AV_REMOTE_URL}" class="inputbox" /></dd> +</dl> +<dl> + <dt><label for="width">{L_LINK_REMOTE_SIZE}:</label><br /><span>{L_LINK_REMOTE_SIZE_EXPLAIN}</span></dt> + <dd> + <label for="av_remote_width"><input type="text" name="av_remote_width" id="av_remote_width" size="3" value="{AV_REMOTE_WIDTH}" class="inputbox autowidth" /> {L_PIXEL}</label> × + <label for="av_remote_height"><input type="text" name="av_remote_height" id="av_remote_height" size="3" value="{AV_REMOTE_HEIGHT}" class="inputbox autowidth" /> {L_PIXEL}</label> + </dd> +</dl> diff --git a/phpBB/adm/style/acp_avatar_options_upload.html b/phpBB/adm/style/acp_avatar_options_upload.html new file mode 100644 index 0000000000..9c8dd9af01 --- /dev/null +++ b/phpBB/adm/style/acp_avatar_options_upload.html @@ -0,0 +1,11 @@ +<dl> + <dt><label for="av_upload_file">{L_UPLOAD_AVATAR_FILE}:</label></dt> + <dd><input type="hidden" name="MAX_FILE_SIZE" value="{AV_UPLOAD_SIZE}" /><input type="file" name="av_upload_file" id="av_upload_file" class="inputbox autowidth" /></dd> +</dl> + +<!-- IF S_UPLOAD_AVATAR_URL --> + <dl> + <dt><label for="av_upload_url">{L_UPLOAD_AVATAR_URL}:</label><br /><span>{L_UPLOAD_AVATAR_URL_EXPLAIN}</span></dt> + <dd><input type="text" name="av_upload_url" id="av_upload_url" value="" class="inputbox" /></dd> + </dl> +<!-- ENDIF --> diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html index 4701bf702f..3a551adca7 100644 --- a/phpBB/adm/style/acp_groups.html +++ b/phpBB/adm/style/acp_groups.html @@ -103,67 +103,26 @@ <fieldset> <legend>{L_GROUP_AVATAR}</legend> <dl> - <dt><label>{L_CURRENT_IMAGE}{L_COLON}</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt> - <dd>{AVATAR_IMAGE}</dd> - <dd><label><input type="checkbox" class="radio" name="delete" /> {L_DELETE_AVATAR}</label></dd> + <dt><label>{L_CURRENT_IMAGE}:</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt> + <dd>{AVATAR}</dd> </dl> - <!-- IF not S_IN_AVATAR_GALLERY --> - <!-- IF S_CAN_UPLOAD --> - <dl> - <dt><label for="uploadfile">{L_UPLOAD_AVATAR_FILE}{L_COLON}</label></dt> - <dd><input type="file" id="uploadfile" name="uploadfile" /></dd> - </dl> - <dl> - <dt><label for="uploadurl">{L_UPLOAD_AVATAR_URL}{L_COLON}</label><br /><span>{L_UPLOAD_AVATAR_URL_EXPLAIN}</span></dt> - <dd><input name="uploadurl" type="text" id="uploadurl" value="" /></dd> - </dl> - <!-- ENDIF --> - <dl> - <dt><label for="remotelink">{L_LINK_REMOTE_AVATAR}{L_COLON}</label><br /><span>{L_LINK_REMOTE_AVATAR_EXPLAIN}</span></dt> - <dd><input name="remotelink" type="text" id="remotelink" value="" /></dd> - </dl> - <dl> - <dt><label for="width">{L_LINK_REMOTE_SIZE}{L_COLON}</label><br /><span>{L_LINK_REMOTE_SIZE_EXPLAIN}</span></dt> - <dd><input name="width" type="text" id="width" size="3" value="{AVATAR_WIDTH}" /> <span>{L_PIXEL} × </span> <input type="text" name="height" size="3" value="{AVATAR_HEIGHT}" /> <span>{L_PIXEL}</span></dd> - </dl> - <!-- IF S_DISPLAY_GALLERY --> - <dl> - <dt><label>{L_AVATAR_GALLERY}{L_COLON}</label></dt> - <dd><input class="button2" type="submit" name="display_gallery" value="{L_DISPLAY_GALLERY}" /></dd> - </dl> - <!-- ENDIF --> - <!-- ELSE --> - </fieldset> - - <fieldset> - <legend>{L_AVATAR_GALLERY}</legend> - <dl> - <dt><label for="category">{L_AVATAR_CATEGORY}{L_COLON}</label></dt> - <dd><select name="category" id="category">{S_CAT_OPTIONS}</select> <input class="button2" type="submit" value="{L_GO}" name="display_gallery" /></dd> - </dl> - <dl> - <table cellspacing="1"> - <!-- BEGIN avatar_row --> - <tr> - <!-- BEGIN avatar_column --> - <td class="row1" style="text-align: center;"><img src="{avatar_row.avatar_column.AVATAR_IMAGE}" alt="{avatar_row.avatar_column.AVATAR_NAME}" title="{avatar_row.avatar_column.AVATAR_NAME}" /></td> - <!-- END avatar_column --> - </tr> - <tr> - <!-- BEGIN avatar_option_column --> - <td class="row2" style="text-align: center;"><input type="radio" class="radio" name="avatar_select" value="{avatar_row.avatar_option_column.S_OPTIONS_AVATAR}" /></td> - <!-- END avatar_option_column --> - </tr> - <!-- END avatar_row --> - </table> - </dl> - </fieldset> - - <fieldset class="quick" style="margin-top: -15px;"> - <input class="button2" type="submit" name="cancel" value="{L_CANCEL}" /> - </fieldset> - - <!-- ENDIF --> + <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> + </dl> + <div id="av_options"> + <!-- BEGIN avatar_drivers --> + <div id="av_option_{avatar_drivers.DRIVER}"> + <p>{avatar_drivers.L_EXPLAIN}</p> + {avatar_drivers.OUTPUT} + </div> + <!-- END avatar_drivers --> + </div> </fieldset> <fieldset class="submit-buttons"> @@ -174,6 +133,8 @@ </fieldset> </form> + <!-- INCLUDEJS avatars.js --> + <!-- ELSEIF S_LIST --> <a href="{U_BACK}" style="float: {S_CONTENT_FLOW_END};">« {L_BACK}</a> diff --git a/phpBB/adm/style/acp_users_avatar.html b/phpBB/adm/style/acp_users_avatar.html index 2135b52fb9..93a7b38390 100644 --- a/phpBB/adm/style/acp_users_avatar.html +++ b/phpBB/adm/style/acp_users_avatar.html @@ -1,4 +1,4 @@ - <form id="avatar_settings" method="post" action="{U_ACTION}"<!-- IF S_CAN_UPLOAD --> enctype="multipart/form-data"<!-- ENDIF -->> + <form id="avatar_settings" method="post" action="{U_ACTION}" enctype="multipart/form-data"> <fieldset> <legend>{L_ACP_USER_AVATAR}</legend> @@ -44,35 +44,37 @@ <dl> <dt><label for="category">{L_AVATAR_CATEGORY}{L_COLON}</label></dt> <dd><select name="category" id="category">{S_CAT_OPTIONS}</select> <input class="button2" type="submit" value="{L_GO}" name="display_gallery" /></dd> + <!-- IF ERROR --><p class="error">{ERROR}</p><!-- ENDIF --> + <dl> + <dt><label>{L_CURRENT_IMAGE}:</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt> + <dd>{AVATAR}</dd> </dl> + </fieldset> + <fieldset> + <legend>{L_AVATAR_SELECT_NEW}</legend> <dl> - <table cellspacing="1"> - <!-- BEGIN avatar_row --> - <tr> - <!-- BEGIN avatar_column --> - <td class="row1" style="text-align: center;"><img src="{avatar_row.avatar_column.AVATAR_IMAGE}" alt="{avatar_row.avatar_column.AVATAR_NAME}" title="{avatar_row.avatar_column.AVATAR_NAME}" /></td> - <!-- END avatar_column --> - </tr> - <tr> - <!-- BEGIN avatar_option_column --> - <td class="row2" style="text-align: center;"><input type="radio" class="radio" name="avatar_select" value="{avatar_row.avatar_option_column.S_OPTIONS_AVATAR}" /></td> - <!-- END avatar_option_column --> - </tr> - <!-- END avatar_row --> - </table> + <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> </dl> - </fieldset> - - <fieldset class="quick" style="margin-top: -15px;"> - <input class="button2" type="submit" name="cancel" value="{L_CANCEL}" /> - </fieldset> - - <!-- ENDIF --> + <div id="av_options"> + <!-- BEGIN avatar_drivers --> + <div id="av_option_{avatar_drivers.DRIVER}"> + <p>{avatar_drivers.L_EXPLAIN}</p> + {avatar_drivers.OUTPUT} + </div> + <!-- END avatar_drivers --> + </div> </fieldset> <fieldset class="quick"> - <input class="button1" type="submit" name="update" value="{L_SUBMIT}" /> - {S_FORM_TOKEN} + <input type="submit" name="update" value="{L_SUBMIT}" class="button1" /> </fieldset> - + {S_FORM_TOKEN} </form> + + <!-- INCLUDEJS avatars.js --> diff --git a/phpBB/adm/style/avatars.js b/phpBB/adm/style/avatars.js new file mode 100644 index 0000000000..2068bdbbc4 --- /dev/null +++ b/phpBB/adm/style/avatars.js @@ -0,0 +1,15 @@ +(function($) { // Avoid conflicts with other libraries + +"use strict"; + +function avatar_simplify() { + $('#av_options > div').hide(); + + var selected = $('#avatar_driver').val(); + $('#av_option_' + selected).show(); +} + +avatar_simplify(); +$('#avatar_driver').bind('change', avatar_simplify); + +})(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/common.php b/phpBB/common.php index c4237dfcf5..068cf4e067 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -128,6 +128,8 @@ $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); $template = $phpbb_container->get('template'); $phpbb_style = $phpbb_container->get('style'); +$phpbb_avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $phpbb_extension_manager, $cache->get_driver()); + // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('phpbb_template', 'display'))); diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 3d3e478032..1d03a5b06e 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1168,7 +1168,7 @@ function get_schema_struct() 'group_desc_uid' => array('VCHAR:8', ''), 'group_display' => array('BOOL', 0), 'group_avatar' => array('VCHAR', ''), - 'group_avatar_type' => array('TINT:2', 0), + 'group_avatar_type' => array('VCHAR:32', ''), 'group_avatar_width' => array('USINT', 0), 'group_avatar_height' => array('USINT', 0), 'group_rank' => array('UINT', 0), @@ -1823,7 +1823,7 @@ function get_schema_struct() 'user_allow_massemail' => array('BOOL', 1), 'user_options' => array('UINT:11', 230271), 'user_avatar' => array('VCHAR', ''), - 'user_avatar_type' => array('TINT:2', 0), + 'user_avatar_type' => array('VCHAR:32', ''), 'user_avatar_width' => array('USINT', 0), 'user_avatar_height' => array('USINT', 0), 'user_sig' => array('MTEXT_UNI', ''), diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 79f53245b9..cb5fcbbef0 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -101,6 +101,8 @@ if (isset($_GET['avatar'])) // worst-case default $browser = strtolower($request->header('User-Agent', 'msie 6.0')); + $phpbb_avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $phpbb_extension_manager, $cache->get_driver()); + $filename = request_var('avatar', ''); $avatar_group = false; $exit = false; diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index b604e20094..1109c64d00 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -26,7 +26,7 @@ class acp_groups { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; - global $request; + global $request, $phpbb_avatar_manager; $user->add_lang('acp/groups'); $this->tpl_name = 'acp_groups'; @@ -55,7 +55,6 @@ class acp_groups // Clear some vars - $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; $group_row = array(); // Grab basic data for group, if group_id is set and exists @@ -282,8 +281,21 @@ class acp_groups $error = array(); $user->add_lang('ucp'); - $avatar_select = basename(request_var('avatar_select', '')); - $category = basename(request_var('category', '')); + // Setup avatar data for later + $avatars_enabled = false; + $avatar_drivers = null; + $avatar_data = null; + $avatar_error = array(); + + if ($config['allow_avatar']) + { + $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); + sort($avatar_drivers); + + // This is normalised data, without the group_ prefix + $avatar_data = phpbb_avatar_manager::clean_row($group_row); + } + // Did we submit? if ($update) @@ -301,12 +313,6 @@ class acp_groups $allow_desc_urls = request_var('desc_parse_urls', false); $allow_desc_smilies = request_var('desc_parse_smilies', false); - $data['uploadurl'] = request_var('uploadurl', ''); - $data['remotelink'] = request_var('remotelink', ''); - $data['width'] = request_var('width', ''); - $data['height'] = request_var('height', ''); - $delete = request_var('delete', ''); - $submit_ary = array( 'colour' => request_var('group_colour', ''), 'rank' => request_var('group_rank', 0), @@ -323,82 +329,38 @@ class acp_groups { $submit_ary['founder_manage'] = isset($_REQUEST['group_founder_manage']) ? 1 : 0; } - - $uploadfile = $request->file('uploadfile'); - if (!empty($uploadfile['tmp_name']) || $data['uploadurl'] || $data['remotelink']) - { - // Avatar stuff - $var_ary = array( - 'uploadurl' => array('string', true, 5, 255), - 'remotelink' => array('string', true, 5, 255), - 'width' => array('string', true, 1, 3), - 'height' => array('string', true, 1, 3), - ); - - if (!($error = validate_data($data, $var_ary))) - { - $data['user_id'] = "g$group_id"; - - if ((!empty($uploadfile['tmp_name']) || $data['uploadurl']) && $can_upload) - { - list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error); - } - else if ($data['remotelink']) - { - list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error); - } - } - } - else if ($avatar_select && $config['allow_avatar_local']) - { - // check avatar gallery - if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) - { - $submit_ary['avatar_type'] = AVATAR_GALLERY; - - list($submit_ary['avatar_width'], $submit_ary['avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_select); - $submit_ary['avatar'] = $category . '/' . $avatar_select; - } - } - else if ($delete) - { - $submit_ary['avatar'] = ''; - $submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0; - } - else if ($data['width'] && $data['height']) - { - // Only update the dimensions? - if ($config['avatar_max_width'] || $config['avatar_max_height']) + + if ($config['allow_avatar']) { + // Handle avatar + $driver = request_var('avatar_driver', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$driver"]) { - if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height']) - { - $error[] = phpbb_avatar_error_wrong_size($data['width'], $data['height']); - } - } + $avatar = $phpbb_avatar_manager->get_driver($driver); + $result = $avatar->process_form($template, $avatar_data, $avatar_error); - if (!sizeof($error)) - { - if ($config['avatar_min_width'] || $config['avatar_min_height']) + if ($result && empty($avatar_error)) { - if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height']) - { - $error[] = phpbb_avatar_error_wrong_size($data['width'], $data['height']); - } + // Success! Lets save the result + + /* + $result = array( + 'avatar' => ..., + 'avatar_width' => ..., + 'avatar_height' => ..., + ); + */ + + $submit_ary = array_merge($submit_ary, $result); + $submit_ary['avatar_type'] = $driver; } } - - if (!sizeof($error)) + else { - $submit_ary['avatar_width'] = $data['width']; - $submit_ary['avatar_height'] = $data['height']; - } - } - - if ((isset($submit_ary['avatar']) && $submit_ary['avatar'] && (!isset($group_row['group_avatar']))) || $delete) - { - if (isset($group_row['group_avatar']) && $group_row['group_avatar']) - { - avatar_delete('group', $group_row, true); + // Removing the avatar + $submit_ary['avatar_type'] = ''; + $submit_ary['avatar'] = ''; + $submit_ary['avatar_width'] = 0; + $submit_ary['avatar_height'] = 0; } } @@ -425,7 +387,7 @@ class acp_groups 'rank' => 'int', 'colour' => 'string', 'avatar' => 'string', - 'avatar_type' => 'int', + 'avatar_type' => 'string', 'avatar_width' => 'int', 'avatar_height' => 'int', 'receive_pm' => 'int', @@ -555,13 +517,54 @@ class acp_groups $type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : ''; $type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : ''; - $avatar_img = (!empty($group_row['group_avatar'])) ? get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR') : '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />'; + // Load up stuff for avatars + if ($config['allow_avatar']) + { + $avatars_enabled = false; + $focused_driver = request_var('avatar_driver', $avatar_data['avatar_type']); + + foreach ($avatar_drivers as $driver) + { + if ($config["allow_avatar_$driver"]) + { + $avatars_enabled = true; + $template->set_filenames(array( + 'avatar' => "acp_avatar_options_$driver.html", + )); - $display_gallery = (isset($_POST['display_gallery'])) ? true : false; + $avatar = $phpbb_avatar_manager->get_driver($driver); - if ($config['allow_avatar_local'] && $display_gallery) + if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) + { + $driver_u = strtoupper($driver); + $template->assign_block_vars('avatar_drivers', array( + 'L_TITLE' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_TITLE'), // @TODO add lang values + 'L_EXPLAIN' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_EXPLAIN'), + + 'DRIVER' => $driver, + 'SELECTED' => ($driver == $focused_driver), + 'OUTPUT' => $template->assign_display('avatar'), + )); + } + } + } + } + + $avatar = get_group_avatar($group_row, 'GROUP_AVATAR', true); + + // Merge any avatars errors into the primary error array + // Drivers use lang constants, so we need to map to the actual strings + foreach ($avatar_error as $e) { - avatar_gallery($category, $avatar_select, 4); + if (is_array($e)) + { + $key = array_shift($e); + $error[] = vsprintf($user->lang($key), $e); + } + else + { + $error[] = $user->lang((string) $e); + } } $back_link = request_var('back_link', ''); @@ -582,12 +585,10 @@ class acp_groups 'S_ADD_GROUP' => ($action == 'add') ? true : false, 'S_GROUP_PERM' => ($action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth')) ? true : false, 'S_INCLUDE_SWATCH' => true, - 'S_CAN_UPLOAD' => $can_upload, 'S_ERROR' => (sizeof($error)) ? true : false, 'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false, - 'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false, - 'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false, 'S_USER_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false, + 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '', 'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name, @@ -608,8 +609,7 @@ class acp_groups 'S_RANK_OPTIONS' => $rank_options, 'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == USER_FOUNDER) ? false : 0)), - 'AVATAR' => $avatar_img, - 'AVATAR_IMAGE' => $avatar_img, + 'AVATAR' => (empty($avatar) ? '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $avatar), 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], 'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '', 'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '', diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 82d8ef5cbb..83c19b3ba6 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -33,6 +33,7 @@ class acp_users global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; global $phpbb_dispatcher, $request; + global $phpbb_avatar_manager; $user->add_lang(array('posting', 'ucp', 'acp/users')); $this->tpl_name = 'acp_users'; @@ -453,10 +454,10 @@ class acp_users { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } - + $sql_ary = array( 'user_avatar' => '', - 'user_avatar_type' => 0, + 'user_avatar_type' => '', 'user_avatar_width' => 0, 'user_avatar_height' => 0, ); @@ -467,9 +468,10 @@ class acp_users $db->sql_query($sql); // Delete old avatar if present - if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) + $driver = $phpbb_avatar_manager->get_driver($user_row['user_avatar_type']); + if ($driver) { - avatar_delete('user', $user_row); + $driver->delete($user_row); } add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']); @@ -1728,65 +1730,124 @@ class acp_users case 'avatar': include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - - $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; - if ($submit) + $avatars_enabled = false; + if ($config['allow_avatar']) { + $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); + sort($avatar_drivers); - if (!check_form_key($form_name)) + // This is normalised data, without the user_ prefix + $avatar_data = phpbb_avatar_manager::clean_row($user_row); + + if ($submit) { + if (check_form_key($form_name)) + { + $driver = request_var('avatar_driver', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$driver"]) + { + $avatar = $phpbb_avatar_manager->get_driver($driver); + $result = $avatar->process_form($template, $avatar_data, $error); + + if ($result && empty($error)) + { + // Success! Lets save the result in the database + $result = array( + 'user_avatar_type' => $driver, + 'user_avatar' => $result['avatar'], + 'user_avatar_width' => $result['avatar_width'], + 'user_avatar_height' => $result['avatar_height'], + ); + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $result) . ' + WHERE user_id = ' . $user_id; + + $db->sql_query($sql); + trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); + } + } + else + { + // Removing the avatar + $result = array( + 'user_avatar' => '', + 'user_avatar_type' => '', + 'user_avatar_width' => 0, + 'user_avatar_height' => 0, + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $result) . ' + WHERE user_id = ' . $user_id; + + $db->sql_query($sql); + trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); + } + } + else + { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); + } } - if (avatar_process_user($error, $user_row, $can_upload)) + $focused_driver = request_var('avatar_driver', $user_row['user_avatar_type']); + + foreach ($avatar_drivers as $driver) { - trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_row['user_id'])); - } + if ($config["allow_avatar_$driver"]) + { + $avatars_enabled = true; + $template->set_filenames(array( + 'avatar' => "acp_avatar_options_$driver.html", + )); - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } + $avatar = $phpbb_avatar_manager->get_driver($driver); - if (!$config['allow_avatar'] && $user_row['user_avatar_type']) - { - $error[] = $user->lang['USER_AVATAR_NOT_ALLOWED']; - } - else if ((($user_row['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) || - (($user_row['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) || - (($user_row['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local'])) - { - $error[] = $user->lang['USER_AVATAR_TYPE_NOT_ALLOWED']; + if ($avatar->prepare_form($template, $avatar_data, $error)) + { + $driver_u = strtoupper($driver); + $template->assign_block_vars('avatar_drivers', array( + 'L_TITLE' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_TITLE'), // @TODO add lang values + 'L_EXPLAIN' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_EXPLAIN'), + + 'DRIVER' => $driver, + 'SELECTED' => ($driver == $focused_driver), + 'OUTPUT' => $template->assign_display('avatar'), + )); + } + } + } } - // Generate users avatar - $avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height'], 'USER_AVATAR', true) : '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />'; - - $display_gallery = (isset($_POST['display_gallery'])) ? true : false; - $avatar_select = basename(request_var('avatar_select', '')); - $category = basename(request_var('category', '')); - - if ($config['allow_avatar_local'] && $display_gallery) + // Replace "error" strings with their real, localised form + $err = $error; + $error = array(); + foreach ($err as $e) { - avatar_gallery($category, $avatar_select, 4); + if (is_array($e)) + { + $key = array_shift($e); + $error[] = vsprintf($user->lang($key), $e); + } + else + { + $error[] = $user->lang((string) $e); + } } + + $avatar = get_user_avatar($user_row, 'USER_AVATAR', true); $template->assign_vars(array( - 'S_AVATAR' => true, - 'S_CAN_UPLOAD' => $can_upload, - 'S_UPLOAD_FILE' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_upload']) ? true : false, - 'S_REMOTE_UPLOAD' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_remote_upload']) ? true : false, - 'S_ALLOW_REMOTE' => ($config['allow_avatar'] && $config['allow_avatar_remote']) ? true : false, - 'S_DISPLAY_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && !$display_gallery) ? true : false, - 'S_IN_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && $display_gallery) ? true : false, - - 'AVATAR_IMAGE' => $avatar_img, - 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], - 'USER_AVATAR_WIDTH' => $user_row['user_avatar_width'], - 'USER_AVATAR_HEIGHT' => $user_row['user_avatar_height'], - - 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), + 'S_AVATAR' => true, + 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', + 'AVATAR' => (empty($avatar) ? '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $avatar), + + 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', + + 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024), + + 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), )); break; diff --git a/phpBB/includes/avatar/driver/core/local.php b/phpBB/includes/avatar/driver/core/local.php new file mode 100644 index 0000000000..ca82b9c175 --- /dev/null +++ b/phpBB/includes/avatar/driver/core/local.php @@ -0,0 +1,189 @@ +<?php +/** +* +* @package avatar +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Handles avatars selected from the board gallery +* @package avatars +*/ +class phpbb_avatar_driver_core_local extends phpbb_avatar_driver +{ + /** + * @inheritdoc + */ + public function get_data($row, $ignore_config = false) + { + if ($ignore_config || $this->config['allow_avatar_local']) + { + return array( + 'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], + ); + } + else + { + return array( + 'src' => '', + 'width' => 0, + 'height' => 0, + ); + } + } + + /** + * @inheritdoc + */ + public function prepare_form($template, $row, &$error) + { + $avatar_list = $this->get_avatar_list(); + $category = $this->request->variable('av_local_cat', ''); + + $categories = array_keys($avatar_list); + + foreach ($categories as $cat) + { + if (!empty($avatar_list[$cat])) + { + $template->assign_block_vars('av_local_cats', array( + 'NAME' => $cat, + 'SELECTED' => ($cat == $category), + )); + } + } + + if (!empty($avatar_list[$category])) + { + $template->assign_vars(array( + 'AV_LOCAL_SHOW' => true, + )); + + $table_cols = isset($row['av_gallery_cols']) ? $row['av_gallery_cols'] : 4; + $row_count = $col_count = $av_pos = 0; + $av_count = sizeof($avatar_list[$category]); + + reset($avatar_list[$category]); + + while ($av_pos < $av_count) + { + $img = current($avatar_list[$category]); + next($avatar_list[$category]); + + if ($col_count == 0) + { + ++$row_count; + $template->assign_block_vars('av_local_row', array( + )); + } + + $template->assign_block_vars('av_local_row.av_local_col', array( + 'AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'], + 'AVATAR_NAME' => $img['name'], + 'AVATAR_FILE' => $img['filename'], + )); + + $col_count = ($col_count + 1) % $table_cols; + + ++$av_pos; + } + } + + return true; + } + + /** + * @inheritdoc + */ + public function process_form($template, $row, &$error) + { + $avatar_list = $this->get_avatar_list(); + $category = $this->request->variable('av_local_cat', ''); + + $file = $this->request->variable('av_local_file', ''); + if (!isset($avatar_list[$category][urldecode($file)])) + { + $error[] = 'AVATAR_URL_NOT_FOUND'; + return false; + } + + return array( + 'avatar' => $category . '/' . $file, + 'avatar_width' => $avatar_list[$category][urldecode($file)]['width'], + 'avatar_height' => $avatar_list[$category][urldecode($file)]['height'], + ); + } + + /** + * @TODO + */ + private function get_avatar_list() + { + $avatar_list = ($this->cache == null) ? false : $this->cache->get('av_local_list'); + + if (!$avatar_list) + { + $avatar_list = array(); + $path = $this->phpbb_root_path . $this->config['avatar_gallery_path']; + + $dh = @opendir($path); + + if ($dh) + { + while (($cat = readdir($dh)) !== false) { + if ($cat[0] != '.' && preg_match('#^[^&"\'<>]+$#i', $cat) && is_dir("$path/$cat")) + { + if ($ch = @opendir("$path/$cat")) + { + while (($image = readdir($ch)) !== false) + { + // Match all images in the gallery folder + if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image)) + { + if (function_exists('getimagesize')) + { + $dims = getimagesize($this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $cat . '/' . $image); + } + else + { + $dims = array(0, 0); + } + $avatar_list[$cat][$image] = array( + 'file' => rawurlencode($cat) . '/' . rawurlencode($image), + 'filename' => rawurlencode($image), + 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))), + 'width' => $dims[0], + 'height' => $dims[1], + ); + } + } + @closedir($ch); + } + } + } + @closedir($dh); + } + + @ksort($avatar_list); + + if ($this->cache != null) + { + $this->cache->put('av_local_list', $avatar_list); + } + } + + return $avatar_list; + } +} diff --git a/phpBB/includes/avatar/driver/core/remote.php b/phpBB/includes/avatar/driver/core/remote.php new file mode 100644 index 0000000000..9f5a58e75a --- /dev/null +++ b/phpBB/includes/avatar/driver/core/remote.php @@ -0,0 +1,163 @@ +<?php +/** +* +* @package avatar +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Handles avatars hosted remotely +* @package avatars +*/ +class phpbb_avatar_driver_core_remote extends phpbb_avatar_driver +{ + /** + * @inheritdoc + */ + public function get_data($row, $ignore_config = false) + { + if ($ignore_config || $this->config['allow_avatar_remote']) + { + return array( + 'src' => $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], + ); + } + else + { + return array( + 'src' => '', + 'width' => 0, + 'height' => 0, + ); + } + } + + /** + * @inheritdoc + */ + public function prepare_form($template, $row, &$error) + { + $template->assign_vars(array( + 'AV_REMOTE_WIDTH' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_width']) ? $row['avatar_width'] : $this->request->variable('av_local_width', 0), + 'AV_REMOTE_HEIGHT' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_height']) ? $row['avatar_height'] : $this->request->variable('av_local_width', 0), + 'AV_REMOTE_URL' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar']) ? $row['avatar'] : '', + )); + + return true; + } + + /** + * @inheritdoc + */ + public function process_form($template, $row, &$error) + { + $url = $this->request->variable('av_remote_url', ''); + $width = $this->request->variable('av_remote_width', 0); + $height = $this->request->variable('av_remote_height', 0); + + if (!preg_match('#^(http|https|ftp)://#i', $url)) + { + $url = 'http://' . $url; + } + + require_once($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx); + + $error = array_merge($error, validate_data(array( + 'url' => $url, + ), array( + 'url' => array('string', true, 5, 255), + ))); + + if (!empty($error)) + { + return false; + } + + // Check if this url looks alright + // This isn't perfect, but it's what phpBB 3.0 did, and might as well make sure everything is compatible + if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.(gif|jpg|jpeg|png)$#i', $url)) + { + $error[] = 'AVATAR_URL_INVALID'; + return false; + } + + // Make sure getimagesize works... + if (function_exists('getimagesize')) + { + if (($width <= 0 || $height <= 0) && (($image_data = @getimagesize($url)) === false)) + { + $error[] = 'UNABLE_GET_IMAGE_SIZE'; + return false; + } + + if (!empty($image_data) && ($image_data[0] <= 0 || $image_data[1] <= 0)) + { + $error[] = 'AVATAR_NO_SIZE'; + return false; + } + + $width = ($width && $height) ? $width : $image_data[0]; + $height = ($width && $height) ? $height : $image_data[1]; + } + + if ($width <= 0 || $height <= 0) + { + $error[] = 'AVATAR_NO_SIZE'; + return false; + } + + include_once($this->phpbb_root_path . 'includes/functions_upload.' . $this->phpEx); + $types = fileupload::image_types(); + $extension = strtolower(filespec::get_extension($url)); + + if (!empty($image_data) && (!isset($types[$image_data[2]]) || !in_array($extension, $types[$image_data[2]]))) + { + if (!isset($types[$image_data[2]])) + { + $error[] = 'UNABLE_GET_IMAGE_SIZE'; + } + else + { + $error[] = array('IMAGE_FILETYPE_MISMATCH', $types[$image_data[2]][0], $extension); + } + + return false; + } + + if ($this->config['avatar_max_width'] || $this->config['avatar_max_height']) + { + if ($width > $this->config['avatar_max_width'] || $height > $this->config['avatar_max_height']) + { + $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height); + return false; + } + } + + if ($this->config['avatar_min_width'] || $this->config['avatar_min_height']) + { + if ($width < $this->config['avatar_min_width'] || $height < $this->config['avatar_min_height']) + { + $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height); + return false; + } + } + + return array( + 'avatar' => $url, + 'avatar_width' => $width, + 'avatar_height' => $height, + ); + } +} diff --git a/phpBB/includes/avatar/driver/core/upload.php b/phpBB/includes/avatar/driver/core/upload.php new file mode 100644 index 0000000000..d0ce856dbe --- /dev/null +++ b/phpBB/includes/avatar/driver/core/upload.php @@ -0,0 +1,147 @@ +<?php +/** +* +* @package avatar +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Handles avatars uploaded to the board +* @package avatars +*/ +class phpbb_avatar_driver_core_upload extends phpbb_avatar_driver +{ + /** + * @inheritdoc + */ + public function get_data($row, $ignore_config = false) + { + if ($ignore_config || $this->config['allow_avatar_upload']) + { + return array( + 'src' => $this->phpbb_root_path . 'download/file.' . $this->phpEx . '?avatar=' . $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], + ); + } + else + { + return array( + 'src' => '', + 'width' => 0, + 'height' => 0, + ); + } + } + + /** + * @inheritdoc + */ + public function prepare_form($template, $row, &$error) + { + if (!$this->can_upload()) + { + return false; + } + + $template->assign_vars(array( + 'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false, + 'AV_UPLOAD_SIZE' => $this->config['avatar_filesize'], + )); + + return true; + } + + /** + * @inheritdoc + */ + public function process_form($template, $row, &$error) + { + if (!$this->can_upload()) + { + return false; + } + + include_once($this->phpbb_root_path . 'includes/functions_upload.' . $this->phpEx); + + $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false)); + + $url = $this->request->variable('av_upload_url', ''); + + if (!empty($_FILES['av_upload_file']['name'])) + { + $file = $upload->form_upload('av_upload_file'); + } + else + { + $file = $upload->remote_upload($url); + } + + $prefix = $this->config['avatar_salt'] . '_'; + $file->clean_filename('avatar', $prefix, $row['id']); + + $destination = $this->config['avatar_path']; + + // Adjust destination path (no trailing slash) + if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') + { + $destination = substr($destination, 0, -1); + } + + $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); + if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) + { + $destination = ''; + } + + // Move file and overwrite any existing image + $file->move_file($destination, true); + + if (sizeof($file->error)) + { + $file->remove(); + $error = array_merge($error, $file->error); + return false; + } + + return array( + 'avatar' => $row['id'] . '_' . time() . '.' . $file->get('extension'), + 'avatar_width' => $file->get('width'), + 'avatar_height' => $file->get('height'), + ); + } + + /** + * @inheritdoc + */ + public function delete($row) + { + $ext = substr(strrchr($row['avatar'], '.'), 1); + $filename = $this->phpbb_root_path . $this->config['avatar_path'] . '/' . $this->config['avatar_salt'] . '_' . $row['id'] . '.' . $ext; + + if (file_exists($filename)) + { + @unlink($filename); + } + + return true; + } + + /** + * @TODO + */ + private function can_upload() + { + return (file_exists($this->phpbb_root_path . $this->config['avatar_path']) && phpbb_is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')); + } +} diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php new file mode 100644 index 0000000000..5cebd1533d --- /dev/null +++ b/phpBB/includes/avatar/driver/driver.php @@ -0,0 +1,143 @@ +<?php +/** +* +* @package avatar +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Base class for avatar drivers +* @package avatars +*/ +abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface +{ + /** + * Current board configuration + * @type phpbb_config + */ + protected $config; + + /** + * Current board configuration + * @type phpbb_config + */ + protected $request; + + /** + * Current $phpbb_root_path + * @type string + */ + protected $phpbb_root_path; + + /** + * Current $phpEx + * @type string + */ + protected $phpEx; + + /** + * A cache driver + * @type phpbb_cache_driver_interface + */ + protected $cache; + + /** + * This flag should be set to true if the avatar requires a nonstandard image + * tag, and will generate the html itself. + * @type boolean + */ + public $custom_html = false; + + /** + * Construct an driver object + * + * @param $config The phpBB configuration + * @param $request The request object + * @param $phpbb_root_path The path to the phpBB root + * @param $phpEx The php file extension + * @param $cache A cache driver + */ + public function __construct(phpbb_config $config, phpbb_request $request, $phpbb_root_path, $phpEx, phpbb_cache_driver_interface $cache = null) + { + $this->config = $config; + $this->request = $request; + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->cache = $cache; + } + + /** + * @inheritdoc + */ + public function get_data($row, $ignore_config = false) + { + return array( + 'src' => '', + 'width' => 0, + 'height' => 0, + ); + } + + /** + * @inheritdoc + */ + public function get_custom_html($row, $ignore_config = false) + { + return ''; + } + + /** + * @inheritdoc + **/ + public function prepare_form($template, $row, &$error) + { + return false; + } + + /** + * @inheritdoc + **/ + public function process_form($template, $row, &$error) + { + return false; + } + + /** + * @inheritdoc + **/ + public function delete($row) + { + return true; + } + + /** + * @inheritdoc + **/ + public function is_enabled() + { + $driver = preg_replace('#^phpbb_avatar_driver_core_#', '', get_class($this)); + + return $this->config["allow_avatar_$driver"]; + } + + /** + * @inheritdoc + **/ + public function get_template_name() + { + $driver = preg_replace('#^phpbb_avatar_driver_core_#', '', get_class($this)); + $template = "ucp_avatar_options_$driver.html"; + + return $template; + } +} diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/includes/avatar/driver/interface.php new file mode 100644 index 0000000000..4f1c1f73cf --- /dev/null +++ b/phpBB/includes/avatar/driver/interface.php @@ -0,0 +1,70 @@ +<?php +/** +* +* @package avatar +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Interface for avatar drivers +* @package avatars +*/ +interface phpbb_avatar_driver_interface +{ + /** + * Get the avatar url and dimensions + * + * @param $ignore_config Whether this function should respect the users prefs + * and board configuration configuration option, or should just render + * the avatar anyways. Useful for the ACP. + * @return array Avatar data, must have keys src, width and height, e.g. + * ['src' => '', 'width' => 0, 'height' => 0] + */ + public function get_data($row, $ignore_config = false); + + /** + * Returns custom html for displaying this avatar. + * Only called if $custom_html is true. + * + * @param $ignore_config Whether this function should respect the users prefs + * and board configuration configuration option, or should just render + * the avatar anyways. Useful for the ACP. + * @return string HTML + */ + public function get_custom_html($row, $ignore_config = false); + + /** + * @TODO + **/ + public function prepare_form($template, $row, &$error); + + /** + * @TODO + **/ + public function process_form($template, $row, &$error); + + /** + * @TODO + **/ + public function delete($row); + + /** + * @TODO + **/ + public function is_enabled(); + + /** + * @TODO + **/ + public function get_template_name(); +} diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php new file mode 100644 index 0000000000..c2c3dbbbca --- /dev/null +++ b/phpBB/includes/avatar/manager.php @@ -0,0 +1,146 @@ +<?php +/** +* +* @package avatar +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* @package avatar +*/ +class phpbb_avatar_manager +{ + private $phpbb_root_path; + private $phpEx; + private $config; + private $request; + private $extension_manager; + private $cache; + private static $valid_drivers = false; + + /** + * @TODO + **/ + public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_request $request, phpbb_extension_manager $extension_manager, phpbb_cache_driver_interface $cache = null) + { + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->config = $config; + $this->request = $request; + $this->extension_manager = $extension_manager; + $this->cache = $cache; + } + + /** + * @TODO + **/ + public function get_driver($avatar_type) + { + if (self::$valid_drivers === false) + { + $this->load_valid_drivers(); + } + + // Legacy stuff... + switch ($avatar_type) + { + case AVATAR_GALLERY: + $avatar_type = 'phpbb_avatar_driver_local'; + break; + case AVATAR_UPLOAD: + $avatar_type = 'phpbb_avatar_driver_upload'; + break; + case AVATAR_REMOTE: + $avatar_type = 'phpbb_avatar_driver_remote'; + break; + } + + if (false === array_search($avatar_type, self::$valid_drivers)) + { + return null; + } + + $r = new ReflectionClass($avatar_type); + + if ($r->isSubClassOf('phpbb_avatar_driver')) { + $driver = new $avatar_type($this->config, $this->request, $this->phpbb_root_path, $this->phpEx, $this->cache); + } else if ($r->implementsInterface('phpbb_avatar_driver')) { + $driver = new $avatar_type(); + } else { + $message = "Invalid avatar driver class name '%s' provided. It must implement phpbb_avatar_driver_interface."; + trigger_error(sprintf($message, $avatar_type)); + } + + return $driver; + } + + /** + * @TODO + **/ + private function load_valid_drivers() + { + if ($this->cache) + { + self::$valid_drivers = $this->cache->get('avatar_drivers'); + } + + if (empty($this->valid_drivers)) + { + self::$valid_drivers = array(); + + $finder = $this->extension_manager->get_finder(); + + self::$valid_drivers = $finder + ->extension_directory('/avatar/driver/') + ->core_path('includes/avatar/driver/core/') + ->get_classes(); + + if ($this->cache) + { + $this->cache->put('avatar_drivers', self::$valid_drivers); + } + } + } + + /** + * @TODO + **/ + public function get_valid_drivers() + { + if (self::$valid_drivers === false) + { + $this->load_valid_drivers(); + } + + return self::$valid_drivers; + } + + /** + * Strip out user_ and group_ prefixes from keys + **/ + public static function clean_row($row) + { + $keys = array_keys($row); + $values = array_values($row); + + $keys = array_map( + function ($key) + { + return preg_replace('#^(?:user_|group_)#', '', $key); + }, + $keys + ); + + return array_combine($keys, $values); + } +} diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 73129803ee..f84652fc50 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1313,79 +1313,86 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank /** * Get user avatar * -* @param string $avatar Users assigned avatar name -* @param int $avatar_type Type of avatar -* @param string $avatar_width Width of users avatar -* @param string $avatar_height Height of users avatar +* @param array $user_row Row from the users table * @param string $alt Optional language string for alt tag within image, can be a language key or text * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP * -* @return string Avatar image +* @return string Avatar html */ -function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false) +function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false) { - global $user, $config, $phpbb_root_path, $phpEx; - global $phpbb_dispatcher; - - $overwrite_avatar = ''; + $row = phpbb_avatar_manager::clean_row($user_row); + return get_avatar($row, $alt, $ignore_config); +} - /** - * Overwrite users avatar - * - * @event core.display_custom_bbcodes_modify_row - * @var string avatar Users assigned avatar name - * @var int avatar_type Type of avatar - * @var string avatar_width Width of users avatar - * @var string avatar_height Height of users avatar - * @var string alt Language string for alt tag within image - * Can be a language key or text - * @var bool ignore_config Ignores config and force displaying avatar - * @var string overwrite_avatar If set, this string will be the avatar - * @since 3.1-A1 - */ - $vars = array('avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'alt', 'ignore_config', 'overwrite_avatar'); - extract($phpbb_dispatcher->trigger_event('core.user_get_avatar', compact($vars))); +/** +* Get group avatar +* +* @param array $group_row Row from the groups table +* @param string $alt Optional language string for alt tag within image, can be a language key or text +* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP +* +* @return string Avatar html +*/ +function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false) +{ + $row = phpbb_avatar_manager::clean_row($user_row); + return get_avatar($row, $alt, $ignore_config); +} - if ($overwrite_avatar) - { - return $overwrite_avatar; - } +/** +* Get avatar +* +* @param array $row Row cleaned by phpbb_avatar_driver::clean_row +* @param string $alt Optional language string for alt tag within image, can be a language key or text +* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP +* +* @return string Avatar html +*/ +function get_avatar($row, $alt, $ignore_config = false) +{ + global $user, $config, $cache, $phpbb_root_path, $phpEx; + global $request; + global $phpbb_avatar_manager; - if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config)) + if (!$config['allow_avatar'] && !$ignore_config) { return ''; } - $avatar_img = ''; + $avatar_data = array( + 'src' => $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], + ); + + $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); - switch ($avatar_type) + if ($avatar) { - case AVATAR_UPLOAD: - if (!$config['allow_avatar_upload'] && !$ignore_config) - { - return ''; - } - $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar="; - break; + if ($avatar->custom_html) + { + return $avatar->get_html($row, $ignore_config); + } - case AVATAR_GALLERY: - if (!$config['allow_avatar_local'] && !$ignore_config) - { - return ''; - } - $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/'; - break; + $avatar_data = $avatar->get_data($row, $ignore_config); + } + else + { + $avatar_data['src'] = ''; + } - case AVATAR_REMOTE: - if (!$config['allow_avatar_remote'] && !$ignore_config) - { - return ''; - } - break; + $html = ''; + + if (!empty($avatar_data['src'])) + { + $html = '<img src="' . $avatar_data['src'] . '" ' . + ($avatar_data['width'] ? ('width="' . $avatar_data['width'] . '" ') : '') . + ($avatar_data['height'] ? ('height="' . $avatar_data['height'] . '" ') : '') . + 'alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />'; } - $avatar_img .= $avatar; - return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />'; + return $html; } /** diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 8f9c9198f4..7cac0fb34f 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2048,6 +2048,7 @@ function avatar_delete($mode, $row, $clean_db = false) avatar_remove_db($row[$mode . '_avatar']); } $filename = get_avatar_filename($row[$mode . '_avatar']); + if (file_exists($phpbb_root_path . $config['avatar_path'] . '/' . $filename)) { @unlink($phpbb_root_path . $config['avatar_path'] . '/' . $filename); diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index 59cdf3c27e..0b00d77d8f 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -179,7 +179,7 @@ class mcp_notes } $rank_title = $rank_img = ''; - $avatar_img = get_user_avatar($userrow['user_avatar'], $userrow['user_avatar_type'], $userrow['user_avatar_width'], $userrow['user_avatar_height']); + $avatar_img = get_user_avatar($userrow); $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']); diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 6a8fb4c5d5..f88ac3803f 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -310,7 +310,7 @@ class mcp_warn } get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src); - $avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']); + $avatar_img = get_user_avatar($user_row); $template->assign_vars(array( 'U_POST_ACTION' => $this->u_action, @@ -415,7 +415,7 @@ class mcp_warn } get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src); - $avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']); + $avatar_img = get_user_avatar($user_row); // OK, they didn't submit a warning so lets build the page for them to do so $template->assign_vars(array( diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 9652986cf2..3aa6146081 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -438,7 +438,7 @@ class ucp_groups $group_name = $group_row['group_name']; $group_type = $group_row['group_type']; - $avatar_img = (!empty($group_row['group_avatar'])) ? get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR') : '<img src="' . $phpbb_root_path . 'adm/images/no_avatar.gif" alt="" />'; + $avatar_img = (!empty($group_row['group_avatar'])) ? get_group_avatar($group_row) : '<img src="' . $phpbb_root_path . 'adm/images/no_avatar.gif" alt="" />'; $template->assign_vars(array( 'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name, diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index c85b05f144..42b63f8ce1 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -376,7 +376,7 @@ function get_user_information($user_id, $user_row) include($phpbb_root_path . 'includes/functions_display.' . $phpEx); } - $user_row['avatar'] = ($user->optionget('viewavatars')) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']) : ''; + $user_row['avatar'] = ($user->optionget('viewavatars')) ? get_user_avatar($user_row) : ''; get_user_rank($user_row['user_rank'], $user_row['user_posts'], $user_row['rank_title'], $user_row['rank_image'], $user_row['rank_image_src']); diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 89bf20a30f..4b0e59b9e8 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -28,8 +28,9 @@ class ucp_profile function main($id, $mode) { - global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; + global $cache, $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; global $request; + global $phpbb_avatar_manager; $user->add_lang('posting'); @@ -544,79 +545,142 @@ class ucp_profile break; case 'avatar': + include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); + add_form_key('ucp_avatar'); - $display_gallery = request_var('display_gallery', '0'); - $avatar_select = basename(request_var('avatar_select', '')); - $category = basename(request_var('category', '')); + $avatars_enabled = false; - $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; + if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar')) + { + $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); + sort($avatar_drivers); - add_form_key('ucp_avatar'); + // This is normalised data, without the user_ prefix + $avatar_data = phpbb_avatar_manager::clean_row($user->data); - if ($submit) - { - if (check_form_key('ucp_avatar')) + if ($submit) { - if (avatar_process_user($error, false, $can_upload)) + if (check_form_key('ucp_avatar')) { - 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); + $driver = request_var('avatar_driver', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$driver"]) + { + $avatar = $phpbb_avatar_manager->get_driver($driver); + $result = $avatar->process_form($template, $avatar_data, $error); + + if ($result && empty($error)) + { + // Success! Lets save the result in the database + $result = array( + 'user_avatar_type' => $driver, + 'user_avatar' => $result['avatar'], + 'user_avatar_width' => $result['avatar_width'], + 'user_avatar_height' => $result['avatar_height'], + ); + + $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 + { + // They are removing their avatar or are trying to play games with us + if ($avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type'])) + { + $avatar->delete($avatar_data); + } + + $result = array( + 'user_avatar' => '', + 'user_avatar_type' => '', + 'user_avatar_width' => 0, + 'user_avatar_height' => 0, + ); + + $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 + { + $error[] = 'FORM_INVALID'; } } - else + + $focused_driver = request_var('avatar_driver', $user->data['user_avatar_type']); + + foreach ($avatar_drivers as $driver) { - $error[] = 'FORM_INVALID'; + $avatar = $phpbb_avatar_manager->get_driver($driver); + + if ($avatar->is_enabled()) + { + $avatars_enabled = true; + $template->set_filenames(array( + 'avatar' => $avatar->get_template_name(), + )); + + if ($avatar->prepare_form($template, $avatar_data, $error)) + { + $driver_u = strtoupper($driver); + + $template->assign_block_vars('avatar_drivers', array( + 'L_TITLE' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_TITLE'), // @TODO add lang values + 'L_EXPLAIN' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_EXPLAIN'), + + 'DRIVER' => $driver, + 'SELECTED' => ($driver == $focused_driver), + 'OUTPUT' => $template->assign_display('avatar'), + )); + } + } } - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); } - if (!$config['allow_avatar'] && $user->data['user_avatar_type']) - { - $error[] = $user->lang['AVATAR_NOT_ALLOWED']; - } - else if ((($user->data['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) || - (($user->data['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) || - (($user->data['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local'])) + // Replace "error" strings with their real, localised form + $err = $error; + $error = array(); + foreach ($err as $e) { - $error[] = $user->lang['AVATAR_TYPE_NOT_ALLOWED']; + if (is_array($e)) + { + $key = array_shift($e); + $error[] = vsprintf($user->lang($key), $e); + } + else + { + $error[] = $user->lang((string) $e); + } } + + $avatar = get_user_avatar($user->data, 'USER_AVATAR', true); $template->assign_vars(array( 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', - 'AVATAR' => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height'], 'USER_AVATAR', true), - 'AVATAR_SIZE' => $config['avatar_filesize'], - - 'U_GALLERY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=avatar&display_gallery=1'), + 'AVATAR' => $avatar, - 'S_FORM_ENCTYPE' => ($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) ? ' enctype="multipart/form-data"' : '', + 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), + + 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), )); - if ($config['allow_avatar'] && $display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) - { - avatar_gallery($category, $avatar_select, 4); - } - else if ($config['allow_avatar']) - { - $avatars_enabled = (($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) || ($auth->acl_get('u_chgavatar') && ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false; - - $template->assign_vars(array( - 'AVATAR_WIDTH' => request_var('width', $user->data['user_avatar_width']), - 'AVATAR_HEIGHT' => request_var('height', $user->data['user_avatar_height']), - - 'S_AVATARS_ENABLED' => $avatars_enabled, - 'S_UPLOAD_AVATAR_FILE' => ($can_upload && $config['allow_avatar_upload']) ? true : false, - 'S_UPLOAD_AVATAR_URL' => ($can_upload && $config['allow_avatar_remote_upload']) ? true : false, - 'S_LINK_AVATAR' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_remote']) ? true : false, - 'S_DISPLAY_GALLERY' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false) - ); - } - break; case 'autologin_keys': diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 297802c210..7522720909 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1130,6 +1130,10 @@ function database_update_info() 'change_columns' => array( GROUPS_TABLE => array( 'group_legend' => array('UINT', 0), + 'group_avatar_type' => array('VCHAR:32', 0), + ), + USERS_TABLE => array( + 'user_avatar_type' => array('VCHAR:32', 0), ), USERS_TABLE => array( 'user_timezone' => array('VCHAR:100', ''), @@ -2710,6 +2714,26 @@ function change_database_data(&$no_updates, $version) $config->set('display_last_subject', '1'); } + // Update avatars to modular types + $avatar_type_map = array( + AVATAR_UPLOAD => 'upload', + AVATAR_GALLERY => 'local', + AVATAR_REMOTE => 'remote', + ); + + foreach ($avatar_type_map as $old => $new) + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_avatar_type = '" . $db->sql_escape($new) . "' + WHERE user_avatar_type = '" . $db->sql_escape($old) . "'"; + _sql($sql, $errored, $error_ary); + + $sql = 'UPDATE ' . GROUPS_TABLE . " + SET group_avatar_type = '" . $db->sql_escape($new) . "' + WHERE group_avatar_type = '" . $db->sql_escape($old) . "'"; + _sql($sql, $errored, $error_ary); + } + $no_updates = false; if (!isset($config['assets_version'])) diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 767ce68b4a..45ab3af337 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -445,7 +445,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, group_display INTEGER DEFAULT 0 NOT NULL, group_avatar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - group_avatar_type INTEGER DEFAULT 0 NOT NULL, + group_avatar_type VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, group_avatar_width INTEGER DEFAULT 0 NOT NULL, group_avatar_height INTEGER DEFAULT 0 NOT NULL, group_rank INTEGER DEFAULT 0 NOT NULL, @@ -1271,7 +1271,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail INTEGER DEFAULT 1 NOT NULL, user_options INTEGER DEFAULT 230271 NOT NULL, user_avatar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_avatar_type INTEGER DEFAULT 0 NOT NULL, + user_avatar_type VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, user_avatar_width INTEGER DEFAULT 0 NOT NULL, user_avatar_height INTEGER DEFAULT 0 NOT NULL, user_sig BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 84c975942f..1925935dc4 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -553,7 +553,7 @@ CREATE TABLE [phpbb_groups] ( [group_desc_uid] [varchar] (8) DEFAULT ('') NOT NULL , [group_display] [int] DEFAULT (0) NOT NULL , [group_avatar] [varchar] (255) DEFAULT ('') NOT NULL , - [group_avatar_type] [int] DEFAULT (0) NOT NULL , + [group_avatar_type] [varchar] (32) DEFAULT ('') NOT NULL , [group_avatar_width] [int] DEFAULT (0) NOT NULL , [group_avatar_height] [int] DEFAULT (0) NOT NULL , [group_rank] [int] DEFAULT (0) NOT NULL , @@ -1555,7 +1555,7 @@ CREATE TABLE [phpbb_users] ( [user_allow_massemail] [int] DEFAULT (1) NOT NULL , [user_options] [int] DEFAULT (230271) NOT NULL , [user_avatar] [varchar] (255) DEFAULT ('') NOT NULL , - [user_avatar_type] [int] DEFAULT (0) NOT NULL , + [user_avatar_type] [varchar] (32) DEFAULT ('') NOT NULL , [user_avatar_width] [int] DEFAULT (0) NOT NULL , [user_avatar_height] [int] DEFAULT (0) NOT NULL , [user_sig] [text] DEFAULT ('') NOT NULL , diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 8aab949103..6634615e9f 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -317,7 +317,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varbinary(8) DEFAULT '' NOT NULL, group_display tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, group_avatar varbinary(255) DEFAULT '' NOT NULL, - group_avatar_type tinyint(2) DEFAULT '0' NOT NULL, + group_avatar_type varbinary(32) DEFAULT '' NOT NULL, group_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, group_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, group_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, @@ -919,7 +919,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, user_options int(11) UNSIGNED DEFAULT '230271' NOT NULL, user_avatar varbinary(255) DEFAULT '' NOT NULL, - user_avatar_type tinyint(2) DEFAULT '0' NOT NULL, + user_avatar_type varbinary(32) DEFAULT '' NOT NULL, user_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, user_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, user_sig mediumblob NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 04aef2844a..7823c91fb8 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -317,7 +317,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varchar(8) DEFAULT '' NOT NULL, group_display tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, group_avatar varchar(255) DEFAULT '' NOT NULL, - group_avatar_type tinyint(2) DEFAULT '0' NOT NULL, + group_avatar_type varchar(32) DEFAULT '' NOT NULL, group_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, group_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, group_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, @@ -919,7 +919,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, user_options int(11) UNSIGNED DEFAULT '230271' NOT NULL, user_avatar varchar(255) DEFAULT '' NOT NULL, - user_avatar_type tinyint(2) DEFAULT '0' NOT NULL, + user_avatar_type varchar(32) DEFAULT '' NOT NULL, user_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, user_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, user_sig mediumtext NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 91f906bc8b..78592decd5 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -610,7 +610,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varchar2(8) DEFAULT '' , group_display number(1) DEFAULT '0' NOT NULL, group_avatar varchar2(255) DEFAULT '' , - group_avatar_type number(2) DEFAULT '0' NOT NULL, + group_avatar_type varchar2(32) DEFAULT '' , group_avatar_width number(4) DEFAULT '0' NOT NULL, group_avatar_height number(4) DEFAULT '0' NOT NULL, group_rank number(8) DEFAULT '0' NOT NULL, @@ -1667,7 +1667,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail number(1) DEFAULT '1' NOT NULL, user_options number(11) DEFAULT '230271' NOT NULL, user_avatar varchar2(255) DEFAULT '' , - user_avatar_type number(2) DEFAULT '0' NOT NULL, + user_avatar_type varchar2(32) DEFAULT '' , user_avatar_width number(4) DEFAULT '0' NOT NULL, user_avatar_height number(4) DEFAULT '0' NOT NULL, user_sig clob DEFAULT '' , diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 619985e0d6..f85cee4277 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -463,7 +463,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varchar(8) DEFAULT '' NOT NULL, group_display INT2 DEFAULT '0' NOT NULL CHECK (group_display >= 0), group_avatar varchar(255) DEFAULT '' NOT NULL, - group_avatar_type INT2 DEFAULT '0' NOT NULL, + group_avatar_type varchar(32) DEFAULT '' NOT NULL, group_avatar_width INT2 DEFAULT '0' NOT NULL CHECK (group_avatar_width >= 0), group_avatar_height INT2 DEFAULT '0' NOT NULL CHECK (group_avatar_height >= 0), group_rank INT4 DEFAULT '0' NOT NULL CHECK (group_rank >= 0), @@ -1169,7 +1169,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail INT2 DEFAULT '1' NOT NULL CHECK (user_allow_massemail >= 0), user_options INT4 DEFAULT '230271' NOT NULL CHECK (user_options >= 0), user_avatar varchar(255) DEFAULT '' NOT NULL, - user_avatar_type INT2 DEFAULT '0' NOT NULL, + user_avatar_type varchar(32) DEFAULT '' NOT NULL, user_avatar_width INT2 DEFAULT '0' NOT NULL CHECK (user_avatar_width >= 0), user_avatar_height INT2 DEFAULT '0' NOT NULL CHECK (user_avatar_height >= 0), user_sig TEXT DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 1690a7dcab..900ed06bfe 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -309,7 +309,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varchar(8) NOT NULL DEFAULT '', group_display INTEGER UNSIGNED NOT NULL DEFAULT '0', group_avatar varchar(255) NOT NULL DEFAULT '', - group_avatar_type tinyint(2) NOT NULL DEFAULT '0', + group_avatar_type varchar(32) NOT NULL DEFAULT '', group_avatar_width INTEGER UNSIGNED NOT NULL DEFAULT '0', group_avatar_height INTEGER UNSIGNED NOT NULL DEFAULT '0', group_rank INTEGER UNSIGNED NOT NULL DEFAULT '0', @@ -893,7 +893,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail INTEGER UNSIGNED NOT NULL DEFAULT '1', user_options INTEGER UNSIGNED NOT NULL DEFAULT '230271', user_avatar varchar(255) NOT NULL DEFAULT '', - user_avatar_type tinyint(2) NOT NULL DEFAULT '0', + user_avatar_type varchar(32) NOT NULL DEFAULT '', user_avatar_width INTEGER UNSIGNED NOT NULL DEFAULT '0', user_avatar_height INTEGER UNSIGNED NOT NULL DEFAULT '0', user_sig mediumtext(16777215) NOT NULL DEFAULT '', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index d9ba147c70..142c510cd7 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -549,7 +549,7 @@ switch ($mode) $member['user_sig'] = smiley_text($member['user_sig']); } - $poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']); + $poster_avatar = get_user_avatar($member); // We need to check if the modules 'zebra' ('friends' & 'foes' mode), 'notes' ('user_notes' mode) and 'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links $zebra_enabled = $friends_enabled = $foes_enabled = $user_notes_enabled = $warn_user_enabled = false; @@ -1234,8 +1234,7 @@ switch ($mode) break; } - // Misusing the avatar function for displaying group avatars... - $avatar_img = get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR'); + $avatar_img = get_group_avatar($group_row); // ... same for group rank $rank_title = $rank_img = $rank_img_src = ''; @@ -1728,7 +1727,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f 'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])), - 'AVATAR_IMG' => get_user_avatar($data['user_avatar'], $data['user_avatar_type'], $data['user_avatar_width'], $data['user_avatar_height']), + 'AVATAR_IMG' => get_user_avatar($data), 'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), 'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false, 'RANK_IMG' => $rank_img, diff --git a/phpBB/styles/prosilver/template/avatars.js b/phpBB/styles/prosilver/template/avatars.js new file mode 100644 index 0000000000..2068bdbbc4 --- /dev/null +++ b/phpBB/styles/prosilver/template/avatars.js @@ -0,0 +1,15 @@ +(function($) { // Avoid conflicts with other libraries + +"use strict"; + +function avatar_simplify() { + $('#av_options > div').hide(); + + var selected = $('#avatar_driver').val(); + $('#av_option_' + selected).show(); +} + +avatar_simplify(); +$('#avatar_driver').bind('change', avatar_simplify); + +})(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options.html b/phpBB/styles/prosilver/template/ucp_avatar_options.html index 850a1412a0..d9763adc85 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options.html @@ -1,4 +1,3 @@ - <div class="panel"> <div class="inner"> <!-- IF not S_AVATARS_ENABLED --> @@ -7,64 +6,41 @@ <fieldset> <!-- IF ERROR --><p class="error">{ERROR}</p><!-- ENDIF --> - <dl> - <dt><label>{L_CURRENT_IMAGE}{L_COLON}</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> - <dd><label for="delete"><input type="checkbox" name="delete" id="delete" /> {L_DELETE_AVATAR}</label></dd> - </dl> - - <!-- IF S_UPLOAD_AVATAR_FILE --> <dl> - <dt><label for="uploadfile">{L_UPLOAD_AVATAR_FILE}{L_COLON}</label></dt> - <dd><input type="hidden" name="MAX_FILE_SIZE" value="{AVATAR_SIZE}" /><input type="file" name="uploadfile" id="uploadfile" class="inputbox autowidth" /></dd> - </dl> - <!-- ENDIF --> - - <!-- IF S_UPLOAD_AVATAR_URL --> - <dl> - <dt><label for="uploadurl">{L_UPLOAD_AVATAR_URL}{L_COLON}</label><br /><span>{L_UPLOAD_AVATAR_URL_EXPLAIN}</span></dt> - <dd><input type="text" name="uploadurl" id="uploadurl" value="{AVATAR_URL}" class="inputbox" /></dd> - </dl> - <!-- ENDIF --> - - <!-- IF S_LINK_AVATAR --> - <dl> - <dt><label for="remotelink">{L_LINK_REMOTE_AVATAR}{L_COLON}</label><br /><span>{L_LINK_REMOTE_AVATAR_EXPLAIN}</span></dt> - <dd><input type="text" name="remotelink" id="remotelink" value="{AVATAR_REMOTE}" class="inputbox" /></dd> + <dt><label>{L_CURRENT_IMAGE}{L_COLON}</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> </dl> + </fieldset> + <h3>{L_AVATAR_SELECT_NEW}</h3> + <fieldset> <dl> - <dt><label for="width">{L_LINK_REMOTE_SIZE}{L_COLON}</label><br /><span>{L_LINK_REMOTE_SIZE_EXPLAIN}</span></dt> - <dd> - <label for="width"><input type="text" name="width" id="width" size="3" value="{AVATAR_WIDTH}" class="inputbox autowidth" /> {L_PIXEL}</label> × - <label for="height"><input type="text" name="height" id="height" size="3" value="{AVATAR_HEIGHT}" class="inputbox autowidth" /> {L_PIXEL}</label> - </dd> - </dl> - <!-- ENDIF --> + <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 --> + <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> - <!-- IF S_IN_AVATAR_GALLERY --> - </div> + <fieldset> + {avatar_drivers.OUTPUT} + </fieldset> </div> - - <div class="panel"> - <div class="inner"> - - <h3>{L_AVATAR_GALLERY}</h3> - - <fieldset> - <label for="category">{L_AVATAR_CATEGORY}{L_COLON} <select name="category" id="category">{S_CAT_OPTIONS}</select></label> - <input type="submit" value="{L_GO}" name="display_gallery" class="button2" /> - <input type="submit" name="cancel" value="{L_CANCEL}" class="button2" /> - </fieldset> - - <div id="gallery"> - <!-- BEGIN avatar_row --><!-- BEGIN avatar_column --> - <label for="av-{avatar_row.S_ROW_COUNT}-{avatar_row.avatar_column.S_ROW_COUNT}"><img src="{avatar_row.avatar_column.AVATAR_IMAGE}" alt="" /><br /> - <input type="radio" name="avatar_select" id="av-{avatar_row.S_ROW_COUNT}-{avatar_row.avatar_column.S_ROW_COUNT}" value="{avatar_row.avatar_column.AVATAR_FILE}" /></label> - <!-- END avatar_column --><!-- END avatar_row --> - </div> - - <!-- ENDIF --> - +<!-- END avatar_drivers --> + </div> + <fieldset class="submit-buttons"> + <input type="reset" value="{L_RESET}" name="reset" class="button2" /> + <input type="submit" name="submit" value="{L_SUBMIT}" class="button1" /> + </fieldset> </div> </div> + +<!-- INCLUDEJS template/avatars.js --> diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_local.html b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html new file mode 100644 index 0000000000..9f726e2ff9 --- /dev/null +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html @@ -0,0 +1,16 @@ +<label for="category">{L_AVATAR_CATEGORY}: <select name="av_local_cat" id="category"> +<option value="">{L_NO_AVATAR_CATEGORY}</option> +<!-- BEGIN av_local_cats --> +<option value="{av_local_cats.NAME}"<!-- IF av_local_cats.SELECTED --> selected="selected"<!-- ENDIF -->>{av_local_cats.NAME}</option> +<!-- END av_local_cats --> +</select></label> +<input type="submit" value="{L_GO}" name="av_local_go" class="button2" /> + +<div id="gallery"> +<!-- BEGIN av_local_row --> +<!-- BEGIN av_local_col --> + <label for="av-{av_local_row.av_local_col.S_ROW_COUNT}"><img src="{av_local_row.av_local_col.AVATAR_IMAGE}" alt="" /><br /> + <input type="radio" name="av_local_file" id="av-{av_local_row.av_local_col.S_ROW_COUNT}" value="{av_local_row.av_local_col.AVATAR_FILE}" /></label> +<!-- END av_local_col --> +<!-- END av_local_row --> +</div> diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html new file mode 100644 index 0000000000..02704c5be8 --- /dev/null +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html @@ -0,0 +1,11 @@ +<dl> + <dt><label for="av_remote_url">{L_LINK_REMOTE_AVATAR}:</label><br /><span>{L_LINK_REMOTE_AVATAR_EXPLAIN}</span></dt> + <dd><input type="text" name="av_remote_url" id="av_remote_url" value="{AV_REMOTE_URL}" class="inputbox" /></dd> +</dl> +<dl> + <dt><label for="width">{L_LINK_REMOTE_SIZE}:</label><br /><span>{L_LINK_REMOTE_SIZE_EXPLAIN}</span></dt> + <dd> + <label for="av_remote_width"><input type="text" name="av_remote_width" id="av_remote_width" size="3" value="{AV_REMOTE_WIDTH}" class="inputbox autowidth" /> {L_PIXEL}</label> × + <label for="av_remote_height"><input type="text" name="av_remote_height" id="av_remote_height" size="3" value="{AV_REMOTE_HEIGHT}" class="inputbox autowidth" /> {L_PIXEL}</label> + </dd> +</dl> diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html b/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html new file mode 100644 index 0000000000..9c8dd9af01 --- /dev/null +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html @@ -0,0 +1,11 @@ +<dl> + <dt><label for="av_upload_file">{L_UPLOAD_AVATAR_FILE}:</label></dt> + <dd><input type="hidden" name="MAX_FILE_SIZE" value="{AV_UPLOAD_SIZE}" /><input type="file" name="av_upload_file" id="av_upload_file" class="inputbox autowidth" /></dd> +</dl> + +<!-- IF S_UPLOAD_AVATAR_URL --> + <dl> + <dt><label for="av_upload_url">{L_UPLOAD_AVATAR_URL}:</label><br /><span>{L_UPLOAD_AVATAR_URL_EXPLAIN}</span></dt> + <dd><input type="text" name="av_upload_url" id="av_upload_url" value="" class="inputbox" /></dd> + </dl> +<!-- ENDIF --> diff --git a/phpBB/styles/prosilver/template/ucp_profile_avatar.html b/phpBB/styles/prosilver/template/ucp_profile_avatar.html index a25c43a588..8157d8c15b 100644 --- a/phpBB/styles/prosilver/template/ucp_profile_avatar.html +++ b/phpBB/styles/prosilver/template/ucp_profile_avatar.html @@ -6,14 +6,8 @@ <!-- INCLUDE ucp_avatar_options.html --> -<fieldset class="submit-buttons"> - {S_HIDDEN_FIELDS} - <!-- IF S_DISPLAY_GALLERY --><input type="submit" name="display_gallery" value="{L_DISPLAY_GALLERY}" class="button2" /> <!-- ENDIF --> - <!-- IF S_IN_AVATAR_GALLERY --><input type="submit" name="cancel" value="{L_CANCEL}" class="button2" /> <!-- ELSE --> - <input type="reset" value="{L_RESET}" name="reset" class="button2" /> <!-- ENDIF --> - <input type="submit" name="submit" value="{L_SUBMIT}" class="button1" /> - {S_FORM_TOKEN} -</fieldset> +{S_HIDDEN_FIELDS} +{S_FORM_TOKEN} </form> <!-- INCLUDE ucp_footer.html --> diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 3fde5b5e03..edd15c0a68 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1083,7 +1083,7 @@ while ($row = $db->sql_fetchrow($result)) 'sig_bbcode_bitfield' => '', 'online' => false, - 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '', + 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row) : '', 'rank_title' => '', 'rank_image' => '', 'rank_image_src' => '', @@ -1149,7 +1149,7 @@ while ($row = $db->sql_fetchrow($result)) 'viewonline' => $row['user_allow_viewonline'], 'allow_pm' => $row['user_allow_pm'], - 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '', + 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row) : '', 'age' => '', 'rank_title' => '', |