phpBB

Code Changes

File: includes/ucp/ucp_pm_compose.php

  Unmodified   Added   Modified   Removed
Line 20Line 20
* Compose private message
* Called from ucp_pm with mode == 'compose'
*/

* Compose private message
* Called from ucp_pm with mode == 'compose'
*/

function compose_pm($id, $mode, $action)

function compose_pm($id, $mode, $action, $user_folders = array())

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

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

Line 45Line 45
	$msg_id			= request_var('p', 0);
$draft_id = request_var('d', 0);
$lastclick = request_var('lastclick', 0);

	$msg_id			= request_var('p', 0);
$draft_id = request_var('d', 0);
$lastclick = request_var('lastclick', 0);

 

// Reply to all triggered (quote/reply)
$reply_to_all = request_var('reply_to_all', 0);


// Do NOT use request_var or specialchars here
$address_list = isset($_REQUEST['address_list']) ? $_REQUEST['address_list'] : array();


// Do NOT use request_var or specialchars here
$address_list = isset($_REQUEST['address_list']) ? $_REQUEST['address_list'] : array();

Line 84Line 87
		}
redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm'));
}

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

 

// Since viewtopic.php language entries are used in several modes,
// we include the language file here
$user->add_lang('viewtopic');


// Output PM_TO box if message composing
if ($action != 'edit')


// Output PM_TO box if message composing
if ($action != 'edit')

Line 128Line 135
	}

$sql = '';

	}

$sql = '';

 
	$folder_id = 0;


// What is all this following SQL for? Well, we need to know
// some basic information in all cases before we do anything.


// What is all this following SQL for? Well, we need to know
// some basic information in all cases before we do anything.

Line 258Line 266
			if (($post['forum_id'] && !$auth->acl_get('f_read', $post['forum_id'])) || (!$post['forum_id'] && !$auth->acl_getf_global('f_read')))
{
trigger_error('NOT_AUTHORISED');

			if (($post['forum_id'] && !$auth->acl_get('f_read', $post['forum_id'])) || (!$post['forum_id'] && !$auth->acl_getf_global('f_read')))
{
trigger_error('NOT_AUTHORISED');

 
			}

// Passworded forum?
if ($post['forum_id'])
{
$sql = 'SELECT forum_id, forum_name, forum_password
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . (int) $post['forum_id'];
$result = $db->sql_query($sql);
$forum_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

if (!empty($forum_data['forum_password']))
{
login_forum_box($forum_data);
}

			}
}


			}
}


Line 291Line 315

if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !sizeof($address_list) && !$refresh && !$submit && !$preview)
{


if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !sizeof($address_list) && !$refresh && !$submit && !$preview)
{

				if ($action == 'quotepost')


				// Add the original author as the recipient if quoting a post or only replying and not having checked "reply to all"
if ($action == 'quotepost' || !$reply_to_all)

				{
$address_list = array('u' => array($post['author_id'] => 'to'));
}
else
{

				{
$address_list = array('u' => array($post['author_id'] => 'to'));
}
else
{

					// We try to include every previously listed member from the TO Header

					// We try to include every previously listed member from the TO Header - Reply to all

					$address_list = rebuild_header(array('to' => $post['to_address']));

// Add the author (if he is already listed then this is no shame (it will be overwritten))

					$address_list = rebuild_header(array('to' => $post['to_address']));

// Add the author (if he is already listed then this is no shame (it will be overwritten))

Line 331Line 356
		$message_attachment = 0;
$message_text = $message_subject = '';


		$message_attachment = 0;
$message_text = $message_subject = '';


		if ($to_user_id && $action == 'post')

		if ($to_user_id && $to_user_id != ANONYMOUS && $action == 'post')

		{
$address_list['u'][$to_user_id] = 'to';
}

		{
$address_list['u'][$to_user_id] = 'to';
}

Line 371Line 396
	unset($message_text);

$s_action = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=$mode&action=$action", true, $user->session_id);

	unset($message_text);

$s_action = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=$mode&action=$action", true, $user->session_id);

	$s_action .= ($msg_id) ? "&p=$msg_id" : '';

	$s_action .= (($folder_id) ? "&f=$folder_id" : '') . (($msg_id) ? "&p=$msg_id" : '');


// Delete triggered ?
if ($action == 'delete')


// Delete triggered ?
if ($action == 'delete')

Line 420Line 445
	$max_recipients = (!$max_recipients) ? $config['pm_max_recipients'] : $max_recipients;

// If this is a quote/reply "to all"... we may increase the max_recpients to the number of original recipients

	$max_recipients = (!$max_recipients) ? $config['pm_max_recipients'] : $max_recipients;

// If this is a quote/reply "to all"... we may increase the max_recpients to the number of original recipients

	if (($action == 'reply' || $action == 'quote') && $max_recipients)

	if (($action == 'reply' || $action == 'quote') && $max_recipients && $reply_to_all)

	{
// We try to include every previously listed member from the TO Header
$list = rebuild_header(array('to' => $post['to_address']));

	{
// We try to include every previously listed member from the TO Header
$list = rebuild_header(array('to' => $post['to_address']));

		$list = $list['u'];




// Can be an empty array too ;)
$list = (!empty($list['u'])) ? $list['u'] : array();

		$list[$post['author_id']] = 'to';

if (isset($list[$user->data['user_id']]))

		$list[$post['author_id']] = 'to';

if (isset($list[$user->data['user_id']]))

Line 610Line 637
	// Load Drafts
if ($load && $drafts)
{

	// Load Drafts
if ($load && $drafts)
{

		load_drafts(0, 0, $id);

		load_drafts(0, 0, $id, $action, $msg_id);

	}

if ($submit || $preview || $refresh)

	}

if ($submit || $preview || $refresh)

Line 712Line 739
			$msg_id = submit_pm($action, $subject, $pm_data);

$return_message_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=view&p=' . $msg_id);

			$msg_id = submit_pm($action, $subject, $pm_data);

$return_message_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=view&p=' . $msg_id);

			$return_folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=outbox');
meta_refresh(3, $return_message_url);

			$inbox_folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox');
$outbox_folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=outbox');





			$message = $user->lang['MESSAGE_STORED'] . '<br /><br />' . sprintf($user->lang['VIEW_PRIVATE_MESSAGE'], '<a href="' . $return_message_url . '">', '</a>') . '<br /><br />' . sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . $return_folder_url . '">', '</a>', $user->lang['PM_OUTBOX']);






















			$folder_url = '';
if (($folder_id > 0) && isset($user_folders[$folder_id]))
{
$folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;folder=' . $folder_id);
}

$return_box_url = ($action === 'post' || $action === 'edit') ? $outbox_folder_url : $inbox_folder_url;
$return_box_lang = ($action === 'post' || $action === 'edit') ? 'PM_OUTBOX' : 'PM_INBOX';


$save_message = ($action === 'edit') ? $user->lang['MESSAGE_EDITED'] : $user->lang['MESSAGE_STORED'];
$message = $save_message . '<br /><br />' . $user->lang('VIEW_PRIVATE_MESSAGE', '<a href="' . $return_message_url . '">', '</a>');

$last_click_type = 'CLICK_RETURN_FOLDER';
if ($folder_url)
{
$message .= '<br /><br />' . sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . $folder_url . '">', '</a>', $user_folders[$folder_id]['folder_name']);
$last_click_type = 'CLICK_GOTO_FOLDER';
}
$message .= '<br /><br />' . sprintf($user->lang[$last_click_type], '<a href="' . $return_box_url . '">', '</a>', $user->lang[$return_box_lang]);

meta_refresh(3, $return_message_url);

			trigger_error($message);
}


			trigger_error($message);
}


Line 725Line 773
	// Preview
if (!sizeof($error) && $preview)
{

	// Preview
if (!sizeof($error) && $preview)
{

		$user->add_lang('viewtopic');

 
		$preview_message = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);

$preview_signature = $user->data['user_sig'];

		$preview_message = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);

$preview_signature = $user->data['user_sig'];

Line 739Line 786
			$parse_sig->bbcode_uid = $preview_signature_uid;
$parse_sig->bbcode_bitfield = $preview_signature_bitfield;


			$parse_sig->bbcode_uid = $preview_signature_uid;
$parse_sig->bbcode_bitfield = $preview_signature_bitfield;


			$parse_sig->format_display($enable_bbcode, $enable_urls, $enable_smilies);

			$parse_sig->format_display($config['allow_sig_bbcode'], $config['allow_sig_links'], $config['allow_sig_smilies']);

			$preview_signature = $parse_sig->message;
unset($parse_sig);
}

			$preview_signature = $parse_sig->message;
unset($parse_sig);
}

Line 783Line 830
	}

// Decode text for message display

	}

// Decode text for message display

	$bbcode_uid = (($action == 'quote' || $action == 'forward') && !$preview && !$refresh && !sizeof($error)) ? $bbcode_uid : $message_parser->bbcode_uid;

	$bbcode_uid = (($action == 'quote' || $action == 'forward') && !$preview && !$refresh && (!sizeof($error) || (sizeof($error) && !$submit))) ? $bbcode_uid : $message_parser->bbcode_uid;


$message_parser->decode_message($bbcode_uid);



$message_parser->decode_message($bbcode_uid);


Line 829Line 876
		$forward_text = array();
$forward_text[] = $user->lang['FWD_ORIGINAL_MESSAGE'];
$forward_text[] = sprintf($user->lang['FWD_SUBJECT'], censor_text($message_subject));

		$forward_text = array();
$forward_text[] = $user->lang['FWD_ORIGINAL_MESSAGE'];
$forward_text[] = sprintf($user->lang['FWD_SUBJECT'], censor_text($message_subject));

		$forward_text[] = sprintf($user->lang['FWD_DATE'], $user->format_date($message_time));

		$forward_text[] = sprintf($user->lang['FWD_DATE'], $user->format_date($message_time, false, true));

		$forward_text[] = sprintf($user->lang['FWD_FROM'], $quote_username_text);
$forward_text[] = sprintf($user->lang['FWD_TO'], implode(', ', $fwd_to_field['to']));


		$forward_text[] = sprintf($user->lang['FWD_FROM'], $quote_username_text);
$forward_text[] = sprintf($user->lang['FWD_TO'], implode(', ', $fwd_to_field['to']));


Line 1018Line 1065
		'FLASH_STATUS'			=> ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
'URL_STATUS' => ($url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],

		'FLASH_STATUS'			=> ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
'URL_STATUS' => ($url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],

 
		'MAX_FONT_SIZE'			=> (int) $config['max_post_font_size'],

		'MINI_POST_IMG'			=> $user->img('icon_post_target', $user->lang['PM']),
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
'MAX_RECIPIENTS' => ($config['allow_mass_pm'] && ($auth->acl_get('u_masspm') || $auth->acl_get('u_masspm_group'))) ? $max_recipients : 0,

		'MINI_POST_IMG'			=> $user->img('icon_post_target', $user->lang['PM']),
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
'MAX_RECIPIENTS' => ($config['allow_mass_pm'] && ($auth->acl_get('u_masspm') || $auth->acl_get('u_masspm_group'))) ? $max_recipients : 0,

Line 1025Line 1073
		'S_COMPOSE_PM'			=> true,
'S_EDIT_POST' => ($action == 'edit'),
'S_SHOW_PM_ICONS' => $s_pm_icons,

		'S_COMPOSE_PM'			=> true,
'S_EDIT_POST' => ($action == 'edit'),
'S_SHOW_PM_ICONS' => $s_pm_icons,

		'S_BBCODE_ALLOWED'		=> $bbcode_status,

		'S_BBCODE_ALLOWED'		=> ($bbcode_status) ? 1 : 0,

		'S_BBCODE_CHECKED'		=> ($bbcode_checked) ? ' checked="checked"' : '',
'S_SMILIES_ALLOWED' => $smilies_status,
'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '',

		'S_BBCODE_CHECKED'		=> ($bbcode_checked) ? ' checked="checked"' : '',
'S_SMILIES_ALLOWED' => $smilies_status,
'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '',

Line 1103Line 1151
	$group_list = request_var('group_list', array(0));

// Build usernames to add

	$group_list = request_var('group_list', array(0));

// Build usernames to add

	$usernames = (isset($_REQUEST['username'])) ? array(request_var('username', '', true)) : array();



	$usernames = request_var('username', '', true);
$usernames = (empty($usernames)) ? array() : array($usernames);


	$username_list = request_var('username_list', '', true);
if ($username_list)
{

	$username_list = request_var('username_list', '', true);
if ($username_list)
{

Line 1117Line 1167

global $refresh, $submit, $preview;



global $refresh, $submit, $preview;


		$refresh = $preview = true;

		$refresh = true;

		$submit = false;

		$submit = false;

 

// Preview is only true if there was also a message entered
if (request_var('message', ''))
{
$preview = true;
}

	}

// Add User/Group [TO]

	}

// Add User/Group [TO]