From b3b0e5ccf2503e7bba72ee922dda175337d1b4e9 Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 31 Mar 2014 14:06:58 +0200 Subject: [PATCH 1/5] [ticket/12335] Add Events to phpbb\profilefields\manager PHPBB3-12335 --- phpBB/config/profilefields.yml | 1 + phpBB/phpbb/profilefields/manager.php | 32 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/phpBB/config/profilefields.yml b/phpBB/config/profilefields.yml index d12a1f8a37..00f025e141 100644 --- a/phpBB/config/profilefields.yml +++ b/phpBB/config/profilefields.yml @@ -4,6 +4,7 @@ services: arguments: - @auth - @dbal.conn + - @dispatcher - @request - @template - @profilefields.type_collection diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 37449c67c4..7d50fd9f24 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -27,6 +27,12 @@ class manager */ protected $db; + /** + * Event dispatcher object + * @var \phpbb\event\dispatcher + */ + protected $dispatcher; + /** * Request object * @var \phpbb\request\request @@ -64,6 +70,7 @@ class manager * * @param \phpbb\auth\auth $auth Auth object * @param \phpbb\db\driver\driver_interface $db Database object + * @param \phpbb\event\dispatcher $dispatcher Event dispatcher object * @param \phpbb\request\request $request Request object * @param \phpbb\template\template $template Template object * @param \phpbb\di\service_collection $type_collection @@ -72,10 +79,11 @@ class manager * @param string $fields_language_table * @param string $fields_data_table */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\di\service_collection $type_collection, \phpbb\user $user, $fields_table, $fields_language_table, $fields_data_table) + public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher $dispatcher, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\di\service_collection $type_collection, \phpbb\user $user, $fields_table, $fields_language_table, $fields_data_table) { $this->auth = $auth; $this->db = $db; + $this->dispatcher = $dispatcher; $this->request = $request; $this->template = $template; $this->type_collection = $type_collection; @@ -313,6 +321,17 @@ class manager } $this->db->sql_freeresult($result); + /** + * Event to modify profile fields data retrieved from the database + * + * @event core.grab_profile_fields_data + * @var int|array $user_ids Single user id or an array of ids + * @var array $field_data Array with profile fields data + * @since 3.1-B3 + */ + $vars = array('user_ids', 'field_data'); + extract($this->dispatcher->trigger_event('core.grab_profile_fields_data', compact($vars))); + $user_fields = array(); // Go through the fields in correct order @@ -404,6 +423,17 @@ class manager ); } + /** + * Event to modify template data of the generated profile fields + * + * @event core.generate_profile_fields_template_data + * @var array profile_row Array with users profile field data + * @var array tpl_fields Array with template data fields + * @since 3.1-B3 + */ + $vars = array('profile_row', 'tpl_fields'); + extract($this->dispatcher->trigger_event('core.generate_profile_fields_template_data', compact($vars))); + return $tpl_fields; } From 1fd1803a3bfffd15e0bc85097cd84c3f2d9ec163 Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 7 Apr 2014 08:05:50 +0200 Subject: [PATCH 2/5] [ticket/12335] Fix phpBB version number PHPBB3-12335 --- phpBB/phpbb/profilefields/manager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 7d50fd9f24..7c0397a563 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -327,7 +327,7 @@ class manager * @event core.grab_profile_fields_data * @var int|array $user_ids Single user id or an array of ids * @var array $field_data Array with profile fields data - * @since 3.1-B3 + * @since 3.1.0-b3 */ $vars = array('user_ids', 'field_data'); extract($this->dispatcher->trigger_event('core.grab_profile_fields_data', compact($vars))); @@ -429,7 +429,7 @@ class manager * @event core.generate_profile_fields_template_data * @var array profile_row Array with users profile field data * @var array tpl_fields Array with template data fields - * @since 3.1-B3 + * @since 3.1.0-b3 */ $vars = array('profile_row', 'tpl_fields'); extract($this->dispatcher->trigger_event('core.generate_profile_fields_template_data', compact($vars))); From 2343d9f8d42337353d32a69fddcc1a51e0a49f5a Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 14 Apr 2014 20:50:51 +0200 Subject: [PATCH 3/5] [ticket/12335] Documentation fix and added use_contact_fields PHPBB3-12335 --- phpBB/phpbb/profilefields/manager.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 7c0397a563..a7b8f55e34 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -325,7 +325,7 @@ class manager * Event to modify profile fields data retrieved from the database * * @event core.grab_profile_fields_data - * @var int|array $user_ids Single user id or an array of ids + * @var array $user_ids Single user id or an array of ids * @var array $field_data Array with profile fields data * @since 3.1.0-b3 */ @@ -429,9 +429,10 @@ class manager * @event core.generate_profile_fields_template_data * @var array profile_row Array with users profile field data * @var array tpl_fields Array with template data fields + * @var bool use_contact_fields Should we display contact fields as such? * @since 3.1.0-b3 */ - $vars = array('profile_row', 'tpl_fields'); + $vars = array('profile_row', 'tpl_fields', 'use_contact_fields'); extract($this->dispatcher->trigger_event('core.generate_profile_fields_template_data', compact($vars))); return $tpl_fields; From 42dfd1aa3c8fda95efd0dac03652a163752575d4 Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 14 Apr 2014 21:15:30 +0200 Subject: [PATCH 4/5] [ticket/12335] Added generate_profile_fields _ before PHPBB3-12335 --- phpBB/phpbb/profilefields/manager.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index a7b8f55e34..5b326fe39c 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -370,6 +370,18 @@ class manager $tpl_fields = array(); $tpl_fields['row'] = $tpl_fields['blockrow'] = array(); + /** + * Event to modify data of the generated profile fields, before the template assignment loop + * + * @event core.generate_profile_fields_template_data_before + * @var array profile_row Array with users profile field data + * @var array tpl_fields Array with template data fields + * @var bool use_contact_fields Should we display contact fields as such? + * @since 3.1.0-b3 + */ + $vars = array('profile_row', 'tpl_fields', 'use_contact_fields'); + extract($this->dispatcher->trigger_event('core.generate_profile_fields_template_data_before', compact($vars))); + foreach ($profile_row as $ident => $ident_ary) { $profile_field = $this->type_collection[$ident_ary['data']['field_type']]; From 5b5b61c6c97d0d4158e6487a47fb5bb584affa34 Mon Sep 17 00:00:00 2001 From: PayBas Date: Fri, 2 May 2014 17:29:52 +0200 Subject: [PATCH 5/5] [ticket/12335] Remove $ from desc Come on travis, play nice this time PHPBB3-12335 --- phpBB/phpbb/profilefields/manager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 5b326fe39c..7d545a5f72 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -325,8 +325,8 @@ class manager * Event to modify profile fields data retrieved from the database * * @event core.grab_profile_fields_data - * @var array $user_ids Single user id or an array of ids - * @var array $field_data Array with profile fields data + * @var array user_ids Single user id or an array of ids + * @var array field_data Array with profile fields data * @since 3.1.0-b3 */ $vars = array('user_ids', 'field_data');