phpBB

Code Changes

File: includes/functions_user.php

  Unmodified   Added   Modified   Removed
Line 44Line 44

$which_ary = ($user_id_ary) ? 'user_id_ary' : 'username_ary';



$which_ary = ($user_id_ary) ? 'user_id_ary' : 'username_ary';


	if ($$which_ary && !is_array($$which_ary))

	if (${$which_ary} && !is_array(${$which_ary}))

	{

	{

		$$which_ary = array($$which_ary);

		${$which_ary} = array(${$which_ary});

	}


	}


	$sql_in = ($which_ary == 'user_id_ary') ? array_map('intval', $$which_ary) : array_map('utf8_clean_string', $$which_ary);
unset($$which_ary);

	$sql_in = ($which_ary == 'user_id_ary') ? array_map('intval', ${$which_ary}) : array_map('utf8_clean_string', ${$which_ary});
unset(${$which_ary});


$user_id_ary = $username_ary = array();



$user_id_ary = $username_ary = array();


Line 119Line 119
	global $config, $db, $cache, $phpbb_dispatcher;

$update_ary = array(

	global $config, $db, $cache, $phpbb_dispatcher;

$update_ary = array(

		FORUMS_TABLE			=> array('forum_last_poster_name'),
MODERATOR_CACHE_TABLE => array('username'),
POSTS_TABLE => array('post_username'),
TOPICS_TABLE => array('topic_first_poster_name', 'topic_last_poster_name'),










		FORUMS_TABLE			=> array(
'forum_last_poster_id' => 'forum_last_poster_name',
),
MODERATOR_CACHE_TABLE => array(
'user_id' => 'username',
),
POSTS_TABLE => array(
'poster_id' => 'post_username',
),
TOPICS_TABLE => array(
'topic_poster' => 'topic_first_poster_name',
'topic_last_poster_id' => 'topic_last_poster_name',
),

	);

foreach ($update_ary as $table => $field_ary)
{

	);

foreach ($update_ary as $table => $field_ary)
{

		foreach ($field_ary as $field)

		foreach ($field_ary as $id_field => $name_field)

		{
$sql = "UPDATE $table

		{
$sql = "UPDATE $table

				SET $field = '" . $db->sql_escape($new_name) . "'
WHERE $field = '" . $db->sql_escape($old_name) . "'";


				SET $name_field = '" . $db->sql_escape($new_name) . "'
WHERE $name_field = '" . $db->sql_escape($old_name) . "'
AND $id_field <> " . ANONYMOUS;

			$db->sql_query($sql);
}
}

			$db->sql_query($sql);
}
}

Line 398Line 408
 */
function user_delete($mode, $user_ids, $retain_username = true)
{

 */
function user_delete($mode, $user_ids, $retain_username = true)
{

	global $cache, $config, $db, $user, $phpbb_dispatcher;

	global $cache, $config, $db, $user, $phpbb_dispatcher, $phpbb_container;

	global $phpbb_root_path, $phpEx;

$db->sql_transaction('begin');

	global $phpbb_root_path, $phpEx;

$db->sql_transaction('begin');

Line 499Line 509
	$db->sql_query('DELETE FROM ' . REPORTS_TABLE . ' WHERE ' . $user_id_sql);

$num_users_delta = 0;

	$db->sql_query('DELETE FROM ' . REPORTS_TABLE . ' WHERE ' . $user_id_sql);

$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)


// Some things need to be done in the loop (if the query changes based
// on which user is currently being deleted)

Line 508Line 521
		if ($user_row['user_avatar'] && $user_row['user_avatar_type'] == 'avatar.driver.upload')
{
avatar_delete('user', $user_row);

		if ($user_row['user_avatar'] && $user_row['user_avatar_type'] == 'avatar.driver.upload')
{
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

		}

// Decrement number of users if this user is active

Line 671Line 716
		include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
}
phpbb_delete_users_pms($user_ids);

		include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
}
phpbb_delete_users_pms($user_ids);

 

$phpbb_notifications = $phpbb_container->get('notification_manager');
$phpbb_notifications->delete_notifications('notification.type.admin_activate_user', $user_ids);


$db->sql_transaction('commit');



$db->sql_transaction('commit');


Line 703Line 751
*/
function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
{

*/
function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
{

	global $config, $db, $user, $auth;

	global $config, $db, $user, $auth, $phpbb_dispatcher;


$deactivated = $activated = 0;
$sql_statements = array();


$deactivated = $activated = 0;
$sql_statements = array();

Line 755Line 803
		$sql_statements[$row['user_id']] = $sql_ary;
}
$db->sql_freeresult($result);

		$sql_statements[$row['user_id']] = $sql_ary;
}
$db->sql_freeresult($result);

 

/**
* Check or modify activated/deactivated users data before submitting it to the database
*
* @event core.user_active_flip_before
* @var string mode User type changing mode, can be: flip|activate|deactivate
* @var int reason Reason for changing user type, can be: INACTIVE_REGISTER|INACTIVE_PROFILE|INACTIVE_MANUAL|INACTIVE_REMIND
* @var int activated The number of users to be activated
* @var int deactivated The number of users to be deactivated
* @var array user_id_ary Array with user ids to change user type
* @var array sql_statements Array with users data to submit to the database, keys: user ids, values: arrays with user data
* @since 3.1.4-RC1
*/
$vars = array('mode', 'reason', 'activated', 'deactivated', 'user_id_ary', 'sql_statements');
extract($phpbb_dispatcher->trigger_event('core.user_active_flip_before', compact($vars)));


if (sizeof($sql_statements))
{


if (sizeof($sql_statements))
{

Line 768Line 831

$auth->acl_clear_prefetch(array_keys($sql_statements));
}


$auth->acl_clear_prefetch(array_keys($sql_statements));
}

 

/**
* Perform additional actions after the users have been activated/deactivated
*
* @event core.user_active_flip_after
* @var string mode User type changing mode, can be: flip|activate|deactivate
* @var int reason Reason for changing user type, can be: INACTIVE_REGISTER|INACTIVE_PROFILE|INACTIVE_MANUAL|INACTIVE_REMIND
* @var int activated The number of users to be activated
* @var int deactivated The number of users to be deactivated
* @var array user_id_ary Array with user ids to change user type
* @var array sql_statements Array with users data to submit to the database, keys: user ids, values: arrays with user data
* @since 3.1.4-RC1
*/
$vars = array('mode', 'reason', 'activated', 'deactivated', 'user_id_ary', 'sql_statements');
extract($phpbb_dispatcher->trigger_event('core.user_active_flip_after', compact($vars)));


if ($deactivated)
{


if ($deactivated)
{

Line 1334Line 1412
	$match = array();

// Test for referrals from $whois_host to other whois databases, roll on rwhois

	$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)
{

	{
if (strpos($match[1], ':') !== false)
{

Line 2630Line 2708
*/
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)
{

*/
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, $phpbb_container;

	global $db, $auth, $phpbb_container, $phpbb_dispatcher;


// We need both username and user_id info
$result = user_get_id_name($user_id_ary, $username_ary);


// We need both username and user_id info
$result = user_get_id_name($user_id_ary, $username_ary);

Line 2706Line 2784

// Clear permissions cache of relevant users
$auth->acl_clear_prefetch($user_id_ary);


// 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)
{


if (!$group_name)
{

Line 2743Line 2841
*
* @return false if no errors occurred, else the user lang string for the relevant error, for example 'NO_USER'
*/

*
* @return false if no errors occurred, else the user lang string for the relevant error, for example 'NO_USER'
*/

function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false)

function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $log_action = true)

{
global $db, $auth, $config, $phpbb_dispatcher, $phpbb_container;


{
global $db, $auth, $config, $phpbb_dispatcher, $phpbb_container;


Line 2865Line 2963
	// Clear permissions cache of relevant users
$auth->acl_clear_prefetch($user_id_ary);


	// 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 ($log_action)
{

	if (!$group_name)
{
$group_name = get_group_name($group_id);

	if (!$group_name)
{
$group_name = get_group_name($group_id);

Line 2875Line 2988
	if ($group_name)
{
add_log('admin', $log, $group_name, implode(', ', $username_ary));

	if ($group_name)
{
add_log('admin', $log, $group_name, implode(', ', $username_ary));

 
		}

	}

group_update_listings($group_id);

	}

group_update_listings($group_id);

Line 2972Line 3086
*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{

*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{

	global $db, $auth, $phpbb_root_path, $phpEx, $config, $phpbb_container;

	global $db, $auth, $phpbb_root_path, $phpEx, $config, $phpbb_container, $phpbb_dispatcher;


// We need both username and user_id info
$result = user_get_id_name($user_id_ary, $username_ary);


// We need both username and user_id info
$result = user_get_id_name($user_id_ary, $username_ary);

Line 3102Line 3216
			$log = 'LOG_GROUP_DEFAULTS';
break;
}

			$log = 'LOG_GROUP_DEFAULTS';
break;
}

 

/**
* Event to perform additional actions on setting user group attributes
*
* @event core.user_set_group_attributes
* @var int group_id ID of the group
* @var string group_name Name of the group
* @var array user_id_ary IDs of the users to set group attributes
* @var array username_ary Names of the users to set group attributes
* @var array group_attributes Group attributes which were changed
* @var string action Action to perform over the group members
* @since 3.1.10-RC1
*/
$vars = array(
'group_id',
'group_name',
'user_id_ary',
'username_ary',
'group_attributes',
'action',
);
extract($phpbb_dispatcher->trigger_event('core.user_set_group_attributes', compact($vars)));


// Clear permissions cache of relevant users
$auth->acl_clear_prefetch($user_id_ary);


// Clear permissions cache of relevant users
$auth->acl_clear_prefetch($user_id_ary);

Line 3518Line 3654
	}

// We need to call group_user_del here, because this function makes sure everything is correctly changed.

	}

// We need to call group_user_del here, because this function makes sure everything is correctly changed.

	// A downside for a call within the session handler is that the language is not set up yet - so no log entry
group_user_del($group_id, $user_id);

	// Force function to not log the removal of users from newly registered users group
group_user_del($group_id, $user_id, false, false, false);


// Set user_new to 0 to let this not be triggered again
$sql = 'UPDATE ' . USERS_TABLE . '


// Set user_new to 0 to let this not be triggered again
$sql = 'UPDATE ' . USERS_TABLE . '