From 9a028c5ec151db5afa908c874ebb524546aa96d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20Rydh=C3=A9?= Date: Tue, 23 Feb 2021 09:18:43 +0100 Subject: [PATCH] Make custom fields selectable for buddy list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At the moment, all custom fields is shown on the buddylist. Make it customizable, like for the members list. Fixes #2878 Signed-off-by: Oscar Rydhé oscar.rydhe@gmail.com --- Sources/ManageSettings.php | 13 ++++++++---- Sources/Profile-Modify.php | 4 +++- Themes/default/Admin.template.php | 6 ++++++ Themes/default/Profile.template.php | 2 +- .../languages/ManageSettings.english.php | 1 + other/install_2-1_mysql.sql | 11 +++++----- other/install_2-1_postgresql.sql | 11 +++++----- other/upgrade_2-1_mysql.sql | 17 +++++++++------ other/upgrade_2-1_postgresql.sql | 21 ++++++++++++------- 9 files changed, 56 insertions(+), 30 deletions(-) diff --git a/Sources/ManageSettings.php b/Sources/ManageSettings.php index 2650979acf..1731b82a44 100644 --- a/Sources/ManageSettings.php +++ b/Sources/ManageSettings.php @@ -1788,7 +1788,7 @@ function EditCustomProfiles() $request = $smcFunc['db_query']('', ' SELECT id_field, col_name, field_name, field_desc, field_type, field_order, field_length, field_options, - show_reg, show_display, show_mlist, show_profile, private, active, default_value, can_search, + show_reg, show_display, show_mlist, show_blist, show_profile, private, active, default_value, can_search, bbc, mask, enclose, placement FROM {db_prefix}custom_fields WHERE id_field = {int:current_field}', @@ -1815,6 +1815,7 @@ function EditCustomProfiles() 'reg' => $row['show_reg'], 'display' => $row['show_display'], 'mlist' => $row['show_mlist'], + 'blist' => $row['show_blist'], 'type' => $row['field_type'], 'order' => $row['field_order'], 'max_length' => $row['field_length'], @@ -1846,6 +1847,7 @@ function EditCustomProfiles() 'reg' => false, 'display' => false, 'mlist' => false, + 'blist' => false, 'type' => 'text', 'order' => 0, 'max_length' => 255, @@ -1937,6 +1939,7 @@ function EditCustomProfiles() $show_reg = isset($_POST['reg']) ? (int) $_POST['reg'] : 0; $show_display = isset($_POST['display']) ? 1 : 0; $show_mlist = isset($_POST['mlist']) ? 1 : 0; + $show_blist = isset($_POST['blist']) ? 1 : 0; $bbc = isset($_POST['bbc']) ? 1 : 0; $show_profile = $_POST['profile_area']; $active = isset($_POST['active']) ? 1 : 0; @@ -2089,7 +2092,8 @@ function EditCustomProfiles() field_name = {string:field_name}, field_desc = {string:field_desc}, field_type = {string:field_type}, field_length = {int:field_length}, field_options = {string:field_options}, show_reg = {int:show_reg}, - show_display = {int:show_display}, show_mlist = {int:show_mlist}, show_profile = {string:show_profile}, + show_display = {int:show_display}, show_mlist = {int:show_mlist}, + show_blist = {int:show_blist}, show_profile = {string:show_profile}, private = {int:private}, active = {int:active}, default_value = {string:default_value}, can_search = {int:can_search}, bbc = {int:bbc}, mask = {string:mask}, enclose = {string:enclose}, placement = {int:placement} @@ -2099,6 +2103,7 @@ function EditCustomProfiles() 'show_reg' => $show_reg, 'show_display' => $show_display, 'show_mlist' => $show_mlist, + 'show_blist' => $show_blist, 'private' => $private, 'active' => $active, 'can_search' => $can_search, @@ -2140,14 +2145,14 @@ function EditCustomProfiles() array( 'col_name' => 'string', 'field_name' => 'string', 'field_desc' => 'string', 'field_type' => 'string', 'field_length' => 'string', 'field_options' => 'string', 'field_order' => 'int', - 'show_reg' => 'int', 'show_display' => 'int', 'show_mlist' => 'int', 'show_profile' => 'string', + 'show_reg' => 'int', 'show_display' => 'int', 'show_mlist' => 'int', 'show_blist' => 'int', 'show_profile' => 'string', 'private' => 'int', 'active' => 'int', 'default_value' => 'string', 'can_search' => 'int', 'bbc' => 'int', 'mask' => 'string', 'enclose' => 'string', 'placement' => 'int', ), array( $col_name, $_POST['field_name'], $_POST['field_desc'], $_POST['field_type'], $field_length, $field_options, $new_order, - $show_reg, $show_display, $show_mlist, $show_profile, + $show_reg, $show_display, $show_mlist, $show_blist, $show_profile, $private, $active, $default, $can_search, $bbc, $mask, $enclose, $placement, ), diff --git a/Sources/Profile-Modify.php b/Sources/Profile-Modify.php index 28a0d68d5d..4263179e0c 100644 --- a/Sources/Profile-Modify.php +++ b/Sources/Profile-Modify.php @@ -1522,10 +1522,12 @@ function editBuddies($memID) SELECT col_name, field_name, field_desc, field_type, bbc, enclose FROM {db_prefix}custom_fields WHERE active = {int:active} - AND private < {int:private_level}', + AND private < {int:private_level} + AND show_blist = {int:show_blist}', array( 'active' => 1, 'private_level' => 2, + 'show_blist' => 1, ) ); diff --git a/Themes/default/Admin.template.php b/Themes/default/Admin.template.php index 9158798c7a..5f8f7face6 100644 --- a/Themes/default/Admin.template.php +++ b/Themes/default/Admin.template.php @@ -1163,6 +1163,12 @@ function template_edit_profile_field()
+
+ +
+
+ +
diff --git a/Themes/default/Profile.template.php b/Themes/default/Profile.template.php index 4a4b0a5f5e..649bb4fb98 100644 --- a/Themes/default/Profile.template.php +++ b/Themes/default/Profile.template.php @@ -789,7 +789,7 @@ function template_editBuddies() if (!empty($context['custom_pf'])) foreach ($context['custom_pf'] as $key => $column) echo ' - ', $buddy['options'][$key], ''; + ', $buddy['options'][$key], ''; echo ' diff --git a/Themes/default/languages/ManageSettings.english.php b/Themes/default/languages/ManageSettings.english.php index fccac75253..7dc48265e4 100755 --- a/Themes/default/languages/ManageSettings.english.php +++ b/Themes/default/languages/ManageSettings.english.php @@ -277,6 +277,7 @@ $txt['custom_edit_registration_require'] = 'Yes, and require entry'; $txt['custom_edit_display'] = 'Show on Topic View'; $txt['custom_edit_mlist'] = 'Show on memberlist'; +$txt['custom_edit_blist'] = 'Show on buddylist'; $txt['custom_edit_picktype'] = 'Field Type'; $txt['custom_edit_max_length'] = 'Maximum Length'; diff --git a/other/install_2-1_mysql.sql b/other/install_2-1_mysql.sql index e1d351d0f8..6b2dc61fba 100644 --- a/other/install_2-1_mysql.sql +++ b/other/install_2-1_mysql.sql @@ -222,6 +222,7 @@ CREATE TABLE {$db_prefix}custom_fields ( show_reg TINYINT NOT NULL DEFAULT '0', show_display TINYINT NOT NULL DEFAULT '0', show_mlist SMALLINT NOT NULL DEFAULT '0', + show_blist SMALLINT NOT NULL DEFAULT '0', show_profile VARCHAR(20) NOT NULL DEFAULT 'forumprofile', private TINYINT NOT NULL DEFAULT '0', active TINYINT NOT NULL DEFAULT '1', @@ -1794,11 +1795,11 @@ VALUES (1, 0, '{$default_category_name}', '', 1); # INSERT INTO {$db_prefix}custom_fields - (`col_name`, `field_name`, `field_desc`, `field_type`, `field_length`, `field_options`, `field_order`, `mask`, `show_reg`, `show_display`, `show_mlist`, `show_profile`, `private`, `active`, `bbc`, `can_search`, `default_value`, `enclose`, `placement`) -VALUES ('cust_icq', 'ICQ', 'This is your ICQ number.', 'text', 12, '', 1, 'regex~[1-9][0-9]{4,9}~i', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', 'ICQ - {INPUT}', 1), - ('cust_skype', 'Skype', 'Your Skype name', 'text', 32, '', 2, 'nohtml', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', '{INPUT} ', 1), - ('cust_loca', 'Location', 'Geographic location.', 'text', 50, '', 4, 'nohtml', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', '', 0), - ('cust_gender', 'Gender', 'Your gender.', 'radio', 255, 'None,Male,Female', 5, 'nohtml', 1, 1, 0, 'forumprofile', 0, 1, 0, 0, 'None', '', 1); + (`col_name`, `field_name`, `field_desc`, `field_type`, `field_length`, `field_options`, `field_order`, `mask`, `show_reg`, `show_display`, `show_mlist`, `show_blist`, `show_profile`, `private`, `active`, `bbc`, `can_search`, `default_value`, `enclose`, `placement`) +VALUES ('cust_icq', 'ICQ', 'This is your ICQ number.', 'text', 12, '', 1, 'regex~[1-9][0-9]{4,9}~i', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', 'ICQ - {INPUT}', 1), + ('cust_skype', 'Skype', 'Your Skype name', 'text', 32, '', 2, 'nohtml', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', '{INPUT} ', 1), + ('cust_loca', 'Location', 'Geographic location.', 'text', 50, '', 4, 'nohtml', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', '', 0), + ('cust_gender', 'Gender', 'Your gender.', 'radio', 255, 'None,Male,Female', 5, 'nohtml', 1, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, 'None', '', 1); # -------------------------------------------------------- diff --git a/other/install_2-1_postgresql.sql b/other/install_2-1_postgresql.sql index 6695044d12..713d21ee9b 100644 --- a/other/install_2-1_postgresql.sql +++ b/other/install_2-1_postgresql.sql @@ -410,6 +410,7 @@ CREATE TABLE {$db_prefix}custom_fields ( show_reg smallint NOT NULL DEFAULT '0', show_display smallint NOT NULL DEFAULT '0', show_mlist smallint NOT NULL DEFAULT '0', + show_blist SMALLINT NOT NULL DEFAULT '0', show_profile varchar(20) NOT NULL DEFAULT 'forumprofile', private smallint NOT NULL DEFAULT '0', active smallint NOT NULL DEFAULT '1', @@ -2350,11 +2351,11 @@ VALUES (1, 0, '{$default_category_name}', '', 1); # INSERT INTO {$db_prefix}custom_fields - (col_name, field_name, field_desc, field_type, field_length, field_options, field_order, mask, show_reg, show_display, show_mlist, show_profile, private, active, bbc, can_search, default_value, enclose, placement) -VALUES ('cust_icq', 'ICQ', 'This is your ICQ number.', 'text', 12, '', 1, 'regex~[1-9][0-9]{4,9}~i', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', 'ICQ - {INPUT}', 1), - ('cust_skype', 'Skype', 'Your Skype name', 'text', 32, '', 2, 'nohtml', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', '{INPUT} ', 1), - ('cust_loca', 'Location', 'Geographic location.', 'text', 50, '', 4, 'nohtml', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', '', 0), - ('cust_gender', 'Gender', 'Your gender.', 'radio', 255, 'None,Male,Female', 5, 'nohtml', 1, 1, 0, 'forumprofile', 0, 1, 0, 0, 'None', '', 1); + (col_name, field_name, field_desc, field_type, field_length, field_options, field_order, mask, show_reg, show_display, show_mlist, show_blist, show_profile, private, active, bbc, can_search, default_value, enclose, placement) +VALUES ('cust_icq', 'ICQ', 'This is your ICQ number.', 'text', 12, '', 1, 'regex~[1-9][0-9]{4,9}~i', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', 'ICQ - {INPUT}', 1), + ('cust_skype', 'Skype', 'Your Skype name', 'text', 32, '', 2, 'nohtml', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', '{INPUT} ', 1), + ('cust_loca', 'Location', 'Geographic location.', 'text', 50, '', 4, 'nohtml', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', '', 0), + ('cust_gender', 'Gender', 'Your gender.', 'radio', 255, 'None,Male,Female', 5, 'nohtml', 1, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, 'None', '', 1); # -------------------------------------------------------- diff --git a/other/upgrade_2-1_mysql.sql b/other/upgrade_2-1_mysql.sql index 606a2f24fa..30abba07f7 100644 --- a/other/upgrade_2-1_mysql.sql +++ b/other/upgrade_2-1_mysql.sql @@ -1184,13 +1184,18 @@ ALTER TABLE {$db_prefix}custom_fields ADD COLUMN show_mlist SMALLINT NOT NULL DEFAULT '0'; ---# +---# Adding new show_blist column... +ALTER TABLE {$db_prefix}custom_fields +ADD COLUMN show_blist SMALLINT NOT NULL DEFAULT '0'; +---# + ---# Insert fields -INSERT INTO `{$db_prefix}custom_fields` (`col_name`, `field_name`, `field_desc`, `field_type`, `field_length`, `field_options`, `field_order`, `mask`, `show_reg`, `show_display`, `show_mlist`, `show_profile`, `private`, `active`, `bbc`, `can_search`, `default_value`, `enclose`, `placement`) VALUES -('cust_icq', 'ICQ', 'This is your ICQ number.', 'text', 12, '', 1, 'regex~[1-9][0-9]{4,9}~i', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', 'ICQ - {INPUT}', 1), -('cust_skype', 'Skype', 'Your Skype name', 'text', 32, '', 2, 'nohtml', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', '{INPUT} ', 1), -('cust_yahoo', 'Yahoo! Messenger', 'This is your Yahoo! Instant Messenger nickname.', 'text', 50, '', 3, 'nohtml', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', 'Yahoo! Messenger - {INPUT}', 1), -('cust_loca', 'Location', 'Geographic location.', 'text', 50, '', 4, 'nohtml', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', '', 0), -('cust_gender', 'Gender', 'Your gender.', 'radio', 255, 'None,Male,Female', 5, 'nohtml', 1, 1, 0, 'forumprofile', 0, 1, 0, 0, 'None', '', 1); +INSERT INTO `{$db_prefix}custom_fields` (`col_name`, `field_name`, `field_desc`, `field_type`, `field_length`, `field_options`, `field_order`, `mask`, `show_reg`, `show_display`, `show_mlist`, `show_blist`, `show_profile`, `private`, `active`, `bbc`, `can_search`, `default_value`, `enclose`, `placement`) VALUES +('cust_icq', 'ICQ', 'This is your ICQ number.', 'text', 12, '', 1, 'regex~[1-9][0-9]{4,9}~i', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', 'ICQ - {INPUT}', 1), +('cust_skype', 'Skype', 'Your Skype name', 'text', 32, '', 2, 'nohtml', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', '{INPUT} ', 1), +('cust_yahoo', 'Yahoo! Messenger', 'This is your Yahoo! Instant Messenger nickname.', 'text', 50, '', 3, 'nohtml', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', 'Yahoo! Messenger - {INPUT}', 1), +('cust_loca', 'Location', 'Geographic location.', 'text', 50, '', 4, 'nohtml', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', '', 0), +('cust_gender', 'Gender', 'Your gender.', 'radio', 255, 'None,Male,Female', 5, 'nohtml', 1, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, 'None', '', 1); ---# ---# Add an order value to each existing cust profile field. diff --git a/other/upgrade_2-1_postgresql.sql b/other/upgrade_2-1_postgresql.sql index 960bb46d66..12f1371c14 100644 --- a/other/upgrade_2-1_postgresql.sql +++ b/other/upgrade_2-1_postgresql.sql @@ -1389,15 +1389,20 @@ ALTER TABLE {$db_prefix}custom_fields ADD COLUMN show_mlist smallint NOT NULL default '0'; ---# +---# Adding new show_blist column... +ALTER TABLE {$db_prefix}custom_fields +ADD COLUMN show_blist SMALLINT NOT NULL DEFAULT '0'; +---# + ---# Insert fields -INSERT INTO {$db_prefix}custom_fields (col_name, field_name, field_desc, field_type, field_length, field_options, field_order, mask, show_reg, show_display, show_mlist, show_profile, private, active, bbc, can_search, default_value, enclose, placement) VALUES -('cust_icq', 'ICQ', 'This is your ICQ number.', 'text', 12, '', 1, 'regex~[1-9][0-9]{4,9}~i', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', 'ICQ - {INPUT}', 1) ON CONFLICT DO NOTHING; -INSERT INTO {$db_prefix}custom_fields (col_name, field_name, field_desc, field_type, field_length, field_options, field_order, mask, show_reg, show_display, show_mlist, show_profile, private, active, bbc, can_search, default_value, enclose, placement) VALUES -('cust_skype', 'Skype', 'Your Skype name', 'text', 32, '', 2, 'nohtml', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', '{INPUT} ', 1) ON CONFLICT DO NOTHING; -INSERT INTO {$db_prefix}custom_fields (col_name, field_name, field_desc, field_type, field_length, field_options, field_order, mask, show_reg, show_display, show_mlist, show_profile, private, active, bbc, can_search, default_value, enclose, placement) VALUES -('cust_loca', 'Location', 'Geographic location.', 'text', 50, '', 4, 'nohtml', 0, 1, 0, 'forumprofile', 0, 1, 0, 0, '', '', 0) ON CONFLICT DO NOTHING; -INSERT INTO {$db_prefix}custom_fields (col_name, field_name, field_desc, field_type, field_length, field_options, field_order, mask, show_reg, show_display, show_mlist, show_profile, private, active, bbc, can_search, default_value, enclose, placement) VALUES -('cust_gender', 'Gender', 'Your gender.', 'radio', 255, 'None,Male,Female', 5, 'nohtml', 1, 1, 0, 'forumprofile', 0, 1, 0, 0, 'None', '', 1) ON CONFLICT DO NOTHING; +INSERT INTO {$db_prefix}custom_fields (col_name, field_name, field_desc, field_type, field_length, field_options, field_order, mask, show_reg, show_display, show_mlist, show_blist, show_profile, private, active, bbc, can_search, default_value, enclose, placement) VALUES +('cust_icq', 'ICQ', 'This is your ICQ number.', 'text', 12, '', 1, 'regex~[1-9][0-9]{4,9}~i', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', 'ICQ - {INPUT}', 1) ON CONFLICT DO NOTHING; +INSERT INTO {$db_prefix}custom_fields (col_name, field_name, field_desc, field_type, field_length, field_options, field_order, mask, show_reg, show_display, show_mlist, show_blist, show_profile, private, active, bbc, can_search, default_value, enclose, placement) VALUES +('cust_skype', 'Skype', 'Your Skype name', 'text', 32, '', 2, 'nohtml', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', '{INPUT} ', 1) ON CONFLICT DO NOTHING; +INSERT INTO {$db_prefix}custom_fields (col_name, field_name, field_desc, field_type, field_length, field_options, field_order, mask, show_reg, show_display, show_mlist, show_blist, show_profile, private, active, bbc, can_search, default_value, enclose, placement) VALUES +('cust_loca', 'Location', 'Geographic location.', 'text', 50, '', 4, 'nohtml', 0, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, '', '', 0) ON CONFLICT DO NOTHING; +INSERT INTO {$db_prefix}custom_fields (col_name, field_name, field_desc, field_type, field_length, field_options, field_order, mask, show_reg, show_display, show_mlist, show_blist, show_profile, private, active, bbc, can_search, default_value, enclose, placement) VALUES +('cust_gender', 'Gender', 'Your gender.', 'radio', 255, 'None,Male,Female', 5, 'nohtml', 1, 1, 0, 0, 'forumprofile', 0, 1, 0, 0, 'None', '', 1) ON CONFLICT DO NOTHING; ---# ---# Add an order value to each existing cust profile field.