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 490Line 490
				'bcc'				=> explode(':', $row['bcc_address']),
'friend' => (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['friend'] : 0,
'foe' => (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['foe'] : 0,

				'bcc'				=> explode(':', $row['bcc_address']),
'friend' => (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['friend'] : 0,
'foe' => (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['foe'] : 0,

				'user_in_group'		=> array($user->data['group_id']),

				'user_in_group'		=> $user->data['group_id'],

				'author_in_group'	=> array())
);


				'author_in_group'	=> array())
);


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 1966Line 1966
*/
function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode = false)
{

*/
function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode = false)
{

	global $db, $user, $template, $phpbb_root_path, $phpEx, $auth;

	global $db, $user, $template, $phpbb_root_path, $phpEx, $auth, $phpbb_dispatcher;


// Select all receipts and the author from the pm we currently view, to only display their pm-history
$sql = 'SELECT author_id, user_id


// Select all receipts and the author from the pm we currently view, to only display their pm-history
$sql = 'SELECT author_id, user_id

Line 1985Line 1985
	$recipients = array_unique($recipients);

// Get History Messages (could be newer)

	$recipients = array_unique($recipients);

// Get History Messages (could be newer)

	$sql = 'SELECT t.*, p.*, u.*
FROM ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TO_TABLE . ' t, ' . USERS_TABLE . ' u
WHERE t.msg_id = p.msg_id

	$sql_where = 't.msg_id = p.msg_id



			AND p.author_id = u.user_id
AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
AND ' . $db->sql_in_set('t.author_id', $recipients, false, true) . "

			AND p.author_id = u.user_id
AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
AND ' . $db->sql_in_set('t.author_id', $recipients, false, true) . "

Line 1998Line 1996

if (!$message_row['root_level'])
{


if (!$message_row['root_level'])
{

		$sql .= " AND (p.root_level = $msg_id OR (p.root_level = 0 AND p.msg_id = $msg_id))";

		$sql_where .= " AND (p.root_level = $msg_id OR (p.root_level = 0 AND p.msg_id = $msg_id))";

	}
else
{

	}
else
{

		$sql .= " AND (p.root_level = " . $message_row['root_level'] . ' OR p.msg_id = ' . $message_row['root_level'] . ')';

		$sql_where .= " AND (p.root_level = " . $message_row['root_level'] . ' OR p.msg_id = ' . $message_row['root_level'] . ')';

	}

	}

	$sql .= ' ORDER BY p.message_time DESC';


























$sql_ary = array(
'SELECT' => 't.*, p.*, u.*',
'FROM' => array(
PRIVMSGS_TABLE => 'p',
PRIVMSGS_TO_TABLE => 't',
USERS_TABLE => 'u'
),
'LEFT_JOIN' => array(),
'WHERE' => $sql_where,
'ORDER_BY' => 'p.message_time DESC',
);

/**
* Event to modify the SQL query before the message history in private message is queried
*
* @event core.message_history_modify_sql_ary
* @var array sql_ary The SQL array to get the data of the message history in private message
* @since 3.2.8-RC1
*/
$vars = array('sql_ary');
extract($phpbb_dispatcher->trigger_event('core.message_history_modify_sql_ary', compact($vars)));

$sql = $db->sql_build_query('SELECT', $sql_ary);
unset($sql_ary);


$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);


$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);

Line 2038Line 2060
	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 2073
	// 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 2087Line 2109
			$previous_history_pm = $prev_id;
}


			$previous_history_pm = $prev_id;
}


		$template->assign_block_vars('history_row', array(

		$template_vars = array(

			'MESSAGE_AUTHOR_QUOTE'		=> (($decoded_message) ? addslashes(get_username_string('username', $author_id, $row['username'], $row['user_colour'], $row['username'])) : ''),
'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $row['username'], $row['user_colour'], $row['username']),
'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $row['username'], $row['user_colour'], $row['username']),

			'MESSAGE_AUTHOR_QUOTE'		=> (($decoded_message) ? addslashes(get_username_string('username', $author_id, $row['username'], $row['user_colour'], $row['username'])) : ''),
'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $row['username'], $row['user_colour'], $row['username']),
'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $row['username'], $row['user_colour'], $row['username']),

Line 2109Line 2131
			'USER_ID'			=> $row['user_id'],
'U_VIEW_MESSAGE' => "$url&amp;f=$folder_id&amp;p=" . $row['msg_id'],
'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&amp;mode=compose&amp;action=quote&amp;f=" . $folder_id . "&amp;p=" . $row['msg_id'] : '',

			'USER_ID'			=> $row['user_id'],
'U_VIEW_MESSAGE' => "$url&amp;f=$folder_id&amp;p=" . $row['msg_id'],
'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&amp;mode=compose&amp;action=quote&amp;f=" . $folder_id . "&amp;p=" . $row['msg_id'] : '',

			'U_POST_REPLY_PM'	=> ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;p=" . $row['msg_id'] : '')

			'U_POST_REPLY_PM'	=> ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;p=" . $row['msg_id'] : ''

		);

		);

 

/**
* Modify the template vars for displaying the message history in private message
*
* @event core.message_history_modify_template_vars
* @var array template_vars Array containing the query
* @var array row Array containing the action user row
* @since 3.2.8-RC1
*/
$vars = array(
'template_vars',
'row',
);
extract($phpbb_dispatcher->trigger_event('core.message_history_modify_template_vars', compact($vars)));

$template->assign_block_vars('history_row', $template_vars);


		unset($rowset[$i]);
$prev_id = $id;
}

		unset($rowset[$i]);
$prev_id = $id;
}

Line 2197Line 2236

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