From 0f6d16920b88ea9aef9391619a64bf9494dd266d Mon Sep 17 00:00:00 2001 From: javiexin Date: Tue, 2 Jun 2015 13:18:33 +0200 Subject: [PATCH 1/4] [ticket/13911] Add events to configure options for profile fields Adds core events to includes/acp/acp_profile.php and template events to adm/style/acp_profile.html to support adding configuration options to profile fields. PHPBB3-13911 --- phpBB/adm/style/acp_profile.html | 1 + phpBB/docs/events.md | 7 ++++ phpBB/includes/acp/acp_profile.php | 53 ++++++++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html index 64bc3df09b..3ce2d9471d 100644 --- a/phpBB/adm/style/acp_profile.html +++ b/phpBB/adm/style/acp_profile.html @@ -79,6 +79,7 @@

{L_HIDE_PROFILE_FIELD_EXPLAIN}
checked="checked" />
+

{L_FIELD_IS_CONTACT_EXPLAIN}
checked="checked" />
diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 8086bc9f43..09c498ca86 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -133,6 +133,13 @@ acp_posting_buttons_before * Since: 3.1.0-b4 * Purpose: Add content before BBCode posting buttons in the ACP +acp_profile_contact_before +=== +* Locations: + + adm/style/acp_profile.html +* Since: 3.1.5-a4 +* Purpose: Add extra options to custom profile field configuration in the ACP + acp_ranks_edit_after === * Locations: diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 97c1f62077..09236f4404 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -31,7 +31,7 @@ class acp_profile { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; - global $request, $phpbb_container; + global $request, $phpbb_container, $phpbb_dispatcher; include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); include($phpbb_root_path . 'includes/functions_user.' . $phpEx); @@ -369,6 +369,23 @@ class acp_profile 'field_is_contact', ); + /** + * Event to add initialization for new profile field table fields + * + * @event core.acp_profile_create_edit_init + * @var string action create|edit + * @var int step Configuration step (1|2|3) + * @var bool submit Form has been submitted + * @var bool save Configuration should be saved + * @var string field_type Type of the field we are dealing with + * @var array field_row Array of data about the field + * @var array exclude Array of excluded fields by step + * @var array visibility_ary Array of fields that are visibility related + * @since 3.1.5-a4 + */ + $vars = array('action', 'step', 'submit', 'save', 'field_type', 'field_row', 'exclude', 'visibility_ary'); + extract($phpbb_dispatcher->trigger_event('core.acp_profile_create_edit_init', compact($vars))); + $options = $profile_field->prepare_options_form($exclude, $visibility_ary); $cp->vars['field_ident'] = ($action == 'create' && $step == 1) ? utf8_clean_string(request_var('field_ident', $field_row['field_ident'], true)) : request_var('field_ident', $field_row['field_ident']); @@ -644,6 +661,24 @@ class acp_profile break; } + $field_data = $cp->vars; + /** + * Event to add template variables for new profile field table fields + * + * @event core.acp_profile_create_edit_after + * @var string action create|edit + * @var int step Configuration step (1|2|3) + * @var bool submit Form has been submitted + * @var bool save Configuration should be saved + * @var string field_type Type of the field we are dealing with + * @var array field_data Array of data about the field + * @var array s_hidden_fields Array of hidden fields in case this needs modification + * @var array options Array of options specific to this step + * @since 3.1.5-a4 + */ + $vars = array('action', 'step', 'submit', 'save', 'field_type', 'field_data', 's_hidden_fields', 'options'); + extract($phpbb_dispatcher->trigger_event('core.acp_profile_create_edit_after', compact($vars))); + $template->assign_vars(array( 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); @@ -810,7 +845,7 @@ class acp_profile */ function save_profile_field(&$cp, $field_type, $action = 'create') { - global $db, $config, $user, $phpbb_container; + global $db, $config, $user, $phpbb_container, $phpbb_dispatcher; $field_id = request_var('field_id', 0); @@ -852,6 +887,20 @@ class acp_profile 'field_contact_url' => $cp->vars['field_contact_url'], ); + $field_data = $cp->vars; + /** + * Event to modify profile field configuration data before saving to database + * + * @event core.acp_profile_create_edit_before_save + * @var string action create|edit + * @var string field_type Type of the field we are dealing with + * @var array field_data Array of data about the field + * @var array profile_fields Array of fields to be sent to the database + * @since 3.1.5-a4 + */ + $vars = array('action', 'field_type', 'field_data', 'profile_fields'); + extract($phpbb_dispatcher->trigger_event('core.acp_profile_create_edit_before_save', compact($vars))); + if ($action == 'create') { $profile_fields += array( From b627a097bb89d8eabdc2ecefbd0205f6cfbe60cc Mon Sep 17 00:00:00 2001 From: javiexin Date: Tue, 2 Jun 2015 18:30:10 +0200 Subject: [PATCH 2/4] [ticket/13911] Add events to configure options for profile fields Adds core events to includes/acp/acp_profile.php and template events to adm/style/acp_profile.html to support adding configuration options to profile fields. Fix bamboo formatting errors. PHPBB3-13911 --- phpBB/includes/acp/acp_profile.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 09236f4404..220361d7ac 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -383,7 +383,16 @@ class acp_profile * @var array visibility_ary Array of fields that are visibility related * @since 3.1.5-a4 */ - $vars = array('action', 'step', 'submit', 'save', 'field_type', 'field_row', 'exclude', 'visibility_ary'); + $vars = array( + 'action', + 'step', + 'submit', + 'save', + 'field_type', + 'field_row', + 'exclude', + 'visibility_ary', + ); extract($phpbb_dispatcher->trigger_event('core.acp_profile_create_edit_init', compact($vars))); $options = $profile_field->prepare_options_form($exclude, $visibility_ary); @@ -676,7 +685,16 @@ class acp_profile * @var array options Array of options specific to this step * @since 3.1.5-a4 */ - $vars = array('action', 'step', 'submit', 'save', 'field_type', 'field_data', 's_hidden_fields', 'options'); + $vars = array( + 'action', + 'step', + 'submit', + 'save', + 'field_type', + 'field_data', + 's_hidden_fields', + 'options', + ); extract($phpbb_dispatcher->trigger_event('core.acp_profile_create_edit_after', compact($vars))); $template->assign_vars(array( @@ -898,7 +916,12 @@ class acp_profile * @var array profile_fields Array of fields to be sent to the database * @since 3.1.5-a4 */ - $vars = array('action', 'field_type', 'field_data', 'profile_fields'); + $vars = array( + 'action', + 'field_type', + 'field_data', + 'profile_fields', + ); extract($phpbb_dispatcher->trigger_event('core.acp_profile_create_edit_before_save', compact($vars))); if ($action == 'create') From 9057f72fc7b523c0e9ae14c55d31e7159577bc99 Mon Sep 17 00:00:00 2001 From: javiexin Date: Thu, 4 Jun 2015 19:13:23 +0200 Subject: [PATCH 3/4] [ticket/13911] Add events to configure options for profile fields Adds core events to includes/acp/acp_profile.php and template events to adm/style/acp_profile.html to support adding configuration options to profile fields. Fixed version number and event name. PHPBB3-13911 --- phpBB/docs/events.md | 2 +- phpBB/includes/acp/acp_profile.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 09c498ca86..5b731cf5fa 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -137,7 +137,7 @@ acp_profile_contact_before === * Locations: + adm/style/acp_profile.html -* Since: 3.1.5-a4 +* Since: 3.1.5-RC1 * Purpose: Add extra options to custom profile field configuration in the ACP acp_ranks_edit_after diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 220361d7ac..78f4e2b9b5 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -381,7 +381,7 @@ class acp_profile * @var array field_row Array of data about the field * @var array exclude Array of excluded fields by step * @var array visibility_ary Array of fields that are visibility related - * @since 3.1.5-a4 + * @since 3.1.5-RC1 */ $vars = array( 'action', @@ -683,7 +683,7 @@ class acp_profile * @var array field_data Array of data about the field * @var array s_hidden_fields Array of hidden fields in case this needs modification * @var array options Array of options specific to this step - * @since 3.1.5-a4 + * @since 3.1.5-RC1 */ $vars = array( 'action', @@ -909,12 +909,12 @@ class acp_profile /** * Event to modify profile field configuration data before saving to database * - * @event core.acp_profile_create_edit_before_save + * @event core.acp_profile_create_edit_save_before * @var string action create|edit * @var string field_type Type of the field we are dealing with * @var array field_data Array of data about the field * @var array profile_fields Array of fields to be sent to the database - * @since 3.1.5-a4 + * @since 3.1.5-RC1 */ $vars = array( 'action', @@ -922,7 +922,7 @@ class acp_profile 'field_data', 'profile_fields', ); - extract($phpbb_dispatcher->trigger_event('core.acp_profile_create_edit_before_save', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.acp_profile_create_edit_save_before', compact($vars))); if ($action == 'create') { From d0cf674f3392b77bcb22ee1450e2336a39f00328 Mon Sep 17 00:00:00 2001 From: javiexin Date: Sat, 27 Jun 2015 12:45:56 +0200 Subject: [PATCH 4/4] [ticket/13911] Add events to configure options for profile fields Adds core events to includes/acp/acp_profile.php and template events to adm/style/acp_profile.html to support adding configuration options to profile fields. Fixed version number again. PHPBB3-13911 --- phpBB/docs/events.md | 2 +- phpBB/includes/acp/acp_profile.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 5b731cf5fa..357fa52e84 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -137,7 +137,7 @@ acp_profile_contact_before === * Locations: + adm/style/acp_profile.html -* Since: 3.1.5-RC1 +* Since: 3.1.6-RC1 * Purpose: Add extra options to custom profile field configuration in the ACP acp_ranks_edit_after diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 78f4e2b9b5..43668b8ad5 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -381,7 +381,7 @@ class acp_profile * @var array field_row Array of data about the field * @var array exclude Array of excluded fields by step * @var array visibility_ary Array of fields that are visibility related - * @since 3.1.5-RC1 + * @since 3.1.6-RC1 */ $vars = array( 'action', @@ -683,7 +683,7 @@ class acp_profile * @var array field_data Array of data about the field * @var array s_hidden_fields Array of hidden fields in case this needs modification * @var array options Array of options specific to this step - * @since 3.1.5-RC1 + * @since 3.1.6-RC1 */ $vars = array( 'action', @@ -914,7 +914,7 @@ class acp_profile * @var string field_type Type of the field we are dealing with * @var array field_data Array of data about the field * @var array profile_fields Array of fields to be sent to the database - * @since 3.1.5-RC1 + * @since 3.1.6-RC1 */ $vars = array( 'action',