mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/12409] Add acp_users.php core events to modify users preferences data
There're events to modify UCP user preferences in ucp_prefs.php, so it makes sense to add related events to acp_users.php to control new user's prefs via ACP. PHPBB3-12409
This commit is contained in:
parent
b487da7c05
commit
71422e5180
1 changed files with 65 additions and 25 deletions
|
@ -1503,6 +1503,17 @@ class acp_users
|
||||||
'notify' => request_var('notify', $user_row['user_notify']),
|
'notify' => request_var('notify', $user_row['user_notify']),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify users preferences data
|
||||||
|
*
|
||||||
|
* @event core.acp_users_prefs_modify_data
|
||||||
|
* @var array data Array with users preferences data
|
||||||
|
* @var array user_row Array with user data
|
||||||
|
* @since 3.1.0-b3
|
||||||
|
*/
|
||||||
|
$vars = array('data', 'user_row');
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_data', compact($vars)));
|
||||||
|
|
||||||
if ($submit)
|
if ($submit)
|
||||||
{
|
{
|
||||||
$error = validate_data($data, array(
|
$error = validate_data($data, array(
|
||||||
|
@ -1559,6 +1570,21 @@ class acp_users
|
||||||
'user_notify' => $data['notify'],
|
'user_notify' => $data['notify'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify SQL query before users preferences are updated
|
||||||
|
*
|
||||||
|
* @event core.acp_users_prefs_modify_sql
|
||||||
|
* @var array data Array with users preferences data
|
||||||
|
* @var array user_row Array with user data
|
||||||
|
* @var array sql_ary SQL array with users preferences data to update
|
||||||
|
* @var array error Array with errors data
|
||||||
|
* @since 3.1.0-b3
|
||||||
|
*/
|
||||||
|
$vars = array('data', 'user_row', 'sql_ary', 'error');
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_sql', compact($vars)));
|
||||||
|
|
||||||
|
if (!sizeof($error))
|
||||||
|
{
|
||||||
$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";
|
||||||
|
@ -1591,6 +1617,7 @@ class acp_users
|
||||||
|
|
||||||
trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
|
trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Replace "error" strings with their real, localised form
|
// Replace "error" strings with their real, localised form
|
||||||
$error = array_map(array($user, 'lang'), $error);
|
$error = array_map(array($user, 'lang'), $error);
|
||||||
|
@ -1653,7 +1680,7 @@ class acp_users
|
||||||
}
|
}
|
||||||
|
|
||||||
$timezone_selects = phpbb_timezone_select($user, $data['tz'], true);
|
$timezone_selects = phpbb_timezone_select($user, $data['tz'], true);
|
||||||
$template->assign_vars(array(
|
$user_prefs_data = array(
|
||||||
'S_PREFS' => true,
|
'S_PREFS' => true,
|
||||||
'S_JABBER_DISABLED' => ($config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml')) ? false : true,
|
'S_JABBER_DISABLED' => ($config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml')) ? false : true,
|
||||||
|
|
||||||
|
@ -1693,9 +1720,22 @@ class acp_users
|
||||||
'S_STYLE_OPTIONS' => style_select($data['style']),
|
'S_STYLE_OPTIONS' => style_select($data['style']),
|
||||||
'S_TZ_OPTIONS' => $timezone_selects['tz_select'],
|
'S_TZ_OPTIONS' => $timezone_selects['tz_select'],
|
||||||
'S_TZ_DATE_OPTIONS' => $timezone_selects['tz_dates'],
|
'S_TZ_DATE_OPTIONS' => $timezone_selects['tz_dates'],
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify users preferences data before assigning it to the template
|
||||||
|
*
|
||||||
|
* @event core.acp_users_prefs_modify_template_data
|
||||||
|
* @var array data Array with users preferences data
|
||||||
|
* @var array user_row Array with user data
|
||||||
|
* @var array user_prefs_data Array with users preferences data to be assigned to the template
|
||||||
|
* @since 3.1.0-b3
|
||||||
|
*/
|
||||||
|
$vars = array('data', 'user_row', 'user_prefs_data');
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_template_data', compact($vars)));
|
||||||
|
|
||||||
|
$template->assign_vars($user_prefs_data);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'avatar':
|
case 'avatar':
|
||||||
|
|
Loading…
Add table
Reference in a new issue