From 3c640e57c5815c970e706f724fb29a3114826352 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 2 Feb 2014 15:41:49 +0100 Subject: [PATCH 01/11] [ticket/12115] Convert user occupation to a profile field PHPBB3-12115 --- phpBB/develop/benchmark.php | 5 +- phpBB/includes/acp/acp_users.php | 4 - phpBB/includes/db/schema_data.php | 2 +- phpBB/includes/functions_user.php | 1 - phpBB/includes/ucp/ucp_main.php | 1 - phpBB/includes/ucp/ucp_profile.php | 4 - phpBB/install/convertors/convert_phpbb20.php | 13 ++ phpBB/install/schemas/firebird_schema.sql | 4 +- phpBB/install/schemas/mssql_schema.sql | 4 +- phpBB/install/schemas/mysql_40_schema.sql | 2 +- phpBB/install/schemas/mysql_41_schema.sql | 2 +- phpBB/install/schemas/oracle_schema.sql | 2 +- phpBB/install/schemas/postgres_schema.sql | 2 +- phpBB/install/schemas/schema_data.sql | 7 +- phpBB/install/schemas/sqlite_schema.sql | 2 +- phpBB/memberlist.php | 1 - .../data/v310/profilefield_occupation.php | 146 ++++++++++++++++++ 17 files changed, 176 insertions(+), 26 deletions(-) create mode 100644 phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php diff --git a/phpBB/develop/benchmark.php b/phpBB/develop/benchmark.php index c653fdaa24..d91da3169e 100644 --- a/phpBB/develop/benchmark.php +++ b/phpBB/develop/benchmark.php @@ -368,7 +368,6 @@ function make_user($username) $email = "nobody@localhost"; $icq = "12345678"; $website = "http://www.phpbb.com"; - $occupation = "phpBB tester"; $location = "phpBB world hq"; $interests = "Eating, sleeping, living, and breathing phpBB"; $signature = "$username: phpBB tester."; @@ -422,8 +421,8 @@ function make_user($username) } - $sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmilies, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey) - VALUES ($new_user_id, '$username', " . time() . ", '$password', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$signature_bbcode_uid', '$avatar_filename', $viewemail, '$aim', '$yim', '$msn', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', $user_style, 0, 1, "; + $sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmilies, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey) + VALUES ($new_user_id, '$username', " . time() . ", '$password', '$email', '$icq', '$website', '$location', '$interests', '$signature', '$signature_bbcode_uid', '$avatar_filename', $viewemail, '$aim', '$yim', '$msn', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', $user_style, 0, 1, "; $sql .= "1, '')"; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index bf11e4f8fe..d9c8ee42ae 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1368,7 +1368,6 @@ class acp_users 'jabber' => utf8_normalize_nfc(request_var('jabber', $user_row['user_jabber'], true)), 'website' => request_var('website', $user_row['user_website']), 'location' => utf8_normalize_nfc(request_var('location', $user_row['user_from'], true)), - 'occupation' => utf8_normalize_nfc(request_var('occupation', $user_row['user_occ'], true)), 'interests' => utf8_normalize_nfc(request_var('interests', $user_row['user_interests'], true)), 'bday_day' => 0, 'bday_month' => 0, @@ -1402,7 +1401,6 @@ class acp_users array('string', true, 12, 255), array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')), 'location' => array('string', true, 2, 100), - 'occupation' => array('string', true, 2, 500), 'interests' => array('string', true, 2, 500), 'bday_day' => array('num', true, 1, 31), 'bday_month' => array('num', true, 1, 12), @@ -1432,7 +1430,6 @@ class acp_users 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], 'user_from' => $data['location'], - 'user_occ' => $data['occupation'], 'user_interests'=> $data['interests'], 'user_birthday' => $data['user_birthday'], ); @@ -1484,7 +1481,6 @@ class acp_users 'JABBER' => $data['jabber'], 'WEBSITE' => $data['website'], 'LOCATION' => $data['location'], - 'OCCUPATION' => $data['occupation'], 'INTERESTS' => $data['interests'], 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, diff --git a/phpBB/includes/db/schema_data.php b/phpBB/includes/db/schema_data.php index 2c1070f459..61f0644495 100644 --- a/phpBB/includes/db/schema_data.php +++ b/phpBB/includes/db/schema_data.php @@ -787,6 +787,7 @@ $schema_data['phpbb_profile_fields'] = array( $schema_data['phpbb_profile_fields_data'] = array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), + 'pf_phpbb_occupation' => array('TEXT_UNI', ''), ), 'PRIMARY_KEY' => 'user_id', ); @@ -1170,7 +1171,6 @@ $schema_data['phpbb_users'] = array( 'user_msnm' => array('VCHAR_UNI', ''), 'user_jabber' => array('VCHAR_UNI', ''), 'user_website' => array('VCHAR_UNI:200', ''), - 'user_occ' => array('TEXT_UNI', ''), 'user_interests' => array('TEXT_UNI', ''), 'user_actkey' => array('VCHAR:32', ''), 'user_newpasswd' => array('VCHAR_UNI:40', ''), diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 17cdd0ce39..4ad6dc4469 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -210,7 +210,6 @@ function user_add($user_row, $cp_data = false) 'user_lastpage' => '', 'user_posts' => 0, 'user_colour' => '', - 'user_occ' => '', 'user_interests' => '', 'user_avatar' => '', 'user_avatar_type' => '', diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index b9f951ace6..90f03a970a 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -195,7 +195,6 @@ class ucp_main 'POSTS_DAY' => $user->lang('POST_DAY', $posts_per_day), 'POSTS_PCT' => $user->lang('POST_PCT', $percentage), - 'OCCUPATION' => (!empty($row['user_occ'])) ? $row['user_occ'] : '', 'INTERESTS' => (!empty($row['user_interests'])) ? $row['user_interests'] : '', // 'S_GROUP_OPTIONS' => $group_options, diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 6ddc6833b7..dc7547239b 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -271,7 +271,6 @@ class ucp_profile 'jabber' => utf8_normalize_nfc(request_var('jabber', $user->data['user_jabber'], true)), 'website' => request_var('website', $user->data['user_website']), 'location' => utf8_normalize_nfc(request_var('location', $user->data['user_from'], true)), - 'occupation' => utf8_normalize_nfc(request_var('occupation', $user->data['user_occ'], true)), 'interests' => utf8_normalize_nfc(request_var('interests', $user->data['user_interests'], true)), ); @@ -308,7 +307,6 @@ class ucp_profile array('string', true, 12, 255), array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')), 'location' => array('string', true, 2, 100), - 'occupation' => array('string', true, 2, 500), 'interests' => array('string', true, 2, 500), ); @@ -356,7 +354,6 @@ class ucp_profile 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], 'user_from' => $data['location'], - 'user_occ' => $data['occupation'], 'user_interests'=> $data['interests'], 'user_notify_type' => $data['notify'], ); @@ -427,7 +424,6 @@ class ucp_profile 'JABBER' => $data['jabber'], 'WEBSITE' => $data['website'], 'LOCATION' => $data['location'], - 'OCCUPATION'=> $data['occupation'], 'INTERESTS' => $data['interests'], )); diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php index c8de3d3b23..290bf73942 100644 --- a/phpBB/install/convertors/convert_phpbb20.php +++ b/phpBB/install/convertors/convert_phpbb20.php @@ -954,6 +954,19 @@ if (!$get_info) 'where' => 'users.user_id <> -1', ), + + array( + 'target' => PROFILE_FIELDS_DATA_TABLE, + 'primary' => 'users.user_id', + 'query_first' => array( + array('target', $convert->truncate_statement . PROFILE_FIELDS_DATA_TABLE), + ), + + array('user_id', 'users.user_id', 'phpbb_user_id'), + array('pf_phpbb_occupation', 'users.user_occ', array('function1' => 'phpbb_set_encoding')), + + 'where' => 'users.user_id <> -1', + ), ), ); } diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 791e4ce6b3..6dd2696dea 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -946,7 +946,8 @@ END;; # Table: 'phpbb_profile_fields_data' CREATE TABLE phpbb_profile_fields_data ( - user_id INTEGER DEFAULT 0 NOT NULL + user_id INTEGER DEFAULT 0 NOT NULL, + pf_phpbb_occupation BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; ALTER TABLE phpbb_profile_fields_data ADD PRIMARY KEY (user_id);; @@ -1423,7 +1424,6 @@ CREATE TABLE phpbb_users ( user_msnm VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_jabber VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_website VARCHAR(200) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_occ BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, user_interests BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, user_actkey VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, user_newpasswd VARCHAR(40) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 21e27c1f21..8ba8097de3 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1153,7 +1153,8 @@ GO Table: 'phpbb_profile_fields_data' */ CREATE TABLE [phpbb_profile_fields_data] ( - [user_id] [int] DEFAULT (0) NOT NULL + [user_id] [int] DEFAULT (0) NOT NULL , + [pf_phpbb_occupation] [varchar] (4000) DEFAULT ('') NOT NULL ) ON [PRIMARY] GO @@ -1739,7 +1740,6 @@ CREATE TABLE [phpbb_users] ( [user_msnm] [varchar] (255) DEFAULT ('') NOT NULL , [user_jabber] [varchar] (255) DEFAULT ('') NOT NULL , [user_website] [varchar] (200) DEFAULT ('') NOT NULL , - [user_occ] [varchar] (4000) DEFAULT ('') NOT NULL , [user_interests] [varchar] (4000) DEFAULT ('') NOT NULL , [user_actkey] [varchar] (32) DEFAULT ('') NOT NULL , [user_newpasswd] [varchar] (40) DEFAULT ('') NOT NULL , diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 37991ea174..0097173a2c 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -672,6 +672,7 @@ CREATE TABLE phpbb_profile_fields ( # Table: 'phpbb_profile_fields_data' CREATE TABLE phpbb_profile_fields_data ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + pf_phpbb_occupation blob NOT NULL, PRIMARY KEY (user_id) ); @@ -1032,7 +1033,6 @@ CREATE TABLE phpbb_users ( user_msnm blob NOT NULL, user_jabber blob NOT NULL, user_website blob NOT NULL, - user_occ blob NOT NULL, user_interests blob NOT NULL, user_actkey varbinary(32) DEFAULT '' NOT NULL, user_newpasswd varbinary(120) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index a88bab9c3c..d5865c0b44 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -672,6 +672,7 @@ CREATE TABLE phpbb_profile_fields ( # Table: 'phpbb_profile_fields_data' CREATE TABLE phpbb_profile_fields_data ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + pf_phpbb_occupation text NOT NULL, PRIMARY KEY (user_id) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; @@ -1032,7 +1033,6 @@ CREATE TABLE phpbb_users ( user_msnm varchar(255) DEFAULT '' NOT NULL, user_jabber varchar(255) DEFAULT '' NOT NULL, user_website varchar(200) DEFAULT '' NOT NULL, - user_occ text NOT NULL, user_interests text NOT NULL, user_actkey varchar(32) DEFAULT '' NOT NULL, user_newpasswd varchar(40) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index ea5cfdf321..ee302e2a82 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1265,6 +1265,7 @@ END; */ CREATE TABLE phpbb_profile_fields_data ( user_id number(8) DEFAULT '0' NOT NULL, + pf_phpbb_occupation clob DEFAULT '' , CONSTRAINT pk_phpbb_profile_fields_data PRIMARY KEY (user_id) ) / @@ -1856,7 +1857,6 @@ CREATE TABLE phpbb_users ( user_msnm varchar2(765) DEFAULT '' , user_jabber varchar2(765) DEFAULT '' , user_website varchar2(600) DEFAULT '' , - user_occ clob DEFAULT '' , user_interests clob DEFAULT '' , user_actkey varchar2(32) DEFAULT '' , user_newpasswd varchar2(120) DEFAULT '' , diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index f06bcdf2a9..ec918835b0 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -882,6 +882,7 @@ CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields (field_order) */ CREATE TABLE phpbb_profile_fields_data ( user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + pf_phpbb_occupation varchar(4000) DEFAULT '' NOT NULL, PRIMARY KEY (user_id) ); @@ -1304,7 +1305,6 @@ CREATE TABLE phpbb_users ( user_msnm varchar(255) DEFAULT '' NOT NULL, user_jabber varchar(255) DEFAULT '' NOT NULL, user_website varchar(200) DEFAULT '' NOT NULL, - user_occ varchar(4000) DEFAULT '' NOT NULL, user_interests varchar(4000) DEFAULT '' NOT NULL, user_actkey varchar(32) DEFAULT '' NOT NULL, user_newpasswd varchar(40) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 9f198595e0..ff224a6ce2 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -467,10 +467,10 @@ INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts_approved, forum_posts_unapproved, forum_posts_softdeleted, forum_topics_approved, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_subject, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents, forum_flags) VALUES ('{L_FORUMS_TEST_FORUM_TITLE}', '{L_FORUMS_TEST_FORUM_DESC}', 2, 3, 1, 1, 1, 0, 0, 1, 0, 0, 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, '', '', '', '', '', '', '', 0, 0, '', 48); # -- Users / Anonymous user -INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0); +INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_interests, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', 0); # -- username: Admin password: admin (change this or remove it once everything is working!) -INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); +INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_interests, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', ''); # -- Groups INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GUESTS', 3, 0, '', 0, '', '', '', 5); @@ -787,6 +787,9 @@ INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'mp3'); INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogg'); INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogm'); +# Add default profile fields +INSERT INTO phpbb_profile_fields ('field_name', 'field_type', 'field_ident', 'field_length', 'field_minlen', 'field_maxlen', 'field_novalue', 'field_default_value', 'field_validation', 'field_required', 'field_show_novalue', 'field_show_on_reg', 'field_show_on_pm', 'field_show_on_vt', 'field_show_profile', 'field_hide', 'field_no_view', 'field_active', 'field_order') VALUES ('phpbb_occupation', 'profilefields.type.text', 'phpbb_occupation', '3|30', '2', '500', '', '', '.*', 0, 0, 0, 0, 0, 1, 0, 0, 1, 1); + # User Notification Options (for first user) INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('post', 0, 2, ''); INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('post', 0, 2, 'email'); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index bfb0e211d7..78eb8c2932 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -652,6 +652,7 @@ CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields (field_order) # Table: 'phpbb_profile_fields_data' CREATE TABLE phpbb_profile_fields_data ( user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + pf_phpbb_occupation text(65535) NOT NULL DEFAULT '', PRIMARY KEY (user_id) ); @@ -1003,7 +1004,6 @@ CREATE TABLE phpbb_users ( user_msnm varchar(255) NOT NULL DEFAULT '', user_jabber varchar(255) NOT NULL DEFAULT '', user_website varchar(200) NOT NULL DEFAULT '', - user_occ text(65535) NOT NULL DEFAULT '', user_interests text(65535) NOT NULL DEFAULT '', user_actkey varchar(32) NOT NULL DEFAULT '', user_newpasswd varchar(40) NOT NULL DEFAULT '', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 019b1873a0..4cf32fc9c3 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -644,7 +644,6 @@ switch ($mode) 'POSTS_DAY' => $user->lang('POST_DAY', $posts_per_day), 'POSTS_PCT' => $user->lang('POST_PCT', $percentage), - 'OCCUPATION' => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '', 'INTERESTS' => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '', 'SIGNATURE' => $member['user_sig'], 'POSTS_IN_QUEUE'=> $member['posts_in_queue'], 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..09c71127f9 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php @@ -0,0 +1,146 @@ +db_tools->sql_column_exists($this->table_prefix . 'profile_fields_data', 'pf_phpbb_occupation'); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\profilefield_types', + ); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'profile_fields_data' => array( + 'pf_phpbb_occupation' => array('MTEXT', ''), + ), + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'create_occupation_custom_field'))), + array('custom', array(array($this, 'convert_occupation_to_custom_field'))), + ); + } + + public function create_occupation_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( + '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, + '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->add(array( + 'field_id' => $field_id, + 'lang_id' => $lang_id, + 'lang_name' => 'OCCUPATION', + '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_occupation_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, user_occ + FROM ' . $this->table_prefix . "users + WHERE user_occ <> '' + 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_phpbb_occupation' => $row['user_occ'], + ); + + $sql = 'UPDATE ' . $this->fields_data_table . ' + 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']; + $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; + } +} From 7d049619196a49957c58c896a1fc50c334b9bc7f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 2 Feb 2014 17:58:34 +0100 Subject: [PATCH 02/11] [ticket/12115] Add language entries for the profile fields PHPBB3-12115 --- phpBB/install/install_install.php | 25 +++++++++++++++++++++++++ phpBB/install/schemas/schema_data.sql | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 1a7e1d1094..a2d44f2b6c 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -1718,6 +1718,7 @@ class install_install extends module $this->error('Unable to access the language directory', __LINE__, __FILE__); } + $installed_languages = array(); while (($file = readdir($dir)) !== false) { $path = $phpbb_root_path . 'language/' . $file; @@ -1741,6 +1742,7 @@ class install_install extends module $db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $lang_pack)); + $installed_languages[] = (int) $db->sql_nextid(); if ($db->sql_error_triggered) { $error = $db->sql_error($db->sql_error_sql); @@ -1749,6 +1751,29 @@ class install_install extends module } } closedir($dir); + + $sql = 'SELECT * + FROM ' . PROFILE_FIELDS_TABLE; + $result = $db->sql_query($sql); + + $profile_fields = array(); + $insert_buffer = new \phpbb\db\sql_insert_buffer($db, PROFILE_LANG_TABLE); + while ($row = $db->sql_fetchrow($result)) + { + foreach ($installed_languages as $lang_id) + { + $insert_buffer->insert(array( + 'field_id' => $row['field_id'], + 'lang_id' => $lang_id, + 'lang_name' => strtoupper(substr($row['field_name'], 6)),// Remove phpbb_ from field name + 'lang_explain' => '', + 'lang_default_value' => '', + )); + } + } + $db->sql_freeresult($result); + + $insert_buffer->flush(); } /** diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index ff224a6ce2..1d14285660 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -788,7 +788,7 @@ INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogg'); INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogm'); # Add default profile fields -INSERT INTO phpbb_profile_fields ('field_name', 'field_type', 'field_ident', 'field_length', 'field_minlen', 'field_maxlen', 'field_novalue', 'field_default_value', 'field_validation', 'field_required', 'field_show_novalue', 'field_show_on_reg', 'field_show_on_pm', 'field_show_on_vt', 'field_show_profile', 'field_hide', 'field_no_view', 'field_active', 'field_order') VALUES ('phpbb_occupation', 'profilefields.type.text', 'phpbb_occupation', '3|30', '2', '500', '', '', '.*', 0, 0, 0, 0, 0, 1, 0, 0, 1, 1); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_profile, field_hide, field_no_view, field_active, field_order) VALUES ('phpbb_occupation', 'profilefields.type.text', 'phpbb_occupation', '3|30', '2', '500', '', '', '.*', 0, 0, 0, 0, 0, 1, 0, 0, 1, 1); # User Notification Options (for first user) INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('post', 0, 2, ''); From 38608bfa62ff9bed744759969345339bd6c60fbf Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 2 Feb 2014 17:59:52 +0100 Subject: [PATCH 03/11] [ticket/12115] Remove occupation field from html files PHPBB3-12115 --- phpBB/adm/style/acp_users_profile.html | 4 ---- phpBB/styles/prosilver/template/memberlist_view.html | 1 - phpBB/styles/prosilver/template/ucp_profile_profile_info.html | 4 ---- phpBB/styles/subsilver2/template/memberlist_view.html | 4 ---- .../styles/subsilver2/template/ucp_profile_profile_info.html | 4 ---- 5 files changed, 17 deletions(-) diff --git a/phpBB/adm/style/acp_users_profile.html b/phpBB/adm/style/acp_users_profile.html index cad1dca9d8..119b3c4be4 100644 --- a/phpBB/adm/style/acp_users_profile.html +++ b/phpBB/adm/style/acp_users_profile.html @@ -30,10 +30,6 @@
-
-
-
-
diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index afe93ef9ac..f580e07879 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -29,7 +29,6 @@
{L_USER_IS_INACTIVE}{L_COLON}
{USER_INACTIVE_REASON}
{L_LOCATION}{L_COLON}
{LOCATION}
{L_AGE}{L_COLON}
{AGE}
-
{L_OCCUPATION}{L_COLON}
{OCCUPATION}
{L_INTERESTS}{L_COLON}
{INTERESTS}
{L_USERGROUPS}{L_COLON}
{custom_fields.PROFILE_FIELD_NAME}{L_COLON}
{custom_fields.PROFILE_FIELD_VALUE}
diff --git a/phpBB/styles/prosilver/template/ucp_profile_profile_info.html b/phpBB/styles/prosilver/template/ucp_profile_profile_info.html index 3578c29e8e..6a44ebafda 100644 --- a/phpBB/styles/prosilver/template/ucp_profile_profile_info.html +++ b/phpBB/styles/prosilver/template/ucp_profile_profile_info.html @@ -38,10 +38,6 @@
-
-
-
-
diff --git a/phpBB/styles/subsilver2/template/memberlist_view.html b/phpBB/styles/subsilver2/template/memberlist_view.html index 06b5af3322..b9ad479246 100644 --- a/phpBB/styles/subsilver2/template/memberlist_view.html +++ b/phpBB/styles/subsilver2/template/memberlist_view.html @@ -156,10 +156,6 @@ {AGE} - - {L_OCCUPATION}{L_COLON} - {OCCUPATION} - {L_INTERESTS}{L_COLON} {INTERESTS} diff --git a/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html b/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html index 2df41fa29e..f0f2119b9f 100644 --- a/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html +++ b/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html @@ -40,10 +40,6 @@ {L_LOCATION}{L_COLON} - - {L_OCCUPATION}{L_COLON} - - {L_INTERESTS}{L_COLON} From f97d268a79502243c6bf259cde854519eea42391 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 2 Feb 2014 18:00:17 +0100 Subject: [PATCH 04/11] [ticket/12115] Translate profile field name before displaying it in errors PHPBB3-12115 --- phpBB/phpbb/profilefields/type/type_base.php | 8 ++++++++ phpBB/phpbb/profilefields/type/type_bool.php | 2 +- phpBB/phpbb/profilefields/type/type_date.php | 6 +++--- phpBB/phpbb/profilefields/type/type_dropdown.php | 4 ++-- phpBB/phpbb/profilefields/type/type_int.php | 4 ++-- phpBB/phpbb/profilefields/type/type_interface.php | 9 +++++++++ .../phpbb/profilefields/type/type_string_common.php | 12 ++++++------ 7 files changed, 31 insertions(+), 14 deletions(-) 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 @@ -76,6 +76,14 @@ abstract class type_base implements type_interface return 'pf_' . $field_data['field_ident']; } + /** + * {@inheritDoc} + */ + public function get_field_name($field_name) + { + return isset($this->user->lang[$field_name]) ? $this->user->lang[$field_name] : $field_name; + } + /** * {@inheritDoc} */ 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..93020935e9 100644 --- a/phpBB/phpbb/profilefields/type/type_interface.php +++ b/phpBB/phpbb/profilefields/type/type_interface.php @@ -174,4 +174,13 @@ 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 + * @param array $profile_row + * @return null + */ + public function process_field_row($mode, $profile_row); } 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'])); } } } From 8dab016a7b652e2a0aafe03c085d9c51ab6f3ff2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 2 Feb 2014 18:04:38 +0100 Subject: [PATCH 05/11] [ticket/12115] Add methods to interface PHPBB3-12115 --- phpBB/phpbb/profilefields/type/type_interface.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/profilefields/type/type_interface.php b/phpBB/phpbb/profilefields/type/type_interface.php index 93020935e9..94f6882524 100644 --- a/phpBB/phpbb/profilefields/type/type_interface.php +++ b/phpBB/phpbb/profilefields/type/type_interface.php @@ -32,6 +32,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 * @@ -178,8 +185,9 @@ interface type_interface /** * 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 - * @param array $profile_row + * + * @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); From 0ad726768c569cf4987aa93e2d6f2e5d185c7dc5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 2 Feb 2014 21:21:24 +0100 Subject: [PATCH 06/11] [ticket/12115] Remove old language strings PHPBB3-12115 --- phpBB/language/en/common.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index abe930c387..2f985a23ac 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -689,7 +689,6 @@ $lang = array_merge($lang, array( 'TOO_LONG_LOCATION' => 'The location you entered is too long.', 'TOO_LONG_MSN' => 'The WLM name you entered is too long.', 'TOO_LONG_NEW_PASSWORD' => 'The password you entered is too long.', - 'TOO_LONG_OCCUPATION' => 'The occupation you entered is too long.', 'TOO_LONG_PASSWORD_CONFIRM' => 'The password confirmation you entered is too long.', 'TOO_LONG_USER_PASSWORD' => 'The password you entered is too long.', 'TOO_LONG_USERNAME' => 'The username you entered is too long.', @@ -710,7 +709,6 @@ $lang = array_merge($lang, array( 'TOO_SHORT_LOCATION' => 'The location you entered is too short.', 'TOO_SHORT_MSN' => 'The WLM name you entered is too short.', 'TOO_SHORT_NEW_PASSWORD' => 'The password you entered is too short.', - 'TOO_SHORT_OCCUPATION' => 'The occupation you entered is too short.', 'TOO_SHORT_PASSWORD_CONFIRM' => 'The password confirmation you entered is too short.', 'TOO_SHORT_USER_PASSWORD' => 'The password you entered is too short.', 'TOO_SHORT_USERNAME' => 'The username you entered is too short.', From bbada27ee9e797c7f6ce997152bc1efb8c8f125d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 2 Feb 2014 21:45:59 +0100 Subject: [PATCH 07/11] [ticket/12115] Also port user interests to profile fields PHPBB3-12115 --- phpBB/adm/style/acp_users_profile.html | 4 ---- phpBB/develop/benchmark.php | 5 ++--- phpBB/includes/acp/acp_users.php | 4 ---- phpBB/includes/db/schema_data.php | 2 +- phpBB/includes/functions_user.php | 1 - phpBB/includes/ucp/ucp_main.php | 2 -- phpBB/includes/ucp/ucp_profile.php | 4 ---- phpBB/install/convertors/convert_phpbb20.php | 3 +-- phpBB/install/schemas/firebird_schema.sql | 2 +- phpBB/install/schemas/mssql_schema.sql | 2 +- phpBB/install/schemas/mysql_40_schema.sql | 2 +- phpBB/install/schemas/mysql_41_schema.sql | 2 +- phpBB/install/schemas/oracle_schema.sql | 2 +- phpBB/install/schemas/postgres_schema.sql | 2 +- phpBB/install/schemas/schema_data.sql | 7 +++--- phpBB/install/schemas/sqlite_schema.sql | 2 +- phpBB/language/en/common.php | 2 -- phpBB/memberlist.php | 1 - .../data/v310/profilefield_occupation.php | 6 ++--- .../prosilver/template/memberlist_view.html | 1 - .../template/ucp_profile_profile_info.html | 4 ---- .../subsilver2/template/memberlist_view.html | 4 ---- .../template/ucp_profile_profile_info.html | 4 ---- tests/auth/fixtures/user.xml | 6 ----- tests/auth/fixtures/user_533.xml | 6 ----- tests/auth/provider_apache_test.php | 2 -- .../fixtures/delete_post.xml | 4 ---- .../fixtures/set_post_visibility.xml | 8 ------- .../fixtures/set_topic_visibility.xml | 4 ---- tests/dbal/fixtures/massmail_crossjoin.xml | 8 ------- tests/dbal/fixtures/three_users.xml | 8 ------- tests/dbal/write_sequence_test.php | 2 -- tests/functions/fixtures/obtain_online.xml | 22 ------------------- tests/functions/fixtures/validate_email.xml | 4 ---- .../functions/fixtures/validate_username.xml | 6 ----- .../fixtures/group_user_attributes.xml | 8 ------- tests/log/fixtures/full_log.xml | 6 ----- tests/notification/fixtures/convert.xml | 14 ------------ tests/notification/fixtures/group_request.xml | 6 ----- .../fixtures/submit_post_bookmark.xml | 14 ------------ .../fixtures/submit_post_post.xml | 14 ------------ .../fixtures/submit_post_post_in_queue.xml | 18 --------------- .../fixtures/submit_post_quote.xml | 14 ------------ tests/privmsgs/fixtures/delete_user_pms.xml | 10 --------- tests/session/fixtures/sessions_banlist.xml | 4 ---- tests/session/fixtures/sessions_empty.xml | 8 ------- tests/session/fixtures/sessions_full.xml | 8 ------- tests/session/fixtures/sessions_garbage.xml | 4 ---- tests/session/fixtures/sessions_key.xml | 4 ---- tests/user/fixtures/user_loader.xml | 8 ------- 50 files changed, 18 insertions(+), 270 deletions(-) diff --git a/phpBB/adm/style/acp_users_profile.html b/phpBB/adm/style/acp_users_profile.html index 119b3c4be4..2c9965687a 100644 --- a/phpBB/adm/style/acp_users_profile.html +++ b/phpBB/adm/style/acp_users_profile.html @@ -30,10 +30,6 @@
-
-
-
-

{L_BIRTHDAY_EXPLAIN}
{L_DAY}{L_COLON} {L_MONTH}{L_COLON} {L_YEAR}{L_COLON}
diff --git a/phpBB/develop/benchmark.php b/phpBB/develop/benchmark.php index d91da3169e..16f10b1225 100644 --- a/phpBB/develop/benchmark.php +++ b/phpBB/develop/benchmark.php @@ -369,7 +369,6 @@ function make_user($username) $icq = "12345678"; $website = "http://www.phpbb.com"; $location = "phpBB world hq"; - $interests = "Eating, sleeping, living, and breathing phpBB"; $signature = "$username: phpBB tester."; $signature_bbcode_uid = ""; $avatar_filename = ""; @@ -421,8 +420,8 @@ function make_user($username) } - $sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmilies, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey) - VALUES ($new_user_id, '$username', " . time() . ", '$password', '$email', '$icq', '$website', '$location', '$interests', '$signature', '$signature_bbcode_uid', '$avatar_filename', $viewemail, '$aim', '$yim', '$msn', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', $user_style, 0, 1, "; + $sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_from, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmilies, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey) + VALUES ($new_user_id, '$username', " . time() . ", '$password', '$email', '$icq', '$website', '$location', '$signature', '$signature_bbcode_uid', '$avatar_filename', $viewemail, '$aim', '$yim', '$msn', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', $user_style, 0, 1, "; $sql .= "1, '')"; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index d9c8ee42ae..6a81f919e4 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1368,7 +1368,6 @@ class acp_users 'jabber' => utf8_normalize_nfc(request_var('jabber', $user_row['user_jabber'], true)), 'website' => request_var('website', $user_row['user_website']), 'location' => utf8_normalize_nfc(request_var('location', $user_row['user_from'], true)), - 'interests' => utf8_normalize_nfc(request_var('interests', $user_row['user_interests'], true)), 'bday_day' => 0, 'bday_month' => 0, 'bday_year' => 0, @@ -1401,7 +1400,6 @@ class acp_users array('string', true, 12, 255), array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')), 'location' => array('string', true, 2, 100), - 'interests' => array('string', true, 2, 500), 'bday_day' => array('num', true, 1, 31), 'bday_month' => array('num', true, 1, 12), 'bday_year' => array('num', true, 1901, gmdate('Y', time())), @@ -1430,7 +1428,6 @@ class acp_users 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], 'user_from' => $data['location'], - 'user_interests'=> $data['interests'], 'user_birthday' => $data['user_birthday'], ); @@ -1481,7 +1478,6 @@ class acp_users 'JABBER' => $data['jabber'], 'WEBSITE' => $data['website'], 'LOCATION' => $data['location'], - 'INTERESTS' => $data['interests'], 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, diff --git a/phpBB/includes/db/schema_data.php b/phpBB/includes/db/schema_data.php index 61f0644495..cb09116856 100644 --- a/phpBB/includes/db/schema_data.php +++ b/phpBB/includes/db/schema_data.php @@ -787,6 +787,7 @@ $schema_data['phpbb_profile_fields'] = array( $schema_data['phpbb_profile_fields_data'] = array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), + 'pf_phpbb_interests' => array('TEXT_UNI', ''), 'pf_phpbb_occupation' => array('TEXT_UNI', ''), ), 'PRIMARY_KEY' => 'user_id', @@ -1171,7 +1172,6 @@ $schema_data['phpbb_users'] = array( 'user_msnm' => array('VCHAR_UNI', ''), 'user_jabber' => array('VCHAR_UNI', ''), 'user_website' => array('VCHAR_UNI:200', ''), - 'user_interests' => array('TEXT_UNI', ''), 'user_actkey' => array('VCHAR:32', ''), 'user_newpasswd' => array('VCHAR_UNI:40', ''), 'user_form_salt' => array('VCHAR_UNI:32', ''), diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 4ad6dc4469..6682622d94 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -210,7 +210,6 @@ function user_add($user_row, $cp_data = false) 'user_lastpage' => '', 'user_posts' => 0, 'user_colour' => '', - 'user_interests' => '', 'user_avatar' => '', 'user_avatar_type' => '', 'user_avatar_width' => 0, diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 90f03a970a..ddea336ce9 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -195,8 +195,6 @@ class ucp_main 'POSTS_DAY' => $user->lang('POST_DAY', $posts_per_day), 'POSTS_PCT' => $user->lang('POST_PCT', $percentage), - 'INTERESTS' => (!empty($row['user_interests'])) ? $row['user_interests'] : '', - // 'S_GROUP_OPTIONS' => $group_options, 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $user->data['user_id'] . '&sr=posts') : '', diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index dc7547239b..22b180ba89 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -271,7 +271,6 @@ class ucp_profile 'jabber' => utf8_normalize_nfc(request_var('jabber', $user->data['user_jabber'], true)), 'website' => request_var('website', $user->data['user_website']), 'location' => utf8_normalize_nfc(request_var('location', $user->data['user_from'], true)), - 'interests' => utf8_normalize_nfc(request_var('interests', $user->data['user_interests'], true)), ); if ($config['allow_birthdays']) @@ -307,7 +306,6 @@ class ucp_profile array('string', true, 12, 255), array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')), 'location' => array('string', true, 2, 100), - 'interests' => array('string', true, 2, 500), ); if ($config['allow_birthdays']) @@ -354,7 +352,6 @@ class ucp_profile 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], 'user_from' => $data['location'], - 'user_interests'=> $data['interests'], 'user_notify_type' => $data['notify'], ); @@ -424,7 +421,6 @@ class ucp_profile 'JABBER' => $data['jabber'], 'WEBSITE' => $data['website'], 'LOCATION' => $data['location'], - 'INTERESTS' => $data['interests'], )); // Get additional profile fields and assign them to the template block var 'profile_fields' diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php index 290bf73942..2effbf49b9 100644 --- a/phpBB/install/convertors/convert_phpbb20.php +++ b/phpBB/install/convertors/convert_phpbb20.php @@ -906,8 +906,6 @@ if (!$get_info) array('user_inactive_reason', '', 'phpbb_inactive_reason'), array('user_inactive_time', '', 'phpbb_inactive_time'), - array('user_interests', 'users.user_interests', array('function1' => 'phpbb_set_encoding')), - array('user_occ', 'users.user_occ', array('function1' => 'phpbb_set_encoding')), array('user_website', 'users.user_website', 'validate_website'), array('user_jabber', '', ''), array('user_msnm', 'users.user_msnm', array('function1' => 'phpbb_set_encoding')), @@ -964,6 +962,7 @@ if (!$get_info) array('user_id', 'users.user_id', 'phpbb_user_id'), array('pf_phpbb_occupation', 'users.user_occ', array('function1' => 'phpbb_set_encoding')), + array('pf_phpbb_interests', 'users.user_interests', array('function1' => 'phpbb_set_encoding')), 'where' => 'users.user_id <> -1', ), diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 6dd2696dea..c717cb7416 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -947,6 +947,7 @@ END;; # Table: 'phpbb_profile_fields_data' CREATE TABLE phpbb_profile_fields_data ( user_id INTEGER DEFAULT 0 NOT NULL, + pf_phpbb_interests BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, pf_phpbb_occupation BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; @@ -1424,7 +1425,6 @@ CREATE TABLE phpbb_users ( user_msnm VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_jabber VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_website VARCHAR(200) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_interests BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, user_actkey VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, user_newpasswd VARCHAR(40) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_form_salt VARCHAR(32) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 8ba8097de3..9d7d0e324b 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1154,6 +1154,7 @@ GO */ CREATE TABLE [phpbb_profile_fields_data] ( [user_id] [int] DEFAULT (0) NOT NULL , + [pf_phpbb_interests] [varchar] (4000) DEFAULT ('') NOT NULL , [pf_phpbb_occupation] [varchar] (4000) DEFAULT ('') NOT NULL ) ON [PRIMARY] GO @@ -1740,7 +1741,6 @@ CREATE TABLE [phpbb_users] ( [user_msnm] [varchar] (255) DEFAULT ('') NOT NULL , [user_jabber] [varchar] (255) DEFAULT ('') NOT NULL , [user_website] [varchar] (200) DEFAULT ('') NOT NULL , - [user_interests] [varchar] (4000) DEFAULT ('') NOT NULL , [user_actkey] [varchar] (32) DEFAULT ('') NOT NULL , [user_newpasswd] [varchar] (40) DEFAULT ('') NOT NULL , [user_form_salt] [varchar] (32) DEFAULT ('') NOT NULL , diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 0097173a2c..b5ccb6c783 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -672,6 +672,7 @@ CREATE TABLE phpbb_profile_fields ( # Table: 'phpbb_profile_fields_data' CREATE TABLE phpbb_profile_fields_data ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + pf_phpbb_interests blob NOT NULL, pf_phpbb_occupation blob NOT NULL, PRIMARY KEY (user_id) ); @@ -1033,7 +1034,6 @@ CREATE TABLE phpbb_users ( user_msnm blob NOT NULL, user_jabber blob NOT NULL, user_website blob NOT NULL, - user_interests blob NOT NULL, user_actkey varbinary(32) DEFAULT '' NOT NULL, user_newpasswd varbinary(120) DEFAULT '' NOT NULL, user_form_salt varbinary(96) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index d5865c0b44..9e911560db 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -672,6 +672,7 @@ CREATE TABLE phpbb_profile_fields ( # Table: 'phpbb_profile_fields_data' CREATE TABLE phpbb_profile_fields_data ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + pf_phpbb_interests text NOT NULL, pf_phpbb_occupation text NOT NULL, PRIMARY KEY (user_id) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; @@ -1033,7 +1034,6 @@ CREATE TABLE phpbb_users ( user_msnm varchar(255) DEFAULT '' NOT NULL, user_jabber varchar(255) DEFAULT '' NOT NULL, user_website varchar(200) DEFAULT '' NOT NULL, - user_interests text NOT NULL, user_actkey varchar(32) DEFAULT '' NOT NULL, user_newpasswd varchar(40) DEFAULT '' NOT NULL, user_form_salt varchar(32) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index ee302e2a82..b752908ef8 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1265,6 +1265,7 @@ END; */ CREATE TABLE phpbb_profile_fields_data ( user_id number(8) DEFAULT '0' NOT NULL, + pf_phpbb_interests clob DEFAULT '' , pf_phpbb_occupation clob DEFAULT '' , CONSTRAINT pk_phpbb_profile_fields_data PRIMARY KEY (user_id) ) @@ -1857,7 +1858,6 @@ CREATE TABLE phpbb_users ( user_msnm varchar2(765) DEFAULT '' , user_jabber varchar2(765) DEFAULT '' , user_website varchar2(600) DEFAULT '' , - user_interests clob DEFAULT '' , user_actkey varchar2(32) DEFAULT '' , user_newpasswd varchar2(120) DEFAULT '' , user_form_salt varchar2(96) DEFAULT '' , diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index ec918835b0..229a57a11b 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -882,6 +882,7 @@ CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields (field_order) */ CREATE TABLE phpbb_profile_fields_data ( user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + pf_phpbb_interests varchar(4000) DEFAULT '' NOT NULL, pf_phpbb_occupation varchar(4000) DEFAULT '' NOT NULL, PRIMARY KEY (user_id) ); @@ -1305,7 +1306,6 @@ CREATE TABLE phpbb_users ( user_msnm varchar(255) DEFAULT '' NOT NULL, user_jabber varchar(255) DEFAULT '' NOT NULL, user_website varchar(200) DEFAULT '' NOT NULL, - user_interests varchar(4000) DEFAULT '' NOT NULL, user_actkey varchar(32) DEFAULT '' NOT NULL, user_newpasswd varchar(40) DEFAULT '' NOT NULL, user_form_salt varchar(32) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 1d14285660..f888c7a0fe 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -467,10 +467,10 @@ INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts_approved, forum_posts_unapproved, forum_posts_softdeleted, forum_topics_approved, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_subject, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents, forum_flags) VALUES ('{L_FORUMS_TEST_FORUM_TITLE}', '{L_FORUMS_TEST_FORUM_DESC}', 2, 3, 1, 1, 1, 0, 0, 1, 0, 0, 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, '', '', '', '', '', '', '', 0, 0, '', 48); # -- Users / Anonymous user -INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_interests, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', 0); +INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', 0); # -- username: Admin password: admin (change this or remove it once everything is working!) -INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_interests, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', ''); +INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', ''); # -- Groups INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GUESTS', 3, 0, '', 0, '', '', '', 5); @@ -788,7 +788,8 @@ INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogg'); INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogm'); # Add default profile fields -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_profile, field_hide, field_no_view, field_active, field_order) VALUES ('phpbb_occupation', 'profilefields.type.text', 'phpbb_occupation', '3|30', '2', '500', '', '', '.*', 0, 0, 0, 0, 0, 1, 0, 0, 1, 1); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_profile, field_hide, field_no_view, field_active, field_order) VALUES ('phpbb_interests', 'profilefields.type.text', 'phpbb_interests', '3|30', '2', '500', '', '', '.*', 0, 0, 0, 0, 0, 1, 0, 0, 1, 1); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_profile, field_hide, field_no_view, field_active, field_order) VALUES ('phpbb_occupation', 'profilefields.type.text', 'phpbb_occupation', '3|30', '2', '500', '', '', '.*', 0, 0, 0, 0, 0, 1, 0, 0, 1, 2); # User Notification Options (for first user) INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('post', 0, 2, ''); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 78eb8c2932..4b1ad2ce46 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -652,6 +652,7 @@ CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields (field_order) # Table: 'phpbb_profile_fields_data' CREATE TABLE phpbb_profile_fields_data ( user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + pf_phpbb_interests text(65535) NOT NULL DEFAULT '', pf_phpbb_occupation text(65535) NOT NULL DEFAULT '', PRIMARY KEY (user_id) ); @@ -1004,7 +1005,6 @@ CREATE TABLE phpbb_users ( user_msnm varchar(255) NOT NULL DEFAULT '', user_jabber varchar(255) NOT NULL DEFAULT '', user_website varchar(200) NOT NULL DEFAULT '', - user_interests text(65535) NOT NULL DEFAULT '', user_actkey varchar(32) NOT NULL DEFAULT '', user_newpasswd varchar(40) NOT NULL DEFAULT '', user_form_salt varchar(32) NOT NULL DEFAULT '', diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 2f985a23ac..bf03393b52 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -684,7 +684,6 @@ $lang = array_merge($lang, array( 'TOO_LONG_CONFIRM_CODE' => 'The confirm code you entered is too long.', 'TOO_LONG_DATEFORMAT' => 'The date format you entered is too long.', 'TOO_LONG_ICQ' => 'The ICQ number you entered is too long.', - 'TOO_LONG_INTERESTS' => 'The interests you entered is too long.', 'TOO_LONG_JABBER' => 'The Jabber account name you entered is too long.', 'TOO_LONG_LOCATION' => 'The location you entered is too long.', 'TOO_LONG_MSN' => 'The WLM name you entered is too long.', @@ -704,7 +703,6 @@ $lang = array_merge($lang, array( 'TOO_SHORT_CONFIRM_CODE' => 'The confirm code you entered is too short.', 'TOO_SHORT_DATEFORMAT' => 'The date format you entered is too short.', 'TOO_SHORT_ICQ' => 'The ICQ number you entered is too short.', - 'TOO_SHORT_INTERESTS' => 'The interests you entered is too short.', 'TOO_SHORT_JABBER' => 'The Jabber account name you entered is too short.', 'TOO_SHORT_LOCATION' => 'The location you entered is too short.', 'TOO_SHORT_MSN' => 'The WLM name you entered is too short.', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 4cf32fc9c3..e8cbcc94ef 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -644,7 +644,6 @@ switch ($mode) 'POSTS_DAY' => $user->lang('POST_DAY', $posts_per_day), 'POSTS_PCT' => $user->lang('POST_PCT', $percentage), - 'INTERESTS' => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '', 'SIGNATURE' => $member['user_sig'], 'POSTS_IN_QUEUE'=> $member['posts_in_queue'], diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php b/phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php index 09c71127f9..ee276fa0f9 100644 --- a/phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php @@ -19,7 +19,7 @@ class profilefield_occupation extends \phpbb\db\migration\migration static public function depends_on() { return array( - '\phpbb\db\migration\data\v310\profilefield_types', + '\phpbb\db\migration\data\v310\profilefield_interests', ); } @@ -83,7 +83,7 @@ class profilefield_occupation extends \phpbb\db\migration\migration $result = $this->db->sql_query($sql); while ($lang_id = (int) $this->db->sql_fetchfield('lang_id')) { - $insert_buffer->add(array( + $insert_buffer->insert(array( 'field_id' => $field_id, 'lang_id' => $lang_id, 'lang_name' => 'OCCUPATION', @@ -120,7 +120,7 @@ class profilefield_occupation extends \phpbb\db\migration\migration 'pf_phpbb_occupation' => $row['user_occ'], ); - $sql = 'UPDATE ' . $this->fields_data_table . ' + $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); diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index f580e07879..ca889f2125 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -29,7 +29,6 @@
{L_USER_IS_INACTIVE}{L_COLON}
{USER_INACTIVE_REASON}
{L_LOCATION}{L_COLON}
{LOCATION}
{L_AGE}{L_COLON}
{AGE}
-
{L_INTERESTS}{L_COLON}
{INTERESTS}
{L_USERGROUPS}{L_COLON}
{custom_fields.PROFILE_FIELD_NAME}{L_COLON}
{custom_fields.PROFILE_FIELD_VALUE}
diff --git a/phpBB/styles/prosilver/template/ucp_profile_profile_info.html b/phpBB/styles/prosilver/template/ucp_profile_profile_info.html index 6a44ebafda..2de9244721 100644 --- a/phpBB/styles/prosilver/template/ucp_profile_profile_info.html +++ b/phpBB/styles/prosilver/template/ucp_profile_profile_info.html @@ -38,10 +38,6 @@
-
-
-
-

{L_BIRTHDAY_EXPLAIN}
diff --git a/phpBB/styles/subsilver2/template/memberlist_view.html b/phpBB/styles/subsilver2/template/memberlist_view.html index b9ad479246..c143b97522 100644 --- a/phpBB/styles/subsilver2/template/memberlist_view.html +++ b/phpBB/styles/subsilver2/template/memberlist_view.html @@ -156,10 +156,6 @@ {AGE} - - {L_INTERESTS}{L_COLON} - {INTERESTS} - {L_WEBSITE}{L_COLON} {U_WWW} diff --git a/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html b/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html index f0f2119b9f..6638eb0266 100644 --- a/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html +++ b/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html @@ -40,10 +40,6 @@ {L_LOCATION}{L_COLON} - - {L_INTERESTS}{L_COLON} - - {L_BIRTHDAY}{L_COLON}
{L_BIRTHDAY_EXPLAIN} diff --git a/tests/auth/fixtures/user.xml b/tests/auth/fixtures/user.xml index 6d475930a4..77f707bab3 100644 --- a/tests/auth/fixtures/user.xml +++ b/tests/auth/fixtures/user.xml @@ -12,8 +12,6 @@ user_login_attempts user_permissions user_sig - user_occ - user_interests 1 foobar @@ -26,8 +24,6 @@ 0 - - 2 @@ -41,8 +37,6 @@ 0 - - diff --git a/tests/auth/fixtures/user_533.xml b/tests/auth/fixtures/user_533.xml index c2a86ea0f9..b64f376e5b 100644 --- a/tests/auth/fixtures/user_533.xml +++ b/tests/auth/fixtures/user_533.xml @@ -12,8 +12,6 @@ user_login_attempts user_permissions user_sig - user_occ - user_interests 1 foobar @@ -26,8 +24,6 @@ 0 - - 2 @@ -41,8 +37,6 @@ 0 - - diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index 1231c16a4c..ad4171cd81 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -200,8 +200,6 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case 'user_msnm' => '', 'user_jabber' => '', 'user_website' => '', - 'user_occ' => '', - 'user_interests' => '', 'user_actkey' => '', 'user_newpasswd' => '', 'user_form_salt' => '', diff --git a/tests/content_visibility/fixtures/delete_post.xml b/tests/content_visibility/fixtures/delete_post.xml index deca9c74b6..c29ad23019 100644 --- a/tests/content_visibility/fixtures/delete_post.xml +++ b/tests/content_visibility/fixtures/delete_post.xml @@ -151,8 +151,6 @@ username_clean user_permissions user_sig - user_occ - user_interests 1 4 @@ -160,8 +158,6 @@ user 1 - - diff --git a/tests/content_visibility/fixtures/set_post_visibility.xml b/tests/content_visibility/fixtures/set_post_visibility.xml index 722525deaa..5f792d0f05 100644 --- a/tests/content_visibility/fixtures/set_post_visibility.xml +++ b/tests/content_visibility/fixtures/set_post_visibility.xml @@ -126,8 +126,6 @@ username_clean user_permissions user_sig - user_occ - user_interests 1 1 @@ -135,8 +133,6 @@ user 1 - - 2 @@ -145,8 +141,6 @@ user 2 - - 3 @@ -155,8 +149,6 @@ user 3 - - diff --git a/tests/content_visibility/fixtures/set_topic_visibility.xml b/tests/content_visibility/fixtures/set_topic_visibility.xml index a875012d4f..02ab5f16fe 100644 --- a/tests/content_visibility/fixtures/set_topic_visibility.xml +++ b/tests/content_visibility/fixtures/set_topic_visibility.xml @@ -120,8 +120,6 @@ username_clean user_permissions user_sig - user_occ - user_interests 1 6 @@ -129,8 +127,6 @@ user 1 - - diff --git a/tests/dbal/fixtures/massmail_crossjoin.xml b/tests/dbal/fixtures/massmail_crossjoin.xml index ef0a2b7149..1050ba067e 100644 --- a/tests/dbal/fixtures/massmail_crossjoin.xml +++ b/tests/dbal/fixtures/massmail_crossjoin.xml @@ -14,16 +14,12 @@ username_clean user_permissions user_sig - user_occ - user_interests 1 mass email mass email - - 2 @@ -31,8 +27,6 @@ banned - - 3 @@ -40,8 +34,6 @@ not in group - - diff --git a/tests/dbal/fixtures/three_users.xml b/tests/dbal/fixtures/three_users.xml index a50e3e8634..a601e539e1 100644 --- a/tests/dbal/fixtures/three_users.xml +++ b/tests/dbal/fixtures/three_users.xml @@ -5,31 +5,23 @@ username_cleanuser_permissionsuser_sig - user_occ - user_interests 1 barfoo - - 2 foobar - - 3 bertie - -
diff --git a/tests/dbal/write_sequence_test.php b/tests/dbal/write_sequence_test.php index f382a971a5..5fe0fe8de9 100644 --- a/tests/dbal/write_sequence_test.php +++ b/tests/dbal/write_sequence_test.php @@ -42,8 +42,6 @@ class phpbb_dbal_write_sequence_test extends phpbb_database_test_case 'username_clean' => $username, 'user_permissions' => '', 'user_sig' => '', - 'user_occ' => '', - 'user_interests' => '', )); $db->sql_query($sql); diff --git a/tests/functions/fixtures/obtain_online.xml b/tests/functions/fixtures/obtain_online.xml index 05bbe6a05e..14621a3287 100644 --- a/tests/functions/fixtures/obtain_online.xml +++ b/tests/functions/fixtures/obtain_online.xml @@ -15,8 +15,6 @@ user_allow_viewonline user_permissions user_sig - user_occ - user_interests 1 anonymous @@ -24,8 +22,6 @@ 1 - - 2 @@ -34,8 +30,6 @@ 1 - - 3 @@ -44,8 +38,6 @@ 1 - - 4 @@ -54,8 +46,6 @@ 1 - - 5 @@ -64,8 +54,6 @@ 1 - - 6 @@ -74,8 +62,6 @@ 0 - - 7 @@ -84,8 +70,6 @@ 0 - - 8 @@ -94,8 +78,6 @@ 0 - - 9 @@ -104,8 +86,6 @@ 0 - - 10 @@ -114,8 +94,6 @@ 0 - - diff --git a/tests/functions/fixtures/validate_email.xml b/tests/functions/fixtures/validate_email.xml index de7fce8a08..eb4fd90217 100644 --- a/tests/functions/fixtures/validate_email.xml +++ b/tests/functions/fixtures/validate_email.xml @@ -6,8 +6,6 @@ username_clean user_permissions user_sig - user_occ - user_interests user_email_hash 1 @@ -15,8 +13,6 @@ admin - - 143317126117 diff --git a/tests/functions/fixtures/validate_username.xml b/tests/functions/fixtures/validate_username.xml index fbe398469c..1b85a2f06d 100644 --- a/tests/functions/fixtures/validate_username.xml +++ b/tests/functions/fixtures/validate_username.xml @@ -14,16 +14,12 @@ username_clean user_permissions user_sig - user_occ - user_interests 1 admin admin - - 2 @@ -31,8 +27,6 @@ moderator - - diff --git a/tests/functions_user/fixtures/group_user_attributes.xml b/tests/functions_user/fixtures/group_user_attributes.xml index f4edbdca49..9b1f1f504b 100644 --- a/tests/functions_user/fixtures/group_user_attributes.xml +++ b/tests/functions_user/fixtures/group_user_attributes.xml @@ -32,8 +32,6 @@ username_clean user_permissions user_sig - user_occ - user_interests 1 1 @@ -42,8 +40,6 @@ barfoo - - 2 @@ -53,8 +49,6 @@ foobar - - 3 @@ -64,8 +58,6 @@ bertie - - diff --git a/tests/log/fixtures/full_log.xml b/tests/log/fixtures/full_log.xml index 2ce2643d26..a10c224e0e 100644 --- a/tests/log/fixtures/full_log.xml +++ b/tests/log/fixtures/full_log.xml @@ -126,16 +126,12 @@ username_cleanuser_permissionsuser_sig - user_occ - user_interests 1 Anonymous Anonymous - - 2 @@ -143,8 +139,6 @@ admin - -
diff --git a/tests/notification/fixtures/convert.xml b/tests/notification/fixtures/convert.xml index 3f0a065cc4..c9d8fafa97 100644 --- a/tests/notification/fixtures/convert.xml +++ b/tests/notification/fixtures/convert.xml @@ -8,8 +8,6 @@ user_notify_pmuser_permissionsuser_sig - user_occ - user_interests 1 1 @@ -18,8 +16,6 @@ 0 - - 2 @@ -29,8 +25,6 @@ 1 - - 3 @@ -40,8 +34,6 @@ 0 - - 4 @@ -51,8 +43,6 @@ 1 - - 5 @@ -62,8 +52,6 @@ 0 - - 6 @@ -73,8 +61,6 @@ 1 - -
diff --git a/tests/notification/fixtures/group_request.xml b/tests/notification/fixtures/group_request.xml index 1eb73f1e15..fbaee0a326 100644 --- a/tests/notification/fixtures/group_request.xml +++ b/tests/notification/fixtures/group_request.xml @@ -6,16 +6,12 @@ username_clean user_permissions user_sig - user_occ - user_interests 2 2 2 - - 3 @@ -23,8 +19,6 @@ 3 - - diff --git a/tests/notification/fixtures/submit_post_bookmark.xml b/tests/notification/fixtures/submit_post_bookmark.xml index d4bf8df73f..525d0484e0 100644 --- a/tests/notification/fixtures/submit_post_bookmark.xml +++ b/tests/notification/fixtures/submit_post_bookmark.xml @@ -79,55 +79,41 @@ username_clean user_permissions user_sig - user_occ - user_interests 2 poster - - 3 test - - 4 unauthorized - - 5 notified - - 6 disabled - - 7 default - - diff --git a/tests/notification/fixtures/submit_post_post.xml b/tests/notification/fixtures/submit_post_post.xml index b0ffa042c5..a38ca77ea0 100644 --- a/tests/notification/fixtures/submit_post_post.xml +++ b/tests/notification/fixtures/submit_post_post.xml @@ -109,55 +109,41 @@ username_cleanuser_permissionsuser_sig - user_occ - user_interests 2 poster - - 3 test - - 4 unauthorized - - 5 notified - - 6 disabled - - 7 default - -
diff --git a/tests/notification/fixtures/submit_post_post_in_queue.xml b/tests/notification/fixtures/submit_post_post_in_queue.xml index 090e90ea49..28cb69be36 100644 --- a/tests/notification/fixtures/submit_post_post_in_queue.xml +++ b/tests/notification/fixtures/submit_post_post_in_queue.xml @@ -51,71 +51,53 @@ username_cleanuser_permissionsuser_sig - user_occ - user_interests 2 poster - - 3 test - - 4 unauthorized-mod - - 5 unauthorized-read - - 6 notified - - 7 disabled - - 8 default - - 9 test glboal-permissions - -
diff --git a/tests/notification/fixtures/submit_post_quote.xml b/tests/notification/fixtures/submit_post_quote.xml index f22ed97d91..2b11992e54 100644 --- a/tests/notification/fixtures/submit_post_quote.xml +++ b/tests/notification/fixtures/submit_post_quote.xml @@ -51,55 +51,41 @@ username_cleanuser_permissionsuser_sig - user_occ - user_interests 2 poster - - 3 test - - 4 unauthorized - - 5 notified - - 6 disabled - - 7 default - -
diff --git a/tests/privmsgs/fixtures/delete_user_pms.xml b/tests/privmsgs/fixtures/delete_user_pms.xml index 9a86501b7a..5f705c9fd2 100644 --- a/tests/privmsgs/fixtures/delete_user_pms.xml +++ b/tests/privmsgs/fixtures/delete_user_pms.xml @@ -8,8 +8,6 @@ user_unread_privmsguser_permissionsuser_sig - user_occ - user_interests 2 sender @@ -18,8 +16,6 @@ 0 - - 3 @@ -29,8 +25,6 @@ 0 - - 4 @@ -40,8 +34,6 @@ 2 - - 5 @@ -51,8 +43,6 @@ 0 - -
diff --git a/tests/session/fixtures/sessions_banlist.xml b/tests/session/fixtures/sessions_banlist.xml index 9422fc0665..e720e35f0a 100644 --- a/tests/session/fixtures/sessions_banlist.xml +++ b/tests/session/fixtures/sessions_banlist.xml @@ -5,15 +5,11 @@ username_cleanuser_permissionsuser_sig - user_occ - user_interests 1 anonymous - -
diff --git a/tests/session/fixtures/sessions_empty.xml b/tests/session/fixtures/sessions_empty.xml index 0e6ddccd88..2acba58f45 100644 --- a/tests/session/fixtures/sessions_empty.xml +++ b/tests/session/fixtures/sessions_empty.xml @@ -5,31 +5,23 @@ username_cleanuser_permissionsuser_sig - user_occ - user_interests 1 anonymous - - 3 foo - - 4 bar - -
diff --git a/tests/session/fixtures/sessions_full.xml b/tests/session/fixtures/sessions_full.xml index 6bbaf1c9d5..4fb6b9dfd4 100644 --- a/tests/session/fixtures/sessions_full.xml +++ b/tests/session/fixtures/sessions_full.xml @@ -5,31 +5,23 @@ username_cleanuser_permissionsuser_sig - user_occ - user_interests 1 anonymous - - 3 foo - - 4 bar - -
diff --git a/tests/session/fixtures/sessions_garbage.xml b/tests/session/fixtures/sessions_garbage.xml index 23c44a975b..5eace839d0 100644 --- a/tests/session/fixtures/sessions_garbage.xml +++ b/tests/session/fixtures/sessions_garbage.xml @@ -5,15 +5,11 @@ username_cleanuser_permissionsuser_sig - user_occ - user_interests 4 bar - -
diff --git a/tests/session/fixtures/sessions_key.xml b/tests/session/fixtures/sessions_key.xml index 246d284557..4f349cd282 100644 --- a/tests/session/fixtures/sessions_key.xml +++ b/tests/session/fixtures/sessions_key.xml @@ -30,15 +30,11 @@ username_cleanuser_permissionsuser_sig - user_occ - user_interests 4 bar - -
diff --git a/tests/user/fixtures/user_loader.xml b/tests/user/fixtures/user_loader.xml index 1fed8b5838..f676f468a6 100644 --- a/tests/user/fixtures/user_loader.xml +++ b/tests/user/fixtures/user_loader.xml @@ -6,16 +6,12 @@ username username_clean user_sig - user_occ - user_interests 1 Guest guest - - 2 @@ -23,8 +19,6 @@ Admin admin - - 3 @@ -32,8 +26,6 @@ Test test - - From c2cf294be539442d331ccd771a665e9113081261 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 2 Feb 2014 21:50:32 +0100 Subject: [PATCH 08/11] [ticket/12115] Add a new migration for profilefield_interests With this we avoid missing to copy one, when the admin already created a phpbb_* profile field. PHPBB3-12115 --- .../data/v310/profilefield_interests.php | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/profilefield_interests.php 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..77e23fcd17 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_interests.php @@ -0,0 +1,146 @@ +db_tools->sql_column_exists($this->table_prefix . 'profile_fields_data', 'pf_phpbb_interests'); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\profilefield_types', + ); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'profile_fields_data' => array( + 'pf_phpbb_interests' => array('MTEXT', ''), + ), + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'create_interests_custom_field'))), + array('custom', array(array($this, 'convert_interests_to_custom_field'))), + ); + } + + public function create_interests_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( + '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, + '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' => 'INTERESTS', + '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_interests_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, user_interests + FROM ' . $this->table_prefix . "users + WHERE user_interests <> '' + 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_phpbb_interests' => $row['user_interests'], + ); + + $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']; + $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; + } +} From 190301021bc85ea4226c1347e1a1209c95997e6f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Feb 2014 11:18:59 +0100 Subject: [PATCH 09/11] [ticket/12115] Use base class to reduce duplicate code PHPBB3-12115 --- .../data/v310/profilefield_interests.php | 147 +++-------------- .../data/v310/profilefield_occupation.php | 147 +++-------------- .../migration/profilefield_base_migration.php | 155 ++++++++++++++++++ 3 files changed, 203 insertions(+), 246 deletions(-) create mode 100644 phpBB/phpbb/db/migration/profilefield_base_migration.php diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_interests.php b/phpBB/phpbb/db/migration/data/v310/profilefield_interests.php index 77e23fcd17..d73bc78edb 100644 --- a/phpBB/phpbb/db/migration/data/v310/profilefield_interests.php +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_interests.php @@ -9,13 +9,8 @@ namespace phpbb\db\migration\data\v310; -class profilefield_interests extends \phpbb\db\migration\migration +class profilefield_interests extends \phpbb\db\migration\profilefield_base_migration { - public function effectively_installed() - { - return $this->db_tools->sql_column_exists($this->table_prefix . 'profile_fields_data', 'pf_phpbb_interests'); - } - static public function depends_on() { return array( @@ -23,124 +18,30 @@ class profilefield_interests extends \phpbb\db\migration\migration ); } - public function update_schema() - { - return array( - 'change_columns' => array( - $this->table_prefix . 'profile_fields_data' => array( - 'pf_phpbb_interests' => array('MTEXT', ''), - ), - ), - ); - } + protected $profilefield_name = 'phpbb_interests'; - public function update_data() - { - return array( - array('custom', array(array($this, 'create_interests_custom_field'))), - array('custom', array(array($this, 'convert_interests_to_custom_field'))), - ); - } + protected $profilefield_database_type = array('MTEXT', ''); - public function create_interests_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); + 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, + ); - $sql_ary = 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, - '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' => 'INTERESTS', - '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_interests_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, user_interests - FROM ' . $this->table_prefix . "users - WHERE user_interests <> '' - 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_phpbb_interests' => $row['user_interests'], - ); - - $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']; - $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 $user_column_name = 'user_interests'; } diff --git a/phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php b/phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php index ee276fa0f9..b0ea961c08 100644 --- a/phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php +++ b/phpBB/phpbb/db/migration/data/v310/profilefield_occupation.php @@ -9,13 +9,8 @@ namespace phpbb\db\migration\data\v310; -class profilefield_occupation extends \phpbb\db\migration\migration +class profilefield_occupation extends \phpbb\db\migration\profilefield_base_migration { - public function effectively_installed() - { - return $this->db_tools->sql_column_exists($this->table_prefix . 'profile_fields_data', 'pf_phpbb_occupation'); - } - static public function depends_on() { return array( @@ -23,124 +18,30 @@ class profilefield_occupation extends \phpbb\db\migration\migration ); } - public function update_schema() - { - return array( - 'change_columns' => array( - $this->table_prefix . 'profile_fields_data' => array( - 'pf_phpbb_occupation' => array('MTEXT', ''), - ), - ), - ); - } + protected $profilefield_name = 'phpbb_occupation'; - public function update_data() - { - return array( - array('custom', array(array($this, 'create_occupation_custom_field'))), - array('custom', array(array($this, 'convert_occupation_to_custom_field'))), - ); - } + protected $profilefield_database_type = array('MTEXT', ''); - public function create_occupation_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); + 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, + ); - $sql_ary = 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, - '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' => 'OCCUPATION', - '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_occupation_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, user_occ - FROM ' . $this->table_prefix . "users - WHERE user_occ <> '' - 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_phpbb_occupation' => $row['user_occ'], - ); - - $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']; - $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 $user_column_name = 'user_occ'; } 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..e637aec9f3 --- /dev/null +++ b/phpBB/phpbb/db/migration/profilefield_base_migration.php @@ -0,0 +1,155 @@ +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; + } +} From 26640bad3d959fd763feeae7647423b4495cf969 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Feb 2014 11:19:31 +0100 Subject: [PATCH 10/11] [ticket/12115] Add migration file to remove old user columns PHPBB3-12115 --- .../data/v310/profilefield_cleanup.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/profilefield_cleanup.php 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 @@ +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', ''), + ), + ), + ); + } +} From 4663ea7c8288ae56e00e2270aee49cb14a7c0276 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Feb 2014 14:18:30 +0100 Subject: [PATCH 11/11] [ticket/12115] Remove space from line ending PHPBB3-12115 --- phpBB/phpbb/db/migration/profilefield_base_migration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/db/migration/profilefield_base_migration.php b/phpBB/phpbb/db/migration/profilefield_base_migration.php index e637aec9f3..dec7a4c2bb 100644 --- a/phpBB/phpbb/db/migration/profilefield_base_migration.php +++ b/phpBB/phpbb/db/migration/profilefield_base_migration.php @@ -68,7 +68,7 @@ abstract class profilefield_base_migration extends \phpbb\db\migration\migration $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(); + $field_id = (int) $this->db->sql_nextid(); $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE);