phpBB

Code Changes

File: includes/functions_admin.php

  Unmodified   Added   Modified   Removed
Line 167Line 167

$s_size_options = '';



$s_size_options = '';


	for ($i = 0, $size = sizeof($size_types_text); $i < $size; $i++)

	for ($i = 0, $size = count($size_types_text); $i < $size; $i++)

	{
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
$s_size_options .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';

	{
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
$s_size_options .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';

Line 192Line 192
	/** @var \phpbb\group\helper $group_helper */
$group_helper = $phpbb_container->get('group_helper');


	/** @var \phpbb\group\helper $group_helper */
$group_helper = $phpbb_container->get('group_helper');


	$exclude_sql = ($exclude_ids !== false && sizeof($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : '';

	$exclude_sql = ($exclude_ids !== false && count($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : '';

	$sql_and = (!$config['coppa_enable']) ? (($exclude_sql) ? ' AND ' : ' WHERE ') . "group_name <> 'REGISTERED_COPPA'" : '';
$sql_founder = ($manage_founder !== false) ? (($exclude_sql || $sql_and) ? ' AND ' : ' WHERE ') . 'group_founder_manage = ' . (int) $manage_founder : '';


	$sql_and = (!$config['coppa_enable']) ? (($exclude_sql) ? ' AND ' : ' WHERE ') . "group_name <> 'REGISTERED_COPPA'" : '';
$sql_founder = ($manage_founder !== false) ? (($exclude_sql || $sql_and) ? ' AND ' : ' WHERE ') . 'group_founder_manage = ' . (int) $manage_founder : '';


Line 747Line 747
	{
$where_ids = (is_array($where_ids)) ? array_unique($where_ids) : array($where_ids);


	{
$where_ids = (is_array($where_ids)) ? array_unique($where_ids) : array($where_ids);


		if (!sizeof($where_ids))

		if (!count($where_ids))

		{
return array('topics' => 0, 'posts' => 0);
}

		{
return array('topics' => 0, 'posts' => 0);
}

Line 777Line 777
	}
$db->sql_freeresult($result);


	}
$db->sql_freeresult($result);


	$return['topics'] = sizeof($topic_ids);

	$return['topics'] = count($topic_ids);





	if (!sizeof($topic_ids))

	if (!count($topic_ids))

	{
return $return;
}

	{
return $return;
}

Line 837Line 837
	}
$db->sql_freeresult($result);


	}
$db->sql_freeresult($result);


	if (sizeof($moved_topic_ids))

	if (count($moved_topic_ids))

	{
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $moved_topic_ids);

	{
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $moved_topic_ids);

Line 923Line 923
			$where_ids = array($where_ids);
}


			$where_ids = array($where_ids);
}


		if (!sizeof($where_ids))

		if (!count($where_ids))

		{
return false;
}

		{
return false;
}

Line 931Line 931
		$where_ids = array_map('intval', $where_ids);

/* Possible code for splitting post deletion

		$where_ids = array_map('intval', $where_ids);

/* Possible code for splitting post deletion

		if (sizeof($where_ids) >= 1001)

		if (count($where_ids) >= 1001)

		{
// Split into chunks of 1000
$chunks = array_chunk($where_ids, 1000);

		{
// Split into chunks of 1000
$chunks = array_chunk($where_ids, 1000);

Line 974Line 974
	}
$db->sql_freeresult($result);


	}
$db->sql_freeresult($result);


	if (!sizeof($post_ids))

	if (!count($post_ids))

	{
return false;
}

	{
return false;
}

Line 1018Line 1018
	unset($table_ary);

// Adjust users post counts

	unset($table_ary);

// Adjust users post counts

	if (sizeof($post_counts) && $post_count_sync)

	if (count($post_counts) && $post_count_sync)

	{
foreach ($post_counts as $poster_id => $substract)
{

	{
foreach ($post_counts as $poster_id => $substract)
{

Line 1037Line 1037
	}

// Remove topics now having no posts?

	}

// Remove topics now having no posts?

	if (sizeof($topic_ids))

	if (count($topic_ids))

	{
$sql = 'SELECT topic_id
FROM ' . POSTS_TABLE . '

	{
$sql = 'SELECT topic_id
FROM ' . POSTS_TABLE . '

Line 1147Line 1147
	}

// We actually remove topics now to not be inconsistent (the delete_topics function calls this function too)

	}

// We actually remove topics now to not be inconsistent (the delete_topics function calls this function too)

	if (sizeof($remove_topics) && $call_delete_topics)

	if (count($remove_topics) && $call_delete_topics)

	{
delete_topics('topic_id', $remove_topics, $auto_sync, $post_count_sync, false);
}

	{
delete_topics('topic_id', $remove_topics, $auto_sync, $post_count_sync, false);
}

Line 1157Line 1157

$phpbb_notifications->delete_notifications($delete_notifications_types, $post_ids);



$phpbb_notifications->delete_notifications($delete_notifications_types, $post_ids);


	return sizeof($post_ids);

	return count($post_ids);

}

/**

}

/**

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

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

	while (sizeof($topic_ids) == $batch_size);

	while (count($topic_ids) == $batch_size);


if ($auto_sync)
{


if ($auto_sync)
{

Line 1363Line 1363
			// Do not sync the "global forum"
$where_ids = array_diff($where_ids, array(0));


			// Do not sync the "global forum"
$where_ids = array_diff($where_ids, array(0));


			if (!sizeof($where_ids))

			if (!count($where_ids))

			{
// Empty array with IDs. This means that we don't have any work to do. Just return.
return;

			{
// Empty array with IDs. This means that we don't have any work to do. Just return.
return;

Line 1377Line 1377
	}
else
{

	}
else
{

		if (!sizeof($where_ids))

		if (!count($where_ids))

		{
return;
}

		{
return;
}

Line 1416Line 1416
					}
$db->sql_freeresult($result);


					}
$db->sql_freeresult($result);


					if (!sizeof($topic_id_ary))

					if (!count($topic_id_ary))

					{
return;
}

					{
return;
}

Line 1533Line 1533
				$post_ids[] = $post_id;
}


				$post_ids[] = $post_id;
}


			if (sizeof($post_ids))

			if (count($post_ids))

			{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 1 - post_reported

			{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 1 - post_reported

Line 1579Line 1579
			}
$db->sql_freeresult($result);


			}
$db->sql_freeresult($result);


			if (sizeof($topic_ids))

			if (count($topic_ids))

			{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 1 - topic_reported

			{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 1 - topic_reported

Line 1638Line 1638
				$post_ids[] = $post_id;
}


				$post_ids[] = $post_id;
}


			if (sizeof($post_ids))

			if (count($post_ids))

			{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_attachment = 1 - post_attachment

			{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_attachment = 1 - post_attachment

Line 1684Line 1684
			}
$db->sql_freeresult($result);


			}
$db->sql_freeresult($result);


			if (sizeof($topic_ids))

			if (count($topic_ids))

			{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_attachment = 1 - topic_attachment

			{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_attachment = 1 - topic_attachment

Line 1736Line 1736
			}
$db->sql_freeresult($result);


			}
$db->sql_freeresult($result);


			if (!sizeof($forum_ids))

			if (!count($forum_ids))

			{
break;
}

			{
break;
}

Line 1775Line 1775
			// 3: Get post count for each forum (optional)
if ($sync_extra)
{

			// 3: Get post count for each forum (optional)
if ($sync_extra)
{

				if (sizeof($forum_ids) == 1)

				if (count($forum_ids) == 1)

				{
$sql = 'SELECT SUM(t.topic_posts_approved) AS forum_posts_approved, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted
FROM ' . TOPICS_TABLE . ' t

				{
$sql = 'SELECT SUM(t.topic_posts_approved) AS forum_posts_approved, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted
FROM ' . TOPICS_TABLE . ' t

Line 1795Line 1795

while ($row = $db->sql_fetchrow($result))
{


while ($row = $db->sql_fetchrow($result))
{

					$forum_id = (sizeof($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id'];

					$forum_id = (count($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id'];


$forum_data[$forum_id]['posts_approved'] = (int) $row['forum_posts_approved'];
$forum_data[$forum_id]['posts_unapproved'] = (int) $row['forum_posts_unapproved'];


$forum_data[$forum_id]['posts_approved'] = (int) $row['forum_posts_approved'];
$forum_data[$forum_id]['posts_unapproved'] = (int) $row['forum_posts_unapproved'];

Line 1805Line 1805
			}

// 4: Get last_post_id for each forum

			}

// 4: Get last_post_id for each forum

			if (sizeof($forum_ids) == 1)

			if (count($forum_ids) == 1)

			{
$sql = 'SELECT MAX(t.topic_last_post_id) as last_post_id
FROM ' . TOPICS_TABLE . ' t

			{
$sql = 'SELECT MAX(t.topic_last_post_id) as last_post_id
FROM ' . TOPICS_TABLE . ' t

Line 1825Line 1825

while ($row = $db->sql_fetchrow($result))
{


while ($row = $db->sql_fetchrow($result))
{

				$forum_id = (sizeof($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id'];

				$forum_id = (count($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id'];


$forum_data[$forum_id]['last_post_id'] = (int) $row['last_post_id'];



$forum_data[$forum_id]['last_post_id'] = (int) $row['last_post_id'];


Line 1834Line 1834
			$db->sql_freeresult($result);

// 5: Retrieve last_post infos

			$db->sql_freeresult($result);

// 5: Retrieve last_post infos

			if (sizeof($post_ids))

			if (count($post_ids))

			{
$sql = 'SELECT p.post_id, p.poster_id, p.post_subject, p.post_time, p.post_username, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u

			{
$sql = 'SELECT p.post_id, p.poster_id, p.post_subject, p.post_time, p.post_username, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u

Line 1902Line 1902
					}
}


					}
}


				if (sizeof($sql_ary))

				if (count($sql_ary))

				{
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '

				{
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '

Line 2025Line 2025
			}

// Now we delete empty topics and orphan posts

			}

// Now we delete empty topics and orphan posts

			if (sizeof($delete_posts))

			if (count($delete_posts))

			{
delete_posts('topic_id', array_keys($delete_posts), false);
unset($delete_posts);
}


			{
delete_posts('topic_id', array_keys($delete_posts), false);
unset($delete_posts);
}


			if (!sizeof($topic_data))

			if (!count($topic_data))

			{
// If we get there, topic ids were invalid or topics did not contain any posts
delete_topics($where_type, $where_ids, true);
return;
}


			{
// If we get there, topic ids were invalid or topics did not contain any posts
delete_topics($where_type, $where_ids, true);
return;
}


			if (sizeof($delete_topics))

			if (count($delete_topics))

			{
$delete_topic_ids = array();
foreach ($delete_topics as $topic_id => $void)

			{
$delete_topic_ids = array();
foreach ($delete_topics as $topic_id => $void)

Line 2081Line 2081
			$db->sql_freeresult($result);

// Make sure shadow topics do link to existing topics

			$db->sql_freeresult($result);

// Make sure shadow topics do link to existing topics

			if (sizeof($moved_topics))

			if (count($moved_topics))

			{
$delete_topics = array();


			{
$delete_topics = array();


Line 2098Line 2098
				}
$db->sql_freeresult($result);


				}
$db->sql_freeresult($result);


				if (sizeof($delete_topics))

				if (count($delete_topics))

				{
delete_topics('topic_id', $delete_topics, false);
}

				{
delete_topics('topic_id', $delete_topics, false);
}

Line 2121Line 2121
				$db->sql_freeresult($result);

$sync_shadow_topics = array();

				$db->sql_freeresult($result);

$sync_shadow_topics = array();

				if (sizeof($post_ids))

				if (count($post_ids))

				{
$sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u

				{
$sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u

Line 2174Line 2174
					$shadow_topic_data = array();

// Update the information we collected

					$shadow_topic_data = array();

// Update the information we collected

					if (sizeof($sync_shadow_topics))

					if (count($sync_shadow_topics))

					{
foreach ($sync_shadow_topics as $sync_topic_id => $sql_ary)
{

					{
foreach ($sync_shadow_topics as $sync_topic_id => $sql_ary)
{

Line 2239Line 2239
					}
}


					}
}


				if (sizeof($sql_ary))

				if (count($sql_ary))

				{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '

				{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '

Line 2256Line 2256
			// if some topics have been resync'ed then resync parent forums
// except when we're only syncing a range, we don't want to sync forums during
// batch processing.

			// if some topics have been resync'ed then resync parent forums
// except when we're only syncing a range, we don't want to sync forums during
// batch processing.

			if ($resync_parents && sizeof($resync_forums) && $where_type != 'range')

			if ($resync_parents && count($resync_forums) && $where_type != 'range')

			{
sync('forum', 'forum_id', array_values($resync_forums), true, true);
}

			{
sync('forum', 'forum_id', array_values($resync_forums), true, true);
}

Line 2278Line 2278
		$forum_id = array($forum_id);
}


		$forum_id = array($forum_id);
}


	if (!sizeof($forum_id))

	if (!count($forum_id))

	{
return;
}

	{
return;
}

Line 2368Line 2368

$topic_list = array_unique($topic_list);
}


$topic_list = array_unique($topic_list);
}

 

/**
* Perform additional actions before topic deletion via pruning
*
* @event core.prune_delete_before
* @var int[] topic_list The IDs of the topics to be deleted
* @since 3.2.2-RC1
*/
$vars = array('topic_list');
extract($phpbb_dispatcher->trigger_event('core.prune_delete_before', compact($vars)));


return delete_topics('topic_id', $topic_list, $auto_sync, false);
}


return delete_topics('topic_id', $topic_list, $auto_sync, false);
}

Line 2441Line 2451
	$hold_ary = $auth->acl_user_raw_data(false, 'm_%', false);

// Add users?

	$hold_ary = $auth->acl_user_raw_data(false, 'm_%', false);

// Add users?

	if (sizeof($hold_ary))

	if (!empty($hold_ary))

	{
// At least one moderative option warrants a display
$ug_id_ary = array_keys($hold_ary);

	{
// At least one moderative option warrants a display
$ug_id_ary = array_keys($hold_ary);

Line 2486Line 2496
		}
$db->sql_freeresult($result);


		}
$db->sql_freeresult($result);


		if (sizeof($hold_ary))

		if (count($hold_ary))

		{
// Get usernames...
$sql = 'SELECT user_id, username

		{
// Get usernames...
$sql = 'SELECT user_id, username

Line 2526Line 2536
	// Now to the groups...
$hold_ary = $auth->acl_group_raw_data(false, 'm_%', false);


	// Now to the groups...
$hold_ary = $auth->acl_group_raw_data(false, 'm_%', false);


	if (sizeof($hold_ary))

	if (!empty($hold_ary))

	{
$ug_id_ary = array_keys($hold_ary);


	{
$ug_id_ary = array_keys($hold_ary);


Line 2630Line 2640
function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false)
{
// update foes for some user

function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false)
{
// update foes for some user

	if (is_array($user_id) && sizeof($user_id))

	if (is_array($user_id) && count($user_id))

	{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE ' . $db->sql_in_set('zebra_id', $user_id) . '

	{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE ' . $db->sql_in_set('zebra_id', $user_id) . '

Line 2640Line 2650
	}

// update foes for some group

	}

// update foes for some group

	if (is_array($group_id) && sizeof($group_id))

	if (is_array($group_id) && count($group_id))

	{
// Grab group settings...
$sql_ary = array(

	{
// Grab group settings...
$sql_ary = array(

Line 2674Line 2684
		}
$db->sql_freeresult($result);


		}
$db->sql_freeresult($result);


		if (!sizeof($groups))

		if (!count($groups))

		{
return;
}

		{
return;
}

Line 2704Line 2714
				}
$db->sql_freeresult($result);


				}
$db->sql_freeresult($result);


				if (sizeof($users))

				if (count($users))

				{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE ' . $db->sql_in_set('zebra_id', $users) . '

				{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE ' . $db->sql_in_set('zebra_id', $users) . '

Line 2727Line 2737
		}
}


		}
}


	if (sizeof($perms))

	if (count($perms))

	{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE ' . $db->sql_in_set('zebra_id', array_unique($perms)) . '

	{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE ' . $db->sql_in_set('zebra_id', array_unique($perms)) . '

Line 2990Line 3000
	}
$db->sql_freeresult($result);


	}
$db->sql_freeresult($result);


	if (sizeof($warning_list))

	if (count($warning_list))

	{
$db->sql_transaction('begin');


	{
$db->sql_transaction('begin');