Skip to content

Commit

Permalink
Merge pull request #1988 from nickvergessen/ticket/12115
Browse files Browse the repository at this point in the history
[ticket/12115] Convert occupation profile field to custom field
  • Loading branch information
naderman committed Feb 10, 2014
2 parents 02674de + 4663ea7 commit 840ab75
Show file tree
Hide file tree
Showing 61 changed files with 404 additions and 321 deletions.
8 changes: 0 additions & 8 deletions phpBB/adm/style/acp_users_profile.html
Expand Up @@ -30,14 +30,6 @@
<dt><label for="location">{L_LOCATION}{L_COLON}</label></dt>
<dd><input type="text" id="location" name="location" value="{LOCATION}" /></dd>
</dl>
<dl>
<dt><label for="occupation">{L_OCCUPATION}{L_COLON}</label></dt>
<dd><textarea id="occupation" name="occupation" rows="3" cols="30">{OCCUPATION}</textarea></dd>
</dl>
<dl>
<dt><label for="interests">{L_INTERESTS}{L_COLON}</label></dt>
<dd><textarea id="interests" name="interests" rows="3" cols="30">{INTERESTS}</textarea></dd>
</dl>
<dl>
<dt><label for="birthday">{L_BIRTHDAY}{L_COLON}</label><br /><span>{L_BIRTHDAY_EXPLAIN}</span></dt>
<dd>{L_DAY}{L_COLON} <select id="birthday" name="bday_day">{S_BIRTHDAY_DAY_OPTIONS}</select> {L_MONTH}{L_COLON} <select name="bday_month">{S_BIRTHDAY_MONTH_OPTIONS}</select> {L_YEAR}{L_COLON} <select name="bday_year">{S_BIRTHDAY_YEAR_OPTIONS}</select></dd>
Expand Down
6 changes: 2 additions & 4 deletions phpBB/develop/benchmark.php
Expand Up @@ -368,9 +368,7 @@ 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.";
$signature_bbcode_uid = "";
$avatar_filename = "";
Expand Down Expand Up @@ -422,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_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_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, '')";
Expand Down
8 changes: 0 additions & 8 deletions phpBB/includes/acp/acp_users.php
Expand Up @@ -1368,8 +1368,6 @@ function main($id, $mode)
'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,
'bday_year' => 0,
Expand Down Expand Up @@ -1402,8 +1400,6 @@ function main($id, $mode)
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),
'bday_year' => array('num', true, 1901, gmdate('Y', time())),
Expand Down Expand Up @@ -1432,8 +1428,6 @@ function main($id, $mode)
'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'],
);

Expand Down Expand Up @@ -1484,8 +1478,6 @@ function main($id, $mode)
'JABBER' => $data['jabber'],
'WEBSITE' => $data['website'],
'LOCATION' => $data['location'],
'OCCUPATION' => $data['occupation'],
'INTERESTS' => $data['interests'],

'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options,
'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options,
Expand Down
4 changes: 2 additions & 2 deletions phpBB/includes/db/schema_data.php
Expand Up @@ -787,6 +787,8 @@
$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',
);
Expand Down Expand Up @@ -1170,8 +1172,6 @@
'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', ''),
'user_form_salt' => array('VCHAR_UNI:32', ''),
Expand Down
2 changes: 0 additions & 2 deletions phpBB/includes/functions_user.php
Expand Up @@ -210,8 +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' => '',
'user_avatar_width' => 0,
Expand Down
3 changes: 0 additions & 3 deletions phpBB/includes/ucp/ucp_main.php
Expand Up @@ -195,9 +195,6 @@ function main($id, $mode)
'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,

'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $user->data['user_id'] . '&amp;sr=posts') : '',
Expand Down
8 changes: 0 additions & 8 deletions phpBB/includes/ucp/ucp_profile.php
Expand Up @@ -271,8 +271,6 @@ function main($id, $mode)
'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)),
);

if ($config['allow_birthdays'])
Expand Down Expand Up @@ -308,8 +306,6 @@ function main($id, $mode)
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),
);

if ($config['allow_birthdays'])
Expand Down Expand Up @@ -356,8 +352,6 @@ function main($id, $mode)
'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'],
);

Expand Down Expand Up @@ -427,8 +421,6 @@ function main($id, $mode)
'JABBER' => $data['jabber'],
'WEBSITE' => $data['website'],
'LOCATION' => $data['location'],
'OCCUPATION'=> $data['occupation'],
'INTERESTS' => $data['interests'],
));

// Get additional profile fields and assign them to the template block var 'profile_fields'
Expand Down
16 changes: 14 additions & 2 deletions phpBB/install/convertors/convert_phpbb20.php
Expand Up @@ -906,8 +906,6 @@
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')),
Expand Down Expand Up @@ -954,6 +952,20 @@

'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')),
array('pf_phpbb_interests', 'users.user_interests', array('function1' => 'phpbb_set_encoding')),

'where' => 'users.user_id <> -1',
),
),
);
}
25 changes: 25 additions & 0 deletions phpBB/install/install_install.php
Expand Up @@ -1718,6 +1718,7 @@ function add_language($mode, $sub)
$this->error('Unable to access the language directory', __LINE__, __FILE__);
}

$installed_languages = array();
while (($file = readdir($dir)) !== false)
{
$path = $phpbb_root_path . 'language/' . $file;
Expand All @@ -1741,6 +1742,7 @@ function add_language($mode, $sub)

$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);
Expand All @@ -1749,6 +1751,29 @@ function add_language($mode, $sub)
}
}
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();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions phpBB/install/schemas/firebird_schema.sql
Expand Up @@ -946,7 +946,9 @@ 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_interests BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' 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);;
Expand Down Expand Up @@ -1423,8 +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_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,
user_form_salt VARCHAR(32) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
Expand Down
6 changes: 3 additions & 3 deletions phpBB/install/schemas/mssql_schema.sql
Expand Up @@ -1153,7 +1153,9 @@ 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_interests] [varchar] (4000) DEFAULT ('') NOT NULL ,
[pf_phpbb_occupation] [varchar] (4000) DEFAULT ('') NOT NULL
) ON [PRIMARY]
GO

Expand Down Expand Up @@ -1739,8 +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_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 ,
[user_form_salt] [varchar] (32) DEFAULT ('') NOT NULL ,
Expand Down
4 changes: 2 additions & 2 deletions phpBB/install/schemas/mysql_40_schema.sql
Expand Up @@ -672,6 +672,8 @@ 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)
);

Expand Down Expand Up @@ -1032,8 +1034,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,
user_form_salt varbinary(96) DEFAULT '' NOT NULL,
Expand Down
4 changes: 2 additions & 2 deletions phpBB/install/schemas/mysql_41_schema.sql
Expand Up @@ -672,6 +672,8 @@ 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`;

Expand Down Expand Up @@ -1032,8 +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_occ text 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,
Expand Down
4 changes: 2 additions & 2 deletions phpBB/install/schemas/oracle_schema.sql
Expand Up @@ -1265,6 +1265,8 @@ 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)
)
/
Expand Down Expand Up @@ -1856,8 +1858,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 '' ,
user_form_salt varchar2(96) DEFAULT '' ,
Expand Down
4 changes: 2 additions & 2 deletions phpBB/install/schemas/postgres_schema.sql
Expand Up @@ -882,6 +882,8 @@ 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)
);

Expand Down Expand Up @@ -1304,8 +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_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,
user_form_salt varchar(32) DEFAULT '' NOT NULL,
Expand Down

0 comments on commit 840ab75

Please sign in to comment.