phpBB

Code Changes

File: includes/functions_user.php

  Unmodified   Added   Modified   Removed
Line 170Line 170
* Adds an user
*
* @param mixed $user_row An array containing the following keys (and the appropriate values): username, group_id (the group to place the user in), user_email and the user_type(usually 0). Additional entries not overridden by defaults will be forwarded.

* Adds an user
*
* @param mixed $user_row An array containing the following keys (and the appropriate values): username, group_id (the group to place the user in), user_email and the user_type(usually 0). Additional entries not overridden by defaults will be forwarded.

* @param string $cp_data custom profile fields, see custom_profile::build_insert_sql_array

* @param array $cp_data custom profile fields, see custom_profile::build_insert_sql_array

* @param array $notifications_data The notifications settings for the new user
* @return the new user's ID.
*/

* @param array $notifications_data The notifications settings for the new user
* @return the new user's ID.
*/

Line 260Line 260
	$remaining_vars = array_diff(array_keys($user_row), array_keys($sql_ary));

// Now fill our sql array with the remaining vars

	$remaining_vars = array_diff(array_keys($user_row), array_keys($sql_ary));

// Now fill our sql array with the remaining vars

	if (sizeof($remaining_vars))

	if (count($remaining_vars))

	{
foreach ($remaining_vars as $key)
{

	{
foreach ($remaining_vars as $key)
{

Line 272Line 272
	* Use this event to modify the values to be inserted when a user is added
*
* @event core.user_add_modify_data

	* Use this event to modify the values to be inserted when a user is added
*
* @event core.user_add_modify_data

	* @var array	user_row			Array of user details submited to user_add
* @var array cp_data Array of Custom profile fields submited to user_add

	* @var array	user_row			Array of user details submitted to user_add
* @var array cp_data Array of Custom profile fields submitted to user_add

	* @var array	sql_ary				Array of data to be inserted when a user is added
* @var array notifications_data Array of notification data to be inserted when a user is added
* @since 3.1.0-a1

	* @var array	sql_ary				Array of data to be inserted when a user is added
* @var array notifications_data Array of notification data to be inserted when a user is added
* @since 3.1.0-a1

Line 289Line 289
	$user_id = $db->sql_nextid();

// Insert Custom Profile Fields

	$user_id = $db->sql_nextid();

// Insert Custom Profile Fields

	if ($cp_data !== false && sizeof($cp_data))

	if ($cp_data !== false && count($cp_data))

	{
$cp_data['user_id'] = (int) $user_id;


	{
$cp_data['user_id'] = (int) $user_id;


Line 375Line 375
			),
);
}

			),
);
}

 

/**
* Modify the notifications data to be inserted in the database when a user is added
*
* @event core.user_add_modify_notifications_data
* @var array user_row Array of user details submitted to user_add
* @var array cp_data Array of Custom profile fields submitted to user_add
* @var array sql_ary Array of data to be inserted when a user is added
* @var array notifications_data Array of notification data to be inserted when a user is added
* @since 3.2.2-RC1
*/
$vars = array('user_row', 'cp_data', 'sql_ary', 'notifications_data');
extract($phpbb_dispatcher->trigger_event('core.user_add_modify_notifications_data', compact($vars)));


// Subscribe user to notifications if necessary
if (!empty($notifications_data))


// Subscribe user to notifications if necessary
if (!empty($notifications_data))

Line 388Line 401
	}

/**

	}

/**

	* Event that returns user id, user detals and user CPF of newly registared user

	* Event that returns user id, user details and user CPF of newly registered user

	*
* @event core.user_add_after

	*
* @event core.user_add_after

	* @var int		user_id			User id of newly registared user
* @var array user_row Array of user details submited to user_add
* @var array cp_data Array of Custom profile fields submited to user_add

	* @var int		user_id			User id of newly registered user
* @var array user_row Array of user details submitted to user_add
* @var array cp_data Array of Custom profile fields submitted to user_add

	* @since 3.1.0-b5
*/
$vars = array('user_id', 'user_row', 'cp_data');

	* @since 3.1.0-b5
*/
$vars = array('user_id', 'user_row', 'cp_data');

Line 468Line 481
	}
$db->sql_freeresult($result);


	}
$db->sql_freeresult($result);


	if (sizeof($report_posts))

	if (count($report_posts))

	{
$report_posts = array_unique($report_posts);
$report_topics = array_unique($report_topics);

	{
$report_posts = array_unique($report_posts);
$report_topics = array_unique($report_topics);

Line 488Line 501
		}
$db->sql_freeresult($result);


		}
$db->sql_freeresult($result);


		if (sizeof($keep_report_topics))

		if (count($keep_report_topics))

		{
$report_topics = array_diff($report_topics, $keep_report_topics);
}

		{
$report_topics = array_diff($report_topics, $keep_report_topics);
}

Line 500Line 513
			WHERE ' . $db->sql_in_set('post_id', $report_posts);
$db->sql_query($sql);


			WHERE ' . $db->sql_in_set('post_id', $report_posts);
$db->sql_query($sql);


		if (sizeof($report_topics))

		if (count($report_topics))

		{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0

		{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0

Line 734Line 747
	* @var	array	user_ids	IDs of the deleted user
* @var mixed retain_username True if username should be retained
* or false if not

	* @var	array	user_ids	IDs of the deleted user
* @var mixed retain_username True if username should be retained
* or false if not

 
	* @var	array	user_rows	Array containing data of the deleted users

	* @since 3.1.0-a1

	* @since 3.1.0-a1

 
	* @changed 3.2.2-RC1 Added user_rows

	*/

	*/

	$vars = array('mode', 'user_ids', 'retain_username');

	$vars = array('mode', 'user_ids', 'retain_username', 'user_rows');

	extract($phpbb_dispatcher->trigger_event('core.delete_user_after', compact($vars)));

// Reset newest user info if appropriate

	extract($phpbb_dispatcher->trigger_event('core.delete_user_after', compact($vars)));

// Reset newest user info if appropriate

Line 765Line 780
		$user_id_ary = array($user_id_ary);
}


		$user_id_ary = array($user_id_ary);
}


	if (!sizeof($user_id_ary))

	if (!count($user_id_ary))

	{
return;
}

	{
return;
}

Line 823Line 838
	$vars = array('mode', 'reason', 'activated', 'deactivated', 'user_id_ary', 'sql_statements');
extract($phpbb_dispatcher->trigger_event('core.user_active_flip_before', compact($vars)));


	$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 (count($sql_statements))

	{
foreach ($sql_statements as $user_id => $sql_ary)
{

	{
foreach ($sql_statements as $user_id => $sql_ary)
{

Line 901Line 916
		else
{
$ban_other = explode('-', $ban_len_other);

		else
{
$ban_other = explode('-', $ban_len_other);

			if (sizeof($ban_other) == 3 && ((int) $ban_other[0] < 9999) &&

			if (count($ban_other) == 3 && ((int) $ban_other[0] < 9999) &&

				(strlen($ban_other[0]) == 4) && (strlen($ban_other[1]) == 2) && (strlen($ban_other[2]) == 2))
{
$ban_end = max($current_time, $user->create_datetime()

				(strlen($ban_other[0]) == 4) && (strlen($ban_other[1]) == 2) && (strlen($ban_other[2]) == 2))
{
$ban_end = max($current_time, $user->create_datetime()

Line 969Line 984
			}

// Make sure we have been given someone to ban

			}

// Make sure we have been given someone to ban

			if (!sizeof($sql_usernames))

			if (!count($sql_usernames))

			{
trigger_error('NO_USER_SPECIFIED', E_USER_WARNING);
}

			{
trigger_error('NO_USER_SPECIFIED', E_USER_WARNING);
}

Line 980Line 995

// Do not allow banning yourself, the guest account, or founders.
$non_bannable = array($user->data['user_id'], ANONYMOUS);


// Do not allow banning yourself, the guest account, or founders.
$non_bannable = array($user->data['user_id'], ANONYMOUS);

			if (sizeof($founder))

			if (count($founder))

			{
$sql .= ' AND ' . $db->sql_in_set('user_id', array_merge(array_keys($founder), $non_bannable), true);
}

			{
$sql .= ' AND ' . $db->sql_in_set('user_id', array_merge(array_keys($founder), $non_bannable), true);
}

Line 1120Line 1135
						continue;
}


						continue;
}


					if (!sizeof($founder) || !in_array($ban_item, $founder))

					if (!count($founder) || !in_array($ban_item, $founder))

					{
$banlist_ary[] = $ban_item;
}
}
}


					{
$banlist_ary[] = $ban_item;
}
}
}


			if (sizeof($ban_list) == 0)

			if (count($ban_list) == 0)

			{
trigger_error('NO_EMAILS_DEFINED', E_USER_WARNING);
}

			{
trigger_error('NO_EMAILS_DEFINED', E_USER_WARNING);
}

Line 1174Line 1189

$banlist_ary_tmp = array_intersect($banlist_ary, $banlist_ary_tmp);



$banlist_ary_tmp = array_intersect($banlist_ary, $banlist_ary_tmp);


		if (sizeof($banlist_ary_tmp))

		if (count($banlist_ary_tmp))

		{
// One or more entities are already banned/excluded, delete the existing bans, so they can be re-inserted with the given new length
$sql = 'DELETE FROM ' . BANLIST_TABLE . '

		{
// One or more entities are already banned/excluded, delete the existing bans, so they can be re-inserted with the given new length
$sql = 'DELETE FROM ' . BANLIST_TABLE . '

Line 1188Line 1203
	$db->sql_freeresult($result);

// We have some entities to ban

	$db->sql_freeresult($result);

// We have some entities to ban

	if (sizeof($banlist_ary))

	if (count($banlist_ary))

	{
$sql_ary = array();


	{
$sql_ary = array();


Line 1316Line 1331

$unban_sql = array_map('intval', $ban);



$unban_sql = array_map('intval', $ban);


	if (sizeof($unban_sql))

	if (count($unban_sql))

	{
// Grab details of bans for logging information later
switch ($mode)

	{
// Grab details of bans for logging information later
switch ($mode)

Line 1580Line 1595
function validate_date($date_string, $optional = false)
{
$date = explode('-', $date_string);

function validate_date($date_string, $optional = false)
{
$date = explode('-', $date_string);

	if ((empty($date) || sizeof($date) != 3) && $optional)

	if ((empty($date) || count($date) != 3) && $optional)

	{
return false;
}

	{
return false;
}

Line 1602Line 1617
		}
}


		}
}


	if (sizeof($date) != 3 || !checkdate($date[1], $date[0], $date[2]))

	if (count($date) != 3 || !checkdate($date[1], $date[0], $date[2]))

	{
return 'INVALID';
}

	{
return 'INVALID';
}

Line 1942Line 1957

$arr = explode('.', $realm);



$arr = explode('.', $realm);


	if (sizeof($arr) == 0)

	if (count($arr) == 0)

	{
return 'WRONG_DATA';
}

	{
return 'WRONG_DATA';
}

Line 2266Line 2281
	$group_teampage = !empty($group_attributes['group_teampage']);
unset($group_attributes['group_teampage']);


	$group_teampage = !empty($group_attributes['group_teampage']);
unset($group_attributes['group_teampage']);


	if (!sizeof($error))

	if (!count($error))

	{
$current_legend = \phpbb\groupposition\legend::GROUP_DISABLED;
$current_teampage = \phpbb\groupposition\teampage::GROUP_DISABLED;

	{
$current_legend = \phpbb\groupposition\legend::GROUP_DISABLED;
$current_teampage = \phpbb\groupposition\teampage::GROUP_DISABLED;

Line 2339Line 2354
			generate_text_for_storage($sql_ary['group_desc'], $sql_ary['group_desc_uid'], $sql_ary['group_desc_bitfield'], $sql_ary['group_desc_options'], $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies);
}


			generate_text_for_storage($sql_ary['group_desc'], $sql_ary['group_desc_uid'], $sql_ary['group_desc_bitfield'], $sql_ary['group_desc_options'], $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies);
}


		if (sizeof($group_attributes))

		if (count($group_attributes))

		{
// Merge them with $sql_ary to properly update the group
$sql_ary = array_merge($sql_ary, $group_attributes);

		{
// Merge them with $sql_ary to properly update the group
$sql_ary = array_merge($sql_ary, $group_attributes);

Line 2465Line 2480

// Set user attributes
$sql_ary = array();


// Set user attributes
$sql_ary = array();

		if (sizeof($group_attributes))

		if (count($group_attributes))

		{
// Go through the user attributes array, check if a group attribute matches it and then set it. ;)
foreach ($user_attribute_ary as $attribute)

		{
// Go through the user attributes array, check if a group attribute matches it and then set it. ;)
foreach ($user_attribute_ary as $attribute)

Line 2485Line 2500
			}
}


			}
}


		if (sizeof($sql_ary) && sizeof($user_ary))

		if (count($sql_ary) && count($user_ary))

		{
group_set_user_default($group_id, $user_ary, $sql_ary);
}

		{
group_set_user_default($group_id, $user_ary, $sql_ary);
}

Line 2496Line 2511
		group_update_listings($group_id);
}


		group_update_listings($group_id);
}


	return (sizeof($error)) ? $error : false;

	return (count($error)) ? $error : false;

}



}



Line 2661Line 2676
	// 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);


	if (!sizeof($user_id_ary) || $result !== false)

	if (empty($user_id_ary) || $result !== false)

	{
return 'NO_USER';
}

	{
return 'NO_USER';
}

Line 2689Line 2704
	$add_id_ary = array_diff($user_id_ary, $add_id_ary);

// If we have no users

	$add_id_ary = array_diff($user_id_ary, $add_id_ary);

// If we have no users

	if (!sizeof($add_id_ary) && !sizeof($update_id_ary))

	if (!count($add_id_ary) && !count($update_id_ary))

	{
return 'GROUP_USERS_EXIST';
}

	{
return 'GROUP_USERS_EXIST';
}

Line 2697Line 2712
	$db->sql_transaction('begin');

// Insert the new users

	$db->sql_transaction('begin');

// Insert the new users

	if (sizeof($add_id_ary))

	if (count($add_id_ary))

	{
$sql_ary = array();


	{
$sql_ary = array();


Line 2714Line 2729
		$db->sql_multi_insert(USER_GROUP_TABLE, $sql_ary);
}


		$db->sql_multi_insert(USER_GROUP_TABLE, $sql_ary);
}


	if (sizeof($update_id_ary))

	if (count($update_id_ary))

	{
$sql = 'UPDATE ' . USER_GROUP_TABLE . '
SET group_leader = 1

	{
$sql = 'UPDATE ' . USER_GROUP_TABLE . '
SET group_leader = 1

Line 2806Line 2821
	// 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);


	if (!sizeof($user_id_ary) || $result !== false)

	if (empty($user_id_ary) || $result !== false)

	{
return 'NO_USER';
}

	{
return 'NO_USER';
}

Line 2882Line 2897

foreach ($special_group_data as $gid => $default_data_ary)
{


foreach ($special_group_data as $gid => $default_data_ary)
{

		if (isset($sql_where_ary[$gid]) && sizeof($sql_where_ary[$gid]))

		if (isset($sql_where_ary[$gid]) && count($sql_where_ary[$gid]))

		{
remove_default_rank($group_id, $sql_where_ary[$gid]);
remove_default_avatar($group_id, $sql_where_ary[$gid]);

		{
remove_default_rank($group_id, $sql_where_ary[$gid]);
remove_default_avatar($group_id, $sql_where_ary[$gid]);

Line 3041Line 3056
	// 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);


	if (!sizeof($user_id_ary) || $result !== false)

	if (empty($user_id_ary) || $result !== false)

	{
return 'NO_USERS';
}

	{
return 'NO_USERS';
}

Line 3096Line 3111
			}
$db->sql_freeresult($result);


			}
$db->sql_freeresult($result);


			if (!sizeof($user_id_ary))

			if (!count($user_id_ary))

			{
return false;
}

			{
return false;
}

Line 3137Line 3152
			$db->sql_freeresult($result);

$result = user_get_id_name($user_id_ary, $username_ary);

			$db->sql_freeresult($result);

$result = user_get_id_name($user_id_ary, $username_ary);

			if (!sizeof($user_id_ary) || $result !== false)

			if (!count($user_id_ary) || $result !== false)

			{
return 'NO_USERS';
}

			{
return 'NO_USERS';
}

Line 3500Line 3515

$hold_ary = $auth->acl_group_raw_data($group_id, array('a_', 'm_'));



$hold_ary = $auth->acl_group_raw_data($group_id, array('a_', 'm_'));


	if (!sizeof($hold_ary))

	if (empty($hold_ary))

	{
return;
}

	{
return;
}