phpBB

Code Changes

File: includes/ucp/ucp_pm_viewfolder.php

  Unmodified   Added   Modified   Removed
Line 64Line 64
		}

$mark_options = array('mark_important', 'delete_marked');

		}

$mark_options = array('mark_important', 'delete_marked');

 

// Minimise edits
if (!$auth->acl_get('u_pm_delete') && $key = array_search('delete_marked', $mark_options))
{
unset($mark_options[$key]);
}


$s_mark_options = '';
foreach ($mark_options as $mark_option)


$s_mark_options = '';
foreach ($mark_options as $mark_option)

Line 115Line 121
			// Build Recipient List if in outbox/sentbox - max two additional queries
if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX)
{

			// Build Recipient List if in outbox/sentbox - max two additional queries
if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX)
{

				$recipient_list = $address = array();

foreach ($folder_info['rowset'] as $message_id => $row)
{
$address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address']));
$_save = array('u', 'g');
foreach ($_save as $save)
{
if (isset($address[$message_id][$save]) && sizeof($address[$message_id][$save]))
{
foreach (array_keys($address[$message_id][$save]) as $ug_id)
{
$recipient_list[$save][$ug_id] = array('name' => $user->lang['NA'], 'colour' => '');

				$address_list = get_recipient_strings($folder_info['rowset']);













							}

							}

						}
}
}

$_types = array('u', 'g');
foreach ($_types as $ug_type)
{
if (!empty($recipient_list[$ug_type]))
{
if ($ug_type == 'u')
{
$sql = 'SELECT user_id as id, username as name, user_colour as colour
FROM ' . USERS_TABLE . '
WHERE ';
}
else
{
$sql = 'SELECT group_id as id, group_name as name, group_colour as colour, group_type
FROM ' . GROUPS_TABLE . '
WHERE ';
}
$sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type])));

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

while ($row = $db->sql_fetchrow($result))
{
if ($ug_type == 'g')
{
$row['name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['name']] : $row['name'];
}

$recipient_list[$ug_type][$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']);
}
$db->sql_freeresult($result);
}
}

foreach ($address as $message_id => $adr_ary)
{
foreach ($adr_ary as $type => $id_ary)
{
foreach ($id_ary as $ug_id => $_id)
{
if ($type == 'u')
{
$address_list[$message_id][] = get_username_string('full', $ug_id, $recipient_list[$type][$ug_id]['name'], $recipient_list[$type][$ug_id]['colour']);
}
else
{
$user_colour = ($recipient_list[$type][$ug_id]['colour']) ? ' style="font-weight: bold; color:#' . $recipient_list[$type][$ug_id]['colour'] . '"' : '';
$link = '<a href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $ug_id) . '"' . $user_colour . '>';
$address_list[$message_id][] = $link . $recipient_list[$type][$ug_id]['name'] . (($link) ? '</a>' : '');
}
}
}
}
unset($recipient_list, $address);
}

$data = array();

 

foreach ($folder_info['pm_list'] as $message_id)
{


foreach ($folder_info['pm_list'] as $message_id)
{

Line 236Line 169
					'PM_IMG'			=> ($row_indicator) ? $user->img('pm_' . $row_indicator, '') : '',
'ATTACH_ICON_IMG' => ($auth->acl_get('u_pm_download') && $row['message_attachment'] && $config['allow_pm_attach']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',


					'PM_IMG'			=> ($row_indicator) ? $user->img('pm_' . $row_indicator, '') : '',
'ATTACH_ICON_IMG' => ($auth->acl_get('u_pm_download') && $row['message_attachment'] && $config['allow_pm_attach']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',


 
					'S_PM_UNREAD'		=> ($row['pm_unread']) ? true : false,

					'S_PM_DELETED'		=> ($row['pm_deleted']) ? true : false,

					'S_PM_DELETED'		=> ($row['pm_deleted']) ? true : false,

 
					'S_PM_REPORTED'		=> (isset($row['report_id'])) ? true : false,

					'S_AUTHOR_DELETED'	=> ($row['author_id'] == ANONYMOUS) ? true : false,

'U_VIEW_PM' => ($row['pm_deleted']) ? '' : $view_message_url,
'U_REMOVE_PM' => ($row['pm_deleted']) ? $remove_message_url : '',

					'S_AUTHOR_DELETED'	=> ($row['author_id'] == ANONYMOUS) ? true : false,

'U_VIEW_PM' => ($row['pm_deleted']) ? '' : $view_message_url,
'U_REMOVE_PM' => ($row['pm_deleted']) ? $remove_message_url : '',

 
					'U_MCP_REPORT'		=> (isset($row['report_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&amp;mode=pm_report_details&amp;r=' . $row['report_id']) : '',

					'RECIPIENTS'		=> ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '')
);
}

					'RECIPIENTS'		=> ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '')
);
}

Line 250Line 186
				'S_SHOW_RECIPIENTS'		=> ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? true : false,
'S_SHOW_COLOUR_LEGEND' => true,


				'S_SHOW_RECIPIENTS'		=> ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? true : false,
'S_SHOW_COLOUR_LEGEND' => true,


 
				'REPORTED_IMG'			=> $user->img('icon_topic_reported', 'PM_REPORTED'),

				'S_PM_ICONS'			=> ($config['enable_pm_icons']) ? true : false)
);
}

				'S_PM_ICONS'			=> ($config['enable_pm_icons']) ? true : false)
);
}

Line 267Line 204
		else
{
// Build Recipient List if in outbox/sentbox

		else
{
// Build Recipient List if in outbox/sentbox

			$address = array();




$address_temp = $address = $data = array();


			if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX)
{
foreach ($folder_info['rowset'] as $message_id => $row)
{

			if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX)
{
foreach ($folder_info['rowset'] as $message_id => $row)
{

					$address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address']));


					$address_temp[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address']));
$address[$message_id] = array();

				}
}


				}
}


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

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

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

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

					{

					{

 
						if (!isset($address[$message_id][$ug_type]))
{
$address[$message_id][$ug_type] = array();
}

						if ($ug_type == 'u')
{
$sql = 'SELECT user_id as id, username as name

						if ($ug_type == 'u')
{
$sql = 'SELECT user_id as id, username as name

Line 310Line 254
								FROM ' . GROUPS_TABLE . '
WHERE ';
}

								FROM ' . GROUPS_TABLE . '
WHERE ';
}

						$sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address[$message_id][$ug_type])));

						$sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address_temp[$message_id][$ug_type])));


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

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


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

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

							$address[$message_id][$ug_type][$address[$message_id][$ug_type][$info_row['id']]][] = $info_row['name'];
unset($address[$message_id][$ug_type][$info_row['id']]);

							$address[$message_id][$ug_type][$address_temp[$message_id][$ug_type][$info_row['id']]][] = $info_row['name'];
unset($address_temp[$message_id][$ug_type][$info_row['id']]);

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

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

 
				}

// There is the chance that all recipients of the message got deleted. To avoid creating
// exports without recipients, we add a bogus "undisclosed recipient".
if (!(isset($address[$message_id]['g']) && sizeof($address[$message_id]['g'])) &&
!(isset($address[$message_id]['u']) && sizeof($address[$message_id]['u'])))
{
$address[$message_id]['u'] = array();
$address[$message_id]['u']['to'] = array();
$address[$message_id]['u']['to'][] = $user->lang['UNDISCLOSED_RECIPIENT'];

				}

decode_message($message_row['message_text'], $message_row['bbcode_uid']);

				}

decode_message($message_row['message_text'], $message_row['bbcode_uid']);

Line 328Line 282
				$data[] = array(
'subject' => censor_text($row['message_subject']),
'sender' => $row['username'],

				$data[] = array(
'subject' => censor_text($row['message_subject']),
'sender' => $row['username'],

					'date'		=> $user->format_date($row['message_time']),


					// ISO 8601 date. For PHP4 we are able to hardcode the timezone because $user->format_date() does not set it.
'date' => $user->format_date($row['message_time'], (PHP_VERSION >= 5) ? 'c' : "Y-m-d\TH:i:s+00:00", true),

					'to'		=> ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? $address[$message_id] : '',
'message' => $message_row['message_text']
);

					'to'		=> ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? $address[$message_id] : '',
'message' => $message_row['message_text']
);

Line 456Line 411
	if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX)
{
$sort_by_text = array('t' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);

	if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX)
{
$sort_by_text = array('t' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);

		$sort_by_sql = array('t' => 'p.msg_id', 's' => 'p.message_subject');

		$sort_by_sql = array('t' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time'));

	}
else
{
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);

	}
else
{
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);

		$sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.msg_id', 's' => 'p.message_subject');

		$sort_by_sql = array('a' => array('u.username_clean', 'p.message_time'), 't' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time'));

	}

$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';

	}

$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';

Line 502Line 457
		'PAGE_NUMBER'		=> on_page($pm_count, $config['topics_per_page'], $start),
'TOTAL_MESSAGES' => (($pm_count == 1) ? $user->lang['VIEW_PM_MESSAGE'] : sprintf($user->lang['VIEW_PM_MESSAGES'], $pm_count)),


		'PAGE_NUMBER'		=> on_page($pm_count, $config['topics_per_page'], $start),
'TOTAL_MESSAGES' => (($pm_count == 1) ? $user->lang['VIEW_PM_MESSAGE'] : sprintf($user->lang['VIEW_PM_MESSAGES'], $pm_count)),


		'POST_IMG'		=> (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'PM_LOCKED') : $user->img('button_pm_new', 'POST_PM'),

		'POST_IMG'		=> (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'POST_PM_LOCKED') : $user->img('button_pm_new', 'POST_NEW_PM'),





		'L_NO_MESSAGES'	=> (!$auth->acl_get('u_sendpm')) ? $user->lang['POST_PM_LOCKED'] : $user->lang['NO_MESSAGES'],

		'S_NO_AUTH_SEND_MESSAGE'	=> !$auth->acl_get('u_sendpm'),


'S_SELECT_SORT_DIR' => $s_sort_dir,
'S_SELECT_SORT_KEY' => $s_sort_key,


'S_SELECT_SORT_DIR' => $s_sort_dir,
'S_SELECT_SORT_KEY' => $s_sort_key,

Line 512Line 467
		'S_TOPIC_ICONS'			=> ($config['enable_pm_icons']) ? true : false,

'U_POST_NEW_TOPIC' => ($auth->acl_get('u_sendpm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose') : '',

		'S_TOPIC_ICONS'			=> ($config['enable_pm_icons']) ? true : false,

'U_POST_NEW_TOPIC' => ($auth->acl_get('u_sendpm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose') : '',

		'S_PM_ACTION'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&amp;mode=view&amp;action=view_folder&amp;f=$folder_id"))
);

		'S_PM_ACTION'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&amp;mode=view&amp;action=view_folder&amp;f=$folder_id" . (($start !== 0) ? "&amp;start=$start" : '')),
));


// Grab all pm data
$rowset = $pm_list = array();


// Grab all pm data
$rowset = $pm_list = array();

Line 531Line 486
		}

// Select the sort order

		}

// Select the sort order

		$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC');

		$direction = ($sort_dir == 'd') ? 'ASC' : 'DESC';

		$sql_start = max(0, $pm_count - $sql_limit - $start);
}
else
{
// Select the sort order

		$sql_start = max(0, $pm_count - $sql_limit - $start);
}
else
{
// Select the sort order

		$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');

		$direction = ($sort_dir == 'd') ? 'DESC' : 'ASC';

		$sql_start = $start;
}


		$sql_start = $start;
}


	$sql = 'SELECT t.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.username_clean, u.user_colour











	// Sql sort order
if (is_array($sort_by_sql[$sort_key]))
{
$sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
}
else
{
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
}

$sql = 'SELECT t.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.username_clean, u.user_colour, p.message_reported

		FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u
WHERE t.user_id = $user_id
AND p.author_id = u.user_id

		FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u
WHERE t.user_id = $user_id
AND p.author_id = u.user_id

Line 551Line 516
		ORDER BY $sql_sort_order";
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);


		ORDER BY $sql_sort_order";
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);


 
	$pm_reported = array();

	while ($row = $db->sql_fetchrow($result))
{
$rowset[$row['msg_id']] = $row;
$pm_list[] = $row['msg_id'];

	while ($row = $db->sql_fetchrow($result))
{
$rowset[$row['msg_id']] = $row;
$pm_list[] = $row['msg_id'];

 
		if ($row['message_reported'])
{
$pm_reported[] = $row['msg_id'];
}

	}
$db->sql_freeresult($result);

	}
$db->sql_freeresult($result);

 

// Fetch the report_ids, if there are any reported pms.
if (!empty($pm_reported) && $auth->acl_getf_global('m_report'))
{
$sql = 'SELECT pm_id, report_id
FROM ' . REPORTS_TABLE . '
WHERE report_closed = 0
AND ' . $db->sql_in_set('pm_id', $pm_reported);
$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
$rowset[$row['pm_id']]['report_id'] = $row['report_id'];
}
$db->sql_freeresult($result);
}


$pm_list = ($store_reverse) ? array_reverse($pm_list) : $pm_list;



$pm_list = ($store_reverse) ? array_reverse($pm_list) : $pm_list;