phpBB

Code Changes

File: includes/ucp/ucp_pm_compose.php

  Unmodified   Added   Modified   Removed
Line 26Line 26
function compose_pm($id, $mode, $action, $user_folders = array())
{
global $template, $db, $auth, $user, $cache;

function compose_pm($id, $mode, $action, $user_folders = array())
{
global $template, $db, $auth, $user, $cache;

	global $phpbb_root_path, $phpEx, $config;

	global $phpbb_root_path, $phpEx, $config, $language;

	global $request, $phpbb_dispatcher, $phpbb_container;

// Damn php and globals - i know, this is horrible
// Needed for handle_message_list_actions()
global $refresh, $submit, $preview;


	global $request, $phpbb_dispatcher, $phpbb_container;

// Damn php and globals - i know, this is horrible
// Needed for handle_message_list_actions()
global $refresh, $submit, $preview;


 
	if (!function_exists('generate_smilies'))
{

	include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);

	include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);

 
	}

if (!function_exists('display_custom_bbcodes'))
{

	include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

	include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

 
	}

if (!class_exists('parse_message'))
{

	include($phpbb_root_path . 'includes/message_parser.' . $phpEx);

	include($phpbb_root_path . 'includes/message_parser.' . $phpEx);

 
	}


if (!$action)
{


if (!$action)
{

Line 48Line 59
	$to_group_id	= $request->variable('g', 0);
$msg_id = $request->variable('p', 0);
$draft_id = $request->variable('d', 0);

	$to_group_id	= $request->variable('g', 0);
$msg_id = $request->variable('p', 0);
$draft_id = $request->variable('d', 0);

	$lastclick		= $request->variable('lastclick', 0);

 

// Reply to all triggered (quote/reply)
$reply_to_all = $request->variable('reply_to_all', 0);


// Reply to all triggered (quote/reply)
$reply_to_all = $request->variable('reply_to_all', 0);

Line 80Line 90
	$group_helper = $phpbb_container->get('group_helper');

// Was cancel pressed? If so then redirect to the appropriate page

	$group_helper = $phpbb_container->get('group_helper');

// Was cancel pressed? If so then redirect to the appropriate page

	if ($cancel || ($current_time - $lastclick < 2 && $submit))

	if ($cancel)

	{
if ($msg_id)
{

	{
if ($msg_id)
{

Line 125Line 135
		// Add groups to PM box
if ($config['allow_mass_pm'] && $auth->acl_get('u_masspm_group'))
{

		// Add groups to PM box
if ($config['allow_mass_pm'] && $auth->acl_get('u_masspm_group'))
{

			$sql = 'SELECT g.group_id, g.group_name, g.group_type

			$sql = 'SELECT g.group_id, g.group_name, g.group_type, g.group_colour

				FROM ' . GROUPS_TABLE . ' g';

if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))

				FROM ' . GROUPS_TABLE . ' g';

if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))

Line 148Line 158
			$group_options = '';
while ($row = $db->sql_fetchrow($result))
{

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

				$group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . $group_helper->get_name($row['group_name']) . '</option>';

				$group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '"' . ($row['group_colour'] ? ' style="color: #' . $row['group_colour'] . '"' : '') . '>' . $group_helper->get_name($row['group_name']) . '</option>';

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

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

Line 298Line 308
		$result = $db->sql_query($sql);
$post = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

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

 

/**
* Alter the row of the post being quoted when composing a private message
*
* @event core.ucp_pm_compose_compose_pm_basic_info_query_after
* @var array post Array with data of the post being quoted
* @var int msg_id topic_id in the page request
* @var int to_user_id The id of whom the message is to
* @var int to_group_id The id of the group whom the message is to
* @var bool submit Whether the user is sending the PM or not
* @var bool preview Whether the user is previewing the PM or not
* @var string action One of: post, reply, quote, forward, quotepost, edit, delete, smilies
* @var bool delete Whether the user is deleting the PM
* @var int reply_to_all Value of reply_to_all request variable.
* @since 3.2.10-RC1
* @since 3.3.1-RC1
*/
$vars = [
'post',
'msg_id',
'to_user_id',
'to_group_id',
'submit',
'preview',
'action',
'delete',
'reply_to_all',
];
extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_compose_pm_basic_info_query_after', compact($vars)));


if (!$post)
{


if (!$post)
{

Line 654Line 693
		$subject = $request->variable('subject', '', true);
$subject = (!$subject && $action != 'post') ? $user->lang['NEW_MESSAGE'] : $subject;
$message = $request->variable('message', '', true);

		$subject = $request->variable('subject', '', true);
$subject = (!$subject && $action != 'post') ? $user->lang['NEW_MESSAGE'] : $subject;
$message = $request->variable('message', '', true);

 

/**
* Replace Emojis and other 4bit UTF-8 chars not allowed by MySQL to UCR/NCR.
* Using their Numeric Character Reference's Hexadecimal notation.
*/
$subject = utf8_encode_ucr($subject);


if ($subject && $message)
{
if (confirm_box(true))
{


if ($subject && $message)
{
if (confirm_box(true))
{

 
				$message_parser->message = $message;
$message_parser->parse($bbcode_status, $url_status, $smilies_status, $img_status, $flash_status, true, $url_status);


				$sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'user_id' => $user->data['user_id'],
'topic_id' => 0,
'forum_id' => 0,
'save_time' => $current_time,
'draft_subject' => $subject,

				$sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'user_id' => $user->data['user_id'],
'topic_id' => 0,
'forum_id' => 0,
'save_time' => $current_time,
'draft_subject' => $subject,

					'draft_message'	=> $message

					'draft_message'	=> $message_parser->message,

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

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

 

/** @var \phpbb\attachment\manager $attachment_manager */
$attachment_manager = $phpbb_container->get('attachment.manager');
$attachment_manager->delete('attach', array_column($message_parser->attachment_data, 'attach_id'));


$redirect_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&amp;mode=$mode");



$redirect_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&amp;mode=$mode");


Line 687Line 739
					'message'	=> $message,
'u' => $to_user_id,
'g' => $to_group_id,

					'message'	=> $message,
'u' => $to_user_id,
'g' => $to_group_id,

					'p'			=> $msg_id)
);


					'p'			=> $msg_id,
'attachment_data' => $message_parser->attachment_data,
));

				$s_hidden_fields .= build_address_field($address_list);

confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields);

				$s_hidden_fields .= build_address_field($address_list);

confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields);

Line 786Line 839
		extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_modify_parse_before', compact($vars)));

// Parse Attachments - before checksum is calculated

		extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_modify_parse_before', compact($vars)));

// Parse Attachments - before checksum is calculated

 
		if ($message_parser->check_attachment_form_token($language, $request, 'ucp_pm_compose'))
{

		$message_parser->parse_attachments('fileupload', $action, 0, $submit, $preview, $refresh, true);

		$message_parser->parse_attachments('fileupload', $action, 0, $submit, $preview, $refresh, true);

 
		}


if (count($message_parser->warn_msg) && !($remove_u || $remove_g || $add_to || $add_bcc))
{


if (count($message_parser->warn_msg) && !($remove_u || $remove_g || $add_to || $add_bcc))
{

Line 830Line 886
				$error[] = $user->lang['NO_RECIPIENT'];
}
}

				$error[] = $user->lang['NO_RECIPIENT'];
}
}

 

/**
* Modify private message
*
* @event core.ucp_pm_compose_modify_parse_after
* @var bool enable_bbcode Whether or not bbcode is enabled
* @var bool enable_smilies Whether or not smilies are enabled
* @var bool enable_urls Whether or not urls are enabled
* @var bool enable_sig Whether or not signature is enabled
* @var string subject PM subject text
* @var object message_parser The message parser object
* @var bool submit Whether or not the form has been sumitted
* @var bool preview Whether or not the signature is being previewed
* @var array error Any error strings
* @since 3.2.10-RC1
* @since 3.3.1-RC1
*/
$vars = [
'enable_bbcode',
'enable_smilies',
'enable_urls',
'enable_sig',
'subject',
'message_parser',
'submit',
'preview',
'error',
];
extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_modify_parse_after', compact($vars)));


// Store message, sync counters
if (!count($error) && $submit)


// Store message, sync counters
if (!count($error) && $submit)

Line 853Line 938
				'filename_data'			=> $message_parser->filename_data,
'address_list' => $address_list
);

				'filename_data'			=> $message_parser->filename_data,
'address_list' => $address_list
);

 

/**
* Replace Emojis and other 4bit UTF-8 chars not allowed by MySQL to UCR/NCR.
* Using their Numeric Character Reference's Hexadecimal notation.
*/
$subject = utf8_encode_ucr($subject);


// ((!$message_subject) ? $subject : $message_subject)
$msg_id = submit_pm($action, $subject, $pm_data);


// ((!$message_subject) ? $subject : $message_subject)
$msg_id = submit_pm($action, $subject, $pm_data);

Line 954Line 1045
			$post_id = $request->variable('p', 0);
if ($config['allow_post_links'])
{

			$post_id = $request->variable('p', 0);
if ($config['allow_post_links'])
{

				$message_link = "[url=" . generate_board_url() . "/viewtopic.$phpEx?p={$post_id}#p{$post_id}]{$user->lang['SUBJECT']}{$user->lang['COLON']} {$message_subject}[/url]\n\n";










				$message_link = generate_board_url() . "/viewtopic.$phpEx?p={$post_id}#p{$post_id}";
$message_link_subject = "{$user->lang['SUBJECT']}{$user->lang['COLON']} {$message_subject}";
if ($bbcode_status)
{
$message_link = "[url=" . $message_link . "]" . $message_link_subject . "[/url]\n\n";
}
else
{
$message_link = $message_link . " - " . $message_link_subject . "\n\n";
}

			}
else
{

			}
else
{

Line 974Line 1074
		{
$quote_attributes['post_id'] = $post['msg_id'];
}

		{
$quote_attributes['post_id'] = $post['msg_id'];
}

		$quote_text = $phpbb_container->get('text_formatter.utils')->generate_quote(
censor_text($message_parser->message),
$quote_attributes
);
$message_parser->message = $message_link . $quote_text . "\n\n";





		if ($action === 'quote')
{
$quote_attributes['msg_id'] = $post['msg_id'];
}
/** @var \phpbb\language\language $language */
$language = $phpbb_container->get('language');
/** @var \phpbb\textformatter\utils_interface $text_formatter_utils */
$text_formatter_utils = $phpbb_container->get('text_formatter.utils');
phpbb_format_quote($language, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link);

	}

if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !$preview && !$refresh)
{
$message_subject = ((!preg_match('/^Re:/', $message_subject)) ? 'Re: ' : '') . censor_text($message_subject);

	}

if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !$preview && !$refresh)
{
$message_subject = ((!preg_match('/^Re:/', $message_subject)) ? 'Re: ' : '') . censor_text($message_subject);

 

/**
* This event allows you to modify the PM subject of the PM being quoted
*
* @event core.pm_modify_message_subject
* @var string message_subject String with the PM subject already censored.
* @since 3.2.8-RC1
*/
$vars = array('message_subject');
extract($phpbb_dispatcher->trigger_event('core.pm_modify_message_subject', compact($vars)));

	}

if ($action == 'forward' && !$preview && !$refresh && !$submit)

	}

if ($action == 'forward' && !$preview && !$refresh && !$submit)

Line 1174Line 1288
		break;
}


		break;
}


	$s_hidden_fields = '<input type="hidden" name="lastclick" value="' . $current_time . '" />';
$s_hidden_fields .= (isset($check_value)) ? '<input type="hidden" name="status_switch" value="' . $check_value . '" />' : '';

	$s_hidden_fields = (isset($check_value)) ? '<input type="hidden" name="status_switch" value="' . $check_value . '" />' : '';


	$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '<input type="hidden" name="draft_loaded" value="' . ((isset($_REQUEST['draft_loaded'])) ? $request->variable('draft_loaded', 0) : $draft_id) . '" />' : '';

$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_pm_attach'] || !$auth->acl_get('u_pm_attach')) ? '' : ' enctype="multipart/form-data"';

	$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '<input type="hidden" name="draft_loaded" value="' . ((isset($_REQUEST['draft_loaded'])) ? $request->variable('draft_loaded', 0) : $draft_id) . '" />' : '';

$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_pm_attach'] || !$auth->acl_get('u_pm_attach')) ? '' : ' enctype="multipart/form-data"';

Line 1184Line 1297
	$controller_helper = $phpbb_container->get('controller.helper');

// Start assigning vars for main posting page ...

	$controller_helper = $phpbb_container->get('controller.helper');

// Start assigning vars for main posting page ...

	$template->assign_vars(array(

	$template_ary = array(

		'L_POST_A'					=> $page_title,
'L_ICON' => $user->lang['PM_ICON'],
'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']),

		'L_POST_A'					=> $page_title,
'L_ICON' => $user->lang['PM_ICON'],
'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']),

Line 1229Line 1342
		'S_CLOSE_PROGRESS_WINDOW'	=> isset($_POST['add_file']),
'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", 'f=0&amp;mode=popup'),
'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", 'f=0&amp;mode=popup')),

		'S_CLOSE_PROGRESS_WINDOW'	=> isset($_POST['add_file']),
'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", 'f=0&amp;mode=popup'),
'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", 'f=0&amp;mode=popup')),

	));













	);

/**
* Modify the default template vars
*
* @event core.ucp_pm_compose_template
* @var array template_ary Template variables
* @since 3.2.6-RC1
*/
$vars = array('template_ary');
extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_template', compact($vars)));

$template->assign_vars($template_ary);


// Build custom bbcodes array
display_custom_bbcodes();


// Build custom bbcodes array
display_custom_bbcodes();

Line 1262Line 1387
function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove_g, $add_to, $add_bcc)
{
global $auth, $db, $user;

function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove_g, $add_to, $add_bcc)
{
global $auth, $db, $user;

	global $request;

	global $request, $phpbb_dispatcher;


// Delete User [TO/BCC]
if ($remove_u && $request->variable('remove_u', array(0 => '')))


// Delete User [TO/BCC]
if ($remove_u && $request->variable('remove_u', array(0 => '')))

Line 1439Line 1564
			$error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION'];
}
}

			$error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION'];
}
}

 

/**
* Event for additional message list actions
*
* @event core.message_list_actions
* @var array address_list The assoc array with the recipient user/group ids
* @var array error The array containing error data
* @var bool remove_u The variable for removing a user
* @var bool remove_g The variable for removing a group
* @var bool add_to The variable for adding a user to the [TO] field
* @var bool add_bcc The variable for adding a user to the [BCC] field
* @since 3.2.4-RC1
*/
$vars = array('address_list', 'error', 'remove_u', 'remove_g', 'add_to', 'add_bcc');
extract($phpbb_dispatcher->trigger_event('core.message_list_actions', compact($vars)));

}

/**

}

/**