mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge pull request #3325 from rxu/ticket/13536
[ticket/13536] Add ACP/UCP core events to allow modifying user profile data on editing
This commit is contained in:
commit
7330c0afd3
2 changed files with 49 additions and 1 deletions
|
@ -1377,6 +1377,19 @@ class acp_users
|
||||||
$data['bday_year'] = request_var('bday_year', $data['bday_year']);
|
$data['bday_year'] = request_var('bday_year', $data['bday_year']);
|
||||||
$data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
|
$data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify user data on editing profile in ACP
|
||||||
|
*
|
||||||
|
* @event core.acp_users_modify_profile
|
||||||
|
* @var array data Array with user profile data
|
||||||
|
* @var bool submit Flag indicating if submit button has been pressed
|
||||||
|
* @var int user_id The user id
|
||||||
|
* @var array user_row Array with the full user data
|
||||||
|
* @since 3.1.4-RC1
|
||||||
|
*/
|
||||||
|
$vars = array('data', 'submit', 'user_id', 'user_row');
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.acp_users_modify_profile', compact($vars)));
|
||||||
|
|
||||||
if ($submit)
|
if ($submit)
|
||||||
{
|
{
|
||||||
$error = validate_data($data, array(
|
$error = validate_data($data, array(
|
||||||
|
@ -1408,6 +1421,19 @@ class acp_users
|
||||||
'user_birthday' => $data['user_birthday'],
|
'user_birthday' => $data['user_birthday'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify profile data in ACP before submitting to the database
|
||||||
|
*
|
||||||
|
* @event core.acp_users_profile_modify_sql_ary
|
||||||
|
* @var array cp_data Array with the user custom profile fields data
|
||||||
|
* @var array data Array with user profile data
|
||||||
|
* @var int user_id The user id
|
||||||
|
* @var array user_row Array with the full user data
|
||||||
|
* @since 3.1.4-RC1
|
||||||
|
*/
|
||||||
|
$vars = array('cp_data', 'data', 'user_id', 'user_row');
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.acp_users_profile_modify_sql_ary', compact($vars)));
|
||||||
|
|
||||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
|
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
|
||||||
WHERE user_id = $user_id";
|
WHERE user_id = $user_id";
|
||||||
|
|
|
@ -32,7 +32,7 @@ class ucp_profile
|
||||||
function main($id, $mode)
|
function main($id, $mode)
|
||||||
{
|
{
|
||||||
global $cache, $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
|
global $cache, $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
|
||||||
global $request, $phpbb_container;
|
global $request, $phpbb_container, $phpbb_dispatcher;
|
||||||
|
|
||||||
$user->add_lang('posting');
|
$user->add_lang('posting');
|
||||||
|
|
||||||
|
@ -307,6 +307,17 @@ class ucp_profile
|
||||||
$data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
|
$data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify user data on editing profile in UCP
|
||||||
|
*
|
||||||
|
* @event core.ucp_profile_modify_profile_info
|
||||||
|
* @var array data Array with user profile data
|
||||||
|
* @var bool submit Flag indicating if submit button has been pressed
|
||||||
|
* @since 3.1.4-RC1
|
||||||
|
*/
|
||||||
|
$vars = array('data', 'submit');
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_profile_info', compact($vars)));
|
||||||
|
|
||||||
add_form_key('ucp_profile_info');
|
add_form_key('ucp_profile_info');
|
||||||
|
|
||||||
if ($submit)
|
if ($submit)
|
||||||
|
@ -363,6 +374,17 @@ class ucp_profile
|
||||||
$sql_ary['user_birthday'] = $data['user_birthday'];
|
$sql_ary['user_birthday'] = $data['user_birthday'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify profile data in UCP before submitting to the database
|
||||||
|
*
|
||||||
|
* @event core.ucp_profile_info_modify_sql_ary
|
||||||
|
* @var array cp_data Array with the user custom profile fields data
|
||||||
|
* @var array data Array with user profile data
|
||||||
|
* @since 3.1.4-RC1
|
||||||
|
*/
|
||||||
|
$vars = array('cp_data', 'data');
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.ucp_profile_info_modify_sql_ary', compact($vars)));
|
||||||
|
|
||||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||||
WHERE user_id = ' . $user->data['user_id'];
|
WHERE user_id = ' . $user->data['user_id'];
|
||||||
|
|
Loading…
Add table
Reference in a new issue