diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2010-10-19 17:06:23 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2011-05-20 16:45:29 +0200 |
commit | 8fa44cc3b9778f84ca20eab1c1d404c4f848eab4 (patch) | |
tree | 9632c945c777f071ae8f51676b575c466b456057 | |
parent | 7074d19c4087fab0e81a31bd806724d7eac7ef87 (diff) | |
download | forums-8fa44cc3b9778f84ca20eab1c1d404c4f848eab4.tar forums-8fa44cc3b9778f84ca20eab1c1d404c4f848eab4.tar.gz forums-8fa44cc3b9778f84ca20eab1c1d404c4f848eab4.tar.bz2 forums-8fa44cc3b9778f84ca20eab1c1d404c4f848eab4.tar.xz forums-8fa44cc3b9778f84ca20eab1c1d404c4f848eab4.zip |
[ticket/8542] Display custom profile fields in private messages
Introduce an option to display the cpf in the PM view.
PHPBB3-8542
-rw-r--r-- | phpBB/adm/style/acp_profile.html | 4 | ||||
-rw-r--r-- | phpBB/develop/create_schema_files.php | 1 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_board.php | 2 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_profile.php | 6 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm_viewmessage.php | 43 | ||||
-rw-r--r-- | phpBB/install/database_update.php | 6 | ||||
-rw-r--r-- | phpBB/install/schemas/firebird_schema.sql | 1 | ||||
-rw-r--r-- | phpBB/install/schemas/mssql_schema.sql | 1 | ||||
-rw-r--r-- | phpBB/install/schemas/mysql_40_schema.sql | 1 | ||||
-rw-r--r-- | phpBB/install/schemas/mysql_41_schema.sql | 1 | ||||
-rw-r--r-- | phpBB/install/schemas/oracle_schema.sql | 1 | ||||
-rw-r--r-- | phpBB/install/schemas/postgres_schema.sql | 1 | ||||
-rw-r--r-- | phpBB/install/schemas/schema_data.sql | 1 | ||||
-rw-r--r-- | phpBB/install/schemas/sqlite_schema.sql | 1 | ||||
-rw-r--r-- | phpBB/language/en/acp/board.php | 1 | ||||
-rw-r--r-- | phpBB/language/en/acp/profile.php | 2 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/ucp_pm_viewmessage.html | 7 |
17 files changed, 78 insertions, 2 deletions
diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html index 85d37568c2..c1143e9ba4 100644 --- a/phpBB/adm/style/acp_profile.html +++ b/phpBB/adm/style/acp_profile.html @@ -56,6 +56,10 @@ <dd><input type="checkbox" class="radio" id="field_show_on_reg" name="field_show_on_reg" value="1"<!-- IF S_SHOW_ON_REG --> checked="checked"<!-- ENDIF --> /></dd> </dl> <dl> + <dt><label for="field_show_on_pm">{L_DISPLAY_ON_PM}:</label><br /><span>{L_DISPLAY_ON_PM_EXPLAIN}</span></dt> + <dd><input type="checkbox" class="radio" id="field_show_on_pm" name="field_show_on_pm" value="1"<!-- IF S_SHOW_ON_PM --> checked="checked"<!-- ENDIF --> /></dd> + </dl> + <dl> <dt><label for="field_show_on_vt">{L_DISPLAY_ON_VT}:</label><br /><span>{L_DISPLAY_ON_VT_EXPLAIN}</span></dt> <dd><input type="checkbox" class="radio" id="field_show_on_vt" name="field_show_on_vt" value="1"<!-- IF S_SHOW_ON_VT --> checked="checked"<!-- ENDIF --> /></dd> </dl> diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 8a4c4a329a..0abd0763d7 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1413,6 +1413,7 @@ function get_schema_struct() 'field_validation' => array('VCHAR_UNI:20', ''), 'field_required' => array('BOOL', 0), 'field_show_on_reg' => array('BOOL', 0), + 'field_show_on_pm' => array('BOOL', 0), 'field_show_on_vt' => array('BOOL', 0), 'field_show_profile' => array('BOOL', 0), 'field_hide' => array('BOOL', 0), diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 6821073749..54cdcb8e32 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -96,6 +96,7 @@ class acp_board 'load_moderators' => array('lang' => 'YES_MODERATORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_jumpbox' => array('lang' => 'YES_JUMPBOX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_memberlist' => array('lang' => 'LOAD_CPF_MEMBERLIST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + 'load_cpf_pm' => array('lang' => 'LOAD_CPF_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_viewprofile' => array('lang' => 'LOAD_CPF_VIEWPROFILE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_viewtopic' => array('lang' => 'LOAD_CPF_VIEWTOPIC', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), @@ -327,6 +328,7 @@ class acp_board 'legend3' => 'CUSTOM_PROFILE_FIELDS', 'load_cpf_memberlist' => array('lang' => 'LOAD_CPF_MEMBERLIST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + 'load_cpf_pm' => array('lang' => 'LOAD_CPF_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_viewprofile' => array('lang' => 'LOAD_CPF_VIEWPROFILE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_viewtopic' => array('lang' => 'LOAD_CPF_VIEWTOPIC', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index ca6a5f04d2..a18a01c44a 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -370,6 +370,7 @@ class acp_profile 'field_show_profile'=> 0, 'field_no_view' => 0, 'field_show_on_reg' => 0, + 'field_show_on_pm' => 0, 'field_show_on_vt' => 0, 'lang_name' => utf8_normalize_nfc(request_var('field_ident', '', true)), 'lang_explain' => '', @@ -381,7 +382,7 @@ class acp_profile // $exclude contains the data we gather in each step $exclude = array( - 1 => array('field_ident', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_show_on_vt', 'field_required', 'field_hide', 'field_show_profile', 'field_no_view'), + 1 => array('field_ident', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_show_on_pm', 'field_show_on_vt', 'field_required', 'field_hide', 'field_show_profile', 'field_no_view'), 2 => array('field_length', 'field_maxlen', 'field_minlen', 'field_validation', 'field_novalue', 'field_default_value'), 3 => array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options') ); @@ -407,6 +408,7 @@ class acp_profile $visibility_ary = array( 'field_required', 'field_show_on_reg', + 'field_show_on_pm', 'field_show_on_vt', 'field_show_profile', 'field_hide', @@ -734,6 +736,7 @@ class acp_profile 'S_STEP_ONE' => true, 'S_FIELD_REQUIRED' => ($cp->vars['field_required']) ? true : false, 'S_SHOW_ON_REG' => ($cp->vars['field_show_on_reg']) ? true : false, + 'S_SHOW_ON_PM' => ($cp->vars['field_show_on_pm']) ? true : false, 'S_SHOW_ON_VT' => ($cp->vars['field_show_on_vt']) ? true : false, 'S_FIELD_HIDE' => ($cp->vars['field_hide']) ? true : false, 'S_SHOW_PROFILE' => ($cp->vars['field_show_profile']) ? true : false, @@ -1050,6 +1053,7 @@ class acp_profile 'field_validation' => $cp->vars['field_validation'], 'field_required' => $cp->vars['field_required'], 'field_show_on_reg' => $cp->vars['field_show_on_reg'], + 'field_show_on_pm' => $cp->vars['field_show_on_pm'], 'field_show_on_vt' => $cp->vars['field_show_on_vt'], 'field_hide' => $cp->vars['field_hide'], 'field_show_profile' => $cp->vars['field_show_profile'], diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 74a32a68c9..8b288f5de1 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -59,6 +59,18 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) $bbcode = new bbcode($message_row['bbcode_bitfield']); } + // Load the custom profile fields + if ($config['load_cpf_pm']) + { + if (!class_exists('custom_profile')) + { + include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); + } + $cp = new custom_profile(); + + $profile_fields = $cp->generate_profile_fields_template('grab', $author_id); + } + // Assign TO/BCC Addresses to template write_pm_addresses(array('to' => $message_row['to_address'], 'bcc' => $message_row['bcc_address']), $author_id); @@ -174,6 +186,25 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) $bbcode_status = ($config['allow_bbcode'] && $config['auth_bbcode_pm'] && $auth->acl_get('u_pm_bbcode')) ? true : false; + // Get the profile fields template data + $cp_row = array(); + if ($config['load_cpf_pm'] && isset($profile_fields[$author_id])) + { + // Filter the fields we don't want to show + foreach ($profile_fields[$author_id] as $used_ident => $profile_field) + { + if (!$profile_field['data']['field_show_on_pm']) + { + unset($profile_fields[$author_id][$used_ident]); + } + } + + if (isset($profile_fields[$author_id])) + { + $cp_row = $cp->generate_profile_fields_template('show', false, $profile_fields[$author_id]); + } + } + $template->assign_vars(array( 'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']), 'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']), @@ -232,11 +263,23 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'S_SPECIAL_FOLDER' => in_array($folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)), 'S_PM_RECIPIENTS' => $num_recipients, 'S_BBCODE_ALLOWED' => ($bbcode_status) ? 1 : 0, + 'S_CUSTOM_FIELDS' => (!empty($cp_row['row'])) ? true : false, 'U_PRINT_PM' => ($config['print_pm'] && $auth->acl_get('u_pm_printpm')) ? "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=print" : '', 'U_FORWARD_PM' => ($config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&mode=compose&action=forward&f=$folder_id&p=" . $message_row['msg_id'] : '') ); + // Display the custom profile fields + if (!empty($cp_row['row'])) + { + $template->assign_vars($cp_row['row']); + + foreach ($cp_row['blockrow'] as $cp_block_row) + { + $template->assign_block_vars('custom_fields', $cp_block_row); + } + } + // Display not already displayed Attachments for this post, we already parsed them. ;) if (isset($attachments) && sizeof($attachments)) { diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index cf611ca951..d646e200a3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -936,6 +936,9 @@ function database_update_info() GROUPS_TABLE => array( 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), ), + PROFILE_FIELDS_TABLE => array( + 'field_show_on_pm' => array('BOOL', 0), + ), ), 'change_columns' => array( GROUPS_TABLE => array( @@ -1962,6 +1965,9 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); + // Allow custom profile fields in pm templates + set_config('load_cpf_pm', '0'); + $no_updates = false; break; } diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index e16b4ab64c..73b9a283de 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -793,6 +793,7 @@ CREATE TABLE phpbb_profile_fields ( field_validation VARCHAR(20) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, field_required INTEGER DEFAULT 0 NOT NULL, field_show_on_reg INTEGER DEFAULT 0 NOT NULL, + field_show_on_pm INTEGER DEFAULT 0 NOT NULL, field_show_on_vt INTEGER DEFAULT 0 NOT NULL, field_show_profile INTEGER DEFAULT 0 NOT NULL, field_hide INTEGER DEFAULT 0 NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index a14e246c8f..f73f0134db 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -950,6 +950,7 @@ CREATE TABLE [phpbb_profile_fields] ( [field_validation] [varchar] (20) DEFAULT ('') NOT NULL , [field_required] [int] DEFAULT (0) NOT NULL , [field_show_on_reg] [int] DEFAULT (0) NOT NULL , + [field_show_on_pm] [int] DEFAULT (0) NOT NULL , [field_show_on_vt] [int] DEFAULT (0) NOT NULL , [field_show_profile] [int] DEFAULT (0) NOT NULL , [field_hide] [int] DEFAULT (0) NOT NULL , diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 3b79afa942..6da9a71420 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -557,6 +557,7 @@ CREATE TABLE phpbb_profile_fields ( field_validation varbinary(60) DEFAULT '' NOT NULL, field_required tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, field_show_on_reg tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_show_on_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, field_show_on_vt tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, field_show_profile tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, field_hide tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index a4b34c05db..743105e485 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -557,6 +557,7 @@ CREATE TABLE phpbb_profile_fields ( field_validation varchar(20) DEFAULT '' NOT NULL, field_required tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, field_show_on_reg tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_show_on_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, field_show_on_vt tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, field_show_profile tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, field_hide tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 9b516b4a56..13c7303a0d 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1064,6 +1064,7 @@ CREATE TABLE phpbb_profile_fields ( field_validation varchar2(60) DEFAULT '' , field_required number(1) DEFAULT '0' NOT NULL, field_show_on_reg number(1) DEFAULT '0' NOT NULL, + field_show_on_pm number(1) DEFAULT '0' NOT NULL, field_show_on_vt number(1) DEFAULT '0' NOT NULL, field_show_profile number(1) DEFAULT '0' NOT NULL, field_hide number(1) DEFAULT '0' NOT NULL, diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 1b9c1a75aa..d2634c7d40 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -744,6 +744,7 @@ CREATE TABLE phpbb_profile_fields ( field_validation varchar(20) DEFAULT '' NOT NULL, field_required INT2 DEFAULT '0' NOT NULL CHECK (field_required >= 0), field_show_on_reg INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_reg >= 0), + field_show_on_pm INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_pm >= 0), field_show_on_vt INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_vt >= 0), field_show_profile INT2 DEFAULT '0' NOT NULL CHECK (field_show_profile >= 0), field_hide INT2 DEFAULT '0' NOT NULL CHECK (field_hide >= 0), diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index f3259b8fe3..76bb6fd6cb 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -157,6 +157,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_search_load' INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_anon_lastread', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_birthdays', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_memberlist', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_profile', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewprofile', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewtopic', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_lastread', '1'); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 9344a29929..0c706d67dd 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -540,6 +540,7 @@ CREATE TABLE phpbb_profile_fields ( field_validation varchar(20) NOT NULL DEFAULT '', field_required INTEGER UNSIGNED NOT NULL DEFAULT '0', field_show_on_reg INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_show_on_pm INTEGER UNSIGNED NOT NULL DEFAULT '0', field_show_on_vt INTEGER UNSIGNED NOT NULL DEFAULT '0', field_show_profile INTEGER UNSIGNED NOT NULL DEFAULT '0', field_hide INTEGER UNSIGNED NOT NULL DEFAULT '0', diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index fe023958a9..084076d8dc 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -353,6 +353,7 @@ $lang = array_merge($lang, array( 'LIMIT_SESSIONS' => 'Limit sessions', 'LIMIT_SESSIONS_EXPLAIN' => 'If the number of sessions exceeds this value within a one minute period the board will go offline. Set to 0 for unlimited sessions.', 'LOAD_CPF_MEMBERLIST' => 'Allow styles to display custom profile fields in memberlist', + 'LOAD_CPF_PM' => 'Display custom profile fields in private messages', 'LOAD_CPF_VIEWPROFILE' => 'Display custom profile fields in user profiles', 'LOAD_CPF_VIEWTOPIC' => 'Display custom profile fields on topic pages', 'LOAD_USER_ACTIVITY' => 'Show user’s activity', diff --git a/phpBB/language/en/acp/profile.php b/phpBB/language/en/acp/profile.php index 31a82fd38f..ea643157d8 100644 --- a/phpBB/language/en/acp/profile.php +++ b/phpBB/language/en/acp/profile.php @@ -66,6 +66,8 @@ $lang = array_merge($lang, array( 'DISPLAY_AT_PROFILE_EXPLAIN' => 'The user is able to change this profile field within the user control panel.', 'DISPLAY_AT_REGISTER' => 'Display on registration screen', 'DISPLAY_AT_REGISTER_EXPLAIN' => 'If this option is enabled, the field will be displayed on registration.', + 'DISPLAY_ON_PM' => 'Display on view pm screen', + 'DISPLAY_ON_PM_EXPLAIN' => 'If this option is enabled, the field will be displayed in the mini-profile on the pm screen.', 'DISPLAY_ON_VT' => 'Display on viewtopic screen', 'DISPLAY_ON_VT_EXPLAIN' => 'If this option is enabled, the field will be displayed in the mini-profile on the topic screen.', 'DISPLAY_PROFILE_FIELD' => 'Publicly display profile field', diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index af5213ae30..5317068d89 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -69,7 +69,12 @@ <dd><strong>{L_POSTS}:</strong> {AUTHOR_POSTS}</dd> <!-- IF AUTHOR_JOINED --><dd><strong>{L_JOINED}:</strong> {AUTHOR_JOINED}</dd><!-- ENDIF --> <!-- IF AUTHOR_FROM --><dd><strong>{L_LOCATION}:</strong> {AUTHOR_FROM}</dd><!-- ENDIF --> - + + <!-- BEGIN custom_fields --> + <dd><strong>{custom_fields.PROFILE_FIELD_NAME}:</strong> {custom_fields.PROFILE_FIELD_VALUE}</dd> + <!-- END custom_fields --> + + <!-- IF U_PM or U_EMAIL or U_WWW or U_MSN or U_ICQ or U_YIM or U_AIM or U_JABBER --> <dd> <ul class="profile-icons"> |