diff options
Diffstat (limited to 'phpBB/phpbb')
23 files changed, 564 insertions, 122 deletions
diff --git a/phpBB/phpbb/cache/driver/redis.php b/phpBB/phpbb/cache/driver/redis.php index 3c6cb0e138..2b6f9bf36d 100644 --- a/phpBB/phpbb/cache/driver/redis.php +++ b/phpBB/phpbb/cache/driver/redis.php @@ -157,4 +157,3 @@ class redis extends \phpbb\cache\driver\memory return false; } } - diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_cleanup.php b/phpBB/phpbb/db/migration/data/v310/profilefield_cleanup.php new file mode 100644 index 0000000000..9e7ba68327 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_cleanup.php @@ -0,0 +1,51 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_cleanup extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_occ') && + !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_interests'); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\profilefield_interests', + '\phpbb\db\migration\data\v310\profilefield_occupation', + ); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'users' => array( + 'user_occ', + 'user_interests', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'users' => array( + 'user_occ' => array('MTEXT', ''), + 'user_interests' => array('MTEXT', ''), + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_interests.php b/phpBB/phpbb/db/migration/data/v310/profilefield_interests.php new file mode 100644 index 0000000000..d73bc78edb --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_interests.php @@ -0,0 +1,47 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_interests extends \phpbb\db\migration\profilefield_base_migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\profilefield_types', + ); + } + + protected $profilefield_name = 'phpbb_interests'; + + protected $profilefield_database_type = array('MTEXT', ''); + + protected $profilefield_data = array( + 'field_name' => 'phpbb_interests', + 'field_type' => 'profilefields.type.text', + 'field_ident' => 'phpbb_interests', + 'field_length' => '3|30', + 'field_minlen' => '2', + 'field_maxlen' => '500', + 'field_novalue' => '', + 'field_default_value' => '', + 'field_validation' => '.*', + 'field_required' => 0, + 'field_show_novalue' => 0, + 'field_show_on_reg' => 0, + 'field_show_on_pm' => 0, + 'field_show_on_vt' => 0, + 'field_show_profile' => 1, + 'field_hide' => 0, + 'field_no_view' => 0, + 'field_active' => 1, + ); + + protected $user_column_name = 'user_interests'; +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_location.php b/phpBB/phpbb/db/migration/data/v310/profilefield_location.php new file mode 100644 index 0000000000..4e62eab2d7 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_location.php @@ -0,0 +1,48 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_location extends \phpbb\db\migration\profilefield_base_migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\profilefield_types', + '\phpbb\db\migration\data\v310\profilefield_on_memberlist', + ); + } + + protected $profilefield_name = 'phpbb_location'; + + protected $profilefield_database_type = array('VCHAR', ''); + + protected $profilefield_data = array( + 'field_name' => 'phpbb_location', + 'field_type' => 'profilefields.type.string', + 'field_ident' => 'phpbb_location', + 'field_length' => '20', + 'field_minlen' => '2', + 'field_maxlen' => '100', + 'field_novalue' => '', + 'field_default_value' => '', + 'field_validation' => '.*', + 'field_required' => 0, + 'field_show_novalue' => 0, + 'field_show_on_reg' => 0, + 'field_show_on_pm' => 1, + 'field_show_on_vt' => 1, + 'field_show_profile' => 1, + 'field_hide' => 0, + 'field_no_view' => 0, + 'field_active' => 1, + ); + + protected $user_column_name = 'user_from'; +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php b/phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php new file mode 100644 index 0000000000..b0ea961c08 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php @@ -0,0 +1,47 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_occupation extends \phpbb\db\migration\profilefield_base_migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\profilefield_interests', + ); + } + + protected $profilefield_name = 'phpbb_occupation'; + + protected $profilefield_database_type = array('MTEXT', ''); + + protected $profilefield_data = array( + 'field_name' => 'phpbb_occupation', + 'field_type' => 'profilefields.type.text', + 'field_ident' => 'phpbb_occupation', + 'field_length' => '3|30', + 'field_minlen' => '2', + 'field_maxlen' => '500', + 'field_novalue' => '', + 'field_default_value' => '', + 'field_validation' => '.*', + 'field_required' => 0, + 'field_show_novalue' => 0, + 'field_show_on_reg' => 0, + 'field_show_on_pm' => 0, + 'field_show_on_vt' => 0, + 'field_show_profile' => 1, + 'field_hide' => 0, + 'field_no_view' => 0, + 'field_active' => 1, + ); + + protected $user_column_name = 'user_occ'; +} diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_on_memberlist.php b/phpBB/phpbb/db/migration/data/v310/profilefield_on_memberlist.php new file mode 100644 index 0000000000..ce51944c3e --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_on_memberlist.php @@ -0,0 +1,47 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +namespace phpbb\db\migration\data\v310; + +class profilefield_on_memberlist extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return $this->db_tools->sql_column_exists($this->table_prefix . 'profile_fields', 'field_show_on_ml'); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\profilefield_cleanup', + ); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_on_ml' => array('BOOL', 0), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_on_ml', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/helper.php b/phpBB/phpbb/db/migration/helper.php index 28a6a56511..009ad1da9f 100644 --- a/phpBB/phpbb/db/migration/helper.php +++ b/phpBB/phpbb/db/migration/helper.php @@ -53,7 +53,7 @@ class helper $steps[] = array( 'dbtools.perform_schema_changes', array(array( $change_type => array( - $value, + (!is_int($key)) ? $key : 0 => $value, ), )), ); diff --git a/phpBB/phpbb/db/migration/profilefield_base_migration.php b/phpBB/phpbb/db/migration/profilefield_base_migration.php new file mode 100644 index 0000000000..dec7a4c2bb --- /dev/null +++ b/phpBB/phpbb/db/migration/profilefield_base_migration.php @@ -0,0 +1,155 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +namespace phpbb\db\migration; + +abstract class profilefield_base_migration extends \phpbb\db\migration\migration +{ + protected $profilefield_name; + + protected $profilefield_database_type; + + protected $profilefield_data; + + protected $user_column_name; + + public function effectively_installed() + { + return $this->db_tools->sql_column_exists($this->table_prefix . 'profile_fields_data', 'pf_' . $this->profilefield_name); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'profile_fields_data' => array( + 'pf_' . $this->profilefield_name => $this->profilefield_database_type, + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'profile_fields_data' => array( + 'pf_' . $this->profilefield_name, + ), + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'create_custom_field'))), + array('custom', array(array($this, 'convert_user_field_to_custom_field'))), + ); + } + + public function create_custom_field() + { + $sql = 'SELECT MAX(field_order) as max_field_order + FROM ' . PROFILE_FIELDS_TABLE; + $result = $this->db->sql_query($sql); + $max_field_order = (int) $this->db->sql_fetchfield('max_field_order'); + $this->db->sql_freeresult($result); + + $sql_ary = array_merge($this->profilefield_data, array( + 'field_order' => $max_field_order + 1, + )); + + $sql = 'INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); + $this->db->sql_query($sql); + $field_id = (int) $this->db->sql_nextid(); + + $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE); + + $sql = 'SELECT lang_id + FROM ' . LANG_TABLE; + $result = $this->db->sql_query($sql); + while ($lang_id = (int) $this->db->sql_fetchfield('lang_id')) + { + $insert_buffer->insert(array( + 'field_id' => $field_id, + 'lang_id' => $lang_id, + 'lang_name' => strtoupper(substr($this->profilefield_name, 6)),// Remove phpbb_ from field name + 'lang_explain' => '', + 'lang_default_value' => '', + )); + } + $this->db->sql_freeresult($result); + + $insert_buffer->flush(); + } + + /** + * @param int $start Start of staggering step + * @return mixed int start of the next step, null if the end was reached + */ + public function convert_user_field_to_custom_field($start) + { + $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'profile_fields_data'); + $limit = 250; + $converted_users = 0; + + $sql = 'SELECT user_id, ' . $this->user_column_name . ' + FROM ' . $this->table_prefix . 'users + WHERE ' . $this->user_column_name . " <> '' + ORDER BY user_id"; + $result = $this->db->sql_query_limit($sql, $limit, $start); + + while ($row = $this->db->sql_fetchrow($result)) + { + $converted_users++; + + $cp_data = array( + 'pf_' . $this->profilefield_name => $row[$this->user_column_name], + ); + + $sql = 'UPDATE ' . $this->table_prefix . 'profile_fields_data + SET ' . $this->db->sql_build_array('UPDATE', $cp_data) . ' + WHERE user_id = ' . (int) $row['user_id']; + $this->db->sql_query($sql); + + if (!$this->db->sql_affectedrows()) + { + $cp_data['user_id'] = (int) $row['user_id']; + $cp_data = array_merge($this->get_insert_sql_array(), $cp_data); + $insert_buffer->insert($cp_data); + } + } + $this->db->sql_freeresult($result); + + $insert_buffer->flush(); + + if ($converted_users < $limit) + { + // No more users left, we are done... + return; + } + + return $start + $limit; + } + + protected function get_insert_sql_array() + { + static $profile_row; + + if ($profile_row === null) + { + global $phpbb_container; + $manager = $phpbb_container->get('profilefields.manager'); + $profile_row = $manager->build_insert_sql_array(array()); + } + + return $profile_row; + } +} diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 65098b643b..3a7207e743 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -492,7 +492,7 @@ class tools // here lies an array, filled with information compiled on the column's data $prepared_column = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - if (isset($prepared_column['auto_increment']) && strlen($column_name) > 26) // "${column_name}_gen" + if (isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'] && strlen($column_name) > 26) // "${column_name}_gen" { trigger_error("Index name '${column_name}_gen' on table '$table_name' is too long. The maximum auto increment column length is 26 characters.", E_USER_ERROR); } diff --git a/phpBB/phpbb/extension/exception.php b/phpBB/phpbb/extension/exception.php index b1f4997fdd..82327c9d5e 100644 --- a/phpBB/phpbb/extension/exception.php +++ b/phpBB/phpbb/extension/exception.php @@ -18,4 +18,4 @@ class exception extends \UnexpectedValueException { return $this->getMessage(); } -}
\ No newline at end of file +} diff --git a/phpBB/phpbb/notification/type/report_pm_closed.php b/phpBB/phpbb/notification/type/report_pm_closed.php index 9d2aac329e..56485f5d37 100644 --- a/phpBB/phpbb/notification/type/report_pm_closed.php +++ b/phpBB/phpbb/notification/type/report_pm_closed.php @@ -114,7 +114,7 @@ class report_pm_closed extends \phpbb\notification\type\pm */ public function get_avatar() { - return $this->get_user_avatar($this->get_data('closer_id')); + return $this->user_loader->get_avatar($this->get_data('closer_id')); } /** diff --git a/phpBB/phpbb/pagination.php b/phpBB/phpbb/pagination.php index 467dc2157f..57e7932341 100644 --- a/phpBB/phpbb/pagination.php +++ b/phpBB/phpbb/pagination.php @@ -76,107 +76,104 @@ class pagination public function generate_template_pagination($base_url, $block_var_name, $start_name, $num_items, $per_page, $start = 1, $reverse_count = false, $ignore_on_page = false) { $total_pages = ceil($num_items / $per_page); - - if ($total_pages == 1 || !$num_items) - { - return; - } - $on_page = $this->get_on_page($per_page, $start); - - if ($reverse_count) - { - $start_page = ($total_pages > 5) ? $total_pages - 4 : 1; - $end_page = $total_pages; - } - else - { - // What we're doing here is calculating what the "start" and "end" pages should be. We - // do this by assuming pagination is "centered" around the currently active page with - // the three previous and three next page links displayed. Anything more than that and - // we display the ellipsis, likewise anything less. - // - // $start_page is the page at which we start creating the list. When we have five or less - // pages we start at page 1 since there will be no ellipsis displayed. Anymore than that - // and we calculate the start based on the active page. This is the min/max calculation. - // First (max) would we end up starting on a page less than 1? Next (min) would we end - // up starting so close to the end that we'd not display our minimum number of pages. - // - // $end_page is the last page in the list to display. Like $start_page we use a min/max to - // determine this number. Again at most five pages? Then just display them all. More than - // five and we first (min) determine whether we'd end up listing more pages than exist. - // We then (max) ensure we're displaying the minimum number of pages. - $start_page = ($total_pages > 5) ? min(max(1, $on_page - 3), $total_pages - 4) : 1; - $end_page = ($total_pages > 5) ? max(min($total_pages, $on_page + 3), 5) : $total_pages; - } - $u_previous_page = $u_next_page = ''; - if ($on_page != 1) - { - $u_previous_page = $this->generate_page_link($base_url, $on_page - 1, $start_name, $per_page); - $this->template->assign_block_vars($block_var_name, array( - 'PAGE_NUMBER' => '', - 'PAGE_URL' => $u_previous_page, - 'S_IS_CURRENT' => false, - 'S_IS_PREV' => true, - 'S_IS_NEXT' => false, - 'S_IS_ELLIPSIS' => false, - )); - } - - // This do...while exists purely to negate the need for start and end assign_block_vars, i.e. - // to display the first and last page in the list plus any ellipsis. We use this loop to jump - // around a little within the list depending on where we're starting (and ending). - $at_page = 1; - do + if ($total_pages > 1) { - // We decide whether to display the ellipsis during the loop. The ellipsis is always - // displayed as either the second or penultimate item in the list. So are we at either - // of those points and of course do we even need to display it, i.e. is the list starting - // on at least page 3 and ending three pages before the final item. - $this->template->assign_block_vars($block_var_name, array( - 'PAGE_NUMBER' => $at_page, - 'PAGE_URL' => $this->generate_page_link($base_url, $at_page, $start_name, $per_page), - 'S_IS_CURRENT' => (!$ignore_on_page && $at_page == $on_page), - 'S_IS_NEXT' => false, - 'S_IS_PREV' => false, - 'S_IS_ELLIPSIS' => ($at_page == 2 && $start_page > 2) || ($at_page == $total_pages - 1 && $end_page < $total_pages - 1), - )); - - // We may need to jump around in the list depending on whether we have or need to display - // the ellipsis. Are we on page 2 and are we more than one page away from the start - // of the list? Yes? Then we jump to the start of the list. Likewise are we at the end of - // the list and are there more than two pages left in total? Yes? Then jump to the penultimate - // page (so we can display the ellipsis next pass). Else, increment the counter and keep - // going - if ($at_page == 2 && $at_page < $start_page - 1) + if ($reverse_count) { - $at_page = $start_page; + $start_page = ($total_pages > 5) ? $total_pages - 4 : 1; + $end_page = $total_pages; } - else if ($at_page == $end_page && $end_page < $total_pages - 1) + else { - $at_page = $total_pages - 1; + // What we're doing here is calculating what the "start" and "end" pages should be. We + // do this by assuming pagination is "centered" around the currently active page with + // the three previous and three next page links displayed. Anything more than that and + // we display the ellipsis, likewise anything less. + // + // $start_page is the page at which we start creating the list. When we have five or less + // pages we start at page 1 since there will be no ellipsis displayed. Anymore than that + // and we calculate the start based on the active page. This is the min/max calculation. + // First (max) would we end up starting on a page less than 1? Next (min) would we end + // up starting so close to the end that we'd not display our minimum number of pages. + // + // $end_page is the last page in the list to display. Like $start_page we use a min/max to + // determine this number. Again at most five pages? Then just display them all. More than + // five and we first (min) determine whether we'd end up listing more pages than exist. + // We then (max) ensure we're displaying the minimum number of pages. + $start_page = ($total_pages > 5) ? min(max(1, $on_page - 3), $total_pages - 4) : 1; + $end_page = ($total_pages > 5) ? max(min($total_pages, $on_page + 3), 5) : $total_pages; } - else + + if ($on_page != 1) { - $at_page++; + $u_previous_page = $this->generate_page_link($base_url, $on_page - 1, $start_name, $per_page); + + $this->template->assign_block_vars($block_var_name, array( + 'PAGE_NUMBER' => '', + 'PAGE_URL' => $u_previous_page, + 'S_IS_CURRENT' => false, + 'S_IS_PREV' => true, + 'S_IS_NEXT' => false, + 'S_IS_ELLIPSIS' => false, + )); } - } - while ($at_page <= $total_pages); - if ($on_page != $total_pages) - { - $u_next_page = $this->generate_page_link($base_url, $on_page + 1, $start_name, $per_page); + // This do...while exists purely to negate the need for start and end assign_block_vars, i.e. + // to display the first and last page in the list plus any ellipsis. We use this loop to jump + // around a little within the list depending on where we're starting (and ending). + $at_page = 1; + do + { + // We decide whether to display the ellipsis during the loop. The ellipsis is always + // displayed as either the second or penultimate item in the list. So are we at either + // of those points and of course do we even need to display it, i.e. is the list starting + // on at least page 3 and ending three pages before the final item. + $this->template->assign_block_vars($block_var_name, array( + 'PAGE_NUMBER' => $at_page, + 'PAGE_URL' => $this->generate_page_link($base_url, $at_page, $start_name, $per_page), + 'S_IS_CURRENT' => (!$ignore_on_page && $at_page == $on_page), + 'S_IS_NEXT' => false, + 'S_IS_PREV' => false, + 'S_IS_ELLIPSIS' => ($at_page == 2 && $start_page > 2) || ($at_page == $total_pages - 1 && $end_page < $total_pages - 1), + )); - $this->template->assign_block_vars($block_var_name, array( - 'PAGE_NUMBER' => '', - 'PAGE_URL' => $u_next_page, - 'S_IS_CURRENT' => false, - 'S_IS_PREV' => false, - 'S_IS_NEXT' => true, - 'S_IS_ELLIPSIS' => false, - )); + // We may need to jump around in the list depending on whether we have or need to display + // the ellipsis. Are we on page 2 and are we more than one page away from the start + // of the list? Yes? Then we jump to the start of the list. Likewise are we at the end of + // the list and are there more than two pages left in total? Yes? Then jump to the penultimate + // page (so we can display the ellipsis next pass). Else, increment the counter and keep + // going + if ($at_page == 2 && $at_page < $start_page - 1) + { + $at_page = $start_page; + } + else if ($at_page == $end_page && $end_page < $total_pages - 1) + { + $at_page = $total_pages - 1; + } + else + { + $at_page++; + } + } + while ($at_page <= $total_pages); + + if ($on_page != $total_pages) + { + $u_next_page = $this->generate_page_link($base_url, $on_page + 1, $start_name, $per_page); + + $this->template->assign_block_vars($block_var_name, array( + 'PAGE_NUMBER' => '', + 'PAGE_URL' => $u_next_page, + 'S_IS_CURRENT' => false, + 'S_IS_PREV' => false, + 'S_IS_NEXT' => true, + 'S_IS_ELLIPSIS' => false, + )); + } } // If the block_var_name is a nested block, we will use the last (most @@ -203,6 +200,7 @@ class pagination 'U_' . $tpl_prefix . 'NEXT_PAGE' => ($on_page != $total_pages) ? $u_next_page : '', $tpl_prefix . 'TOTAL_PAGES' => $total_pages, $tpl_prefix . 'CURRENT_PAGE' => $on_page, + $tpl_prefix . 'PAGE_NUMBER' => $this->on_page($num_items, $per_page, $start), ); if ($tpl_block_name) @@ -229,24 +227,15 @@ class pagination /** * Return current page - * This function also sets certain specific template variables * - * @param string $base_url the base url used to call this page, used by Javascript for popup jump to page * @param int $num_items the total number of items, posts, topics, etc. * @param int $per_page the number of items, posts, etc. per page * @param int $start the item which should be considered currently active, used to determine the page we're on * @return string Descriptive pagination string (e.g. "page 1 of 10") */ - public function on_page($base_url, $num_items, $per_page, $start) + public function on_page($num_items, $per_page, $start) { $on_page = $this->get_on_page($per_page, $start); - - $this->template->assign_vars(array( - 'PER_PAGE' => $per_page, - 'ON_PAGE' => $on_page, - 'BASE_URL' => $base_url, - )); - return $this->user->lang('PAGE_OF', $on_page, max(ceil($num_items / $per_page), 1)); } @@ -262,7 +251,7 @@ class pagination { if ($start < 0 || $start >= $num_items) { - return ($start < 0) ? 0 : floor(($num_items - 1) / $per_page) * $per_page; + return ($start < 0 || $num_items <= 0) ? 0 : floor(($num_items - 1) / $per_page) * $per_page; } return $start; diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index ead978374c..ac2542a6d4 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -243,6 +243,41 @@ class manager } /** + * Generate the template arrays in order to display the column names + * + * @param string $restrict_option Restrict the published fields to a certain profile field option + * @return array Returns an array with the template variables type, name and explain for the fields to display + */ + public function generate_profile_fields_template_headlines($restrict_option = '') + { + if (!sizeof($this->profile_cache)) + { + $this->build_cache(); + } + + $tpl_fields = array(); + + // Go through the fields in correct order + foreach ($this->profile_cache as $field_ident => $field_data) + { + if ($restrict_option && !$field_data[$restrict_option]) + { + continue; + } + + $profile_field = $this->type_collection[$field_data['field_type']]; + + $tpl_fields[] = array( + 'PROFILE_FIELD_TYPE' => $field_data['field_type'], + 'PROFILE_FIELD_NAME' => $profile_field->get_field_name($field_data['lang_name']), + 'PROFILE_FIELD_EXPLAIN' => $this->user->lang($field_data['lang_explain']), + ); + } + + return $tpl_fields; + } + + /** * Assign fields to template, used for viewprofile, viewtopic and memberlist (if load setting is enabled) * This is directly connected to the user -> mode == grab is to grab the user specific fields, mode == show is for assigning the row to the template */ diff --git a/phpBB/phpbb/profilefields/type/type_base.php b/phpBB/phpbb/profilefields/type/type_base.php index 95e9b8768b..9c363a7b4e 100644 --- a/phpBB/phpbb/profilefields/type/type_base.php +++ b/phpBB/phpbb/profilefields/type/type_base.php @@ -79,6 +79,14 @@ abstract class type_base implements type_interface /** * {@inheritDoc} */ + public function get_field_name($field_name) + { + return isset($this->user->lang[$field_name]) ? $this->user->lang[$field_name] : $field_name; + } + + /** + * {@inheritDoc} + */ public function get_language_options_input($field_data) { $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true); diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php index 47a5ed4992..fa9c0a8714 100644 --- a/phpBB/phpbb/profilefields/type/type_bool.php +++ b/phpBB/phpbb/profilefields/type/type_bool.php @@ -136,7 +136,7 @@ class type_bool extends type_base if (!$field_value && $field_data['field_required']) { - return $this->user->lang('FIELD_REQUIRED', $field_data['lang_name']); + return $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name'])); } return false; diff --git a/phpBB/phpbb/profilefields/type/type_date.php b/phpBB/phpbb/profilefields/type/type_date.php index 0de80f2baf..fc012dd97a 100644 --- a/phpBB/phpbb/profilefields/type/type_date.php +++ b/phpBB/phpbb/profilefields/type/type_date.php @@ -159,17 +159,17 @@ class type_date extends type_base if ((!$day || !$month || !$year) && $field_data['field_required']) { - return $this->user->lang('FIELD_REQUIRED', $field_data['lang_name']); + return $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name'])); } if ($day < 0 || $day > 31 || $month < 0 || $month > 12 || ($year < 1901 && $year > 0) || $year > gmdate('Y', time()) + 50) { - return $this->user->lang('FIELD_INVALID_DATE', $field_data['lang_name']); + return $this->user->lang('FIELD_INVALID_DATE', $this->get_field_name($field_data['lang_name'])); } if (checkdate($month, $day, $year) === false) { - return $this->user->lang('FIELD_INVALID_DATE', $field_data['lang_name']); + return $this->user->lang('FIELD_INVALID_DATE', $this->get_field_name($field_data['lang_name'])); } return false; diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php index b5b393d91b..bcf0ba05f9 100644 --- a/phpBB/phpbb/profilefields/type/type_dropdown.php +++ b/phpBB/phpbb/profilefields/type/type_dropdown.php @@ -137,12 +137,12 @@ class type_dropdown extends type_base if (!$this->lang_helper->is_set($field_data['field_id'], $field_data['lang_id'], $field_value)) { - return $this->user->lang('FIELD_INVALID_VALUE', $field_data['lang_name']); + return $this->user->lang('FIELD_INVALID_VALUE', $this->get_field_name($field_data['lang_name'])); } if ($field_value == $field_data['field_novalue'] && $field_data['field_required']) { - return $this->user->lang('FIELD_REQUIRED', $field_data['lang_name']); + return $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name'])); } return false; diff --git a/phpBB/phpbb/profilefields/type/type_int.php b/phpBB/phpbb/profilefields/type/type_int.php index 77a4f813da..b89faca018 100644 --- a/phpBB/phpbb/profilefields/type/type_int.php +++ b/phpBB/phpbb/profilefields/type/type_int.php @@ -126,11 +126,11 @@ class type_int extends type_base if ($field_value < $field_data['field_minlen']) { - return $this->user->lang('FIELD_TOO_SMALL', (int) $row['field_minlen'], $row['lang_name']); + return $this->user->lang('FIELD_TOO_SMALL', (int) $field_data['field_minlen'], $this->get_field_name($field_data['lang_name'])); } else if ($field_value > $field_data['field_maxlen']) { - return $this->user->lang('FIELD_TOO_LARGE', (int) $row['field_maxlen'], $row['lang_name']); + return $this->user->lang('FIELD_TOO_LARGE', (int) $field_data['field_maxlen'], $this->get_field_name($field_data['lang_name'])); } return false; diff --git a/phpBB/phpbb/profilefields/type/type_interface.php b/phpBB/phpbb/profilefields/type/type_interface.php index 7d0cf7662f..94f6882524 100644 --- a/phpBB/phpbb/profilefields/type/type_interface.php +++ b/phpBB/phpbb/profilefields/type/type_interface.php @@ -33,6 +33,13 @@ interface type_interface public function get_service_name(); /** + * Get the name of template file for this type + * + * @return string Returns the name of the template file + */ + public function get_template_filename(); + + /** * Get dropdown options for second step in ACP * * @param string $default_lang_id ID of the default language @@ -174,4 +181,14 @@ interface type_interface * @return null */ public function display_options(&$template_vars, &$field_data); + + /** + * Return templated value/field. Possible values for $mode are: + * change == user is able to set/enter profile values; preview == just show the value + * + * @param string $mode Mode for displaying the field (preview|change) + * @param array $profile_row Array with data for this field + * @return null + */ + public function process_field_row($mode, $profile_row); } diff --git a/phpBB/phpbb/profilefields/type/type_string.php b/phpBB/phpbb/profilefields/type/type_string.php index 12a14d9b83..9d241c49ef 100644 --- a/phpBB/phpbb/profilefields/type/type_string.php +++ b/phpBB/phpbb/profilefields/type/type_string.php @@ -60,7 +60,7 @@ class type_string extends type_string_common $options = array( 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" name="field_length" size="5" value="' . $field_data['field_length'] . '" />'), 1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" name="field_minlen" size="5" value="' . $field_data['field_minlen'] . '" />'), - 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" size="5" value="' . $field_data['field_maxlen'] . '" />'), + 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" name="field_maxlen" size="5" value="' . $field_data['field_maxlen'] . '" />'), 3 => array('TITLE' => $this->user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options($field_data) . '</select>'), ); diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php index d322099c34..f00a7e6a08 100644 --- a/phpBB/phpbb/profilefields/type/type_string_common.php +++ b/phpBB/phpbb/profilefields/type/type_string_common.php @@ -52,16 +52,16 @@ abstract class type_string_common extends type_base } else if (trim($field_value) === '' && $field_data['field_required']) { - return $this->user->lang('FIELD_REQUIRED', $field_data['lang_name']); + return $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name'])); } if ($field_data['field_minlen'] && utf8_strlen($field_value) < $field_data['field_minlen']) { - return $this->user->lang('FIELD_TOO_SHORT', (int) $row['field_minlen'], $row['lang_name']); + return $this->user->lang('FIELD_TOO_SHORT', (int) $field_data['field_minlen'], $this->get_field_name($field_data['lang_name'])); } else if ($field_data['field_maxlen'] && utf8_strlen($field_value) > $field_data['field_maxlen']) { - return $this->user->lang('FIELD_TOO_LONG', (int) $row['field_maxlen'], $row['lang_name']); + return $this->user->lang('FIELD_TOO_LONG', (int) $field_data['field_maxlen'], $this->get_field_name($field_data['lang_name'])); } if (!empty($field_data['field_validation']) && $field_data['field_validation'] != '.*') @@ -72,13 +72,13 @@ abstract class type_string_common extends type_base switch ($row['field_validation']) { case '[0-9]+': - return $this->user->lang('FIELD_INVALID_CHARS_NUMBERS_ONLY', $row['lang_name']); + return $this->user->lang('FIELD_INVALID_CHARS_NUMBERS_ONLY', $this->get_field_name($field_data['lang_name'])); case '[\w]+': - return $this->user->lang('FIELD_INVALID_CHARS_ALPHA_ONLY', $row['lang_name']); + return $this->user->lang('FIELD_INVALID_CHARS_ALPHA_ONLY', $this->get_field_name($field_data['lang_name'])); case '[\w_\+\. \-\[\]]+': - return $this->user->lang('FIELD_INVALID_CHARS_SPACERS_ONLY', $row['lang_name']); + return $this->user->lang('FIELD_INVALID_CHARS_SPACERS_ONLY', $this->get_field_name($field_data['lang_name'])); } } } diff --git a/phpBB/phpbb/request/deactivated_super_global.php b/phpBB/phpbb/request/deactivated_super_global.php index b03624593e..b6940cf51f 100644 --- a/phpBB/phpbb/request/deactivated_super_global.php +++ b/phpBB/phpbb/request/deactivated_super_global.php @@ -112,4 +112,3 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg $this->error(); } } - diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index b2ab187a70..2a7cc602da 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -183,7 +183,7 @@ class user extends \phpbb\session unset($lang_set_ext); $style_request = request_var('style', 0); - if ($style_request && $auth->acl_get('a_styles') && !defined('ADMIN_START')) + if ($style_request && (!$config['override_user_style'] || $auth->acl_get('a_styles')) && !defined('ADMIN_START')) { global $SID, $_EXTRA_URL; |