aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_user.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r--phpBB/includes/functions_user.php107
1 files changed, 88 insertions, 19 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 85b6f2be62..e1c687551b 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -166,7 +166,7 @@ function user_update_name($old_name, $new_name)
*/
function user_add($user_row, $cp_data = false, $notifications_data = null)
{
- global $db, $user, $auth, $config, $phpbb_root_path, $phpEx;
+ global $db, $config;
global $phpbb_dispatcher, $phpbb_container;
if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type']))
@@ -502,6 +502,9 @@ function user_delete($mode, $user_ids, $retain_username = true)
$num_users_delta = 0;
+ // Get auth provider collection in case accounts might need to be unlinked
+ $provider_collection = $phpbb_container->get('auth.provider_collection');
+
// Some things need to be done in the loop (if the query changes based
// on which user is currently being deleted)
$added_guest_posts = 0;
@@ -512,6 +515,38 @@ function user_delete($mode, $user_ids, $retain_username = true)
avatar_delete('user', $user_row);
}
+ // Unlink accounts
+ foreach ($provider_collection as $provider_name => $auth_provider)
+ {
+ $provider_data = $auth_provider->get_auth_link_data($user_id);
+
+ if ($provider_data !== null)
+ {
+ $link_data = array(
+ 'user_id' => $user_id,
+ 'link_method' => 'user_delete',
+ );
+
+ // BLOCK_VARS might contain hidden fields necessary for unlinking accounts
+ if (isset($provider_data['BLOCK_VARS']) && is_array($provider_data['BLOCK_VARS']))
+ {
+ foreach ($provider_data['BLOCK_VARS'] as $provider_service)
+ {
+ if (!array_key_exists('HIDDEN_FIELDS', $provider_service))
+ {
+ $provider_service['HIDDEN_FIELDS'] = array();
+ }
+
+ $auth_provider->unlink_account(array_merge($link_data, $provider_service['HIDDEN_FIELDS']));
+ }
+ }
+ else
+ {
+ $auth_provider->unlink_account($link_data);
+ }
+ }
+ }
+
// Decrement number of users if this user is active
if ($user_row['user_type'] != USER_INACTIVE && $user_row['user_type'] != USER_IGNORE)
{
@@ -831,7 +866,7 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
*/
function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason = '')
{
- global $db, $user, $auth, $cache, $phpbb_log;
+ global $db, $user, $cache, $phpbb_log;
// Delete stale bans
$sql = 'DELETE FROM ' . BANLIST_TABLE . '
@@ -980,7 +1015,6 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
if ($ip_2_counter == 0 && $ip_2_end == 254)
{
$ip_2_counter = 256;
- $ip_2_fragment = 256;
$banlist_ary[] = "$ip_1_counter.*";
}
@@ -993,7 +1027,6 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
if ($ip_3_counter == 0 && $ip_3_end == 254)
{
$ip_3_counter = 256;
- $ip_3_fragment = 256;
$banlist_ary[] = "$ip_1_counter.$ip_2_counter.*";
}
@@ -1006,7 +1039,6 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
if ($ip_4_counter == 0 && $ip_4_end == 254)
{
$ip_4_counter = 256;
- $ip_4_fragment = 256;
$banlist_ary[] = "$ip_1_counter.$ip_2_counter.$ip_3_counter.*";
}
@@ -1257,7 +1289,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
*/
function user_unban($mode, $ban)
{
- global $db, $user, $auth, $cache, $phpbb_log;
+ global $db, $user, $cache, $phpbb_log;
// Delete stale bans
$sql = 'DELETE FROM ' . BANLIST_TABLE . '
@@ -1385,7 +1417,7 @@ function user_ipwhois($ip)
$match = array();
// Test for referrals from $whois_host to other whois databases, roll on rwhois
- if (preg_match('#ReferralServer: whois://(.+)#im', $ipwhois, $match))
+ if (preg_match('#ReferralServer:[\x20]*whois://(.+)#im', $ipwhois, $match))
{
if (strpos($match[1], ':') !== false)
{
@@ -2106,7 +2138,7 @@ function phpbb_style_is_active($style_id)
*/
function avatar_delete($mode, $row, $clean_db = false)
{
- global $phpbb_root_path, $config, $db, $user;
+ global $phpbb_root_path, $config;
// Check if the users avatar is actually *not* a group avatar
if ($mode == 'user')
@@ -2178,7 +2210,10 @@ function phpbb_avatar_explanation_string()
*/
function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow_desc_bbcode = false, $allow_desc_urls = false, $allow_desc_smilies = false)
{
- global $phpbb_root_path, $config, $db, $user, $file_upload, $phpbb_container, $phpbb_log;
+ global $db, $user, $phpbb_container, $phpbb_log;
+
+ /** @var \phpbb\group\helper $group_helper */
+ $group_helper = $phpbb_container->get('group_helper');
$error = array();
@@ -2287,8 +2322,6 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
// Setting the log message before we set the group id (if group gets added)
$log = ($group_id) ? 'LOG_GROUP_UPDATED' : 'LOG_GROUP_CREATED';
- $query = '';
-
if ($group_id)
{
$sql = 'SELECT user_id
@@ -2431,7 +2464,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
group_set_user_default($group_id, $user_ary, $sql_ary);
}
- $name = ($type == GROUP_SPECIAL) ? $user->lang['G_' . $name] : $name;
+ $name = $group_helper->get_name($name);
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($name));
group_update_listings($group_id);
@@ -2470,7 +2503,7 @@ function group_correct_avatar($group_id, $old_entry)
*/
function avatar_remove_db($avatar_name)
{
- global $config, $db;
+ global $db;
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_avatar = '',
@@ -2597,7 +2630,7 @@ function group_delete($group_id, $group_name = false)
*/
function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $default = false, $leader = 0, $pending = 0, $group_attributes = false)
{
- global $db, $auth, $user, $phpbb_container, $phpbb_log;
+ global $db, $auth, $user, $phpbb_container, $phpbb_log, $phpbb_dispatcher;
// We need both username and user_id info
$result = user_get_id_name($user_id_ary, $username_ary);
@@ -2674,6 +2707,26 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
// Clear permissions cache of relevant users
$auth->acl_clear_prefetch($user_id_ary);
+ /**
+ * Event after users are added to a group
+ *
+ * @event core.group_add_user_after
+ * @var int group_id ID of the group to which users are added
+ * @var string group_name Name of the group
+ * @var array user_id_ary IDs of the users which are added
+ * @var array username_ary names of the users which are added
+ * @var int pending Pending setting, 1 if user(s) added are pending
+ * @since 3.1.7-RC1
+ */
+ $vars = array(
+ 'group_id',
+ 'group_name',
+ 'user_id_ary',
+ 'username_ary',
+ 'pending',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.group_add_user_after', compact($vars)));
+
if (!$group_name)
{
$group_name = get_group_name($group_id);
@@ -2833,6 +2886,19 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
// Clear permissions cache of relevant users
$auth->acl_clear_prefetch($user_id_ary);
+ /**
+ * Event after users are removed from a group
+ *
+ * @event core.group_delete_user_after
+ * @var int group_id ID of the group from which users are deleted
+ * @var string group_name Name of the group
+ * @var array user_id_ary IDs of the users which are removed
+ * @var array username_ary names of the users which are removed
+ * @since 3.1.7-RC1
+ */
+ $vars = array('group_id', 'group_name', 'user_id_ary', 'username_ary');
+ extract($phpbb_dispatcher->trigger_event('core.group_delete_user_after', compact($vars)));
+
if (!$group_name)
{
$group_name = get_group_name($group_id);
@@ -2941,7 +3007,7 @@ function remove_default_rank($group_id, $user_ids)
*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{
- global $db, $auth, $user, $phpbb_root_path, $phpEx, $config, $phpbb_container, $phpbb_log;
+ global $db, $auth, $user, $phpbb_container, $phpbb_log;
// We need both username and user_id info
$result = user_get_id_name($user_id_ary, $username_ary);
@@ -3088,7 +3154,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
*/
function group_validate_groupname($group_id, $group_name)
{
- global $config, $db;
+ global $db;
$group_name = utf8_clean_string($group_name);
@@ -3285,7 +3351,7 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal
*/
function get_group_name($group_id)
{
- global $db, $user;
+ global $db, $phpbb_container;
$sql = 'SELECT group_name, group_type
FROM ' . GROUPS_TABLE . '
@@ -3294,12 +3360,15 @@ function get_group_name($group_id)
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- if (!$row || ($row['group_type'] == GROUP_SPECIAL && !$user->is_setup()))
+ if (!$row)
{
return '';
}
- return ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
+ /** @var \phpbb\group\helper $group_helper */
+ $group_helper = $phpbb_container->get('group_helper');
+
+ return $group_helper->get_name($row['group_name']);
}
/**