phpBB

Code Changes

File: includes/functions_privmsgs.php

  Unmodified   Added   Modified   Removed
Line 466Line 466
		$user_rules = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);


		$user_rules = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);


		if (sizeof($user_rules))

		if (count($user_rules))

		{
$sql = 'SELECT zebra_id, friend, foe
FROM ' . ZEBRA_TABLE . "

		{
$sql = 'SELECT zebra_id, friend, foe
FROM ' . ZEBRA_TABLE . "

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

// Retrieve user memberships

		$db->sql_freeresult($result);

// Retrieve user memberships

		if (sizeof($user_ids))

		if (count($user_ids))

		{
$sql = 'SELECT *
FROM ' . USER_GROUP_TABLE . '

		{
$sql = 'SELECT *
FROM ' . USER_GROUP_TABLE . '

Line 600Line 600
	// only gone through if new messages arrive.

// Delete messages

	// only gone through if new messages arrive.

// Delete messages

	if (sizeof($delete_ids))

	if (count($delete_ids))

	{

	{

		$num_removed += sizeof($delete_ids);

		$num_removed += count($delete_ids);

		delete_pm($user_id, $delete_ids, PRIVMSGS_NO_BOX);
}

// Set messages to Unread

		delete_pm($user_id, $delete_ids, PRIVMSGS_NO_BOX);
}

// Set messages to Unread

	if (sizeof($unread_ids))

	if (count($unread_ids))

	{
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET pm_unread = 0

	{
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET pm_unread = 0

Line 618Line 618
	}

// mark messages as important

	}

// mark messages as important

	if (sizeof($important_ids))

	if (count($important_ids))

	{
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET pm_marked = 1 - pm_marked

	{
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET pm_marked = 1 - pm_marked

Line 631Line 631
	// Move into folder
$folder = array();


	// Move into folder
$folder = array();


	if (sizeof($move_into_folder))

	if (count($move_into_folder))

	{
// Determine Full Folder Action - we need the move to folder id later eventually
$full_folder_action = ($user->data['user_full_folder'] == FULL_FOLDER_NONE) ? ($config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : $user->data['user_full_folder'];

	{
// Determine Full Folder Action - we need the move to folder id later eventually
$full_folder_action = ($user->data['user_full_folder'] == FULL_FOLDER_NONE) ? ($config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : $user->data['user_full_folder'];

Line 676Line 676

// Check Message Limit - we calculate with the complete array, most of the time it is one message
// But we are making sure that the other way around works too (more messages in queue than allowed to be stored)


// Check Message Limit - we calculate with the complete array, most of the time it is one message
// But we are making sure that the other way around works too (more messages in queue than allowed to be stored)

		if ($user->data['message_limit'] && $folder[$folder_id] && ($folder[$folder_id] + sizeof($msg_ary)) > $user->data['message_limit'])

		if ($user->data['message_limit'] && $folder[$folder_id] && ($folder[$folder_id] + count($msg_ary)) > $user->data['message_limit'])

		{
$full_folder_action = ($user->data['user_full_folder'] == FULL_FOLDER_NONE) ? ($config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : $user->data['user_full_folder'];

// If destination folder itself is full...

		{
$full_folder_action = ($user->data['user_full_folder'] == FULL_FOLDER_NONE) ? ($config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : $user->data['user_full_folder'];

// If destination folder itself is full...

			if ($full_folder_action >= 0 && ($folder[$full_folder_action] + sizeof($msg_ary)) > $user->data['message_limit'])

			if ($full_folder_action >= 0 && ($folder[$full_folder_action] + count($msg_ary)) > $user->data['message_limit'])

			{
$full_folder_action = $config['full_folder_action'] - (FULL_FOLDER_NONE*(-1));
}

			{
$full_folder_action = $config['full_folder_action'] - (FULL_FOLDER_NONE*(-1));
}

Line 699Line 699
					WHERE user_id = $user_id
AND folder_id = $dest_folder
ORDER BY msg_id ASC";

					WHERE user_id = $user_id
AND folder_id = $dest_folder
ORDER BY msg_id ASC";

				$result = $db->sql_query_limit($sql, (($folder[$dest_folder] + sizeof($msg_ary)) - $user->data['message_limit']));

				$result = $db->sql_query_limit($sql, (($folder[$dest_folder] + count($msg_ary)) - $user->data['message_limit']));


$delete_ids = array();
while ($row = $db->sql_fetchrow($result))


$delete_ids = array();
while ($row = $db->sql_fetchrow($result))

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


				}
$db->sql_freeresult($result);


				$num_removed += sizeof($delete_ids);

				$num_removed += count($delete_ids);

				delete_pm($user_id, $delete_ids, $dest_folder);
}
}

				delete_pm($user_id, $delete_ids, $dest_folder);
}
}

Line 744Line 744
		}
}


		}
}


	if (sizeof($action_ary))

	if (count($action_ary))

	{
// Move from OUTBOX to SENTBOX
// We are not checking any full folder status here... SENTBOX is a special treatment (old messages get deleted)

	{
// Move from OUTBOX to SENTBOX
// We are not checking any full folder status here... SENTBOX is a special treatment (old messages get deleted)

Line 785Line 785
		$move_msg_ids = array($move_msg_ids);
}


		$move_msg_ids = array($move_msg_ids);
}


	if (sizeof($move_msg_ids) && !in_array($dest_folder, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX)) &&

	if (count($move_msg_ids) && !in_array($dest_folder, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX)) &&

		!in_array($cur_folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)) && $cur_folder_id != $dest_folder)
{
// We have to check the destination folder ;)

		!in_array($cur_folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)) && $cur_folder_id != $dest_folder)
{
// We have to check the destination folder ;)

Line 805Line 805
				trigger_error('NOT_AUTHORISED');
}


				trigger_error('NOT_AUTHORISED');
}


			if ($message_limit && $row['pm_count'] + sizeof($move_msg_ids) > $message_limit)

			if ($message_limit && $row['pm_count'] + count($move_msg_ids) > $message_limit)

			{
$message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $row['folder_name']) . '<br /><br />';
$message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;folder=' . $row['folder_id']) . '">', '</a>', $row['folder_name']);

			{
$message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $row['folder_name']) . '<br /><br />';
$message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;folder=' . $row['folder_id']) . '">', '</a>', $row['folder_name']);

Line 822Line 822
			$num_messages = (int) $db->sql_fetchfield('num_messages');
$db->sql_freeresult($result);


			$num_messages = (int) $db->sql_fetchfield('num_messages');
$db->sql_freeresult($result);


			if ($message_limit && $num_messages + sizeof($move_msg_ids) > $message_limit)

			if ($message_limit && $num_messages + count($move_msg_ids) > $message_limit)

			{
$message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $user->lang['PM_INBOX']) . '<br /><br />';
$message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;folder=inbox') . '">', '</a>', $user->lang['PM_INBOX']);

			{
$message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $user->lang['PM_INBOX']) . '<br /><br />';
$message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;folder=inbox') . '">', '</a>', $user->lang['PM_INBOX']);

Line 949Line 949
	$msg_ids		= $request->variable('marked_msg_id', array(0));
$cur_folder_id = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX);


	$msg_ids		= $request->variable('marked_msg_id', array(0));
$cur_folder_id = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX);


	if (!sizeof($msg_ids))

	if (!count($msg_ids))

	{
return false;
}

	{
return false;
}

Line 981Line 981
			{
delete_pm($user_id, $msg_ids, $cur_folder_id);


			{
delete_pm($user_id, $msg_ids, $cur_folder_id);


				$success_msg = (sizeof($msg_ids) == 1) ? 'MESSAGE_DELETED' : 'MESSAGES_DELETED';

				$success_msg = (count($msg_ids) == 1) ? 'MESSAGE_DELETED' : 'MESSAGES_DELETED';

				$redirect = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;folder=' . $cur_folder_id);

meta_refresh(3, $redirect);

				$redirect = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;folder=' . $cur_folder_id);

meta_refresh(3, $redirect);

Line 1032Line 1032
		$msg_ids = array($msg_ids);
}


		$msg_ids = array($msg_ids);
}


	if (!sizeof($msg_ids))

	if (!count($msg_ids))

	{
return false;
}

	{
return false;
}

Line 1069Line 1069
	$db->sql_freeresult($result);
unset($msg_ids);


	$db->sql_freeresult($result);
unset($msg_ids);


	if (!sizeof($delete_rows))

	if (!count($delete_rows))

	{
return false;
}

	{
return false;
}

Line 1156Line 1156

$delete_ids = array_keys($delete_rows);



$delete_ids = array_keys($delete_rows);


	if (sizeof($delete_ids))

	if (count($delete_ids))

	{
// Check if there are any attachments we need to remove
/** @var \phpbb\attachment\manager $attachment_manager */

	{
// Check if there are any attachments we need to remove
/** @var \phpbb\attachment\manager $attachment_manager */

Line 1289Line 1289
			$num_pms = (int) $row['num_undelivered_privmsgs'];
$undelivered_user[$num_pms][] = (int) $row['user_id'];


			$num_pms = (int) $row['num_undelivered_privmsgs'];
$undelivered_user[$num_pms][] = (int) $row['user_id'];


			if (sizeof($undelivered_user[$num_pms]) > 50)

			if (count($undelivered_user[$num_pms]) > 50)

			{
// If there are too many users affected the query might get
// too long, so we update the value for the first bunch here.

			{
// If there are too many users affected the query might get
// too long, so we update the value for the first bunch here.

Line 1416Line 1416
		$_types = array('u', 'g');
foreach ($_types as $type)
{

		$_types = array('u', 'g');
foreach ($_types as $type)
{

			if (sizeof(${$type}))

			if (count(${$type}))

			{
foreach (${$type} as $id)
{

			{
foreach (${$type} as $id)
{

Line 1461Line 1461
		}

$address = array();

		}

$address = array();

		if (sizeof($u))

		if (count($u))

		{
$sql = 'SELECT user_id, username, user_colour
FROM ' . USERS_TABLE . '

		{
$sql = 'SELECT user_id, username, user_colour
FROM ' . USERS_TABLE . '

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


			$db->sql_freeresult($result);
}


		if (sizeof($g))

		if (count($g))

		{
if ($plaintext)
{

		{
if ($plaintext)
{

Line 1532Line 1532
			}
}


			}
}


		if (sizeof($address) && !$plaintext)

		if (count($address) && !$plaintext)

		{
$template->assign_var('S_' . strtoupper($check_type) . '_RECIPIENT', true);


		{
$template->assign_var('S_' . strtoupper($check_type) . '_RECIPIENT', true);


Line 1651Line 1651
		$_types = array('u', 'g');
foreach ($_types as $ug_type)
{

		$_types = array('u', 'g');
foreach ($_types as $ug_type)
{

			if (isset($data_ary['address_list'][$ug_type]) && sizeof($data_ary['address_list'][$ug_type]))

			if (isset($data_ary['address_list'][$ug_type]) && count($data_ary['address_list'][$ug_type]))

			{
foreach ($data_ary['address_list'][$ug_type] as $id => $field)
{

			{
foreach ($data_ary['address_list'][$ug_type] as $id => $field)
{

Line 1673Line 1673
			}
}


			}
}


		if (isset($data_ary['address_list']['g']) && sizeof($data_ary['address_list']['g']))

		if (isset($data_ary['address_list']['g']) && count($data_ary['address_list']['g']))

		{
// We need to check the PM status of group members (do they want to receive PM's?)
// Only check if not a moderator or admin, since they are allowed to override this user setting

		{
// We need to check the PM status of group members (do they want to receive PM's?)
// Only check if not a moderator or admin, since they are allowed to override this user setting

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


			$db->sql_freeresult($result);
}


		if (!sizeof($recipients))

		if (!count($recipients))

		{
trigger_error('NO_RECIPIENT');
}

		{
trigger_error('NO_RECIPIENT');
}

Line 1764Line 1764
		break;
}


		break;
}


	if (sizeof($sql_data))

	if (count($sql_data))

	{
if ($mode == 'post' || $mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward')
{

	{
if ($mode == 'post' || $mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward')
{

Line 1844Line 1844
			$orphan_rows[(int) $attach_row['attach_id']] = array();
}


			$orphan_rows[(int) $attach_row['attach_id']] = array();
}


		if (sizeof($orphan_rows))

		if (count($orphan_rows))

		{
$sql = 'SELECT attach_id, filesize, physical_filename
FROM ' . ATTACHMENTS_TABLE . '

		{
$sql = 'SELECT attach_id, filesize, physical_filename
FROM ' . ATTACHMENTS_TABLE . '

Line 2038Line 2038
	while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);


	while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);


	if (sizeof($rowset) == 1 && !$in_post_mode)

	if (count($rowset) == 1 && !$in_post_mode)

	{
return false;
}

	{
return false;
}

Line 2051Line 2051
	// Re-order rowset to be able to get the next/prev message rows...
$rowset = array_values($rowset);


	// Re-order rowset to be able to get the next/prev message rows...
$rowset = array_values($rowset);


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

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

	{
$row = &$rowset[$i];
$id = (int) $row['msg_id'];

	{
$row = &$rowset[$i];
$id = (int) $row['msg_id'];

Line 2197Line 2197

foreach ($_types as $ug_type)
{


foreach ($_types as $ug_type)
{

			if (isset($address[$message_id][$ug_type]) && sizeof($address[$message_id][$ug_type]))

			if (isset($address[$message_id][$ug_type]) && count($address[$message_id][$ug_type]))

			{
foreach ($address[$message_id][$ug_type] as $ug_id => $in_to)
{

			{
foreach ($address[$message_id][$ug_type] as $ug_id => $in_to)
{