1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-24 03:54:10 +01:00

Merge pull request #2219 from PayBas/ticket/12335

[ticket/12335] Add Events to phpbb\profilefields\manager

* PayBas/ticket/12335:
  [ticket/12335] Remove $ from desc
  [ticket/12335] Added generate_profile_fields _ before
  [ticket/12335] Documentation fix and added use_contact_fields
  [ticket/12335] Fix phpBB version number
  [ticket/12335] Add Events to phpbb\profilefields\manager
This commit is contained in:
Joas Schilling 2014-05-04 15:48:05 +02:00
commit 329c2d9292
2 changed files with 45 additions and 1 deletions

View File

@ -4,6 +4,7 @@ services:
arguments: arguments:
- @auth - @auth
- @dbal.conn - @dbal.conn
- @dispatcher
- @request - @request
- @template - @template
- @profilefields.type_collection - @profilefields.type_collection

View File

@ -27,6 +27,12 @@ class manager
*/ */
protected $db; protected $db;
/**
* Event dispatcher object
* @var \phpbb\event\dispatcher
*/
protected $dispatcher;
/** /**
* Request object * Request object
* @var \phpbb\request\request * @var \phpbb\request\request
@ -64,6 +70,7 @@ class manager
* *
* @param \phpbb\auth\auth $auth Auth object * @param \phpbb\auth\auth $auth Auth object
* @param \phpbb\db\driver\driver_interface $db Database 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\request\request $request Request object
* @param \phpbb\template\template $template Template object * @param \phpbb\template\template $template Template object
* @param \phpbb\di\service_collection $type_collection * @param \phpbb\di\service_collection $type_collection
@ -72,10 +79,11 @@ class manager
* @param string $fields_language_table * @param string $fields_language_table
* @param string $fields_data_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->auth = $auth;
$this->db = $db; $this->db = $db;
$this->dispatcher = $dispatcher;
$this->request = $request; $this->request = $request;
$this->template = $template; $this->template = $template;
$this->type_collection = $type_collection; $this->type_collection = $type_collection;
@ -313,6 +321,17 @@ class manager
} }
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
/**
* 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
* @since 3.1.0-b3
*/
$vars = array('user_ids', 'field_data');
extract($this->dispatcher->trigger_event('core.grab_profile_fields_data', compact($vars)));
$user_fields = array(); $user_fields = array();
// Go through the fields in correct order // Go through the fields in correct order
@ -351,6 +370,18 @@ class manager
$tpl_fields = array(); $tpl_fields = array();
$tpl_fields['row'] = $tpl_fields['blockrow'] = 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) foreach ($profile_row as $ident => $ident_ary)
{ {
$profile_field = $this->type_collection[$ident_ary['data']['field_type']]; $profile_field = $this->type_collection[$ident_ary['data']['field_type']];
@ -404,6 +435,18 @@ 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
* @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', compact($vars)));
return $tpl_fields; return $tpl_fields;
} }