aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/functions_privmsgs.php1039
-rw-r--r--phpBB/includes/session.php3
-rw-r--r--phpBB/includes/ucp/ucp_pm.php292
-rw-r--r--phpBB/includes/ucp/ucp_pm_compose.php1176
-rw-r--r--phpBB/includes/ucp/ucp_pm_options.php543
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewfolder.php343
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewmessage.php471
-rw-r--r--phpBB/language/en/common.php3
-rw-r--r--phpBB/language/en/ucp.php4
-rw-r--r--phpBB/styles/subSilver/template/ucp_header.html74
-rw-r--r--phpBB/styles/subSilver/template/ucp_pm_history.html67
-rw-r--r--phpBB/styles/subSilver/template/ucp_pm_message_footer.html39
-rw-r--r--phpBB/styles/subSilver/template/ucp_pm_message_header.html46
-rw-r--r--phpBB/styles/subSilver/template/ucp_pm_options.html170
-rw-r--r--phpBB/styles/subSilver/template/ucp_pm_viewfolder.html83
-rw-r--r--phpBB/styles/subSilver/template/ucp_pm_viewmessage.html182
-rw-r--r--phpBB/styles/subSilver/template/ucp_pm_viewmessage_print.html127
17 files changed, 4652 insertions, 10 deletions
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
new file mode 100644
index 0000000000..ad7502cb12
--- /dev/null
+++ b/phpBB/includes/functions_privmsgs.php
@@ -0,0 +1,1039 @@
+<?php
+// -------------------------------------------------------------
+//
+// $Id$
+//
+// FILENAME : functions_privmsgs.php
+// STARTED : Sun Apr 18, 2004
+// COPYRIGHT : © 2004 phpBB Group
+// WWW : http://www.phpbb.com/
+// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
+//
+// -------------------------------------------------------------
+
+// Define Rule processing scheme
+// NOTE: might change
+
+/*
+ Ability to simply add own rules by doing three things:
+ 1) Add an appropiate constant
+ 2) Add a new check array to the global_privmsgs_rules variable and the condition array (if one is required)
+ 3) Add a new language variable to ucp.php
+
+ The user is then able to select the new rule. It will be checked agains and handled as specified.
+ To add new actions (yes, checks can be added here too) to the rule management, the core code has to be modified.
+*/
+
+define('RULE_IS_LIKE', 1); // Is Like
+define('RULE_IS_NOT_LIKE', 2); // Is Not Like
+define('RULE_IS', 3); // Is
+define('RULE_IS_NOT', 4); // Is Not
+define('RULE_BEGINS_WITH', 5); // Begins with
+define('RULE_ENDS_WITH', 6); // Ends with
+define('RULE_IS_FRIEND', 7); // Is Friend
+define('RULE_IS_FOE', 8); // Is Foe
+define('RULE_IS_USER', 9); // Is User
+define('RULE_IS_GROUP', 10); // Is In Usergroup
+define('RULE_ANSWERED', 11); // Answered
+define('RULE_FORWARDED', 12); // Forwarded
+define('RULE_REPORTED', 13); // Reported
+define('RULE_TO_GROUP', 14); // Usergroup
+define('RULE_TO_ME', 15); // Me
+
+define('ACTION_PLACE_INTO_FOLDER', 1);
+define('ACTION_MARK_AS_READ', 2);
+define('ACTION_MARK_AS_IMPORTANT', 3);
+define('ACTION_DELETE_MESSAGE', 4);
+
+define('CHECK_SUBJECT', 1);
+define('CHECK_SENDER', 2);
+define('CHECK_MESSAGE', 3);
+define('CHECK_STATUS', 4);
+define('CHECK_TO', 5);
+
+$global_privmsgs_rules = array(
+ CHECK_SUBJECT => array(
+ RULE_IS_LIKE => array('check0' => 'message_subject', 'function' => 'preg_match("/" . preg_quote({STRING}) . "/i", {CHECK0})'),
+ RULE_IS_NOT_LIKE => array('check0' => 'message_subject', 'function' => '!(preg_match("/" . preg_quote({STRING}) . "/i", {CHECK0}))'),
+ RULE_IS => array('check0' => 'message_subject', 'function' => '{CHECK0} == {STRING}'),
+ RULE_IS_NOT => array('check0' => 'message_subject', 'function' => '{CHECK0} != {STRING}'),
+ RULE_BEGINS_WITH => array('check0' => 'message_subject', 'function' => 'preg_match("/^" . preg_quote({STRING}) . "/i", {CHECK0})'),
+ RULE_ENDS_WITH => array('check0' => 'message_subject', 'function' => 'preg_match("/" . preg_quote({STRING}) . "$/i", {CHECK0})')),
+
+ CHECK_SENDER => array(
+ RULE_IS_LIKE => array('check0' => 'username', 'function' => 'preg_match("/" . preg_quote({STRING}) . "/i", {CHECK0})'),
+ RULE_IS_NOT_LIKE => array('check0' => 'username', 'function' => '!(preg_match("/" . preg_quote({STRING}) . "/i", {CHECK0}))'),
+ RULE_IS => array('check0' => 'username', 'function' => '{CHECK0} == {STRING}'),
+ RULE_IS_NOT => array('check0' => 'username', 'function' => '{CHECK0} != {STRING}'),
+ RULE_BEGINS_WITH => array('check0' => 'username', 'function' => 'preg_match("/^" . preg_quote({STRING}) . "/i", {CHECK0})'),
+ RULE_ENDS_WITH => array('check0' => 'username', 'function' => 'preg_match("/" . preg_quote({STRING}) . "$/i", {CHECK0})'),
+ RULE_IS_FRIEND => array('check0' => 'friend', 'function' => '{CHECK0} == 1'),
+ RULE_IS_FOE => array('check0' => 'foe', 'function' => '{CHECK0} == 1'),
+ RULE_IS_USER => array('check0' => 'author_id', 'function' => '{CHECK0} == {USER_ID}'),
+ RULE_IS_GROUP => array('check0' => 'author_in_group', 'function' => '{CHECK0} == {GROUP_ID}')),
+
+ CHECK_MESSAGE => array(
+ RULE_IS_LIKE => array('check0' => 'message_text', 'function' => 'preg_match("/" . preg_quote({STRING}) . "/i", {CHECK0})'),
+ RULE_IS_NOT_LIKE => array('check0' => 'message_text', 'function' => '!(preg_match("/" . preg_quote({STRING}) . "/i", {CHECK0}))'),
+ RULE_IS => array('check0' => 'message_text', 'function' => '{CHECK0} == {STRING}'),
+ RULE_IS_NOT => array('check0' => 'message_text', 'function' => '{CHECK0} != {STRING}')),
+
+ CHECK_STATUS => array(
+ RULE_ANSWERED => array('check0' => 'replied', 'function' => '{CHECK0} == 1'),
+ RULE_FORWARDED => array('check0' => 'forwarded', 'function' => '{CHECK0} == 1'),
+ RULE_REPORTED => array('check0' => 'message_reported', 'function' => '{CHECK0} == 1')),
+
+ CHECK_TO => array(
+ RULE_TO_GROUP => array('check0' => 'to', 'check1' => 'bcc', 'check2' => 'user_in_group', 'function' => 'in_array("g_" . {CHECK2}, {CHECK0}) || in_array("g_" . {CHECK2}, {CHECK1})'),
+ RULE_TO_ME => array('check0' => 'to', 'check1' => 'bcc', 'function' => 'in_array("u_" . $user_id, {CHECK0}) || in_array("u_" . $user_id, {CHECK1})'))
+);
+
+// This is for defining which condition fields to show for which Rule
+$global_rule_conditions = array(
+ RULE_IS_LIKE => 'text',
+ RULE_IS_NOT_LIKE => 'text',
+ RULE_IS => 'text',
+ RULE_IS_NOT => 'text',
+ RULE_BEGINS_WITH => 'text',
+ RULE_ENDS_WITH => 'text',
+ RULE_IS_USER => 'user',
+ RULE_IS_GROUP => 'group'
+);
+
+// Get number of unread messages from all folder
+function get_unread_pm($user_id)
+{
+ global $db;
+
+ $unread_pm = array();
+
+ $sql = 'SELECT folder_id, SUM(unread) as sum_unread
+ FROM ' . PRIVMSGS_TO_TABLE . "
+ WHERE user_id = $user_id
+ AND folder_id <> " . PRIVMSGS_OUTBOX . '
+ GROUP BY folder_id';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($row['sum_unread'])
+ {
+ $unread_pm[$row['folder_id']] = $row['sum_unread'];
+ }
+ }
+ $db->sql_freeresult($result);
+
+ return $unread_pm;
+}
+
+// Get all folder
+function get_folder($user_id, &$folder)
+{
+ global $db, $user;
+
+ if (!is_array($folder))
+ {
+ $folder = array();
+ }
+
+ $sql = 'SELECT folder_id, COUNT(msg_id) as num_messages
+ FROM ' . PRIVMSGS_TO_TABLE . "
+ WHERE user_id = $user_id
+ AND folder_id <> " . PRIVMSGS_NO_BOX . '
+ GROUP BY folder_id';
+ $result = $db->sql_query($sql);
+
+ $num_messages = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $num_messages[(int) $row['folder_id']] = $row['num_messages'];
+ }
+ $db->sql_freeresult($result);
+
+ if (!isset($num_messages[PRIVMSGS_OUTBOX]))
+ {
+ $num_messages[PRIVMSGS_OUTBOX] = 0;
+ }
+
+ $folder[PRIVMSGS_INBOX] = array('folder_name' => $user->lang['PM_INBOX'], 'num_messages' => (int) $num_messages[PRIVMSGS_INBOX]);
+
+ $sql = 'SELECT folder_id, folder_name, pm_count
+ FROM ' . PRIVMSGS_FOLDER_TABLE . "
+ WHERE user_id = $user_id";
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $folder[$row['folder_id']] = array('folder_name' => $row['folder_name'], 'num_messages' => $row['pm_count']);
+ }
+ $db->sql_freeresult($result);
+
+ $folder[PRIVMSGS_OUTBOX] = array('folder_name' => $user->lang['PM_OUTBOX'], 'num_messages' => (int) $num_messages[PRIVMSGS_OUTBOX]);
+ $folder[PRIVMSGS_SENTBOX] = array('folder_name' => $user->lang['PM_SENTBOX'], 'num_messages' => (int) $num_messages[PRIVMSGS_SENTBOX]);
+
+ return;
+}
+
+// Delete Messages From Sentbox - we are doing this here because this saves us a bunch of checks and queries
+function clean_sentbox($num_sentbox_messages)
+{
+ global $db, $user, $config;
+
+ $message_limit = (!$user->data['group_message_limit']) ? $config['pm_max_msgs'] : $user->data['group_message_limit'];
+
+ // Check Message Limit -
+ if ($message_limit && $num_sentbox_messages > $message_limit)
+ {
+ // Delete old messages
+ $sql = 'SELECT t.msg_id
+ FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p
+ WHERE t.msg_id = p.msg_id
+ AND t.user_id = ' . $user->data['user_id'] . '
+ AND t.folder_id = ' . PRIVMSGS_SENTBOX . '
+ ORDER BY p.message_time ASC';
+ $result = $db->sql_query_limit($sql, ($num_sentbox_messages - $message_limit));
+
+ $delete_ids = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $delete_ids[] = $row['msg_id'];
+ }
+ $db->sql_freeresult($result);
+ delete_pm($user->data['user_id'], $delete_ids, PRIVMSGS_SENTBOX);
+ }
+}
+
+// Check Rule against Message Informations
+function check_rule($rules, $rule_row, $message_row, $user_id)
+{
+ global $user, $config;
+
+ if (!isset($rules[$rule_row['rule_check']][$rule_row['rule_connection']]))
+ {
+ return false;
+ }
+
+ $check_ary = $rules[$rule_row['rule_check']][$rule_row['rule_connection']];
+
+ // Replace Check Literals
+ $evaluate = $check_ary['function'];
+ $evaluate = preg_replace('/{(CHECK[0-9])}/', '$message_row[$check_ary[strtolower("\1")]]', $evaluate);
+
+ // Replace Rule Literals
+ $evaluate = preg_replace('/{(STRING|USER_ID|GROUP_ID)}/', '$rule_row["rule_" . strtolower("\1")]', $evaluate);
+
+ // Eval Statement
+ $result = false;
+ eval('$result = (' . $evaluate . ') ? true : false;');
+
+ if (!$result)
+ {
+ return false;
+ }
+
+ switch ($rule_row['rule_action'])
+ {
+ case ACTION_PLACE_INTO_FOLDER:
+ return array('action' => $rule_row['rule_action'], 'folder_id' => $rule_row['rule_folder_id']);
+ break;
+ case ACTION_MARK_AS_READ:
+ case ACTION_MARK_AS_IMPORTANT:
+ case ACTION_DELETE_MESSAGE:
+ return array('action' => $rule_row['rule_action'], 'unread' => $row['unread'], 'important' => $row['important']);
+ break;
+ default:
+ return false;
+ }
+
+ return false;
+}
+
+// Place new messages into appropiate folder
+function place_pm_into_folder($global_privmsgs_rules, $release = false)
+{
+ global $db, $user, $config;
+
+ if (!$user->data['user_new_privmsg'])
+ {
+ return;
+ }
+
+ $user_new_privmsg = (int) $user->data['user_new_privmsg'];
+ $user_message_rules = (int) $user->data['user_message_rules'];
+ $user_id = (int) $user->data['user_id'];
+
+ $user_rules = $zebra = array();
+ if ($user_message_rules)
+ {
+ $sql = 'SELECT *
+ FROM ' . PRIVMSGS_RULES_TABLE . "
+ WHERE user_id = $user_id";
+ $result = $db->sql_query($sql);
+
+ $user_rules = $db->sql_fetchrowset($result);
+ $db->sql_freeresult($result);
+
+ if (sizeof($user_rules))
+ {
+ $sql = 'SELECT zebra_id, friend, foe
+ FROM ' . ZEBRA_TABLE . "
+ WHERE user_id = $user_id";
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $zebra[$row['zebra_id']] = $row;
+ }
+ $db->sql_freeresult($result);
+ }
+ }
+
+ if ($release)
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
+ SET folder_id = ' . PRIVMSGS_NO_BOX . '
+ WHERE folder_id = ' . PRIVMSGS_HOLD_BOX . "
+ AND user_id = $user_id";
+ $db->sql_query($sql);
+ }
+
+ // Get those messages not yet placed into any box
+ // NOTE: Expand Group Information to all groups the user/author is in?
+ $sql = 'SELECT t.*, p.*, u.username, u.group_id as author_in_group
+ FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u
+ WHERE t.user_id = $user_id
+ AND p.author_id = u.user_id
+ AND t.folder_id = " . PRIVMSGS_NO_BOX . '
+ AND t.msg_id = p.msg_id';
+ $result = $db->sql_query($sql);
+
+ $action_ary = $move_into_folder = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $row['to'] = explode(':', $row['to_address']);
+ $row['bcc'] = explode(':', $row['bcc_address']);
+ $row['friend'] = (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['friend'] : 0;
+ $row['foe'] = (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['foe'] : 0;
+ $row['user_in_group'] = $user->data['group_id'];
+
+ // Check Rule - this should be very quick since we have all informations we need
+ $is_match = false;
+ foreach ($user_rules as $rule_row)
+ {
+ if (($action = check_rule($global_privmsgs_rules, $rule_row, $row, $user_id)) !== false)
+ {
+ $is_match = true;
+ $action_ary[$row['msg_id']][] = $action;
+ }
+ }
+
+ if (!$is_match)
+ {
+ $action_ary[$row['msg_id']][] = array('action' => false);
+ $move_into_folder[PRIVMSGS_INBOX][] = $row['msg_id'];
+ }
+ }
+ $db->sql_freeresult($result);
+
+ // We place actions into arrays, to save queries.
+ $num_new = $num_unread = 0;
+ $sql = $unread_ids = $delete_ids = $important_ids = array();
+
+ foreach ($action_ary as $msg_id => $msg_ary)
+ {
+ // It is allowed to execute actions more than once, except placing messages into folder
+ $folder_action = false;
+
+ foreach ($msg_ary as $pos => $rule_ary)
+ {
+ if ($folder_action && $rule_ary['action'] == ACTION_PLACE_INTO_FOLDER)
+ {
+ continue;
+ }
+
+ switch ($rule_ary['action'])
+ {
+ case ACTION_PLACE_INTO_FOLDER:
+ $folder_action = true;
+ $move_into_folder[$rule_ary['folder_id']][] = $msg_id;
+ $num_new++;
+ break;
+
+ case ACTION_MARK_AS_READ:
+ if ($rule_ary['unread'])
+ {
+ $unread_ids[] = $msg_id;
+ }
+ $move_into_folder[PRIVMSGS_INBOX][] = $msg_id;
+ break;
+
+ case ACTION_DELETE_MESSAGE:
+ $delete_ids[] = $msg_id;
+ break;
+
+ case ACTION_MARK_AS_IMPORTANT:
+ if (!$rule_ary['important'])
+ {
+ $important_ids[] = $msg_id;
+ }
+ $move_into_folder[PRIVMSGS_INBOX][] = $msg_id;
+ break;
+
+ default:
+ }
+ }
+ }
+
+ $num_new += sizeof(array_unique($delete_ids));
+ $num_unread += sizeof(array_unique($delete_ids));
+ $num_unread += sizeof(array_unique($unread_ids));
+
+ // Do not change the order of processing
+ // The number of queries needed to be executed here highly depends on the defined rules and are
+ // only gone through if new messages arrive.
+ $num_not_moved = 0;
+
+ // Delete messages
+ if (sizeof($delete_ids))
+ {
+ delete_pm($user_id, $delete_ids, PRIVMSGS_NO_BOX);
+ }
+
+ // Set messages to Unread
+ if (sizeof($unread_ids))
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
+ SET unread = 0
+ WHERE msg_id IN (' . implode(', ', $unread_ids) . ")
+ AND user_id = $user_id
+ AND folder_id = " . PRIVMSGS_NO_BOX;
+ $db->sql_query($sql);
+ }
+
+ // mark messages as important
+ if (sizeof($important_ids))
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
+ SET marked = !marked
+ WHERE folder_id = ' . PRIVMSGS_NO_BOX . "
+ AND user_id = $user_id
+ AND msg_id IN (" . implode(', ', $important_ids) . ')';
+ $db->sql_query($sql);
+ }
+
+ // Move into folder
+ $folder = array();
+
+ if (sizeof($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'];
+
+ $sql = 'SELECT folder_id, pm_count
+ FROM ' . PRIVMSGS_FOLDER_TABLE . '
+ WHERE folder_id IN (' . implode(', ', array_keys($move_into_folder)) . (($full_folder_action >= 0) ? ', ' . $full_folder_action : '') . ")
+ AND user_id = $user_id";
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $folder[(int) $row['folder_id']] = (int) $row['pm_count'];
+ }
+ $db->sql_freeresult($result);
+
+ if (in_array(PRIVMSGS_INBOX, array_keys($move_into_folder)))
+ {
+ $sql = 'SELECT folder_id, COUNT(msg_id) as num_messages
+ FROM ' . PRIVMSGS_TO_TABLE . "
+ WHERE user_id = $user_id
+ AND folder_id = " . PRIVMSGS_INBOX . "
+ GROUP BY folder_id";
+ $result = $db->sql_query_limit($sql, 1);
+
+ $folder[PRIVMSGS_INBOX] = (int) $db->sql_fetchfield('num_messages', 0, $result);
+ $db->sql_freeresult($result);
+ }
+ }
+
+ // Here we have ideally only one folder to move into
+ foreach ($move_into_folder as $folder_id => $msg_ary)
+ {
+ $message_limit = (!$user->data['group_message_limit']) ? $config['pm_max_msgs'] : $user->data['group_message_limit'];
+ $dest_folder = $folder_id;
+ $full_folder_action = FULL_FOLDER_NONE;
+
+ // 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 ($message_limit && $folder[$folder_id] && ($folder[$folder_id] + sizeof($msg_ary)) > $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...
+ if ($full_folder_action >= 0 && ($folder[$full_folder_action] + sizeof($msg_ary)) > $message_limit)
+ {
+ $full_folder_action = $config['full_folder_action'] - (FULL_FOLDER_NONE*(-1));
+ }
+
+ // If Full Folder Action is to move to another folder, we simply adjust the destination folder
+ if ($full_folder_action >= 0)
+ {
+ $dest_folder = $full_folder_action;
+ }
+ else if ($full_folder_action == FULL_FOLDER_DELETE)
+ {
+ // Delete some messages ;)
+ $sql = 'SELECT t.msg_id
+ FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . " p
+ WHERE t.msg_id = p.msg_id
+ AND t.user_id = $user_id
+ AND t.folder_id = $dest_folder
+ ORDER BY p.message_time ASC";
+ $result = $db->sql_query_limit($sql, (($folder[$dest_folder] + sizeof($msg_ary)) - $message_limit));
+
+ $delete_ids = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $delete_ids[] = $row['msg_id'];
+ }
+ $db->sql_freeresult($result);
+ delete_pm($user_id, $delete_ids, $dest_folder);
+ }
+ }
+
+ if ($full_folder_action != FULL_FOLDER_MOVE)
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . "
+ SET folder_id = $dest_folder, new = 0
+ WHERE folder_id = " . PRIVMSGS_NO_BOX . "
+ AND user_id = $user_id
+ AND new = 1
+ AND msg_id IN (" . implode(', ', $msg_ary) . ')';
+ $db->sql_query($sql);
+
+ if ($dest_folder != PRIVMSGS_INBOX)
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . '
+ SET pm_count = pm_count + ' . (int) $db->sql_affectedrows() . "
+ WHERE folder_id = $dest_folder
+ AND user_id = $user_id";
+ $db->sql_query($sql);
+ }
+ else
+ {
+ $num_new += $db->sql_affectedrows();
+ }
+ }
+ else
+ {
+ $num_not_moved += sizeof($msg_ary);
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
+ SET folder_id = ' . PRIVMSGS_HOLD_BOX . '
+ WHERE folder_id = ' . PRIVMSGS_NO_BOX . "
+ AND user_id = $user_id
+ AND msg_id IN (" . implode(', ', $msg_ary) . ')';
+ $db->sql_query($sql);
+ }
+ }
+
+ if (sizeof($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)
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
+ SET folder_id = ' . PRIVMSGS_SENTBOX . '
+ WHERE folder_id = ' . PRIVMSGS_OUTBOX . '
+ AND msg_id IN (' . implode(', ', array_keys($action_ary)) . ')';
+ $db->sql_query($sql);
+ }
+
+ // Update unread and new status field
+ if ($num_unread || $num_new)
+ {
+ $set_sql = ($num_unread) ? 'user_unread_privmsg = user_unread_privmsg - ' . $num_unread : '';
+ if ($num_new)
+ {
+ $set_sql .= ($set_sql != '') ? ', ' : '';
+ $set_sql .= 'user_new_privmsg = user_new_privmsg - ' . $num_new;
+ }
+
+ $db->sql_query('UPDATE ' . USERS_TABLE . " SET $set_sql WHERE user_id = $user_id");
+ $user->data['user_new_privmsg'] -= $num_new;
+ $user->data['user_unread_privmsg'] -= $num_unread;
+ }
+
+ return $num_not_moved;
+}
+
+// Move PM from one to another folder
+function move_pm($user_id, $message_limit)
+{
+ global $db, $user;
+ global $_POST, $phpbb_root_path, $phpEx, $SID;
+
+ $move_msg_ids = (isset($_POST['marked_msg_id'])) ? array_map('intval', $_POST['marked_msg_id']) : array();
+ $dest_folder = request_var('dest_folder', PRIVMSGS_NO_BOX);
+ $cur_folder_id = request_var('cur_folder_id', PRIVMSGS_NO_BOX);
+
+ $num_moved = 0;
+
+ if (sizeof($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, PRIVMSGS_SENTBOX)) && $cur_folder_id != $dest_folder)
+ {
+ // We have to check the destination folder ;)
+ if ($dest_folder != PRIVMSGS_INBOX)
+ {
+ $sql = 'SELECT folder_id, folder_name, pm_count
+ FROM ' . PRIVMSGS_FOLDER_TABLE . "
+ WHERE folder_id = $dest_folder
+ AND user_id = $user_id";
+ $result = $db->sql_query($sql);
+
+ if (!($row = $db->sql_fetchrow($result)))
+ {
+ trigger_error('NOT_AUTHORIZED');
+ }
+ $db->sql_freeresult($result);
+
+ if ($row['pm_count'] + sizeof($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=\"{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;folder={$row['folder_id']}\">", '</a>', $row['folder_name']);
+ trigger_error($message);
+ }
+ }
+ else
+ {
+ $sql = 'SELECT COUNT(msg_id) as num_messages
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE folder_id = ' . PRIVMSGS_INBOX . "
+ AND user_id = $user_id";
+ $result = $db->sql_query($sql);
+ if ($db->sql_fetchfield('num_messages', 0, $result) + sizeof($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=\"{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;folder=inbox\">", '</a>', $user->lang['PM_INBOX']);
+ trigger_error($message);
+ }
+ }
+
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . "
+ SET folder_id = $dest_folder
+ WHERE folder_id = $cur_folder_id
+ AND user_id = $user_id
+ AND msg_id IN (" . implode(', ', $move_msg_ids) . ')';
+ $db->sql_query($sql);
+ $num_moved = $db->sql_affectedrows();
+
+ // Update pm counts
+ if ($num_moved)
+ {
+ if (!in_array($cur_folder_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX)))
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . "
+ SET pm_count = pm_count - $num_moved
+ WHERE folder_id = $cur_folder_id
+ AND user_id = $user_id";
+ $db->sql_query($sql);
+ }
+
+ if ($dest_folder != PRIVMSGS_INBOX)
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . "
+ SET pm_count = pm_count + $num_moved
+ WHERE folder_id = $dest_folder
+ AND user_id = $user_id";
+ $db->sql_query($sql);
+ }
+ }
+ }
+
+ return $num_moved;
+}
+
+// Update unread message status
+function update_unread_status($unread, $msg_id, $user_id, $folder_id)
+{
+ if (!$unread)
+ {
+ return;
+ }
+
+ global $db;
+
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . "
+ SET unread = 0
+ WHERE msg_id = $msg_id
+ AND user_id = $user_id
+ AND folder_id = $folder_id";
+ $db->sql_query($sql);
+
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_unread_privmsg = user_unread_privmsg - 1
+ WHERE user_id = $user_id";
+ $db->sql_query($sql);
+}
+
+// Handle all actions possible with marked messages
+function handle_mark_actions($user_id, $mark_action)
+{
+ global $db, $user, $_POST, $phpbb_root_path, $SID, $phpEx;
+
+ $msg_ids = (isset($_POST['marked_msg_id'])) ? array_map('intval', $_POST['marked_msg_id']) : array();
+ $cur_folder_id = request_var('cur_folder_id', PRIVMSGS_NO_BOX);
+ $confirm = (isset($_POST['confirm'])) ? true : false;
+
+ if (!sizeof($msg_ids))
+ {
+ return;
+ }
+
+ switch ($mark_action)
+ {
+ case 'mark_important':
+
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . "
+ SET marked = !marked
+ WHERE folder_id = $cur_folder_id
+ AND user_id = $user_id
+ AND msg_id IN (" . implode(', ', $msg_ids) . ')';
+ $db->sql_query($sql);
+
+ break;
+
+ case 'delete_marked':
+ $hidden_fields = array('cur_folder_id' => $cur_folder_id, 'mark_option' => 'delete_marked', 'submit_mark' => true);
+ $hidden_fields['marked_msg_id'] = $msg_ids;
+ $s_hidden_fields = '';
+
+ foreach ($hidden_fields as $key => $var)
+ {
+ if (is_array($var))
+ {
+ foreach ($var as $_key => $_var)
+ {
+ $s_hidden_fields .= '<input type="hidden" name="' . $key . '[' . $_key . ']" value="' . $_var . '" />';
+ }
+ }
+ else
+ {
+ $s_hidden_fields .= '<input type="hidden" name="' . $key . '" value="' . $var . '" />';
+ }
+ }
+ unset($hidden_fields);
+
+ if (confirm_box(true))
+ {
+ delete_pm($user_id, $msg_ids, $cur_folder_id);
+ // TODO: meta blabla
+ trigger_error('MESSAGE_DELETED');
+ }
+ else
+ {
+ confirm_box(false, 'DELETE_MARKED_PM', $s_hidden_fields);
+ }
+
+ break;
+
+ case 'export_as_xml':
+ case 'export_as_csv':
+ case 'export_as_txt':
+ $export_as = str_replace('export_as_', '', $mark_action);
+ break;
+
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+// Delete PM(s)
+function delete_pm($user_id, $msg_ids, $folder_id)
+{
+ global $db;
+
+ $user_id = (int) $user_id;
+ $folder_id = (int) $folder_id;
+
+ if (!$user_id)
+ {
+ return false;
+ }
+
+ if (!is_array($msg_ids))
+ {
+ if (!$msg_ids)
+ {
+ return false;
+ }
+ $msg_ids = array($msg_ids);
+ }
+
+ if (!sizeof($msg_ids))
+ {
+ return false;
+ }
+
+ // Get PM Informations for later deleting
+ $sql = 'SELECT msg_id, unread, new
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE msg_id IN (' . implode(', ', array_map('intval', $msg_ids)) . ")
+ AND folder_id = $folder_id
+ AND user_id = $user_id";
+ $result = $db->sql_query($sql);
+
+ $delete_rows = array();
+ $num_unread = $num_new = $num_deleted = 0;
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $num_unread += (int) $row['unread'];
+ $num_new += (int) $row['new'];
+
+ $delete_rows[$row['msg_id']] = 1;
+ }
+ $db->sql_freeresult($result);
+ unset($msg_ids);
+
+ if (!sizeof($delete_rows))
+ {
+ return false;
+ }
+
+ // if no one has read the message yet (meaning it is in users outbox)
+ // then mark the message as deleted...
+ if ($folder_id == PRIVMSGS_OUTBOX)
+ {
+ // TODO: Recipients will see the message as deleted later
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
+ SET deleted = 1, msg_id = 0
+ WHERE msg_id IN (' . implode(', ', array_keys($delete_rows)) . ')';
+ $db->sql_query($sql);
+ $num_deleted = $db->sql_affectedrows();
+ }
+ else
+ {
+ // Delete Private Message Informations
+ $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . "
+ WHERE user_id = $user_id
+ AND folder_id = $folder_id
+ AND msg_id IN (" . implode(', ', array_keys($delete_rows)) . ')';
+ $db->sql_query($sql);
+ $num_deleted = $db->sql_affectedrows();
+ }
+
+ // if folder id is user defined folder then decrease pm_count
+ if (!in_array($folder_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX, PRIVMSGS_NO_BOX)))
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . "
+ SET pm_count = pm_count - $num_deleted
+ WHERE folder_id = $folder_id";
+ $db->sql_query($sql);
+ }
+
+ // Update unread and new status field
+ if ($num_unread || $num_new)
+ {
+ $set_sql = ($num_unread) ? 'user_unread_privmsg = user_unread_privmsg - ' . $num_unread : '';
+ if ($num_new)
+ {
+ $set_sql .= ($set_sql != '') ? ', ' : '';
+ $set_sql .= 'user_new_privmsg = user_new_privmsg - ' . $num_new;
+ }
+
+ $db->sql_query('UPDATE ' . USERS_TABLE . " SET $set_sql WHERE user_id = $user_id");
+ }
+
+ // Now we have to check which messages we can delete completely
+ $sql = 'SELECT msg_id
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE msg_id IN (' . implode(', ', array_keys($delete_rows)) . ')';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ unset($delete_rows[$row['msg_id']]);
+ }
+ $db->sql_freeresult($result);
+
+ $delete_ids = implode(', ', $delete_rows);
+
+ if ($delete_ids)
+ {
+ $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
+ WHERE msg_id IN (' . $delete_ids . ')';
+ $db->sql_query($sql);
+ }
+}
+
+// Rebuild message header
+function rebuild_header($check_ary)
+{
+ global $db;
+
+ $address = array();
+
+ foreach ($check_ary as $check_type => $address_field)
+ {
+ // Split Addresses into users and groups
+ preg_match_all('/:?(u|g)_([0-9]+):?/', $address_field, $match);
+
+ $u = $g = array();
+ foreach ($match[1] as $id => $type)
+ {
+ ${$type}[] = (int) $match[2][$id];
+ }
+
+ foreach (array('u', 'g') as $type)
+ {
+ if (sizeof($$type))
+ {
+ foreach ($$type as $id)
+ {
+ $address[$type][$id] = $check_type;
+ }
+ }
+ }
+ }
+
+ return $address;
+}
+
+// Print out/Assign recipient informations
+function write_pm_addresses($check_ary, $author, $plaintext = false)
+{
+ global $db, $user, $template, $phpbb_root_path, $SID, $phpEx;
+
+ $addresses = array();
+
+ foreach ($check_ary as $check_type => $address_field)
+ {
+ // Split Addresses into users and groups
+ preg_match_all('/:?(u|g)_([0-9]+):?/', $address_field, $match);
+
+ $u = $g = array();
+ foreach ($match[1] as $id => $type)
+ {
+ ${$type}[] = (int) $match[2][$id];
+ }
+
+ $address = array();
+ if (sizeof($u))
+ {
+ $sql = 'SELECT user_id, username, user_colour
+ FROM ' . USERS_TABLE . '
+ WHERE user_id IN (' . implode(', ', $u) . ')';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($check_type == 'to' || $author == $user->data['user_id'] || $row['user_id'] == $user->data['user_id'])
+ {
+ if ($plaintext)
+ {
+ $address[] = $row['username'];
+ }
+ else
+ {
+ $address['user'][$row['user_id']] = array('name' => $row['username'], 'colour' => $row['user_colour']);
+ }
+ }
+ }
+ $db->sql_freeresult($result);
+ }
+
+ if (sizeof($g))
+ {
+ if ($plaintext)
+ {
+ $sql = 'SELECT group_name
+ FROM ' . GROUPS_TABLE . '
+ WHERE group_id IN (' . implode(', ', $g) . ')';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($check_type == 'to' || $author == $user->data['user_id'] || $row['user_id'] == $user->data['user_id'])
+ {
+ $address[] = $row['group_name'];
+ }
+ }
+ $db->sql_freeresult($result);
+ }
+ else
+ {
+ $sql = 'SELECT g.group_id, g.group_name, g.group_colour, ug.user_id
+ FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
+ WHERE g.group_id IN (' . implode(', ', $g) . ')
+ AND g.group_id = ug.group_id
+ AND ug.user_pending = 0';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if (!isset($address['group'][$row['group_id']]))
+ {
+ if ($check_type == 'to' || $author == $user->data['user_id'] || $row['user_id'] == $user->data['user_id'])
+ {
+ $address['group'][$row['group_id']] = array('name' => $row['group_name'], 'colour' => $row['group_colour']);
+ }
+ }
+
+ if (isset($address['user'][$row['user_id']]))
+ {
+ $address['user'][$row['user_id']]['in_group'] = $row['group_id'];
+ }
+ }
+ $db->sql_freeresult($result);
+ }
+ }
+
+ if (sizeof($address) && !$plaintext)
+ {
+ $template->assign_var('S_' . strtoupper($check_type) . '_RECIPIENT', true);
+
+ foreach ($address as $type => $adr_ary)
+ {
+ foreach ($adr_ary as $id => $row)
+ {
+ $template->assign_block_vars($check_type . '_recipient', array(
+ 'NAME' => $row['name'],
+ 'IS_GROUP' => ($type == 'group'),
+ 'IS_USER' => ($type == 'user'),
+ 'COLOUR' => ($row['colour']) ? $row['colour'] : '',
+ 'UG_ID' => $id,
+ 'U_VIEW' => ($type == 'user') ? "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $id : "{$phpbb_root_path}groupcp.$phpEx$SID&amp;g=" . $id)
+ );
+ }
+ }
+ }
+
+ $addresses[$check_type] = $address;
+ }
+
+ return $addresses;
+}
+
+// Get folder status
+function get_folder_status($folder_id, $folder)
+{
+ global $db, $user, $config;
+
+ $folder = $folder[$folder_id];
+ $return = array();
+
+ $message_limit = (!$user->data['group_message_limit']) ? $config['pm_max_msgs'] : $user->data['group_message_limit'];
+
+ $return = array(
+ 'folder_name' => $folder['folder_name'],
+ 'cur' => $folder['num_messages'],
+ 'remaining' => $message_limit - $folder['num_messages'],
+ 'max' => $message_limit,
+ 'percent' => ($message_limit > 0) ? round(($folder['num_messages'] / $message_limit) * 100) : 100
+ );
+
+ $return['message'] = sprintf($user->lang['FOLDER_STATUS_MSG'], $return['percent'], $return['cur'], $return['max']);
+
+ return $return;
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 4708cd0e1a..e035090ca6 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -759,7 +759,8 @@ class user extends session
{
if (!$this->theme['primary'][$img])
{
- $imgs[$img . $suffix] = $alt; //'{{IMG:' . $img . '}}';
+ // Do not fill the image to let designers decide what to do if the image is empty
+ $imgs[$img . $suffix] = '';
return $imgs[$img . $suffix];
}
diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php
index 4b121c316a..b2971533aa 100644
--- a/phpBB/includes/ucp/ucp_pm.php
+++ b/phpBB/includes/ucp/ucp_pm.php
@@ -11,15 +11,12 @@
//
// -------------------------------------------------------------
-// TODO for 2.2:
+// TODO for M-4:
//
-// * Utilise more code from posting, modularise as appropriate
-// * Give option of recieving a receipt upon reading (sender)
-// * Give option of not sending a receipt upon reading (recipient)
-// * Archive inbox to text file? to email?
// * Review of post when replying/quoting
// * Introduce post/post thread forwarding
// * Introduce (option of) emailing entire PM when notifying user of new message
+// * Handle delete flag (user deletes PM from outbox)
class ucp_pm extends module
{
@@ -41,8 +38,291 @@ class ucp_pm extends module
$user->add_lang('posting');
$template->assign_var('S_PRIVMSGS', true);
- trigger_error('No, not yet. :P');
+ $folder_specified = request_var('folder', '');
+ if (!in_array($folder_specified, array('inbox', 'outbox', 'sentbox')))
+ {
+ $folder_specified = (int) $folder_specified;
+ }
+ else
+ {
+ $folder_specified = ($folder_specified == 'inbox') ? PRIVMSGS_INBOX : (($folder_specified == 'outbox') ? PRIVMSGS_OUTBOX : PRIVMSGS_SENTBOX);
+ }
+
+ if (!$folder_specified)
+ {
+ $mode = (!$mode) ? request_var('mode', 'view_messages') : $mode;
+ }
+ else
+ {
+ $mode = 'view_messages';
+ }
+
+ include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
+
+ $tpl_file = 'ucp_pm_' . $mode . '.html';
+ switch ($mode)
+ {
+ // New private messages popup
+ case 'popup':
+
+ $l_new_message = '';
+ if ($user->data['user_id'] != ANONYMOUS)
+ {
+ if ($user->data['user_new_privmsg'])
+ {
+ $l_new_message = ($user->data['user_new_privmsg'] == 1 ) ? $user->lang['YOU_NEW_PM'] : $user->lang['YOU_NEW_PMS'];
+ }
+ else
+ {
+ $l_new_message = $user->lang['YOU_NO_NEW_PM'];
+ }
+
+ $l_new_message .= '<br /><br />' . sprintf($user->lang['CLICK_VIEW_PRIVMSG'], '<a href="' . $phpbb_root_path . 'ucp.' . $phpEx . $SID . '&amp;i=pm&amp;folder=inbox" onclick="jump_to_inbox();return false;" target="_new">', '</a>');
+ }
+ else
+ {
+ $l_new_message = $user->lang['LOGIN_CHECK_PM'];
+ }
+
+ $template->assign_vars(array(
+ 'MESSAGE' => $l_new_message)
+ );
+
+ break;
+
+ // Compose message
+ case 'compose':
+ $action = request_var('action', 'post');
+
+ if (!$auth->acl_get('u_sendpm'))
+ {
+ trigger_error('NOT_AUTHORIZED');
+ }
+
+ include($phpbb_root_path . 'includes/ucp/ucp_pm_compose.'.$phpEx);
+ compose_pm($id, $mode, $action);
+
+ $tpl_file = 'posting_body.html';
+ break;
+
+ case 'options':
+ include($phpbb_root_path . 'includes/ucp/ucp_pm_options.'.$phpEx);
+ message_options($id, $mode, $global_privmsgs_rules, $global_rule_conditions);
+ break;
+
+ case 'drafts':
+ include($phpbb_root_path . 'includes/ucp/ucp_main.'.$phpEx);
+ $module = new ucp_main($id, $mode);
+ unset($module);
+ exit;
+ break;
+
+ case 'unread':
+ case 'view_messages':
+ if ($folder_specified)
+ {
+ $folder_id = $folder_specified;
+ $action = 'view_folder';
+ }
+ else
+ {
+ $folder_id = request_var('f', PRIVMSGS_NO_BOX);
+ $action = request_var('action', 'view_folder');
+ }
+
+ $msg_id = request_var('p', 0);
+ $view = request_var('view', '');
+
+ if ($msg_id && $action == 'view_folder')
+ {
+ $action = 'view_message';
+ }
+
+ if (!$auth->acl_get('u_readpm'))
+ {
+ trigger_error('NOT_AUTHORIZED');
+ }
+
+ // First Handle Mark actions and moving messages
+
+ // Move PM
+ if (isset($_REQUEST['move_pm']))
+ {
+ $message_limit = (!$user->data['group_message_limit']) ? $config['pm_max_msgs'] : $user->data['group_message_limit'];
+
+ if (move_pm($user->data['user_id'], $message_limit))
+ {
+ // Return to folder view if single message moved
+ if ($action == 'view_message')
+ {
+ $msg_id = 0;
+ $folder_id = request_var('cur_folder_id', PRIVMSGS_NO_BOX);
+ $action = 'view_folder';
+ }
+ }
+ }
+
+ // Message Mark Options
+ if (isset($_REQUEST['submit_mark']))
+ {
+ handle_mark_actions($user->data['user_id'], request_var('mark_option', ''));
+ }
+
+ // If new messages arrived, place them into the appropiate folder
+ $num_not_moved = 0;
+ if ($user->data['user_new_privmsg'] && $action == 'view_folder')
+ {
+ place_pm_into_folder($global_privmsgs_rules, request_var('release', 0));
+ $num_not_moved = $user->data['user_new_privmsg'];
+ }
+ if (!$msg_id && $folder_id == PRIVMSGS_NO_BOX && $mode != 'unread')
+ {
+ $folder_id = PRIVMSGS_INBOX;
+ }
+ else if ($msg_id && $folder_id == PRIVMSGS_NO_BOX)
+ {
+ $sql = 'SELECT folder_id
+ FROM ' . PRIVMSGS_TO_TABLE . "
+ WHERE msg_id = $msg_id
+ AND user_id = " . $user->data['user_id'];
+ $result = $db->sql_query_limit($sql, 1);
+ if (!($row = $db->sql_fetchrow($result)))
+ {
+ trigger_error('MESSAGE_NO_LONGER_AVAILABLE');
+ }
+ $folder_id = (int) $row['folder_id'];
+ }
+
+ $message_row = array();
+ if ($mode == 'view_messages' && $action == 'view_message' && $msg_id)
+ {
+ // Get Message user want to see
+
+ if ($view == 'next' || $view == 'previous')
+ {
+ $sql_condition = ($view == 'next') ? '>' : '<';
+ $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC';
+
+ $sql = 'SELECT t.msg_id
+ FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TABLE . " p2
+ WHERE p2.msg_id = $msg_id
+ AND t.folder_id = $folder_id
+ AND t.user_id = " . $user->data['user_id'] . "
+ AND t.msg_id = p.msg_id
+ AND p.message_time $sql_condition p2.message_time
+ ORDER BY p.message_time $sql_ordering";
+ $result = $db->sql_query_limit($sql, 1);
+
+ if (!($row = $db->sql_fetchrow($result)))
+ {
+ $message = ($view == 'next') ? 'NO_NEWER_PM' : 'NO_OLDER_PM';
+ trigger_error($message);
+ }
+ else
+ {
+ $msg_id = $row['msg_id'];
+ }
+ }
+
+ $sql = 'SELECT t.*, p.*, u.*
+ FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
+ WHERE t.user_id = ' . $user->data['user_id'] . "
+ AND p.author_id = u.user_id
+ AND t.folder_id = $folder_id
+ AND t.msg_id = p.msg_id
+ AND p.msg_id = $msg_id";
+ $result = $db->sql_query_limit($sql, 1);
+
+ if (!($message_row = $db->sql_fetchrow($result)))
+ {
+ trigger_error('MESSAGE_NO_LONGER_AVAILABLE');
+ }
+
+ // Update unread status
+ update_unread_status($message_row['unread'], $message_row['msg_id'], $user->data['user_id'], $folder_id);
+ }
+
+ $unread_pm = array();
+ if ($user->data['user_unread_privmsg'])
+ {
+ $unread_pm = get_unread_pm($user->data['user_id']);
+ }
+ $folder = array();
+
+ if ($mode == 'unread')
+ {
+ $folder['unread'] = array('folder_name' => $user->lang['UNREAD_MESSAGES']);
+ }
+ get_folder($user->data['user_id'], $folder);
+
+ $s_folder_options = $s_to_folder_options = '';
+ foreach ($folder as $f_id => $folder_ary)
+ {
+ $unread = ((isset($unread_pm[$f_id]) || ($f_id == PRIVMSGS_OUTBOX && $folder_ary['num_messages'])) ? ' [' . (($f_id == PRIVMSGS_OUTBOX) ? $folder_ary['num_messages'] : $unread_pm[$f_id]) . ']' : '');
+
+ $option = '<option' . ((!in_array($f_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX))) ? ' class="blue"' : '') . ' value="' . $f_id . '"' . ((($f_id == $folder_id && $mode != 'unread') || ($f_id === 'unread' && $mode == 'unread')) ? ' selected="selected"' : '') . '>' . $folder_ary['folder_name'] . $unread . '</option>';
+
+ $s_to_folder_options .= ($f_id != PRIVMSGS_OUTBOX && $f_id != PRIVMSGS_SENTBOX) ? $option : '';
+ $s_folder_options .= $option;
+ }
+
+ clean_sentbox($folder[PRIVMSGS_SENTBOX]['num_messages']);
+
+ // Header for message view - folder and so on
+ $folder_status = get_folder_status($folder_id, $folder);
+ $url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=$id";
+
+ $template->assign_vars(array(
+ 'CUR_FOLDER_ID' => $folder_id,
+ 'CUR_FOLDER_NAME' => $folder_status['folder_name'],
+ 'NUM_NOT_MOVED' => $num_not_moved,
+ 'RELEASE_MESSAGE_INFO' => sprintf($user->lang['RELEASE_MESSAGES'], '<a href="' . $url . '&amp;folder=' . $folder_id . '&amp;release=1">', '</a>'),
+ 'NOT_MOVED_MESSAGES' => ($num_not_moved == 1) ? $user->lang['NOT_MOVED_MESSAGE'] : sprintf($user->lang['NOT_MOVED_MESSAGES'], $num_not_moved),
+
+ 'S_FOLDER_OPTIONS' => $s_folder_options,
+ 'S_TO_FOLDER_OPTIONS' => $s_to_folder_options,
+ 'S_FOLDER_ACTION' => "$url&amp;mode=view_messages&amp;action=view_folder",
+ 'S_PM_ACTION' => "$url&amp;mode=$mode&amp;action=$action",
+
+ 'U_INBOX' => ($folder_id != PRIVMSGS_INBOX) ? "$url&amp;folder=inbox" : '',
+ 'U_OUTBOX' => ($folder_id != PRIVMSGS_OUTBOX) ? "$url&amp;folder=outbox" : '',
+ 'U_SENTBOX' => ($folder_id != PRIVMSGS_SENTBOX) ? "$url&amp;folder=sentbox" : '',
+ 'U_CREATE_FOLDER' => "$url&amp;mode=options",
+
+ 'FOLDER_STATUS' => $folder_status['message'],
+ 'FOLDER_MAX_MESSAGES' => $folder_status['max'],
+ 'FOLDER_CUR_MESSAGES' => $folder_status['cur'],
+ 'FOLDER_REMAINING_MESSAGES' => $folder_status['remaining'],
+ 'FOLDER_PERCENT' => $folder_status['percent'])
+ );
+
+ if ($mode == 'unread' || $action == 'view_folder')
+ {
+ include($phpbb_root_path . 'includes/ucp/ucp_pm_viewfolder.'.$phpEx);
+ view_folder($id, $mode, $folder_id, $folder, (($mode == 'unread') ? 'unread' : 'folder'));
+
+ $tpl_file = 'ucp_pm_viewfolder.html';
+ }
+ else if ($action == 'view_message')
+ {
+ $template->assign_vars(array(
+ 'S_VIEW_MESSAGE'=> true,
+ 'MSG_ID' => $msg_id)
+ );
+
+ include($phpbb_root_path . 'includes/ucp/ucp_pm_viewmessage.'.$phpEx);
+ view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row);
+
+ $tpl_file = ($view == 'print') ? 'ucp_pm_viewmessage_print.html' : 'ucp_pm_viewmessage.html';
+ }
+
+ break;
+
+ default:
+ trigger_error('NOT_AUTHORIZED');
+ }
+
$template->assign_vars(array(
'L_TITLE' => $user->lang['UCP_PM_' . strtoupper($mode)],
'S_UCP_ACTION' => "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode&amp;action=$action")
diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php
new file mode 100644
index 0000000000..d5516dc280
--- /dev/null
+++ b/phpBB/includes/ucp/ucp_pm_compose.php
@@ -0,0 +1,1176 @@
+<?php
+// -------------------------------------------------------------
+//
+// $Id$
+//
+// FILENAME : compose.php
+// STARTED : Sat Mar 27, 2004
+// COPYRIGHT : © 2004 phpBB Group
+// WWW : http://www.phpbb.com/
+// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
+//
+// -------------------------------------------------------------
+
+// * Called from ucp_pm with mode == 'compose'
+
+function compose_pm($id, $mode, $action)
+{
+ global $template, $db, $auth, $user;
+ global $phpbb_root_path, $phpEx, $config, $SID;
+
+ include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
+ include($phpbb_root_path . 'includes/functions_posting.'.$phpEx);
+ include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
+
+ if (!$action)
+ {
+ $action = 'post';
+ }
+
+ // Grab only parameters needed here
+ $msg_id = request_var('p', 0);
+ $quote_post = request_var('q', 0);
+ $draft_id = request_var('d', 0);
+ $lastclick = request_var('lastclick', 0);
+
+ // Do NOT use request_var or specialchars here
+ $address_list = isset($_REQUEST['address_list']) ? $_REQUEST['address_list'] : array();
+
+ $submit = (isset($_POST['post']));
+ $preview = (isset($_POST['preview']));
+ $save = (isset($_POST['save']));
+ $load = (isset($_POST['load']));
+ $cancel = (isset($_POST['cancel']));
+ $confirm = (isset($_POST['confirm']));
+ $delete = (isset($_POST['delete']));
+
+ $remove_u = (isset($_REQUEST['remove_u']));
+ $remove_g = (isset($_REQUEST['remove_g']));
+ $add_to = (isset($_REQUEST['add_to']));
+ $add_bcc = (isset($_REQUEST['add_bcc']));
+
+ $refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['edit_comment']) || $save || $load
+ || $remove_u || $remove_g || $add_to || $add_bcc;
+
+ $action = ($delete && !$preview && !$refresh && $submit) ? 'delete' : $action;
+
+ $error = array();
+ $current_time = time();
+
+ // Was cancel pressed? If so then redirect to the appropriate page
+ if ($cancel || ($current_time - $lastclick < 2 && $submit))
+ {
+ $redirect = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=$id&amp;mode=view_messages&amp;action=view_message" . (($msg_id) ? "&amp;p=$msg_id" : '');
+ redirect($redirect);
+ }
+
+ $sql = '';
+
+ // What is all this following SQL for? Well, we need to know
+ // some basic information in all cases before we do anything.
+ switch ($action)
+ {
+ case 'post':
+ if (!$auth->acl_get('u_sendpm'))
+ {
+ trigger_error('NOT_AUTHORIZED_POST_PM');
+ }
+
+ break;
+
+ case 'reply':
+ case 'quote':
+ case 'forward':
+ if (!$msg_id)
+ {
+ trigger_error('NO_PM');
+ }
+
+ if ($quote_post)
+ {
+ $sql = 'SELECT p.post_text as message_text, p.poster_id as author_id, p.post_time as message_time, p.bbcode_bitfield, p.bbcode_uid, p.enable_sig, p.enable_html, p.enable_smilies, p.enable_magic_url, t.topic_title as message_subject, u.username as quote_username
+ FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . " u
+ WHERE p.post_id = $msg_id
+ AND t.topic_id = p.topic_id
+ AND u.user_id = p.poster_id";
+ }
+ else
+ {
+ $sql = 'SELECT t.*, p.*, u.username as quote_username
+ FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
+ WHERE t.user_id = ' . $user->data['user_id'] . "
+ AND p.author_id = u.user_id
+ AND t.msg_id = p.msg_id
+ AND p.msg_id = $msg_id";
+ }
+ break;
+
+ case 'edit':
+ if (!$msg_id)
+ {
+ trigger_error('NO_PM');
+ }
+
+ // check for outbox (not read) status, we do not allow editing if one user already having the message
+ $sql = 'SELECT p.*, t.*
+ FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p
+ WHERE t.user_id = ' . $user->data['user_id'] . '
+ AND t.folder_id = ' . PRIVMSGS_OUTBOX . "
+ AND t.msg_id = $msg_id
+ AND t.msg_id = p.msg_id";
+ break;
+
+ case 'delete':
+ if (!$auth->acl_get('u_pm_delete'))
+ {
+ trigger_error('NOT_AUTHORIZED_DELETE_PM');
+ }
+
+ if (!$msg_id)
+ {
+ trigger_error('NO_PM');
+ }
+
+ $sql = 'SELECT msg_id, unread, new, author_id
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE user_id = ' . $user->data['user_id'] . "
+ AND msg_id = $msg_id";
+ break;
+
+ case 'smilies':
+ generate_smilies('window', 0);
+ break;
+
+ default:
+ trigger_error('NO_POST_MODE');
+ }
+
+ if ($action == 'reply' && !$auth->acl_get('u_sendpm'))
+ {
+ trigger_error('NOT_AUTHORIZED_REPLY_PM');
+ }
+
+ if ($action == 'quote' && (!$config['auth_quote_pm'] || !$auth->acl_get('u_sendpm')))
+ {
+ trigger_error('NOT_AUTHORIZED_QUOTE_PM');
+ }
+
+ if ($action == 'forward' && (!$config['forward_pm'] || !$auth->acl_get('u_pm_forward')))
+ {
+ trigger_error('NOT_AUTHORIZED_FORWARD_PM');
+ }
+
+ if ($action == 'edit' && !$auth->acl_get('u_pm_edit'))
+ {
+ trigger_error('NOT_AUTHORIZED_EDIT_PM');
+ }
+
+ if ($sql)
+ {
+ $result = $db->sql_query_limit($sql, 1);
+
+ if (!($row = $db->sql_fetchrow($result)))
+ {
+ trigger_error('NOT_AUTHORIZED');
+ }
+
+ extract($row);
+ $db->sql_freeresult($result);
+
+ $msg_id = (int) $msg_id;
+ $enable_urls = $enable_magic_url;
+
+ if (!$author_id && $msg_id)
+ {
+ trigger_error('NO_USER');
+ }
+
+ if (($action == 'reply' || $action == 'quote') && !sizeof($address_list) && !$refresh && !$submit && !$preview)
+ {
+ $address_list = array('u' => array($author_id => 'to'));
+ }
+ else if ($action == 'edit' && !sizeof($address_list) && !$refresh && !$submit && !$preview)
+ {
+ // Rebuild TO and BCC Header
+ $address_list = rebuild_header(array('to' => $to_address, 'bcc' => $bcc_address));
+ }
+ }
+ else
+ {
+ $message_attachment = 0;
+ $message_text = $subject = '';
+ }
+
+ if ($action == 'edit' && !$refresh && !$preview && !$submit)
+ {
+ if (!($message_time > time() - $config['pm_edit_time'] || !$config['pm_edit_time']))
+ {
+ trigger_error('NOT_AUTHORIZED_EDIT_TIME');
+ }
+ }
+
+ $message_parser = new parse_message();
+
+ $message_subject = (isset($message_subject)) ? $message_subject : '';
+ $message_text = ($action == 'reply') ? '' : ((isset($message_text)) ? $message_text : '');
+ $icon_id = 0;
+
+ $s_action = "{$phpbb_root_path}ucp.$phpEx?sid={$user->session_id}&amp;i=$id&amp;mode=$mode&amp;action=$action";
+ $s_action .= ($msg_id) ? "&amp;p=$msg_id" : '';
+ $s_action .= ($quote_post) ? "&amp;q=1" : '';
+
+ // Handle User/Group adding/removing
+ handle_message_list_actions($address_list, $remove_u, $remove_g, $add_to, $add_bcc);
+
+ // Check for too many recipients
+ if (!$config['allow_mass_pm'] && num_recipients($address_list) > 1)
+ {
+ $address_list = get_recipient_pos($address_list, 1);
+ $error[] = $user->lang['TOO_MANY_RECIPIENTS'];
+ }
+
+ $message_parser->get_submitted_attachment_data();
+
+ if ($message_attachment && !$submit && !$refresh && !$preview && $action == 'edit')
+ {
+ $sql = 'SELECT attach_id, physical_filename, comment, real_filename, extension, mimetype, filesize, filetime, thumbnail
+ FROM ' . ATTACHMENTS_TABLE . "
+ WHERE post_msg_id = $msg_id
+ AND in_message = 1
+ ORDER BY filetime " . ((!$config['display_order']) ? 'DESC' : 'ASC');
+ $result = $db->sql_query($sql);
+
+ $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result));
+
+ $db->sql_freeresult($result);
+ }
+
+ if (!in_array($action, array('quote', 'edit', 'delete', 'forward')))
+ {
+ $enable_sig = ($config['allow_sig_pm'] && $auth->acl_get('u_pm_sig') && $user->optionget('attachsig'));
+ $enable_smilies = ($config['allow_smilies'] && $auth->acl_get('u_pm_smilies') && $user->optionget('smile'));
+ $enable_bbcode = ($config['allow_bbcode'] && $auth->acl_get('u_pm_bbcode') && $user->optionget('bbcode'));
+ $enable_urls = true;
+ }
+
+ $enable_magic_url = $drafts = false;
+
+ // User own some drafts?
+ if ($auth->acl_get('u_savedrafts') && $action != 'delete')
+ {
+ $sql = 'SELECT draft_id
+ FROM ' . DRAFTS_TABLE . '
+ WHERE (forum_id = 0 AND topic_id = 0)
+ AND user_id = ' . $user->data['user_id'] .
+ (($draft_id) ? " AND draft_id <> $draft_id" : '');
+ $result = $db->sql_query_limit($sql, 1);
+
+ if ($db->sql_fetchrow($result))
+ {
+ $drafts = true;
+ }
+ $db->sql_freeresult($result);
+ }
+
+ if ($action == 'edit' || $action == 'forward')
+ {
+ $message_parser->bbcode_uid = $bbcode_uid;
+ }
+
+ // Delete triggered ?
+ if ($action == 'delete')
+ {
+ // Get Folder ID
+ $folder_id = request_var('f', PRIVMSGS_NO_BOX);
+
+ $s_hidden_fields = '<input type="hidden" name="p" value="' . $msg_id . '" /><input type="hidden" name="f" value="' . $folder_id . '" /><input type="hidden" name="action" value="delete" />';
+
+ // Do we need to confirm ?
+ if (confirm_box(true))
+ {
+ delete_pm($user->data['user_id'], $msg_id, $folder_id);
+
+ // TODO - jump to next message in "history"?
+ $meta_info = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;folder=$folder_id";
+ $message = $user->lang['PM_DELETED'];
+
+ meta_refresh(3, $meta_info);
+ $message .= '<br /><br />' . sprintf($user->lang['RETURN_FOLDER'], '<a href="' . $meta_info . '">', '</a>');
+ trigger_error($message);
+ }
+ else
+ {
+ // "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;mode=compose"
+ confirm_box(false, 'DELETE_PM', $s_hidden_fields);
+ }
+ }
+
+ $html_status = ($config['allow_html'] && $config['auth_html_pm'] && $auth->acl_get('u_pm_html'));
+ $bbcode_status = ($config['allow_bbcode'] && $config['auth_bbcode_pm'] && $auth->acl_get('u_pm_bbcode'));
+ $smilies_status = ($config['allow_smilies'] && $config['auth_smilies_pm'] && $auth->acl_get('u_pm_smilies'));
+ $img_status = ($config['auth_img_pm'] && $auth->acl_get('u_pm_img'));
+ $flash_status = ($config['auth_flash_pm'] && $auth->acl_get('u_pm_flash'));
+ $quote_status = ($config['auth_quote_pm']);
+
+ // Save Draft
+ if ($save && $auth->acl_get('u_savedrafts'))
+ {
+ $subject = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', request_var('subject', ''));
+ $subject = (!$subject && $action != 'post') ? $user->lang['NEW_MESSAGE'] : $subject;
+ $message = (isset($_POST['message'])) ? htmlspecialchars(trim(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message']))) : '';
+ $message = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', $message);
+
+ if ($subject && $message)
+ {
+ $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));
+ $db->sql_query($sql);
+
+ meta_refresh(3, "ucp.$phpEx$SID&i=pm&mode=$mode");
+
+ $message = $user->lang['DRAFT_SAVED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=pm&amp;mode=$mode\">", '</a>');
+
+ trigger_error($message);
+ }
+
+ unset($subject);
+ unset($message);
+ }
+
+ // Load Draft
+ if ($draft_id && $auth->acl_get('u_savedrafts'))
+ {
+ $sql = 'SELECT draft_subject, draft_message
+ FROM ' . DRAFTS_TABLE . "
+ WHERE draft_id = $draft_id
+ AND topic_id = 0
+ AND forum_id = 0
+ AND user_id = " . $user->data['user_id'];
+ $result = $db->sql_query_limit($sql, 1);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $_REQUEST['subject'] = $row['draft_subject'];
+ $_POST['message'] = $row['draft_message'];
+ $refresh = true;
+ $template->assign_var('S_DRAFT_LOADED', true);
+ }
+ else
+ {
+ $draft_id = 0;
+ }
+ }
+
+ // Load Drafts
+ if ($load && $drafts)
+ {
+ load_drafts(0, 0, $id);
+ }
+
+ if ($submit || $preview || $refresh)
+ {
+ $subject = request_var('subject', '');
+
+ if (strcmp($subject, strtoupper($subject)) == 0 && $subject)
+ {
+ $subject = phpbb_strtolower($subject);
+ }
+ $subject = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', $subject);
+
+
+ $message_parser->message = (isset($_POST['message'])) ? htmlspecialchars(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message'])) : '';
+ $message_parser->message = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', $message_parser->message);
+
+ $icon_id = request_var('icon', 0);
+
+ $enable_html = (!$html_status || isset($_POST['disable_html'])) ? false : true;
+ $enable_bbcode = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true;
+ $enable_smilies = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true;
+ $enable_urls = (isset($_POST['disable_magic_url'])) ? 0 : 1;
+ $enable_sig = (!$config['allow_sig']) ? false : ((isset($_POST['attach_sig'])) ? true : false);
+
+ // Faster than crc32
+ $check_value = (($preview || $refresh) && isset($_POST['status_switch'])) ? (int) $_POST['status_switch'] : (($enable_html+1) << 16) + (($enable_bbcode+1) << 8) + (($enable_smilies+1) << 4) + (($enable_urls+1) << 2) + (($enable_sig+1) << 1);
+ $status_switch = (isset($_POST['status_switch']) && (int) $_POST['status_switch'] != $check_value);
+
+
+ // Parse Attachments - before checksum is calculated
+ $message_parser->parse_attachments($action, $msg_id, $submit, $preview, $refresh, true);
+
+ // Grab md5 'checksum' of new message
+ $message_md5 = md5($message_parser->message);
+
+ // Check checksum ... don't re-parse message if the same
+ if ($action != 'edit' || $message_md5 != $post_checksum || $status_switch || $preview)
+ {
+ // Parse message
+ $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $img_status, $flash_status, $quote_status);
+ }
+
+ if ($action != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('u_ignoreflood'))
+ {
+ // Flood check
+ $last_post_time = $user->data['user_lastpost_time'];
+
+ if ($last_post_time)
+ {
+ if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval']))
+ {
+ $error[] = $user->lang['FLOOD_ERROR'];
+ }
+ }
+ }
+
+ // Subject defined
+ if (!$subject)
+ {
+ $error[] = $user->lang['EMPTY_SUBJECT'];
+ }
+
+ if (!sizeof($address_list))
+ {
+ $error[] = $user->lang['NO_RECIPIENT'];
+ }
+
+ if (sizeof($message_parser->warn_msg))
+ {
+ $error[] = implode('<br />', $message_parser->warn_msg);
+ }
+
+ // Store message, sync counters
+ if (!sizeof($error) && $submit)
+ {
+ $pm_data = array(
+ 'subject' => (!$message_subject) ? $subject : $message_subject,
+ 'msg_id' => (int) $msg_id,
+ 'reply_from_root_level' => (int) $root_level,
+ 'reply_from_msg_id' => (int) $msg_id,
+ 'icon_id' => (int) $icon_id,
+ 'author_id' => (int) $author_id,
+ 'enable_sig' => (bool) $enable_sig,
+ 'enable_bbcode' => (bool) $enable_bbcode,
+ 'enable_html' => (bool) $enable_html,
+ 'enable_smilies' => (bool) $enable_smilies,
+ 'enable_urls' => (bool) $enable_urls,
+ 'message_md5' => (int) $message_md5,
+ 'post_checksum' => (int) $post_checksum,
+ 'post_edit_reason' => $post_edit_reason,
+ 'post_edit_user' => ($action == 'edit') ? $user->data['user_id'] : (int) $post_edit_user,
+ 'author_ip' => (int) $author_ip,
+ 'bbcode_bitfield' => (int) $message_parser->bbcode_bitfield,
+ 'address_list' => $address_list
+ );
+
+ submit_pm($action, $message_parser->message, $subject, $message_parser->bbcode_uid, $message_parser->attachment_data, $message_parser->filename_data, $pm_data);
+ }
+
+ $message_text = $message_parser->message;
+ $message_subject = stripslashes($subject);
+ }
+
+ // Preview
+ if (!sizeof($error) && $preview)
+ {
+ $post_time = ($action == 'edit') ? $post_time : $current_time;
+
+ $preview_subject = censor_text($subject);
+
+ $preview_signature = $user->data['user_sig'];
+ $preview_signature_uid = $user->data['user_sig_bbcode_uid'];
+ $preview_signature_bitfield = $user->data['user_sig_bbcode_bitfield'];
+
+ include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
+ $bbcode = new bbcode($message_parser->bbcode_bitfield | $preview_signature_bitfield);
+
+ $preview_message = $message_parser->message;
+ format_display($preview_message, $preview_signature, $message_parser->bbcode_uid, $preview_signature_uid, $enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $enable_sig, $bbcode);
+
+ // Attachment Preview
+ if (sizeof($message_parser->attachment_data))
+ {
+ include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
+ $extensions = $update_count = array();
+
+ $template->assign_var('S_HAS_ATTACHMENTS', true);
+ display_attachments(0, 'attachment', $message_parser->attachment_data, $update_count, true);
+ }
+ }
+
+
+ // Decode text for message display
+ $bbcode_uid = (($action == 'quote' || $action == 'forward')&& !$preview && !$refresh && !sizeof($error)) ? $bbcode_uid : $message_parser->bbcode_uid;
+
+ decode_text($message_text, $bbcode_uid);
+
+ if ($subject)
+ {
+ decode_text($subject, $bbcode_uid);
+ }
+
+
+ if ($action == 'quote' && !$preview && !$refresh)
+ {
+ $message_text = '[quote="' . $quote_username . '"]' . censor_text(trim($message_text)) . "[/quote]\n";
+ }
+
+ if (($action == 'reply' || $action == 'quote') && !$preview && !$refresh)
+ {
+ $message_subject = ((!preg_match('/^Re:/', $message_subject)) ? 'Re: ' : '') . censor_text($message_subject);
+ }
+
+ if ($action == 'forward' && !$preview && !$refresh)
+ {
+ $user->lang['FWD_ORIGINAL_MESSAGE'] = '-------- Original Message --------';
+ $user->lang['FWD_SUBJECT'] = 'Subject: %s';
+ $user->lang['FWD_DATE'] = 'Date: %s';
+ $user->lang['FWD_FROM'] = 'From: %s';
+ $user->lang['FWD_TO'] = 'To: %s';
+
+ $fwd_to_field = write_pm_addresses(array('to' => $to_address), 0, true);
+
+ $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_FROM'], $quote_username);
+ $forward_text[] = sprintf($user->lang['FWD_TO'], implode(', ', $fwd_to_field['to']));
+
+ $message_text = implode("\n", $forward_text) . "\n\n[quote=\"[url=" . generate_board_url() . "/memberlist.$phpEx$SID&mode=viewprofile&u={$author_id}]{$quote_username}[/url]\"]\n" . censor_text(trim($message_text)) . "\n[/quote]";
+ $message_subject = ((!preg_match('/^Fwd:/', $message_subject)) ? 'Fwd: ' : '') . censor_text($message_subject);
+ }
+
+
+ // MAIN PM PAGE BEGINS HERE
+
+ // Generate smilie listing
+ generate_smilies('inline', 0);
+
+ // Generate PM Icons
+ $s_pm_icons = false;
+ if ($config['enable_pm_icons'])
+ {
+ $s_pm_icons = posting_gen_topic_icons($action, $icon_id);
+ }
+
+ // Generate inline attachment select box
+ posting_gen_inline_attachments($message_parser);
+
+ // Build address list for display
+ // array('u' => array($author_id => 'to'));
+ if (sizeof($address_list))
+ {
+ // Get Usernames and Group Names
+ $result = array();
+ if (isset($address_list['u']) && sizeof($address_list['u']))
+ {
+ $result['u'] = $db->sql_query('SELECT user_id as id, username as name, user_colour as colour
+ FROM ' . USERS_TABLE . '
+ WHERE user_id IN (' . implode(', ', array_map('intval', array_keys($address_list['u']))) . ')');
+ }
+
+ if (isset($address_list['g']) && sizeof($address_list['g']))
+ {
+ $result['g'] = $db->sql_query('SELECT group_id as id, group_name as name, group_colour as colour
+ FROM ' . GROUPS_TABLE . '
+ WHERE group_id IN (' . implode(', ', array_map('intval', array_keys($address_list['g']))) . ')');
+ }
+
+ $u = $g = array();
+ foreach (array('u', 'g') as $type)
+ {
+ if (isset($result[$type]) && $result[$type])
+ {
+ while ($row = $db->sql_fetchrow($result[$type]))
+ {
+ ${$type}[$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']);
+ }
+ $db->sql_freeresult($result[$type]);
+ }
+ }
+
+ // Now Build the address list
+ $plain_address_field = '';
+ foreach ($address_list as $type => $adr_ary)
+ {
+ foreach ($adr_ary as $id => $field)
+ {
+ $field = ($field == 'to') ? 'to' : 'bcc';
+ $type = ($type == 'u') ? 'u' : 'g';
+ $id = (int) $id;
+
+ $template->assign_block_vars($field . '_recipient', array(
+ 'NAME' => ${$type}[$id]['name'],
+ 'IS_GROUP' => ($type == 'g'),
+ 'IS_USER' => ($type == 'u'),
+ 'COLOUR' => (${$type}[$id]['colour']) ? ${$type}[$id]['colour'] : '',
+ 'UG_ID' => $id,
+ 'U_VIEW' => ($type == 'u') ? "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $id : "{$phpbb_root_path}groupcp.$phpEx$SID&amp;g=" . $id,
+ 'TYPE' => $type)
+ );
+ }
+ }
+ }
+
+ // Build hidden address list
+ $s_hidden_address_field = '';
+ foreach ($address_list as $type => $adr_ary)
+ {
+ foreach ($adr_ary as $id => $field)
+ {
+ $s_hidden_address_field .= '<input type="hidden" name="address_list[' . (($type == 'u') ? 'u' : 'g') . '][' . (int) $id . ']" value="' . (($field == 'to') ? 'to' : 'bcc') . '" />';
+ }
+ }
+
+ $html_checked = (isset($enable_html)) ? !$enable_html : (($config['allow_html'] && $auth->acl_get('u_pm_html')) ? !$user->optionget('html') : 1);
+ $bbcode_checked = (isset($enable_bbcode)) ? !$enable_bbcode : (($config['allow_bbcode'] && $auth->acl_get('u_pm_bbcode')) ? !$user->optionget('bbcode') : 1);
+ $smilies_checked = (isset($enable_smilies)) ? !$enable_smilies : (($config['allow_smilies'] && $auth->acl_get('u_pm_smilies')) ? !$user->optionget('smile') : 1);
+ $urls_checked = (isset($enable_urls)) ? !$enable_urls : 0;
+ $sig_checked = $enable_sig;
+
+ switch ($action)
+ {
+ case 'post':
+ $page_title = $user->lang['POST_NEW_PM'];
+ break;
+
+ case 'quote':
+ $page_title = $user->lang['POST_QUOTE_PM'];
+ break;
+
+ case 'reply':
+ $page_title = $user->lang['POST_REPLY_PM'];
+ break;
+
+ case 'edit':
+ $page_title = $user->lang['POST_EDIT_PM'];
+ break;
+
+ case 'forward':
+ $page_title = $user->lang['POST_FORWARD_PM'];
+ break;
+
+ default:
+ trigger_error('NOT_AUTHORIZED');
+ }
+
+ $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 .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '<input type="hidden" name="draft_loaded" value="' . ((isset($_REQUEST['draft_loaded'])) ? intval($_REQUEST['draft_loaded']) : $draft_id) . '" />' : '';
+
+ $form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || @ini_get('file_uploads') == '0' || !$config['allow_pm_attach'] || !$auth->acl_get('u_pm_attach')) ? '' : ' enctype="multipart/form-data"';
+
+ // Start assigning vars for main posting page ...
+ $template->assign_vars(array(
+ 'L_POST_A' => $page_title,
+ 'L_ICON' => $user->lang['PM_ICON'],
+ 'L_MESSAGE_BODY_EXPLAIN'=> (intval($config['max_post_chars'])) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '',
+
+ 'SUBJECT' => (isset($message_subject)) ? $message_subject : '',
+ 'MESSAGE' => trim($message_text),
+ 'PREVIEW_SUBJECT' => ($preview && !sizeof($error)) ? $preview_subject : '',
+ 'PREVIEW_MESSAGE' => ($preview && !sizeof($error)) ? $preview_message : '',
+ 'PREVIEW_SIGNATURE' => ($preview && !sizeof($error)) ? $preview_signature : '',
+ 'HTML_STATUS' => ($html_status) ? $user->lang['HTML_IS_ON'] : $user->lang['HTML_IS_OFF'],
+ 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . "faq.$phpEx$SID&amp;mode=bbcode" . '" target="_phpbbcode">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . "faq.$phpEx$SID&amp;mode=bbcode" . '" target="_phpbbcode">', '</a>'),
+ 'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_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'],
+ 'MINI_POST_IMG' => $user->img('icon_post', $user->lang['POST']),
+ 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
+
+ 'S_DISPLAY_PREVIEW' => ($preview && !sizeof($error)),
+ 'S_EDIT_POST' => ($action == 'edit'),
+ 'S_SHOW_PM_ICONS' => $s_pm_icons,
+ 'S_HTML_ALLOWED' => $html_status,
+ 'S_HTML_CHECKED' => ($html_checked) ? ' checked="checked"' : '',
+ 'S_BBCODE_ALLOWED' => $bbcode_status,
+ 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '',
+ 'S_SMILIES_ALLOWED' => $smilies_status,
+ 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '',
+ 'S_SIG_ALLOWED' => ($config['allow_sig_pm'] && $auth->acl_get('u_pm_sig')),
+ 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '',
+ 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '',
+ 'S_SAVE_ALLOWED' => $auth->acl_get('u_savedrafts'),
+ 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $drafts),
+ 'S_FORM_ENCTYPE' => $form_enctype,
+
+ 'S_POST_ACTION' => $s_action,
+ 'S_HIDDEN_ADDRESS_FIELD'=> $s_hidden_address_field,
+ 'S_HIDDEN_FIELDS' => $s_hidden_fields)
+ );
+
+ // Attachment entry
+ if ($auth->acl_get('u_pm_attach') && $config['allow_pm_attach'] && $form_enctype)
+ {
+ posting_gen_attachment_entry($message_parser);
+ }
+}
+
+// Submit PM
+function submit_pm($mode, $message, $subject, $bbcode_uid, $attach_data, $filename_data, $data)
+{
+ global $db, $auth, $user, $config, $phpEx, $SID, $template;
+
+ // We do not handle erasing posts here
+ if ($mode == 'delete')
+ {
+ return;
+ }
+
+ $current_time = time();
+
+ // Collect some basic informations about which tables and which rows to update/insert
+ $sql_data = array();
+ $root_level = 0;
+
+ // Recipient Informations
+ $recipients = $to = $bcc = array();
+
+ if ($mode != 'edit')
+ {
+ // Build Recipient List
+ foreach (array('u', 'g') as $ug_type)
+ {
+ if (sizeof($data['address_list'][$ug_type]))
+ {
+ foreach ($data['address_list'][$ug_type] as $id => $field)
+ {
+ $field = ($field == 'to') ? 'to' : 'bcc';
+ if ($ug_type == 'u')
+ {
+ $recipients[$id] = $field;
+ }
+ ${$field}[] = $ug_type . '_' . (int) $id;
+ }
+ }
+ }
+
+ if (sizeof($data['address_list']['g']))
+ {
+ $sql = 'SELECT group_id, user_id
+ FROM ' . USER_GROUP_TABLE . '
+ WHERE group_id IN (' . implode(', ', array_keys($data['address_list']['g'])) . ')
+ AND user_pending = 0';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $field = ($data['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc';
+ $recipients[$row['user_id']] = $field;
+ }
+ $db->sql_freeresult($result);
+ }
+
+ if (!sizeof($recipients))
+ {
+ trigger_error('NO_RECIPIENT');
+ }
+ }
+
+ $sql = '';
+ switch ($mode)
+ {
+ case 'reply':
+ case 'quote':
+ $root_level = ($data['reply_from_root_level']) ? $data['reply_from_root_level'] : $data['reply_from_msg_id'];
+
+ // Set message_replied switch for this user
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
+ SET replied = 1
+ WHERE user_id = ' . $user->data['user_id'] . '
+ AND msg_id = ' . $data['reply_from_msg_id'];
+
+ case 'forward':
+ case 'post':
+ $sql_data = array(
+ 'root_level' => $root_level,
+ 'author_id' => (int) $user->data['user_id'],
+ 'icon_id' => $data['icon_id'],
+ 'author_ip' => $user->ip,
+ 'message_time' => $current_time,
+ 'enable_bbcode' => $data['enable_bbcode'],
+ 'enable_html' => $data['enable_html'],
+ 'enable_smilies' => $data['enable_smilies'],
+ 'enable_magic_url' => $data['enable_urls'],
+ 'enable_sig' => $data['enable_sig'],
+ 'message_subject' => $subject,
+ 'message_text' => $message,
+ 'message_checksum' => $data['message_md5'],
+ 'message_encoding' => $user->lang['ENCODING'],
+ 'message_attachment'=> (sizeof($filename_data['physical_filename'])) ? 1 : 0,
+ 'bbcode_bitfield' => $data['bbcode_bitfield'],
+ 'bbcode_uid' => $bbcode_uid,
+ 'to_address' => implode(':', $to),
+ 'bcc_address' => implode(':', $bcc)
+ );
+ break;
+
+ case 'edit':
+ $sql_data = array(
+ 'icon_id' => $data['icon_id'],
+ 'message_edit_time' => $current_time,
+ 'enable_bbcode' => $data['enable_bbcode'],
+ 'enable_html' => $data['enable_html'],
+ 'enable_smilies' => $data['enable_smilies'],
+ 'enable_magic_url' => $data['enable_urls'],
+ 'enable_sig' => $data['enable_sig'],
+ 'message_subject' => $subject,
+ 'message_text' => $message,
+ 'message_checksum' => $data['message_md5'],
+ 'message_encoding' => $user->lang['ENCODING'],
+ 'message_attachment'=> (sizeof($filename_data['physical_filename'])) ? 1 : 0,
+ 'bbcode_bitfield' => $data['bbcode_bitfield'],
+ 'bbcode_uid' => $bbcode_uid
+ );
+ break;
+ }
+
+ if (sizeof($sql_data))
+ {
+ if ($mode == 'post' || $mode == 'reply' || $mode == 'quote' || $mode == 'forward')
+ {
+ $db->sql_query('INSERT INTO ' . PRIVMSGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data));
+ $data['msg_id'] = $db->sql_nextid();
+ }
+ else if ($mode == 'edit')
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
+ SET message_edit_count = message_edit_count + 1, ' . $db->sql_build_array('UPDATE', $sql_data) . '
+ WHERE msg_id = ' . $data['msg_id'];
+ $db->sql_query($sql);
+ }
+ }
+
+ if ($mode != 'edit')
+ {
+ $db->sql_transaction();
+
+ if ($sql)
+ {
+ $db->sql_query($sql);
+ }
+ unset($sql);
+
+ foreach ($recipients as $user_id => $type)
+ {
+ $db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array(
+ 'msg_id' => $data['msg_id'],
+ 'user_id' => $user_id,
+ 'author_id' => $user->data['user_id'],
+ 'folder_id' => PRIVMSGS_NO_BOX,
+ 'new' => 1,
+ 'unread' => 1,
+ 'forwarded' => ($mode == 'forward') ? 1 : 0))
+ );
+ }
+
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_new_privmsg = user_new_privmsg + 1, user_unread_privmsg = user_unread_privmsg + 1
+ WHERE user_id IN (' . implode(', ', array_keys($recipients)) . ')';
+ $db->sql_query($sql);
+
+ // Put PM into outbox
+ $db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array(
+ 'msg_id' => (int) $data['msg_id'],
+ 'user_id' => (int) $user->data['user_id'],
+ 'author_id' => (int) $user->data['user_id'],
+ 'folder_id' => PRIVMSGS_OUTBOX,
+ 'new' => 0,
+ 'unread' => 0,
+ 'forwarded' => ($mode == 'forward') ? 1 : 0))
+ );
+
+ $db->sql_transaction('commit');
+ }
+
+ // Set user last post time
+ if ($mode == 'reply' || $mode == 'quote' || $mode == 'forward' || $mode == 'post')
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_lastpost_time = $current_time
+ WHERE user_id = " . $user->data['user_id'];
+ $db->sql_query($sql);
+ }
+
+ $db->sql_transaction();
+
+ // Submit Attachments
+ if (count($attach_data) && $data['msg_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit', 'forward')))
+ {
+ $space_taken = $files_added = 0;
+
+ foreach ($attach_data as $pos => $attach_row)
+ {
+ if ($attach_row['attach_id'])
+ {
+ // update entry in db if attachment already stored in db and filespace
+ $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
+ SET comment = '" . $db->sql_escape($attach_row['comment']) . "'
+ WHERE attach_id = " . (int) $attach_row['attach_id'];
+ $db->sql_query($sql);
+ }
+ else
+ {
+ // insert attachment into db
+ $attach_sql = array(
+ 'post_msg_id' => $data['msg_id'],
+ 'topic_id' => 0,
+ 'in_message' => 1,
+ 'poster_id' => $user->data['user_id'],
+ 'physical_filename' => $attach_row['physical_filename'],
+ 'real_filename' => $attach_row['real_filename'],
+ 'comment' => $attach_row['comment'],
+ 'extension' => $attach_row['extension'],
+ 'mimetype' => $attach_row['mimetype'],
+ 'filesize' => $attach_row['filesize'],
+ 'filetime' => $attach_row['filetime'],
+ 'thumbnail' => $attach_row['thumbnail']
+ );
+
+ $sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' .
+ $db->sql_build_array('INSERT', $attach_sql);
+ $db->sql_query($sql);
+
+ $space_taken += $attach_row['filesize'];
+ $files_added++;
+ }
+ }
+
+ if (count($attach_data))
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
+ SET message_attachment = 1
+ WHERE msg_id = ' . $data['msg_id'];
+ $db->sql_query($sql);
+ }
+
+ set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, true);
+ set_config('num_files', $config['num_files'] + $files_added, true);
+ }
+
+ $db->sql_transaction('commit');
+
+ // Delete draft if post was loaded...
+ $draft_id = request_var('draft_loaded', 0);
+ if ($draft_id)
+ {
+ $sql = 'DELETE FROM ' . DRAFTS_TABLE . "
+ WHERE draft_id = $draft_id
+ AND user_id = " . $user->data['user_id'];
+ $db->sql_query($sql);
+ }
+
+ // Send Notifications
+ if ($mode != 'edit')
+ {
+ pm_notification($mode, stripslashes($user->data['username']), $recipients, stripslashes($subject), stripslashes($message));
+ }
+
+ $return_message_url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;mode=view_messages&amp;action=view_message&amp;p=" . $data['msg_id'];
+ $return_folder_url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;folder=outbox";
+ meta_refresh(3, $return_message_url);
+
+ $message = $user->lang['MESSAGE_STORED'] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="' . $return_message_url . '">', '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_FOLDER'], '<a href="' . $return_folder_url . '">', '</a>');
+ trigger_error($message);
+}
+
+// For composing messages, handle list actions
+function handle_message_list_actions(&$address_list, $remove_u, $remove_g, $add_to, $add_bcc)
+{
+ global $_REQUEST;
+
+ // Delete User [TO/BCC]
+ if ($remove_u)
+ {
+ $remove_user_id = array_keys($_REQUEST['remove_u']);
+ unset($address_list['u'][(int) $remove_user_id[0]]);
+ }
+
+ // Delete Group [TO/BCC]
+ if ($remove_g)
+ {
+ $remove_group_id = array_keys($_REQUEST['remove_g']);
+ unset($address_list['g'][(int) $remove_group_id[0]]);
+ }
+
+ // Add User/Group [TO]
+ if ($add_to || $add_bcc)
+ {
+ $type = ($add_to) ? 'to' : 'bcc';
+
+ // Add Selected Groups
+ $group_list = isset($_REQUEST['group_list']) ? array_map('intval', $_REQUEST['group_list']) : array();
+
+ if (sizeof($group_list))
+ {
+ foreach ($group_list as $group_id)
+ {
+ $address_list['g'][$group_id] = $type;
+ }
+ }
+
+ // Build usernames to add
+ $usernames = (isset($_REQUEST['username'])) ? array(request_var('username', '')) : array();
+ $username_list = request_var('username_list', '');
+ if ($username_list)
+ {
+ $usernames = array_merge($usernames, explode("\n", $username_list));
+ }
+
+ // Reveal the correct user_ids
+ if (sizeof($usernames))
+ {
+ $user_id_ary = array();
+ user_get_id_name($user_id_ary, $usernames);
+
+ if (sizeof($user_id_ary))
+ {
+ foreach ($user_id_ary as $user_id)
+ {
+ $address_list['u'][$user_id] = $type;
+ }
+ }
+ }
+
+ // Add Friends if specified
+ $friend_list = (is_array($_REQUEST['add_' . $type])) ? array_map('intval', array_keys($_REQUEST['add_' . $type])) : array();
+
+ foreach ($friend_list as $user_id)
+ {
+ $address_list['u'][$user_id] = $type;
+ }
+ }
+
+}
+
+// PM Notification
+function pm_notification($mode, $author, $recipients, $subject, $message)
+{
+ global $db, $user, $config, $phpbb_root_path, $phpEx, $auth;
+
+ decode_text($subject);
+ $subject = censor_text($subject);
+
+ // Get banned User ID's
+ $sql = 'SELECT ban_userid
+ FROM ' . BANLIST_TABLE;
+ $result = $db->sql_query($sql);
+
+ unset($recipients[ANONYMOUS], $recipients[$user->data['user_id']]);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if (isset($row['ban_userid']))
+ {
+ unset($recipients[$row['ban_userid']]);
+ }
+ }
+ $db->sql_freeresult($result);
+
+ if (!sizeof($recipients))
+ {
+ return;
+ }
+
+ $recipient_list = implode(', ', array_keys($recipients));
+
+ $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_type, user_jabber
+ FROM ' . USERS_TABLE . "
+ WHERE user_id IN ($recipient_list)";
+ $result = $db->sql_query($sql);
+
+ $msg_list_ary = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if (trim($row['user_email']))
+ {
+ $msg_list_ary[] = array(
+ 'method' => $row['method'],
+ 'email' => $row['user_email'],
+ 'jabber' => $row['user_jabber'],
+ 'name' => $row['username'],
+ 'lang' => $row['user_lang']
+ );
+ }
+ }
+ $db->sql_freeresult($result);
+
+ if (!sizeof($msg_list_ary))
+ {
+ return;
+ }
+
+ include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
+ $messenger = new messenger();
+
+ $email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
+
+ foreach ($msg_list_ary as $pos => $addr)
+ {
+ $messenger->template('privmsg_notify', $addr['lang']);
+
+ $messenger->replyto($config['board_email']);
+ $messenger->to($addr['email'], $addr['name']);
+ $messenger->im($addr['jabber'], $addr['name']);
+
+ $messenger->assign_vars(array(
+ 'EMAIL_SIG' => $email_sig,
+ 'SITENAME' => $config['sitename'],
+ 'SUBJECT' => $subject,
+ 'AUTHOR_NAME' => $author,
+
+ 'U_INBOX' => generate_board_url() . "/ucp.$phpEx?i=pm&mode=unread")
+ );
+
+ $messenger->send($addr['method']);
+ $messenger->reset();
+ }
+ unset($msg_list_ary);
+
+ if ($messenger->queue)
+ {
+ $messenger->queue->save();
+ }
+}
+
+// Return number of recipients
+function num_recipients($address_list)
+{
+ $num_recipients = 0;
+
+ foreach ($address_list as $field => $adr_ary)
+ {
+ $num_recipients += sizeof($adr_ary);
+ }
+
+ return $num_recipients;
+}
+
+// Get recipient at position 'pos'
+function get_recipient_pos($address_list, $position = 1)
+{
+ $recipient = array();
+
+ $count = 1;
+ foreach ($address_list as $field => $adr_ary)
+ {
+ foreach ($adr_ary as $id => $type)
+ {
+ if ($count == $position)
+ {
+ $recipient[$field][$id] = $type;
+ break 2;
+ }
+ $count++;
+ }
+ }
+
+ return $recipient;
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/includes/ucp/ucp_pm_options.php b/phpBB/includes/ucp/ucp_pm_options.php
new file mode 100644
index 0000000000..699452fe69
--- /dev/null
+++ b/phpBB/includes/ucp/ucp_pm_options.php
@@ -0,0 +1,543 @@
+<?php
+// -------------------------------------------------------------
+//
+// $Id$
+//
+// FILENAME : options.php
+// STARTED : Mon Apr 19, 2004
+// COPYRIGHT : © 2004 phpBB Group
+// WWW : http://www.phpbb.com/
+// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
+//
+// -------------------------------------------------------------
+
+function message_options($id, $mode, $global_privmsgs_rules, $global_rule_conditions)
+{
+ global $phpbb_root_path, $phpEx, $SID, $user, $template, $auth, $config, $db;
+
+ $redirect_url = "{$phpbb_root_path}ucp.$phpEx$SID&i=pm&mode=options";
+
+ if (isset($_POST['fullfolder']))
+ {
+ $full_action = request_var('full_action', 0);
+
+ $set_folder_id = 0;
+ switch ($full_action)
+ {
+ case 1:
+ $set_folder_id = FULL_FOLDER_DELETE;
+ break;
+ case 2:
+ $set_folder_id = request_var('full_move_to', PRIVMSGS_INBOX);
+ break;
+ case 3:
+ $set_folder_id = FULL_FOLDER_HOLD;
+ break;
+ default:
+ $full_action = 0;
+ }
+
+ if ($full_action)
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_full_folder = ' . $set_folder_id . '
+ WHERE user_id = ' . $user->data['user_id'];
+ $db->sql_query($sql);
+
+ $user->data['user_full_folder'] = $set_folder_id;
+
+ $message = $user->lang['FULL_FOLDER_OPTION_CHANGED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $redirect_url . '">', '</a>');
+ meta_refresh(3, $redirect_url);
+ trigger_error($message);
+ }
+ }
+
+ if (isset($_POST['addfolder']))
+ {
+ $folder_name = request_var('foldername', '');
+
+ if ($folder_name)
+ {
+ $sql = 'SELECT folder_name
+ FROM ' . PRIVMSGS_FOLDER_TABLE . "
+ WHERE folder_name = '$folder_name'
+ AND user_id = " . $user->data['user_id'];
+ $result = $db->sql_query_limit($sql, 1);
+
+ if ($db->sql_fetchrow($result))
+ {
+ trigger_error(sprintf($user->lang['FOLDER_NAME_EXIST'], $folder_name));
+ }
+ $db->sql_freeresult($result);
+
+ $sql = 'SELECT COUNT(folder_id) as num_folder
+ FROM ' . PRIVMSGS_FOLDER_TABLE . '
+ WHERE user_id = ' . $user->data['user_id'];
+ $result = $db->sql_query($sql);
+
+ if ($db->sql_fetchfield('num_folder', 0, $result) >= $config['pm_max_boxes'])
+ {
+ trigger_error('MAX_FOLDER_REACHED');
+ }
+ $db->sql_freeresult($result);
+
+ $sql = 'INSERT INTO ' . PRIVMSGS_FOLDER_TABLE . ' ' . $db->sql_build_array('INSERT', array(
+ 'user_id' => (int) $user->data['user_id'], 'folder_name' => $folder_name));
+ $db->sql_query($sql);
+
+ $message = $user->lang['FOLDER_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $redirect_url . '">', '</a>');
+ meta_refresh(3, $redirect_url);
+ trigger_error($message);
+
+ }
+ }
+
+ if (isset($_POST['add_rule']))
+ {
+ $check_option = request_var('check_option', 0);
+ $rule_option = request_var('rule_option', 0);
+ $cond_option = request_var('cond_option', '');
+ $action_option = explode('|', request_var('action_option', ''));
+ $rule_string = ($cond_option != 'none') ? request_var('rule_string', '') : '';
+ $rule_user_id = ($cond_option != 'none') ? request_var('rule_user_id', 0) : 0;
+ $rule_group_id = ($cond_option != 'none') ? request_var('rule_group_id', 0) : 0;
+
+ $action = (int) $action_option[0];
+ $folder_id = (int) $action_option[1];
+
+ if (!$action || !$check_option || !$rule_option || !$cond_option || ($cond_option != 'none' && !$rule_string))
+ {
+ trigger_error('RULE_NOT_DEFINED');
+ }
+
+ if (($cond_option == 'user' && !$rule_user_id) || ($cond_option == 'group' && !$rule_group_id))
+ {
+ trigger_error('RULE_NOT_DEFINED');
+ }
+
+ $rule_ary = array(
+ 'user_id' => $user->data['user_id'],
+ 'rule_check' => $check_option,
+ 'rule_connection' => $rule_option,
+ 'rule_string' => $rule_string,
+ 'rule_user_id' => $rule_user_id,
+ 'rule_group_id' => $rule_group_id,
+ 'rule_action' => $action,
+ 'rule_folder_id'=> $folder_id
+ );
+
+ $sql = 'SELECT rule_id
+ FROM ' . PRIVMSGS_RULES_TABLE . '
+ WHERE ' . $db->sql_build_array('SELECT', $rule_ary);
+ $result = $db->sql_query($sql);
+
+ if ($db->sql_fetchrow($result))
+ {
+ trigger_error('RULE_ALREADY_DEFINED');
+ }
+ $db->sql_freeresult($result);
+
+ $sql = 'INSERT INTO ' . PRIVMSGS_RULES_TABLE . ' ' . $db->sql_build_array('INSERT', $rule_ary);
+ $db->sql_query($sql);
+
+ $message = $user->lang['RULE_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $redirect_url . '">', '</a>');
+ meta_refresh(3, $redirect_url);
+ trigger_error($message);
+ }
+
+ if (isset($_POST['delete_rule']) && !isset($_POST['cancel']))
+ {
+ $delete_id = array_map('intval', array_keys($_POST['delete_rule']));
+ $delete_id = (int) $delete_id[0];
+
+ if (!$delete_id)
+ {
+ redirect("{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;mode=$mode");
+ }
+
+ $s_hidden_fields = '<input type="hidden" name="delete_rule[' . $delete_id . ']" value="1" />';
+
+ // Do we need to confirm ?
+ if (confirm_box(true))
+ {
+ $sql = 'DELETE FROM ' . PRIVMSGS_RULES_TABLE . '
+ WHERE user_id = ' . $user->data['user_id'] . "
+ AND rule_id = $delete_id";
+ $db->sql_query($sql);
+
+ $meta_info = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;mode=$mode";
+ $message = $user->lang['RULE_DELETED'];
+
+ meta_refresh(3, $meta_info);
+ $message .= '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $meta_info . '">', '</a>');
+ trigger_error($message);
+ }
+ else
+ {
+ confirm_box(false, 'DELETE_RULE', $s_hidden_fields);
+ }
+
+ }
+
+ $folder = array();
+ $message_limit = (!$user->data['group_message_limit']) ? $config['pm_max_msgs'] : $user->data['group_message_limit'];
+
+ $sql = 'SELECT COUNT(msg_id) as num_messages
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE user_id = ' . $user->data['user_id'] . '
+ AND folder_id = ' . PRIVMSGS_INBOX;
+ $result = $db->sql_query($sql);
+ $num_messages = $db->sql_fetchfield('num_messages', 0, $result);
+ $db->sql_freeresult($result);
+
+ $folder[PRIVMSGS_INBOX] = array(
+ 'folder_name' => $user->lang['PM_INBOX'],
+ 'message_status'=> sprintf($user->lang['FOLDER_MESSAGE_STATUS'], $num_messages, $message_limit)
+ );
+
+ $sql = 'SELECT folder_id, folder_name, pm_count
+ FROM ' . PRIVMSGS_FOLDER_TABLE . '
+ WHERE user_id = ' . $user->data['user_id'];
+ $result = $db->sql_query($sql);
+
+ $num_user_folder = 0;
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $num_user_folder++;
+ $folder[$row['folder_id']] = array(
+ 'folder_name' => $row['folder_name'],
+ 'message_status'=> sprintf($user->lang['FOLDER_MESSAGE_STATUS'], $row['pm_count'], $message_limit)
+ );
+ }
+ $db->sql_freeresult($result);
+
+ $s_full_folder_options = $s_to_folder_options = $s_folder_options = '';
+
+ foreach ($folder as $folder_id => $folder_ary)
+ {
+ $s_full_folder_options .= '<option value="' . $folder_id . '"' . (($user->data['user_full_folder'] == $folder_id) ? ' selected="selected"' : '') . '>' . $folder_ary['folder_name'] . ' (' . $folder_ary['message_status'] . ')</option>';
+ $s_to_folder_options .= '<option value="' . $folder_id . '"' . (($to_folder_id == $folder_id) ? ' selected="selected"' : '') . '>' . $folder_ary['folder_name'] . ' (' . $folder_ary['message_status'] . ')</option>';
+
+ if ($folder_id != PRIVMSGS_INBOX)
+ {
+ $s_folder_options .= '<option value="' . $folder_id . '">' . $folder_ary['folder_name'] . ' (' . $folder_ary['message_status'] . ')</option>';
+ }
+ }
+
+ $s_delete_checked = ($user->data['user_full_folder'] == FULL_FOLDER_DELETE) ? ' checked="checked"' : '';
+ $s_hold_checked = ($user->data['user_full_folder'] == FULL_FOLDER_HOLD) ? ' checked="checked"' : '';
+ $s_move_checked = ($user->data['user_full_folder'] >= 0) ? ' checked="checked"' : '';
+
+ if ($user->data['user_full_folder'] == FULL_FOLDER_NONE)
+ {
+ switch ($config['full_folder_action'])
+ {
+ case 1:
+ $s_delete_checked = ' checked="checked"';
+ break;
+ case 2:
+ $s_hold_checked = ' checked="checked"';
+ break;
+ }
+ }
+
+ $template->assign_vars(array(
+ 'S_FULL_FOLDER_OPTIONS' => $s_full_folder_options,
+ 'S_TO_FOLDER_OPTIONS' => $s_to_folder_options,
+ 'S_FOLDER_OPTIONS' => $s_folder_options,
+ 'S_DELETE_CHECKED' => $s_delete_checked,
+ 'S_HOLD_CHECKED' => $s_hold_checked,
+ 'S_MOVE_CHECKED' => $s_move_checked,
+ 'S_MAX_FOLDER_REACHED' => ($num_user_folder >= $config['pm_max_boxes']) ? true : false,
+
+ 'DEFAULT_ACTION' => ($config['full_folder_action'] == 1) ? $user->lang['DELETE_OLDEST_MESSAGES'] : $user->lang['HOLD_NEW_MESSAGES'],
+
+ 'U_FIND_USERNAME' => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=searchuser&amp;form=ucp&amp;field=rule_string")
+ );
+
+ $rule_lang = $action_lang = $check_lang = array();
+
+ // Build all three language arrays
+ preg_replace('#(?:)((RULE|ACTION|CHECK)_([A-Z0-9_]+))(?:)#e', "\${strtolower('\\2') . '_lang'}[constant('\\1')] = \$user->lang['PM_\\2']['\\3']", implode(':', array_keys(get_defined_constants())));
+
+ /*
+ Rule Ordering:
+ -> CHECK_* -> RULE_* [IN $global_privmsgs_rules:CHECK_*] -> [IF $rule_conditions[RULE_*] [|text|bool|user|group|own_group]] -> ACTION_*
+ */
+
+ $check_option = request_var('check_option', 0);
+ $rule_option = request_var('rule_option', 0);
+ $cond_option = request_var('cond_option', '');
+ $action_option = request_var('action_option', '');
+ $back = (isset($_REQUEST['back'])) ? request_var('back', '') : array();
+
+ if (sizeof($back))
+ {
+ if ($action_option)
+ {
+ $action_option = '';
+ }
+ else if ($cond_option)
+ {
+ $cond_option = '';
+ }
+ else if ($rule_option)
+ {
+ $rule_option = 0;
+ }
+ else if ($check_option)
+ {
+ $check_option = 0;
+ }
+ }
+
+ if (isset($back['action']) && $cond_option == 'none')
+ {
+ $back['cond'] = true;
+ }
+
+ // Check
+ define_check_option(($check_option && !isset($back['rule'])) ? true : false, $check_option, $check_lang);
+
+ if ($check_option && !isset($back['rule']))
+ {
+ define_rule_option(($rule_option && !isset($back['cond'])) ? true : false, $rule_option, $rule_lang, $global_privmsgs_rules[$check_option]);
+ }
+
+ if ($rule_option && !isset($back['cond']))
+ {
+ if (!isset($global_rule_conditions[$rule_option]))
+ {
+ $cond_option = 'none';
+ $template->assign_var('NONE_CONDITION', true);
+ }
+ else
+ {
+ define_cond_option(($cond_option && !isset($back['action'])) ? true : false, $cond_option, $rule_option, $global_rule_conditions);
+ }
+ }
+
+ if ($cond_option && !isset($back['action']))
+ {
+ define_action_option(false, $action_option, $action_lang, $folder);
+ }
+
+ show_defined_rules($user->data['user_id'], $check_lang, $rule_lang, $action_lang, $folder);
+}
+
+function define_check_option($hardcoded, $check_option, $check_lang)
+{
+ global $template;
+
+ $s_check_options = '';
+ if (!$hardcoded)
+ {
+ foreach ($check_lang as $value => $lang)
+ {
+ $s_check_options .= '<option value="' . $value . '"' . (($value == $check_option) ? ' selected="selected"' : '') . '>' . $lang . '</option>';
+ }
+ }
+
+ $template->assign_vars(array(
+ 'S_CHECK_DEFINED' => true,
+ 'S_CHECK_SELECT' => ($hardcoded) ? false : true,
+ 'CHECK_CURRENT' => isset($check_lang[$check_option]) ? $check_lang[$check_option] : '',
+ 'S_CHECK_OPTIONS' => $s_check_options,
+ 'CHECK_OPTION' => $check_option)
+ );
+}
+
+function define_action_option($hardcoded, $action_option, $action_lang, $folder)
+{
+ global $db, $template, $user;
+
+ $l_action = $s_action_options = '';
+ if ($hardcoded)
+ {
+ $option = explode('|', $action_option);
+ $action = (int) $option[0];
+ $folder_id = (int) $option[1];
+
+ $l_action = $action_lang[$action];
+ if ($action == ACTION_PLACE_INTO_FOLDER)
+ {
+ $l_action .= ' -> ' . $folder[$folder_id]['folder_name'];
+ }
+ }
+ else
+ {
+ foreach ($action_lang as $action => $lang)
+ {
+ if ($action == ACTION_PLACE_INTO_FOLDER)
+ {
+ foreach ($folder as $folder_id => $folder_ary)
+ {
+ $s_action_options .= '<option value="' . $action . '|' . $folder_id . '"' . (($action_option == $action . '|' . $folder_id) ? ' selected="selected"' : '') . '>' . $lang . ' -> ' . $folder_ary['folder_name'] . '</option>';
+ }
+ }
+ else
+ {
+ $s_action_options .= '<option value="' . $action . '|0"' . (($action_option == $action . '|0') ? ' selected="selected"' : '') . '>' . $lang . '</option>';
+ }
+ }
+ }
+
+ $template->assign_vars(array(
+ 'S_ACTION_DEFINED' => true,
+ 'S_ACTION_SELECT' => ($hardcoded) ? false : true,
+ 'ACTION_CURRENT' => $l_action,
+ 'S_ACTION_OPTIONS' => $s_action_options,
+ 'ACTION_OPTION' => $action_option)
+ );
+}
+
+function define_rule_option($hardcoded, $rule_option, $rule_lang, $check_ary)
+{
+ global $template;
+
+ $s_rule_options = '';
+ if (!$hardcoded)
+ {
+ foreach ($check_ary as $value => $_check)
+ {
+ $s_rule_options .= '<option value="' . $value . '"' . (($value == $rule_option) ? ' selected="selected"' : '') . '>' . $rule_lang[$value] . '</option>';
+ }
+ }
+
+ $template->assign_vars(array(
+ 'S_RULE_DEFINED' => true,
+ 'S_RULE_SELECT' => !$hardcoded,
+ 'RULE_CURRENT' => isset($rule_lang[$rule_option]) ? $rule_lang[$rule_option] : '',
+ 'S_RULE_OPTIONS' => $s_rule_options,
+ 'RULE_OPTION' => $rule_option)
+ );
+}
+
+function define_cond_option($hardcoded, $cond_option, $rule_option, $global_rule_conditions, &$rule_save_ary)
+{
+ global $db, $template, $_REQUEST;
+
+ $template->assign_vars(array(
+ 'S_COND_DEFINED' => true,
+ 'S_COND_SELECT' => (!$hardcoded && isset($global_rule_conditions[$rule_option])) ? true : false)
+ );
+
+ // Define COND_OPTION
+ if (!isset($global_rule_conditions[$rule_option]))
+ {
+ $template->assign_vars(array(
+ 'COND_OPTION' => 'none',
+ 'COND_CURRENT' => false)
+ );
+ return;
+ }
+
+ // Define Condition
+ $condition = $global_rule_conditions[$rule_option];
+ $current_value = '';
+
+ switch ($condition)
+ {
+ case 'text':
+ $rule_string = request_var('rule_string', '');
+
+ $template->assign_vars(array(
+ 'S_TEXT_CONDITION' => true,
+ 'CURRENT_STRING' => $rule_string,
+ 'CURRENT_USER_ID' => 0,
+ 'CURRENT_GROUP_ID' => 0)
+ );
+
+ $current_value = $rule_string;
+ break;
+
+ case 'user':
+ $rule_user_id = request_var('rule_user_id', 0);
+ $rule_string = request_var('rule_string', '');
+
+ if ($rule_string && !$rule_user_id)
+ {
+ $sql = 'SELECT user_id
+ FROM ' . USERS_TABLE . "
+ WHERE username = '" . $db->sql_escape($rule_string) . "'";
+ $result = $db->sql_query($sql);
+ if (!($rule_user_id = $db->sql_fetchfield('user_id', 0, $result)))
+ {
+ $rule_string = '';
+ }
+ $db->sql_freeresult($result);
+ }
+ else if (!$rule_string && $rule_user_id)
+ {
+ $sql = 'SELECT username
+ FROM ' . USERS_TABLE . "
+ WHERE user_id = $rule_user_id";
+ $result = $db->sql_query($sql);
+ if (!($rule_string = $db->sql_fetchfield('username', 0, $result)))
+ {
+ $rule_user_id = 0;
+ }
+ $db->sql_freeresult($result);
+ }
+
+ $template->assign_vars(array(
+ 'S_USER_CONDITION' => true,
+ 'CURRENT_STRING' => $rule_string,
+ 'CURRENT_USER_ID' => $rule_user_id,
+ 'CURRENT_GROUP_ID' => 0)
+ );
+
+ $current_value = $rule_string;
+ break;
+
+ case 'group':
+ $rule_group_id = request_var('rule_group_id', 0);
+ $rule_string = request_var('rule_string', '');
+
+ $template->assign_vars(array(
+ 'S_GROUP_CONDITION' => true,
+ 'CURRENT_STRING' => $rule_string,
+ 'CURRENT_USER_ID' => 0,
+ 'CURRENT_GROUP_ID' => $rule_group_id)
+ );
+
+ $current_value = $rule_string;
+
+ break;
+
+ default:
+ return;
+ }
+
+ $template->assign_vars(array(
+ 'COND_OPTION' => $condition,
+ 'COND_CURRENT' => $current_value)
+ );
+}
+
+function show_defined_rules($user_id, $check_lang, $rule_lang, $action_lang, $folder)
+{
+ global $db, $template;
+
+ $sql = 'SELECT *
+ FROM ' . PRIVMSGS_RULES_TABLE . '
+ WHERE user_id = ' . $user_id;
+ $result = $db->sql_query($sql);
+
+ $count = 0;
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $template->assign_block_vars('rule', array(
+ 'COUNT' => ++$count,
+ 'RULE_ID' => $row['rule_id'],
+ 'CHECK' => $check_lang[$row['rule_check']],
+ 'RULE' => $rule_lang[$row['rule_connection']],
+ 'STRING' => $row['rule_string'],
+ 'ACTION' => $action_lang[$row['rule_action']],
+ 'FOLDER' => ($row['rule_action'] == ACTION_PLACE_INTO_FOLDER) ? $folder[$row['rule_folder_id']]['folder_name'] : '')
+ );
+ }
+ $db->sql_freeresult($result);
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php
new file mode 100644
index 0000000000..328161baa6
--- /dev/null
+++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php
@@ -0,0 +1,343 @@
+<?php
+// -------------------------------------------------------------
+//
+// $Id$
+//
+// FILENAME : viewfolder.php
+// STARTED : Sun Apr 11, 2004
+// COPYRIGHT : © 2004 phpBB Group
+// WWW : http://www.phpbb.com/
+// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
+//
+// -------------------------------------------------------------
+
+// * Called from ucp_pm with mode == 'view_messages' && action == 'view_folder'
+
+function view_folder($id, $mode, $folder_id, $folder, $type)
+{
+ global $phpbb_root_path, $phpEx, $SID, $user, $template, $auth, $config, $db;
+
+ $user->add_lang('viewforum');
+
+ // Grab icons
+ $icons = array();
+ obtain_icons($icons);
+
+ $color_rows = array('marked', 'replied', 'message_reported', 'friend', 'foe');
+
+ foreach ($color_rows as $var)
+ {
+ $template->assign_block_vars('pm_colour_info', array(
+ 'IMG' => $user->img("pm_{$var}", ''),
+ 'CLASS' => "pm_{$var}_colour",
+ 'LANG' => $user->lang[strtoupper($var) . '_MESSAGE'])
+ );
+ }
+
+ $mark_options = array('mark_important', 'delete_marked');
+
+ $s_mark_options = '';
+ foreach ($mark_options as $mark_option)
+ {
+ $s_mark_options .= '<option value="' . $mark_option . '">' . $user->lang[strtoupper($mark_option)] . '</option>';
+ }
+
+ $friend = $foe = array();
+
+ // Get friends and foes
+ $sql = 'SELECT *
+ FROM ' . ZEBRA_TABLE . '
+ WHERE user_id = ' . $user->data['user_id'];
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $friend[$row['zebra_id']] = $row['friend'];
+ $foe[$row['zebra_id']] = $row['foe'];
+ }
+ $db->sql_freeresult($result);
+
+ $template->assign_vars(array(
+ 'S_UNREAD' => ($type == 'unread'),
+ 'S_MARK_OPTIONS'=> $s_mark_options)
+ );
+
+ $folder_info = get_pm_from($folder_id, $folder, $user->data['user_id'], "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=$id", $type);
+
+ // Okay, lets dump out the page ...
+ if (sizeof($folder_info['pm_list']))
+ {
+ // Build Recipient List if in outbox/sentbox - max two additional queries
+ $recipient_list = $address_list = $address = array();
+ 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']));
+ foreach (array('u', 'g') 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' => '');
+ }
+ }
+ }
+ }
+
+ foreach (array('u', 'g') as $ug_type)
+ {
+ if (isset($recipient_list[$ug_type]) && sizeof($recipient_list[$ug_type]))
+ {
+ $sql = ($ug_type == 'u') ? 'SELECT user_id as id, username as name, user_colour as colour FROM ' . USERS_TABLE . ' WHERE user_id' : 'SELECT group_id as id, group_name as name, group_colour as colour FROM ' . GROUPS_TABLE . ' WHERE group_id';
+ $sql .= ' IN (' . implode(', ', array_keys($recipient_list[$ug_type])) . ')';
+
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $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)
+ {
+ $address_list[$message_id][] = (($type == 'u') ? "<a href=\"{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=$ug_id\">" : "<a href=\"{$phpbb_root_path}groupcp.$phpEx$SID&amp;g=$ug_id\">") . (($recipient_list[$type][$ug_id]['colour']) ? '<span style="color:#' . $recipient_list[$type][$ug_id]['colour'] . '">' : '<span>') . $recipient_list[$type][$ug_id]['name'] . '</span></a>';
+ }
+ }
+ }
+
+ unset($recipient_list, $address);
+ }
+
+ $i = 0;
+ $url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=$id";
+
+ foreach ($folder_info['pm_list'] as $message_id)
+ {
+ $row =& $folder_info['rowset'][$message_id];
+
+ $folder_img = ($row['unread']) ? 'folder_new' : 'folder';
+ $folder_alt = ($row['unread']) ? 'NEW_MESSAGES' : 'NO_NEW_MESSAGES';
+
+ // Generate all URIs ...
+ $message_author = "<a href=\"{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $row['author_id'] . '">' . $row['username'] . '</a>';
+ $view_message_url = "$url&amp;f=$folder_id&amp;p=$message_id";
+
+ $row_indicator = '';
+ foreach ($color_rows as $var)
+ {
+ if (($var != 'friend' && $var != 'foe' && $row[$var])
+ ||
+ (($var == 'friend' || $var == 'foe') && isset(${$var}[$row['author_id']]) && ${$var}[$row['author_id']]))
+ {
+ $row_indicator = $var;
+ break;
+ }
+ }
+
+ // Send vars to template
+ $template->assign_block_vars('messagerow', array(
+ 'PM_CLASS' => ($row_indicator) ? 'pm_' . $row_indicator . '_colour' : '',
+
+ 'FOLDER_ID' => $folder_id,
+ 'MESSAGE_ID' => $message_id,
+ 'MESSAGE_AUTHOR' => $message_author,
+ 'SENT_TIME' => $user->format_date($row['message_time'], $config['board_timezone']),
+ 'SUBJECT' => censor_text($row['message_subject']),
+ 'FOLDER' => (isset($folder[$row['folder_id']])) ? $folder[$row['folder_id']]['folder_name'] : '',
+ 'U_FOLDER' => (isset($folder[$row['folder_id']])) ? "$url&amp;folder=" . $row['folder_id'] : '',
+ 'PM_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? '<img src="' . $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] . '" width="' . $icons[$row['icon_id']]['width'] . '" height="' . $icons[$row['icon_id']]['height'] . '" alt="" title="" />' : '',
+ 'FOLDER_IMG' => $user->img($folder_img, $folder_alt),
+ 'PM_IMG' => ($row_indicator) ? $user->img('pm_' . $row_indicator, '') : '',
+ 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $row['message_attachment'] && $config['pm_attachments'] && $config['auth_download_pm']) ? $user->img('icon_attach', sprintf($user->lang['TOTAL_ATTACHMENTS'], $row['message_attachment'])) : '',
+
+ 'S_ROW_COUNT' => $i,
+ 'S_PM_REPORTED' => (!empty($row['message_reported']) && $auth->acl_get('m_')) ? true : false,
+
+ 'U_VIEW_PM' => $view_message_url,
+ 'RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '',
+ 'U_MCP_REPORT' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&amp;mode=reports&amp;pm=$message_id")
+// 'U_MCP_QUEUE' => "mcp.$phpEx?sid={$user->session_id}&amp;mode=mod_queue&amp;t=$topic_id")
+ );
+
+ $i++;
+
+ unset($folder_info['rowset'][$message_id]);
+ }
+
+ $template->assign_vars(array(
+ 'S_SHOW_RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? true : false,
+ 'S_SHOW_COLOUR_LEGEND' => true)
+ );
+ }
+}
+
+// Get PM's in folder x from user x
+// Get PM's in all folders from user x with type of x (unread, new)
+function get_pm_from($folder_id, $folder, $user_id, $url, $type = 'folder')
+{
+ global $user, $db, $template, $config, $auth, $_POST;
+
+ $start = request_var('start', 0);
+
+ $sort_days = (isset($_REQUEST['st'])) ? max(intval($_REQUEST['st']), 0) : ((!empty($user->data['user_show_days'])) ? $user->data['user_show_days'] : 0);
+ $sort_key = (!empty($_REQUEST['sk'])) ? htmlspecialchars($_REQUEST['sk']) : ((!empty($user->data['user_sortby_type'])) ? $user->data['user_sortby_type'] : 't');
+ $sort_dir = (!empty($_REQUEST['sd'])) ? htmlspecialchars($_REQUEST['sd']) : ((!empty($user->data['user_sortby_dir'])) ? $user->data['user_sortby_dir'] : 'd');
+
+ // PM ordering options
+ $limit_days = array(0 => $user->lang['ALL_MESSAGES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
+ $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
+ $sort_by_sql = array('a' => 'u.username', 't' => 'p.message_time', 's' => 'p.subject');
+
+ $sort_key = (!in_array($sort_key, array('a', 't', 's'))) ? 't' : $sort_key;
+
+ $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
+ gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
+
+ if ($type != 'folder')
+ {
+ $folder_sql = ($type == 'unread') ? 't.unread = 1' : 't.new = 1';
+ $folder_id = PRIVMSGS_INBOX;
+ }
+ else
+ {
+ $folder_sql = 't.folder_id = ' . (int) $folder_id;
+ }
+
+ // Limit pms to certain time frame, obtain correct pm count
+ if ($sort_days)
+ {
+ $min_post_time = time() - ($sort_days * 86400);
+
+ $sql = 'SELECT COUNT(t.msg_id) AS pm_count
+ FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . " p
+ WHERE $folder_sql
+ AND t.user_id = $user_id
+ AND t.msg_id = p.msg_id
+ AND p.message_time >= $min_post_time";
+ $result = $db->sql_query_limit($sql, 1);
+
+ if (isset($_POST['sort']))
+ {
+ $start = 0;
+ }
+
+ $pm_count = ($row = $db->sql_fetchrow($result)) ? $row['pm_count'] : 0;
+ $db->sql_freeresult($result);
+
+ $sql_limit_time = "AND p.message_time >= $min_post_time";
+ }
+ else
+ {
+ if ($type == 'folder')
+ {
+ $pm_count = $folder[$folder_id]['num_messages'];
+ }
+ else
+ {
+ if (in_array($folder_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX)))
+ {
+ $sql = 'SELECT COUNT(t.msg_id) AS pm_count
+ FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . " p
+ WHERE $folder_sql
+ AND t.user_id = $user_id
+ AND t.msg_id = p.msg_id";
+ }
+ else
+ {
+ $sql = 'SELECT pm_count
+ FROM ' . PRIVMSGS_FOLDER_TABLE . "
+ WHERE folder_id = $folder_id
+ AND user_id = $user_id";
+ }
+ $result = $db->sql_query_limit($sql, 1);
+ $pm_count = ($row = $db->sql_fetchrow($result)) ? $row['pm_count'] : 0;
+ $db->sql_freeresult($result);
+ }
+
+ $sql_limit_time = '';
+ }
+
+ $template->assign_vars(array(
+ 'PAGINATION' => generate_pagination("$url&amp;mode=view_messages&amp;action=view_folder&amp;f=$folder_id&amp;$u_sort_param", $pm_count, $config['topics_per_page'], $start),
+ '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('btn_locked', $post_alt) : $user->img('btn_post_pm', $post_alt),
+
+ 'REPORTED_IMG' => $user->img('icon_reported', 'MESSAGE_REPORTED'),
+
+ 'L_NO_MESSAGES' => (!$auth->acl_get('u_sendpm')) ? $user->lang['POST_PM_LOCKED'] : $user->lang['NO_MESSAGES'],
+
+ 'S_SELECT_SORT_DIR' => $s_sort_dir,
+ 'S_SELECT_SORT_KEY' => $s_sort_key,
+ 'S_SELECT_SORT_DAYS' => $s_limit_days,
+ 'S_TOPIC_ICONS' => ($config['enable_pm_icons']) ? true : false,
+
+ 'U_POST_NEW_TOPIC' => ($auth->acl_get('u_sendpm')) ? "$url&amp;mode=compose&amp;action=post" : '',
+ 'S_PM_ACTION' => "$url&amp;mode=view_messages&amp;action=view_folder&amp;f=$folder_id")
+ );
+
+ // Grab all pm data
+ $rowset = $pm_list = array();
+
+ // If the user is trying to reach late pages, start searching from the end
+ $store_reverse = false;
+ $sql_limit = $config['topics_per_page'];
+ if ($start > $pm_count / 2)
+ {
+ $store_reverse = true;
+
+ if ($start + $config['topics_per_page'] > $pm_count)
+ {
+ $sql_limit = min($config['topics_per_page'], max(1, $pm_count - $start));
+ }
+
+ // Select the sort order
+ $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC');
+ $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');
+ $sql_start = $start;
+ }
+
+ $sql = 'SELECT t.*, p.author_id, p.root_level, p.message_time, p.message_subject, p.icon_id, p.message_reported, p.to_address, p.message_attachment, p.bcc_address, u.username
+ FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u
+ WHERE t.user_id = $user_id
+ AND p.author_id = u.user_id
+ AND $folder_sql
+ AND t.msg_id = p.msg_id
+ $sql_limit_time
+ ORDER BY $sql_sort_order";
+
+ $result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
+
+ while($row = $db->sql_fetchrow($result))
+ {
+ $rowset[$row['msg_id']] = $row;
+ $pm_list[] = $row['msg_id'];
+ }
+ $db->sql_freeresult($result);
+
+ $pm_list = ($store_reverse) ? array_reverse($pm_list) : $pm_list;
+
+ return array(
+ 'pm_count' => $pm_count,
+ 'pm_list' => $pm_list,
+ 'rowset' => $rowset
+ );
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php
new file mode 100644
index 0000000000..bb9cda5804
--- /dev/null
+++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php
@@ -0,0 +1,471 @@
+<?php
+// -------------------------------------------------------------
+//
+// $Id$
+//
+// FILENAME : viewmessage.php
+// STARTED : Mon Apr 12, 2004
+// COPYRIGHT : © 2004 phpBB Group
+// WWW : http://www.phpbb.com/
+// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
+//
+// -------------------------------------------------------------
+
+function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
+{
+ global $phpbb_root_path, $phpEx, $SID, $user, $template, $auth, $config, $db;
+
+ $user->add_lang('viewtopic');
+
+ $msg_id = (int) $msg_id;
+ $folder_id = (int) $folder_id;
+ $author_id = (int) $message_row['author_id'];
+
+ // Grab icons
+ $icons = array();
+ obtain_icons($icons);
+
+ // Instantiate BBCode if need be
+ if ($message_row['bbcode_bitfield'])
+ {
+ include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
+ $bbcode = new bbcode($message_row['bbcode_bitfield']);
+ }
+
+ // Assign TO/BCC Addresses to template
+ write_pm_addresses(array('to' => $message_row['to_address'], 'bcc' => $message_row['bcc_address']), $author_id);
+
+ $user_info = get_user_informations($author_id, $message_row);
+
+ // Parse the message and subject
+ $message = $message_row['message_text'];
+
+ // If the board has HTML off but the message has HTML on then we process it, else leave it alone
+ if (!$config['auth_html_pm'] || !$auth->acl_get('u_pm_html'))
+ {
+ if ($message_row['enable_html'] && $config['auth_bbcode_pm'] && $auth->acl_get('u_pm_bbcode'))
+ {
+ $message = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $message);
+ }
+ }
+
+ // Second parse bbcode here
+ if ($message_row['bbcode_bitfield'])
+ {
+ $bbcode->bbcode_second_pass($message, $message_row['bbcode_uid'], $message_row['bbcode_bitfield']);
+ }
+
+ // Always process smilies after parsing bbcodes
+ $message = smilie_text($message);
+
+ // Replace naughty words such as farty pants
+ $message_row['message_subject'] = censor_text($message_row['message_subject']);
+ $message = str_replace("\n", '<br />', censor_text($message));
+
+ // Editing information
+ if ($message_row['message_edit_count'] && $config['display_last_edited'])
+ {
+ $l_edit_time_total = ($message_row['message_edit_count'] == 1) ? $user->lang['EDITED_TIME_TOTAL'] : $user->lang['EDITED_TIMES_TOTAL'];
+ $l_edited_by = '<br /><br />' . sprintf($l_edit_time_total, (!$message_row['message_edit_user']) ? $message_row['username'] : $message_row['message_edit_user'], $user->format_date($message_row['message_edit_time']), $message_row['message_edit_count']);
+ }
+ else
+ {
+ $l_edited_by = '';
+ }
+
+ // Pull attachment data
+ $display_notice = false;
+ $attachments = array();
+
+ if ($message_row['message_attachment'] && $config['allow_pm_attach'])
+ {
+ if ($config['auth_download_pm'] && $auth->acl_get('u_pm_download'))
+ {
+ include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
+
+ $sql = 'SELECT *
+ FROM ' . ATTACHMENTS_TABLE . "
+ WHERE post_msg_id = $msg_id
+ AND in_message = 1
+ ORDER BY filetime " . ((!$config['display_order']) ? 'DESC' : 'ASC') . ', post_msg_id ASC';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $attachments[] = $row;
+ }
+ $db->sql_freeresult($result);
+
+ // No attachments exist, but message table thinks they do so go ahead and reset attach flags
+ if (!sizeof($attachments))
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . "
+ SET message_attachment = 0
+ WHERE msg_id = $msg_id";
+ $db->sql_query($sql);
+ }
+ }
+ else
+ {
+ $display_notice = true;
+ }
+ }
+
+ // Assign inline attachments
+ if (sizeof($attachments))
+ {
+ // preg_replace_callback does not work here because of inability to correctly assign globals (seems to be a bug in some PHP versions)
+ process_inline_attachments($message, $attachments, $update_count);
+ }
+
+ $user_info['sig'] = '';
+
+ $signature = ($message_row['enable_sig'] && $config['allow_sig_pm'] && $auth->acl_get('u_pm_sig') && $user->optionget('viewsigs')) ? $user_info['user_sig'] : '';
+
+ // End signature parsing, only if needed
+ if ($signature)
+ {
+ if ($user_info['user_sig_bbcode_bitfield'])
+ {
+ if (!isset($bbcode) || !$bbcode)
+ {
+ include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
+ $bbcode = new bbcode($user_info['user_sig_bbcode_bitfield']);
+ }
+
+ $bbcode->bbcode_second_pass($signature, $user_info['user_sig_bbcode_uid'], $user_info['user_sig_bbcode_bitfield']);
+ }
+
+ $signature = smilie_text($signature);
+ $signature = str_replace("\n", '<br />', censor_text($signature));
+ }
+
+ $url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=$id";
+
+ $template->assign_vars(array(
+ 'AUTHOR_NAME' => ($user_info['user_colour']) ? '<span style="color:#' . $user_info['user_colour'] . '">' . $user_info['username'] . '</span>' : $user_info['username'],
+ 'AUTHOR_RANK' => $user_info['rank_title'],
+ 'RANK_IMAGE' => $user_info['rank_image'],
+ 'AUTHOR_AVATAR' => (isset($user_info['avatar'])) ? $user_info['avatar'] : '',
+ 'AUTHOR_JOINED' => $user->format_date($user_info['user_regdate'], $user->lang['DATE_FORMAT']),
+ 'AUTHOR_POSTS' => (!empty($user_info['user_posts'])) ? $user_info['user_posts'] : '',
+ 'AUTHOR_FROM' => (!empty($user_info['user_from'])) ? $user_info['user_from'] : '',
+
+ 'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($user_info['online']) ? $user->img('btn_online', $user->lang['ONLINE']) : $user->img('btn_offline', $user->lang['OFFLINE'])),
+ 'DELETE_IMG' => $user->img('btn_delete', $user->lang['DELETE_PM']),
+ 'IP_IMG' => $user->img('btn_ip', $user->lang['VIEW_IP']),
+ 'REPORT_IMG' => $user->img('btn_report', $user->lang['REPORT_PM']),
+ 'REPORTED_IMG' => $user->img('icon_reported', $user->lang['REPORTED_MESSAGE']),
+ 'PROFILE_IMG' => $user->img('btn_profile', $user->lang['READ_PROFILE']),
+ 'EMAIL_IMG' => $user->img('btn_email', $user->lang['SEND_EMAIL']),
+ 'QUOTE_IMG' => $user->img('btn_quote', $user->lang['POST_QUOTE_PM']),
+ 'REPLY_IMG' => $user->img('btn_reply_pm', $user->lang['POST_REPLY_PM']),
+ 'EDIT_IMG' => $user->img('btn_edit', $user->lang['POST_EDIT_PM']),
+ 'MINI_POST_IMG' => $user->img('icon_post', $user->lang['PM']),
+
+ 'SENT_DATE' => $user->format_date($message_row['message_time']),
+ 'SUBJECT' => $message_row['message_subject'],
+ 'MESSAGE' => $message,
+ 'SIGNATURE' => ($message_row['enable_sig']) ? $signature : '',
+ 'EDITED_MESSAGE' => $l_edited_by,
+
+ 'U_MCP_REPORT' => "{$phpbb_root_path}mcp.$phpEx$SID&amp;mode=pm_details&amp;p=" . $message_row['msg_id'],
+ 'U_REPORT' => ($config['auth_report_pm'] && $auth->acl_get('u_pm_report')) ? "{$phpbb_root_path}report.$phpEx$SID&amp;pm=" . $message_row['msg_id'] : '',
+ 'U_IP' => ($auth->acl_get('m_') && $message_row['message_reported']) ? "{$phpbb_root_path}mcp.$phpEx?sid=" . $user->session_id . "&amp;mode=pm_details&amp;p=" . $message_row['msg_id'] . '#ip' : '',
+ 'U_DELETE' => ($auth->acl_get('u_pm_delete')) ? "$url&amp;mode=compose&amp;action=delete&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '',
+ 'U_AUTHOR_PROFILE' => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $author_id,
+ 'U_EMAIL' => $user_info['email'],
+ 'U_QUOTE' => ($config['auth_quote_pm'] && $auth->acl_get('u_sendpm') && $author_id != $user->data['user_id']) ? "$url&amp;mode=compose&amp;action=quote&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '',
+ 'U_EDIT' => (($message_row['message_time'] > time() - $config['pm_edit_time'] || !$config['pm_edit_time']) && $folder_id == PRIVMSGS_OUTBOX && $auth->acl_get('u_pm_edit')) ? "$url&amp;mode=compose&amp;action=edit&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '',
+ 'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $auth->acl_get('u_sendpm')) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '',
+ 'U_PREVIOUS_PM' => "$url&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] . "&amp;view=previous",
+ 'U_NEXT_PM' => "$url&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] . "&amp;view=next",
+
+ 'S_MESSAGE_REPORTED'=> ($message_row['message_reported'] && $auth->acl_get('m_')) ? true : false,
+ 'S_HAS_ATTACHMENTS' => (sizeof($attachments)) ? true : false,
+ 'S_DISPLAY_NOTICE' => $display_notice && $message_row['message_attachment'],
+
+ 'U_PRINT_PM' => ($config['print_pm'] && $auth->acl_get('u_pm_printpm')) ? "$url&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] . "&amp;view=print" : '',
+ 'U_EMAIL_PM' => ($config['email_pm'] && $config['email_enable'] && $auth->acl_get('u_pm_emailpm')) ? 'Email' : '',
+ 'U_FORWARD_PM' => ($config['forward_pm'] && $auth->acl_get('u_pm_forward')) ? "$url&amp;mode=compose&amp;action=forward&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '')
+ );
+
+ // Display not already displayed Attachments for this post, we already parsed them. ;)
+ if (sizeof($attachments))
+ {
+ foreach ($attachments as $attachment)
+ {
+ $template->assign_block_vars('attachment', array(
+ 'DISPLAY_ATTACHMENT' => $attachment)
+ );
+ }
+ }
+
+ if ($_REQUEST['view'] != 'print')
+ {
+ // Message History
+ if (message_history($msg_id, $user->data['user_id'], $message_row, $folder))
+ {
+ $template->assign_var('S_DISPLAY_HISTORY', true);
+ }
+ }
+}
+
+// Display Message History
+function message_history($msg_id, $user_id, $message_row, $folder)
+{
+ global $db, $user, $config, $template, $phpbb_root_path, $phpEx, $SID, $auth, $bbcode;
+
+ // 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
+ AND p.author_id = u.user_id
+ AND t.folder_id <> ' . PRIVMSGS_NO_BOX . "
+ AND t.user_id = $user_id";
+
+ if (!$message_row['root_level'])
+ {
+ $sql .= " AND (p.root_level = $msg_id OR (p.root_level = 0 AND p.msg_id = $msg_id))";
+ }
+ else
+ {
+ $sql .= " AND (p.root_level = " . $message_row['root_level'] . ' OR p.msg_id = ' . $message_row['root_level'] . ')';
+ }
+ $sql .= ' ORDER BY p.message_time ';
+ $sort_dir = (!empty($user->data['user_sortby_dir'])) ? $user->data['user_sortby_dir'] : 'd';
+ $sql .= ($sort_dir == 'd') ? 'ASC' : 'DESC';
+
+ $result = $db->sql_query($sql);
+
+ if (!($row = $db->sql_fetchrow($result)))
+ {
+ return false;
+ }
+
+ $rowset = array();
+ $bbcode_bitfield = 0;
+ $folder_url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;folder=";
+
+ $title = ($sort_dir == 'd') ? $row['message_subject'] : '';
+ do
+ {
+ $folder_id = (int) $row['folder_id'];
+
+ $row['folder'][] = (isset($folder[$folder_id])) ? '<a href="' . $folder_url . $folder_id . '">' . $folder[$folder_id]['folder_name'] . '</a>' : $user->lang['UNKOWN_FOLDER'];
+
+ if (isset($rowset[$row['msg_id']]))
+ {
+ $rowset[$row['msg_id']]['folder'][] = (isset($folder[$folder_id])) ? '<a href="' . $folder_url . $folder_id . '">' . $folder[$folder_id]['folder_name'] . '</a>' : $user->lang['UNKOWN_FOLDER'];
+ }
+ else
+ {
+ $rowset[$row['msg_id']] = $row;
+ $bbcode_bitfield |= $row['bbcode_bitfield'];
+ }
+ }
+ while ($row = $db->sql_fetchrow($result));
+ $db->sql_freeresult($result);
+
+ $title = ($sort_dir == 'a') ? $row['message_subject'] : $title;
+
+ if (sizeof($rowset) == 1)
+ {
+ return false;
+ }
+
+ // Instantiate BBCode class
+ if (!isset($bbcode) && $bbcode_bitfield)
+ {
+ if (!class_exists('bbcode'))
+ {
+ include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
+ }
+ $bbcode = new bbcode($bbcode_bitfield);
+ }
+
+ $title = censor_text($title);
+
+ $i = 1;
+ $url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm";
+ $next_history_pm = $previous_history_pm = $prev_id = 0;
+
+ foreach ($rowset as $id => $row)
+ {
+ $author_id = $row['author_id'];
+ $author = $row['username'];
+ $folder_id = (int) $row['folder_id'];
+
+ $subject = $row['message_subject'];
+ $message = $row['message_text'];
+
+ if ($row['bbcode_bitfield'])
+ {
+ $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
+ }
+
+ $message = smilie_text($message, !$row['enable_smilies']);
+
+ $subject = censor_text($subject);
+ $message = censor_text($message);
+
+ if ($id == $msg_id)
+ {
+ $next_history_pm = next($rowset);
+ $next_history_pm = (sizeof($next_history_pm)) ? (int) $next_history_pm['msg_id'] : 0;
+ $previous_history_pm = $prev_id;
+ }
+
+ $template->assign_block_vars('history_row', array(
+ 'AUTHOR_NAME' => $author,
+ 'SUBJECT' => $subject,
+ 'SENT_DATE' => $user->format_date($row['message_time']),
+ 'MESSAGE' => str_replace("\n", '<br />', $message),
+ 'FOLDER' => implode(', ', $row['folder']),
+
+ 'S_CURRENT_MSG' => ($row['msg_id'] == $msg_id),
+
+ 'U_MSG_ID' => $row['msg_id'],
+ 'U_VIEW_MESSAGE'=> "$url&amp;f=$folder_id&amp;p=" . $row['msg_id'],
+ 'U_AUTHOR_PROFILE' => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=$author_id",
+ 'U_QUOTE' => ($config['auth_quote_pm'] && $auth->acl_get('u_sendpm') && $author_id != $user->data['user_id']) ? "$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'] && $auth->acl_get('u_sendpm')) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;p=" . $row['msg_id'] : '',
+
+ 'S_ROW_COUNT' => $i)
+ );
+ unset($rowset[$id]);
+ $prev_id = $id;
+ $i++;
+ }
+
+ $template->assign_vars(array(
+ 'QUOTE_IMG' => $user->img('btn_quote', $user->lang['REPLY_WITH_QUOTE']),
+ 'TITLE' => $title,
+
+ 'U_VIEW_NEXT_HISTORY' => "$url&amp;p=" . (($next_history_pm) ? $next_history_pm : $msg_id),
+ 'U_VIEW_PREVIOUS_HISTORY' => "$url&amp;p=" . (($previous_history_pm) ? $previous_history_pm : $msg_id))
+ );
+
+ return true;
+}
+
+// Get User Informations (only for message display)
+function get_user_informations($user_id, $user_row)
+{
+ global $config, $db, $auth, $user, $phpbb_root_path, $phpEx, $SID;
+
+ if (!$user_id)
+ {
+ return;
+ }
+
+ if (empty($user_row))
+ {
+ $user_row = get_userdata((int) $user_id);
+ }
+
+ // Grab ranks
+ $ranks = array();
+ obtain_ranks($ranks);
+
+ // Generate online information for user
+ if ($config['load_onlinetrack'])
+ {
+ $sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_allow_viewonline) AS viewonline
+ FROM ' . SESSIONS_TABLE . "
+ WHERE session_user_id = $user_id
+ GROUP BY session_user_id";
+ $result = $db->sql_query_limit($sql, 1);
+
+ $update_time = $config['load_online_time'] * 60;
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $user_row['online'] = (time() - $update_time < $row['online_time'] && ($row['viewonline'] && $user_row['user_allow_viewonline'])) ? true : false;
+ }
+ }
+ else
+ {
+ $user_row['online'] = false;
+ }
+
+ if ($user_row['user_avatar'] && $user->optionget('viewavatars'))
+ {
+ $avatar_img = '';
+ switch ($user_row['user_avatar_type'])
+ {
+ case AVATAR_UPLOAD:
+ $avatar_img = $config['avatar_path'] . '/';
+ break;
+ case AVATAR_GALLERY:
+ $avatar_img = $config['avatar_gallery_path'] . '/';
+ break;
+ }
+ $avatar_img .= $user_row['user_avatar'];
+
+ $user_row['avatar'] = '<img src="' . $avatar_img . '" width="' . $user_row['user_avatar_width'] . '" height="' . $user_row['user_avatar_height'] . '" border="0" alt="" />';
+ }
+
+ if (!empty($user_row['user_rank']))
+ {
+ $user_row['rank_title'] = $ranks['special'][$user_row['user_rank']]['rank_title'];
+ $user_row['rank_image'] = (!empty($ranks['special'][$user_row['user_rank']]['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $ranks['special'][$user_row['user_rank']]['rank_image'] . '" border="0" alt="' . $ranks['special'][$user_row['user_rank']]['rank_title'] . '" title="' . $ranks['special'][$user_row['user_rank']]['rank_title'] . '" /><br />' : '';
+ }
+ else
+ {
+ foreach ($ranks['normal'] as $rank)
+ {
+ if ($user_row['user_posts'] >= $rank['rank_min'])
+ {
+ $user_row['rank_title'] = $rank['rank_title'];
+ $user_row['rank_image'] = (!empty($rank['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $rank['rank_image'] . '" border="0" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" /><br />' : '';
+ break;
+ }
+ }
+ }
+
+ if (!empty($user_row['user_allow_viewemail']) || $auth->acl_get('a_email'))
+ {
+ $user_row['email'] = ($config['board_email_form'] && $config['email_enable']) ? "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=email&amp;u=" . $user_id : 'mailto:' . $user_row['user_email'];
+ }
+ else
+ {
+ $user_row['email'] = '';
+ }
+
+ return $user_row;
+}
+
+function process_inline_attachments(&$message, &$attachments, &$update_count)
+{
+ global $user, $config;
+
+ $tpl = array();
+ $tpl = display_attachments(0, NULL, $attachments, $update_count, false, true);
+ $tpl_size = sizeof($tpl);
+
+ $unset_tpl = array();
+
+ preg_match_all('#<!\-\- ia([0-9]+) \-\->(.*?)<!\-\- ia\1 \-\->#', $message, $matches);
+
+ $replace = array();
+ foreach ($matches[0] as $num => $capture)
+ {
+ // Flip index if we are displaying the reverse way
+ $index = ($config['display_order']) ? ($tpl_size-($matches[1][$num] + 1)) : $matches[1][$num];
+
+ $replace['from'][] = $matches[0][$index];
+ $replace['to'][] = (isset($tpl[$index])) ? $tpl[$index] : sprintf($user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][$num]);
+
+ $unset_tpl[] = $index;
+ }
+ unset($tpl, $tpl_size);
+
+ $message = str_replace($replace['from'], $replace['to'], $message);
+
+ foreach (array_unique($unset_tpl) as $index)
+ {
+ unset($attachments[$index]);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index 3eb4ad909e..5435989395 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -64,6 +64,7 @@ $lang += array(
'AVATAR_WRONG_SIZE' => 'The avatar must be at least %1$d pixels wide, %2$d pixels high and at most %3$d pixels wide and %4$d pixels high.',
'BACK_TO_TOP' => 'Top',
+ 'BCC' => 'Bcc',
'BIRTHDAYS' => 'Birthdays',
'BOARD_BAN_PERM' => 'You have been <b>permanently</b> banned from this board.<br /><br />Please contact the %2$sBoard Administrator%3$s for more information.',
'BOARD_BAN_REASON' => 'Reason given for ban: <b>%s</b>',
@@ -75,6 +76,7 @@ $lang += array(
'BYTES' => 'Bytes',
'CANCEL' => 'Cancel',
+ 'CHANGE' => 'Change',
'CLICK_VIEW_PRIVMSG' => 'Click %sHere%s to visit your Inbox',
'CONFIRM' => 'Confirm',
'CONGRATULATIONS' => 'Congratulations to',
@@ -288,6 +290,7 @@ $lang += array(
'REG_USERS_ZERO_TOTAL' => '0 Registered, ',
'REG_USER_ONLINE' => 'There is %d Registered user and ',
'REG_USER_TOTAL' => '%d Registered, ',
+ 'REMOVE' => 'Remove',
'REMOVE_INSTALL' => 'Please delete, move or rename the install directory.',
'REPLIES' => 'Replies',
'REPLY_WITH_QUOTE' => 'Reply with quote',
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index 365d7a4256..7b93e011e2 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -41,6 +41,7 @@ $lang += array(
'ADD_FRIENDS' => 'Add new friends',
'ADD_FRIENDS_EXPLAIN' => 'You may enter several usernames each on a different line',
'ADD_NEW_RULE' => 'Add new Rule',
+ 'ADD_RULE' => 'Add Rule',
'ADD_TO' => 'Add [To]',
'ADMIN_EMAIL' => 'Administrators can email me information',
'AGREE' => 'I agree to these terms',
@@ -86,6 +87,7 @@ $lang += array(
'CUR_PASSWORD_ERROR' => 'The current password you entered is incorrect.',
'DEFAULT_ACTION' => 'Default Action',
+ 'DEFAULT_ACTION_EXPLAIN' => 'This Action will be triggered if none of the above is applicable',
'DEFAULT_ADD_SIG' => 'Attach my signature by default',
'DEFAULT_BBCODE' => 'Enable BBCode by default',
'DEFAULT_HTML' => 'Enable HTML by default',
@@ -126,6 +128,7 @@ $lang += array(
'FOLDER_ADDED' => 'Folder successfully added',
'FOLDER_MESSAGE_STATUS' => '%1$d from %2$d messages stored',
'FOLDER_NAME_EXIST' => 'Folder <b>%s</b> already exist',
+ 'FOLDER_OPTIONS' => 'Folder Options',
'FOLDER_STATUS_MSG' => 'Folder is %1$d%% full (%2$d from %3$d messages stored)',
'FORWARD_PM' => 'Forward PM',
'FRIEND_MESSAGE' => 'Message from friend',
@@ -159,6 +162,7 @@ $lang += array(
'MESSAGE_REPORTED_MESSAGE' => 'Reported Message',
'MINIMUM_KARMA' => 'Minimum User Karma',
'MINIMUM_KARMA_EXPLAIN' => 'Posts by users with Karma less than this will be ignored.',
+ 'MOVE_TO_FOLDER' => 'Move to Folder',
'NEW_EMAIL_ERROR' => 'The email addresses you entered do not match.',
'NEW_PASSWORD' => 'Password',
diff --git a/phpBB/styles/subSilver/template/ucp_header.html b/phpBB/styles/subSilver/template/ucp_header.html
index 271ea3fb16..31905d4b3e 100644
--- a/phpBB/styles/subSilver/template/ucp_header.html
+++ b/phpBB/styles/subSilver/template/ucp_header.html
@@ -6,6 +6,47 @@
<tr>
<td width="20%" valign="top">
+<!-- IF S_SHOW_PM_BOX and S_POST_ACTION -->
+ <form action="{S_POST_ACTION}" method="post" name="post"{S_FORM_ENCTYPE}>
+ <table class="tablebg" width="100%" cellspacing="1">
+ <tr>
+ <th>{L_PM_TO}</th>
+ </tr>
+ <tr>
+ <td class="row1"><b class="genmed">{L_USERNAME}:</b></td>
+ </tr>
+ <tr>
+ <td class="row2"><input class="post" type="text" name="username" size="20" maxlength="40" value="" />&nbsp;<input class="post" type="submit" name="add_to" value="{L_ADD}" /></td>
+ </tr>
+ <!-- IF S_ALLOW_MASS_PM -->
+ <tr>
+ <td class="row1"><b class="genmed">{L_USERNAMES}:</b></td>
+ </tr>
+ <tr>
+ <td class="row2"><textarea name="username_list" rows="5" cols="22"></textarea><br />
+ <ul class="nav" style="margin: 0px; padding: 0px; list-style-type: none; line-height: 175%;">
+ <li>&#187; <a href="{U_SEARCH_USER}" onclick="window.open('{U_SEARCH_USER}', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=740');return false">{L_FIND_USERNAME}</a></li>
+ </ul>
+ </td>
+ </tr>
+ <!-- ENDIF -->
+ <!-- IF S_GROUP_OPTIONS -->
+ <tr>
+ <td class="row1"><b class="genmed">{L_USERGROUPS}:</b></td>
+ </tr>
+ <tr>
+ <td class="row2"><select name="group_list[]" multiple="true" size="5" style="width:150px">{S_GROUP_OPTIONS}</select></td>
+ </tr>
+ <!-- ENDIF -->
+ <!-- IF S_ALLOW_MASS_PM -->
+ <tr>
+ <td class="row1"><div style="float:left">&nbsp;<input class="post" type="submit" name="add_bcc" value="{L_ADD_BCC}" />&nbsp;</div><div style="float:right">&nbsp;<input class="post" type="submit" name="add_to" value="{L_ADD_TO}" />&nbsp;</div></td>
+ </tr>
+ <!-- ENDIF -->
+ </table>
+ <div style="padding: 2px;"></div>
+<!-- ENDIF -->
+
<table class="tablebg" width="100%" cellspacing="1">
<tr>
<th>{L_OPTIONS}</th>
@@ -31,6 +72,26 @@
<div style="padding: 2px;"></div>
+<!-- IF S_SHOW_COLOUR_LEGEND -->
+<table class="tablebg" width="100%" cellspacing="1" cellpadding="0">
+ <tr>
+ <th colspan="2">{L_MESSAGE_COLOURS}</th>
+ </tr>
+ <!-- BEGIN pm_colour_info -->
+ <tr>
+ <!-- IF not pm_colour_info.IMG -->
+ <td class="row1 {pm_colour_info.CLASS}" width="5"><img src="images/spacer.gif" width="5" alt="{pm_colour_info.LANG}" border="0" /></td>
+ <!-- ELSE -->
+ <td class="row1" width="25" align="center">{pm_colour_info.IMG}</td>
+ <!-- ENDIF -->
+ <td class="row1"><span class="genmed">{pm_colour_info.LANG}</span></td>
+ </tr>
+ <!-- END pm_colour_info -->
+</table>
+
+<div style="padding: 2px;"></div>
+<!-- ENDIF -->
+
<table class="tablebg" width="100%" cellspacing="1">
<tr>
<th>{L_FRIENDS}</th>
@@ -42,7 +103,11 @@
<ul class="nav" style="margin: 0px; padding: 0px; list-style-type: none; line-height: 175%;">
<!-- BEGIN friends_online -->
- <li><a href="{friends_online.U_PROFILE}">{friends_online.USERNAME}</a></li>
+ <li><a href="{friends_online.U_PROFILE}">{friends_online.USERNAME}</a>
+ <!-- IF S_SHOW_PM_BOX -->
+ &nbsp;[ <input class="post" type="submit" name="add_to[{friends_online.USER_ID}]" value="{L_ADD}" /> ]
+ <!-- ENDIF -->
+ </li>
<!-- BEGINELSE -->
<li>{L_NO_FRIENDS_ONLINE}</li>
<!-- END friends_online -->
@@ -54,7 +119,10 @@
<ul class="nav" style="margin: 0px; padding: 0px; list-style-type: none; line-height: 175%;">
<!-- BEGIN friends_offline -->
- <li><a href="{friends_online.U_PROFILE}">{friends_offline.USERNAME}</a></li>
+ <li><a href="{friends_offline.U_PROFILE}">{friends_offline.USERNAME}</a>
+ <!-- IF S_SHOW_PM_BOX -->
+ &nbsp;[ <input class="post" type="submit" name="add_to[{friends_offline.USER_ID}]" value="{L_ADD}" /> ]
+ <!-- ENDIF -->
<!-- BEGINELSE -->
<li>{L_NO_FRIENDS_OFFLINE}</li>
<!-- END friends_offline -->
@@ -66,4 +134,4 @@
</td>
<td><img src="images/spacer.gif" width="4" alt="" /></td>
- <td width="80%" valign="top"><form name="ucp" method="post" action="{S_UCP_ACTION}">
+ <td width="80%" valign="top"><!-- IF not S_PRIVMSGS --><form name="ucp" method="post" action="{S_UCP_ACTION}"><!-- ENDIF -->
diff --git a/phpBB/styles/subSilver/template/ucp_pm_history.html b/phpBB/styles/subSilver/template/ucp_pm_history.html
new file mode 100644
index 0000000000..8bbf4440b4
--- /dev/null
+++ b/phpBB/styles/subSilver/template/ucp_pm_history.html
@@ -0,0 +1,67 @@
+
+<!-- $Id$ -->
+
+<table class="tablebg" width="100%" cellspacing="1">
+ <tr>
+ <th align="center">{L_MESSAGE_HISTORY} - {TITLE}</th>
+ </tr>
+ <tr>
+ <td class="row1"><div style="overflow: auto; width: 100%; height: 300px;">
+
+ <table class="tablebg" width="100%" cellspacing="1">
+ <tr>
+ <th width="22%">{L_AUTHOR}</th>
+ <th>{L_MESSAGE}</th>
+ </tr>
+ <!-- BEGIN history_row -->
+
+ <!-- IF history_row.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->
+ <td rowspan="2" align="left" valign="top"><a name="{history_row.U_POST_ID}"></a>
+ <table width="150" cellspacing="0">
+ <tr>
+ <td align="center" colspan="2"><b class="postauthor">{history_row.AUTHOR_NAME}</b></td>
+ </tr>
+ </table>
+ </td>
+
+ <td width="100%"<!-- IF history_row.S_CURRENT_MSG --> style="background-color:lightblue"<!-- ENDIF -->>
+ <div class="gensmall" style="float:left"><b>{L_PM_SUBJECT}:</b>&nbsp;{history_row.SUBJECT}</div><div class="gensmall" style="float:right"><b>{L_FOLDER}:</b>&nbsp;{history_row.FOLDER}</div>
+ </td>
+ </tr>
+
+ <!-- IF history_row.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->
+ <td valign="top"><table width="100%" cellspacing="0">
+ <tr>
+ <td valign="top"><table width="100%" cellspacing="0" cellpadding="2">
+ <tr>
+ <td><div id="message_{history_row.U_POST_ID}"><div class="postbody">{history_row.MESSAGE}</div></div></td>
+ </tr>
+ </table></td>
+ </tr>
+ <tr>
+ <td><table width="100%" cellspacing="0">
+ <tr valign="middle">
+ <td width="100%">&nbsp;</td>
+ <td width="10" nowrap="nowrap">{history_row.MINI_POST_IMG}</td>
+ <td class="gensmall" nowrap="nowrap"><b>{L_SENT_AT}:</b> {history_row.SENT_DATE}</td>
+ </tr>
+ </table></td>
+ </tr>
+ </table></td>
+ </tr>
+
+ <!-- IF history_row.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->
+ <td class="gensmall"><a href="{history_row.U_VIEW_MESSAGE}">{L_VIEW_PM}</a></td>
+ <td><div class="gensmall" style="float:left">&nbsp;<!-- IF history_row.U_PROFILE --><a href="{history_row.U_PROFILE}">{PROFILE_IMG}</a> <!-- ENDIF --> <!-- IF history_row.U_EMAIL --><a href="{history_row.U_EMAIL}">{EMAIL_IMG}</a> <!-- ENDIF -->&nbsp;</div> <div class="gensmall" style="float:right"><!-- IF history_row.U_QUOTE --><a href="{history_row.U_QUOTE}">{QUOTE_IMG}</a> <!-- ENDIF --> <!-- IF history_row.U_POST_REPLY_PM --><a href="{history_row.U_POST_REPLY_PM}">{REPLY_IMG}</a><!-- ENDIF -->&nbsp;</div></td>
+ </tr>
+
+ <tr>
+ <td class="spacer" colspan="2"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
+ </tr>
+ <!-- END history_row -->
+ </table>
+ </div></td>
+ </tr>
+</table>
+
+<br clear="all" />
diff --git a/phpBB/styles/subSilver/template/ucp_pm_message_footer.html b/phpBB/styles/subSilver/template/ucp_pm_message_footer.html
new file mode 100644
index 0000000000..90f48fc112
--- /dev/null
+++ b/phpBB/styles/subSilver/template/ucp_pm_message_footer.html
@@ -0,0 +1,39 @@
+
+<!-- $Id$ -->
+
+<table class="tablebg" width="100%" cellspacing="1" cellpadding="0">
+ <tr>
+ <td class="row1"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td align="left">
+ <!-- IF TOTAL_MESSAGES -->
+ <table width="100%" cellspacing="1">
+ <tr>
+ <td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
+ <td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL_MESSAGES} ]&nbsp;</td>
+ <td class="gensmall" width="100%" align="right" nowrap="nowrap"><b>{PAGINATION}</b></td>
+ </tr>
+ </table>
+ <!-- ENDIF -->
+ <!-- IF S_VIEW_MESSAGE -->
+ <span class="gensmall">
+ <!-- IF U_PRINT_PM --><a href="{U_PRINT_PM}" title="{L_PRINT_PM}">{L_PRINT_PM}</a><!-- IF U_EMAIL_PM or U_FORWARD_PM--> | <!-- ENDIF --><!-- ENDIF -->
+ <!-- IF U_EMAIL_PM --><a href="{U_EMAIL_PM}" title="{L_EMAIL_PM}">{L_EMAIL_PM}</a><!-- IF U_FORWARD_PM --> | <!-- ENDIF --><!-- ENDIF -->
+ <!-- IF U_FORWARD_PM --><a href="{U_FORWARD_PM}" title="{L_FORWARD_PM}">{L_FORWARD_PM}</a><!-- ENDIF -->
+ </span>
+ <!-- ENDIF -->
+ </td>
+ <td align="right" nowrap="nowrap">
+ <!-- IF S_VIEW_MESSAGE -->
+ <form name="movepm" method="post" action="{S_PM_ACTION}" style="margin:0px">
+ <input type="hidden" name="marked_msg_id[]" value="{MSG_ID}" />
+ <input type="hidden" name="cur_folder_id" value="{CUR_FOLDER_ID}" />
+ <input type="hidden" name="p" value="{MSG_ID}" />
+ <!-- ENDIF -->
+ <!-- IF not S_UNREAD -->
+ <select name="dest_folder">{S_TO_FOLDER_OPTIONS}</select>&nbsp;<input class="btnlite" type="submit" name="move_pm" value="<!-- IF S_VIEW_MESSAGE -->Place Message into Folder<!-- ELSE -->Place Marked into Folder<!-- ENDIF -->" />
+ <!-- ENDIF -->
+ </form>
+ </td></tr></table></td>
+ </tr>
+</table>
+<!-- IF not S_VIEW_MESSAGE --><div style="float:right"><b class="gensmall"><a href="javascript:marklist('viewfolder', true);">{L_MARK_ALL}</a> :: <a href="javascript:marklist('viewfolder', false);">{L_UNMARK_ALL}</a></b></div><!-- ENDIF -->
+
diff --git a/phpBB/styles/subSilver/template/ucp_pm_message_header.html b/phpBB/styles/subSilver/template/ucp_pm_message_header.html
new file mode 100644
index 0000000000..e3209bb767
--- /dev/null
+++ b/phpBB/styles/subSilver/template/ucp_pm_message_header.html
@@ -0,0 +1,46 @@
+
+<!-- $Id$ -->
+
+<script language="javascript" type="text/javascript">
+<!--
+function marklist(form_name, status)
+{
+ for (i = 0; i < document.forms[form_name].length; i++)
+ {
+ document.forms[form_name].elements[i].checked = status;
+ }
+}
+//-->
+</script>
+
+<table width="100%" cellspacing="1">
+ <tr>
+ <td class="gensmall" nowrap="nowrap" align="left">
+ <!-- IF S_UNREAD --><b>{L_UNREAD_MESSAGES}</b><!-- ELSE -->{FOLDER_STATUS}<!-- ENDIF -->
+ <td class="gensmall" nowrap="nowrap" align="right"><!-- IF U_INBOX --><a href="{U_INBOX}">{L_PM_INBOX}</a><!-- ELSE -->{L_PM_INBOX}<!-- ENDIF -->&nbsp;|&nbsp;<!-- IF U_OUTBOX --><a href="{U_OUTBOX}">{L_PM_OUTBOX}</a><!-- ELSE -->{L_PM_OUTBOX}<!-- ENDIF -->&nbsp;|&nbsp;<!-- IF U_SENTBOX --><a href="{U_SENTBOX}">{L_PM_SENTBOX}</a><!-- ELSE -->{L_PM_SENTBOX}<!-- ENDIF -->&nbsp;|&nbsp;<a href="{U_CREATE_FOLDER}">{L_CREATE_FOLDER}</a></td>
+ </tr>
+</table>
+
+<table class="tablebg" width="100%" cellspacing="1" cellpadding="0">
+ <tr>
+ <td class="row1"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td align="left">
+ <!-- IF TOTAL_MESSAGES -->
+ <table width="100%" cellspacing="1">
+ <tr>
+ <td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
+ <td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL_MESSAGES} ]&nbsp;</td>
+ <td class="gensmall" width="100%" align="right" nowrap="nowrap"><b>{PAGINATION}</b></td>
+ </tr>
+ </table>
+ <!-- ENDIF -->
+ <!-- IF S_VIEW_MESSAGE -->
+ <span class="gensmall">
+ <!-- IF S_DISPLAY_HISTORY --><a href="{U_VIEW_PREVIOUS_HISTORY}">{L_VIEW_PREVIOUS_HISTORY}</a> | <a href="{U_VIEW_NEXT_HISTORY}">{L_VIEW_NEXT_HISTORY}</a> | <!-- ENDIF --><a href="{U_PREVIOUS_PM}">{L_VIEW_PREVIOUS_PM}</a> | <a href="{U_NEXT_PM}">{L_VIEW_NEXT_PM}</a>&nbsp;
+ </span>
+ <!-- ENDIF -->
+ </td><td align="right" nowrap="nowrap"><form name="choosefolder" method="post" action="{S_FOLDER_ACTION}" style="margin:0px">
+ <select name="f">{S_FOLDER_OPTIONS}</select>&nbsp;<input class="btnlite" type="submit" name="folder" value="{L_GO}" /></form>
+ </td></tr></table></td>
+ </tr>
+</table>
+
diff --git a/phpBB/styles/subSilver/template/ucp_pm_options.html b/phpBB/styles/subSilver/template/ucp_pm_options.html
new file mode 100644
index 0000000000..90ce7ccb11
--- /dev/null
+++ b/phpBB/styles/subSilver/template/ucp_pm_options.html
@@ -0,0 +1,170 @@
+<!-- INCLUDE ucp_header.html -->
+
+<!-- $Id$ -->
+
+<!-- IF ERROR_MESSAGE or NOTIFICATION_MESSAGE -->
+ <table border="0" cellspacing="0" cellpadding="0" width="100%">
+ <tr>
+ <td class="row3" align="center">
+ <!-- IF ERROR_MESSAGE --><span class="genmed" style="color:red">{ERROR_MESSAGE}</span><!-- ENDIF -->
+ <!-- IF NOTIFICATION_MESSAGE --><span class="genmed" style="color:red">{NOTIFICATION_MESSAGE}</span><!-- ENDIF -->
+ </td>
+ </tr>
+ </table>
+ <div style="padding: 2px;"></div>
+<!-- ENDIF -->
+
+<form name="ucp" method="post" action="{S_UCP_ACTION}">
+
+<table class="tablebg" width="100%" cellspacing="1">
+ <tr>
+ <th colspan="3">{L_ADD_NEW_RULE}</th>
+ </tr>
+ <!-- IF S_CHECK_DEFINED -->
+ <tr>
+ <td class="row1" width="50" align="left" valign="top"><b class="gen">{L_IF}:</b></td>
+ <td class="row2" align="center" valign="top"><!-- IF S_CHECK_SELECT --><select name="check_option">{S_CHECK_OPTIONS}</select><!-- ELSE --><b class="gen">{CHECK_CURRENT}</b><input type="hidden" name="check_option" value="{CHECK_OPTION}" /><!-- ENDIF --></td>
+ <td class="row1" width="50" align="right" valign="top"><!-- IF S_CHECK_SELECT --><input type="submit" name="next" value="{L_NEXT}" class="btnlite" /><!-- ELSE -->&nbsp;<!-- ENDIF --></td>
+ </tr>
+ <!-- ENDIF -->
+ <!-- IF S_RULE_DEFINED -->
+ <tr>
+ <td class="row1" width="50" align="left" valign="top"><!-- IF S_RULE_SELECT --><input type="submit" name="back[rule]" value="{L_PREVIOUS}" class="btnlite" /><!-- ELSE -->&nbsp;<!-- ENDIF --></td>
+ <td class="row2" align="center" valign="top"><!-- IF S_RULE_SELECT --><select name="rule_option">{S_RULE_OPTIONS}</select><!-- ELSE --><b class="gen">{RULE_CURRENT}</b><input type="hidden" name="rule_option" value="{RULE_OPTION}" /><!-- ENDIF --></td>
+ <td class="row1" width="50" align="right" valign="top"><!-- IF S_RULE_SELECT --><input type="submit" name="next" value="{L_NEXT}" class="btnlite" /><!-- ELSE -->&nbsp;<!-- ENDIF --></td>
+ </tr>
+ <!-- ENDIF -->
+
+ <!-- IF S_COND_DEFINED -->
+ <!-- IF S_COND_SELECT or COND_CURRENT -->
+ <tr>
+ <td class="row1" width="50" align="left" valign="top"><!-- IF S_COND_SELECT --><input type="submit" name="back[cond]" value="{L_PREVIOUS}" class="btnlite" /><!-- ELSE -->&nbsp;<!-- ENDIF --></td>
+ <td class="row2" align="center" valign="top">
+ <!-- IF S_COND_SELECT -->
+ <!-- IF S_TEXT_CONDITION -->
+ <input type="text" name="rule_string" value="{CURRENT_STRING}" size="30" maxlength="250" class="post" />
+ <!-- ELSEIF S_USER_CONDITION -->
+ <input type="text" class="post" name="rule_string" value="{CURRENT_STRING}" maxlength="50" size="20" />&nbsp;<span class="gensmall">[ <a href="{U_FIND_USERNAME}" onclick="window.open('{U_FIND_USERNAME}', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=740');return false;">{L_FIND_USERNAME}</a> ]</span>
+ <!-- ELSEIF S_GROUP_CONDITION -->
+ SELECT GROUP
+ <!-- ENDIF -->
+ <!-- ELSE -->
+ <b class="gen">{COND_CURRENT}</b>
+ <input type="hidden" name="rule_string" value="{CURRENT_STRING}" /><input type="hidden" name="rule_user_id" value="{CURRENT_USER_ID}" /><input type="hidden" name="rule_group_id" value="{CURRENT_GROUP_ID}" />
+ <!-- ENDIF -->
+ </td>
+ <td class="row1" width="50" align="right" valign="top"><!-- IF S_COND_SELECT --><input type="submit" name="next" value="{L_NEXT}" class="btnlite" /><!-- ELSE -->&nbsp;<!-- ENDIF --></td>
+ </tr>
+ <!-- ENDIF -->
+ <input type="hidden" name="cond_option" value="{COND_OPTION}" />
+ <!-- ENDIF -->
+ <!-- IF NONE_CONDITION --><input type="hidden" name="cond_option" value="none" /><!-- ENDIF -->
+
+ <!-- IF S_ACTION_DEFINED -->
+ <tr>
+ <td class="row1" width="50" align="left" valign="top"><!-- IF S_ACTION_SELECT --><input type="submit" name="back[action]" value="{L_PREVIOUS}" class="btnlite" /><!-- ELSE -->&nbsp;<!-- ENDIF --></td>
+ <td class="row2" align="center" valign="top"><!-- IF S_ACTION_SELECT --><select name="action_option">{S_ACTION_OPTIONS}</select><!-- ELSE --><b class="gen">{ACTION_CURRENT}</b><input type="hidden" name="action_option" value="{ACTION_OPTION}" /><!-- ENDIF --></td>
+ <td class="row1" width="50" align="right" valign="top"><!-- IF S_ACTION_SELECT --><input type="submit" name="add_rule" value="{L_ADD_RULE}" class="btnlite" /><!-- ELSE -->&nbsp;<!-- ENDIF --></td>
+ </tr>
+ <!-- ENDIF -->
+</table>
+
+<div style="padding: 2px;"></div>
+
+<table class="tablebg" width="100%" cellspacing="1">
+ <tr>
+ <th colspan="6">{L_DEFINED_RULES}</th>
+ </tr>
+ <!-- BEGIN rule -->
+ <tr>
+ <td class="row1" width="25" align="center"><span class="gen">{rule.COUNT}</span></td>
+ <td class="row2" width="120"><span class="gen">{rule.CHECK}</span></td>
+ <td class="row1" width="120"><span class="gen">{rule.RULE}</span></td>
+ <td class="row2" width="120"><span class="gen"><!-- IF rule.STRING -->{rule.STRING}<!-- ENDIF --></span></td>
+ <td class="row1"><span class="gen">{rule.ACTION}<!-- IF rule.FOLDER --> -> {rule.FOLDER}<!-- ENDIF --></span></td>
+ <td class="row2" width="25"><input type="submit" name="delete_rule[{rule.RULE_ID}]" value="{L_DELETE_RULE}" class="btnlite" /></td>
+ </tr>
+ <!-- BEGINELSE -->
+ <tr>
+ <td colspan="6" class="row3" align="center"><span class="gen">{L_NO_RULES_DEFINED}</span></td>
+ </tr>
+ <!-- END rule -->
+</table>
+
+<div style="padding: 2px;"></div>
+
+<table class="tablebg" width="100%" cellspacing="1">
+ <tr>
+ <th colspan="2">{L_ADD_FOLDER}</th>
+ </tr>
+ <!-- IF S_MAX_FOLDER_REACHED -->
+ <tr>
+ <td colspan="2">{L_MAX_FOLDER_REACHED}</td>
+ </tr>
+ <!-- ELSE -->
+ <tr>
+ <td class="row1" width="200"><b class="gen">{L_ADD_FOLDER}: </b></td>
+ <td class="row1"><input type="text" class="post" name="foldername" size="30" maxlength="30" /></td>
+ </tr>
+ <tr>
+ <td class="row1" align="right" colspan="2"><input class="btnlite" style="width:150px" type="submit" name="addfolder" value="{L_ADD}" /></td>
+ </tr>
+ <!-- ENDIF -->
+</table>
+
+<div style="padding: 2px;"></div>
+
+<!-- IF S_FOLDER_OPTIONS -->
+<table class="tablebg" width="100%" cellspacing="1">
+ <tr>
+ <th colspan="3">{L_REMOVE_FOLDER}</th>
+ </tr>
+ <tr>
+ <td class="row1" width="200"><b class="gen">{L_REMOVE_FOLDER}: </b></td>
+ <td class="row1"><select name="removefolder">{S_FOLDER_OPTIONS}</select></td>
+ <td class="row1"><b class="genmed">{L_AND}</b></td>
+ </tr>
+ <tr>
+ <td class="row2" width="200">&nbsp;</td>
+ <td class="row2" colspan="2"><input type="radio" name="remove_action" value="1" checked="checked" />&nbsp;<span class="genmed">Move messages from removed folder to </span>&nbsp;<select name="move_to">{S_TO_FOLDER_OPTIONS}</select></td>
+ </tr>
+ <tr>
+ <td class="row2" width="200">&nbsp;</td>
+ <td class="row2" colspan="2"><input type="radio" name="remove_action" value="2" />&nbsp;<span class="genmed">Delete all messages within removed folder</span></td>
+ </tr>
+ <tr>
+ <td class="row2" width="200">&nbsp;</td>
+ <td class="row2" colspan="2" align="right"><input class="btnlite" style="width:150px" type="submit" name="remove" value="{L_REMOVE}" /></td>
+ </tr>
+
+</table>
+
+<div style="padding: 2px;"></div>
+<!-- ENDIF -->
+
+<table class="tablebg" width="100%" cellspacing="1">
+ <tr>
+ <th colspan="2">{L_FOLDER_OPTIONS}</th>
+ </tr>
+ <tr>
+ <td class="row1" width="200"><b class="genmed">{L_IF_FOLDER_FULL}: </b></span></td>
+ <td class="row1"><input type="radio" name="full_action" value="1"{S_DELETE_CHECKED} />&nbsp;<span class="genmed">{L_DELETE_OLDEST_MESSAGES}</span></td>
+ </tr>
+ <tr>
+ <td class="row1" width="200">&nbsp;</td>
+ <td class="row1"><input type="radio" name="full_action" value="2"{S_MOVE_CHECKED} />&nbsp;<span class="genmed">{L_MOVE_TO_FOLDER}: </span><select name="full_move_to">{S_FULL_FOLDER_OPTIONS}</select></td>
+ </tr>
+ <tr>
+ <td class="row1" width="200">&nbsp;</td>
+ <td class="row1"><input type="radio" name="full_action" value="3"{S_HOLD_CHECKED} />&nbsp;<span class="genmed">{L_HOLD_NEW_MESSAGES}</span></td>
+ </tr>
+ <tr>
+ <td class="row2" width="200"><b class="genmed">{L_DEFAULT_ACTION}: </b><br /><span class="gensmall">{L_DEFAULT_ACTION_EXPLAIN}</span></td>
+ <td class="row2"><span class="genmed">{DEFAULT_ACTION}</span></td>
+ </tr>
+ <tr>
+ <td class="row1" colspan="2" align="right"><input class="btnlite" style="width:150px" type="submit" name="fullfolder" value="{L_CHANGE}" /></td>
+ </tr>
+</table>
+
+<!-- INCLUDE ucp_footer.html -->
diff --git a/phpBB/styles/subSilver/template/ucp_pm_viewfolder.html b/phpBB/styles/subSilver/template/ucp_pm_viewfolder.html
new file mode 100644
index 0000000000..fc538e4266
--- /dev/null
+++ b/phpBB/styles/subSilver/template/ucp_pm_viewfolder.html
@@ -0,0 +1,83 @@
+<!-- INCLUDE ucp_header.html -->
+
+<!-- $Id$ -->
+
+<div id="pagecontent">
+
+<!-- INCLUDE ucp_pm_message_header.html -->
+ <div style="padding: 2px;"></div>
+
+<!-- IF S_PM_ICONS and S_UNREAD -->
+ <!-- DEFINE $COLSPAN = 7 -->
+<!-- ELSEIF not S_PM_ICONS and not S_UNREAD -->
+ <!-- DEFINE $COLSPAN = 5 -->
+<!-- ELSE -->
+ <!-- DEFINE $COLSPAN = 6 -->
+<!-- ENDIF -->
+
+<form name="viewfolder" method="post" action="{S_PM_ACTION}" style="margin:0px">
+
+<table class="tablebg" width="100%" cellspacing="1" cellpadding="0" border="0">
+<!-- IF NUM_NOT_MOVED -->
+ <tr>
+ <td class="row3" colspan="{$COLSPAN}" align="center"><span class="gen">{NOT_MOVED_MESSAGES}<br />{RELEASE_MESSAGE_INFO}</span></td>
+ </tr>
+<!-- ENDIF -->
+ <tr>
+ <th colspan="<!-- IF S_PM_ICONS -->3<!-- ELSE -->2<!-- ENDIF -->">&nbsp;{L_SUBJECT}&nbsp;</th>
+ <!-- IF S_UNREAD -->
+ <th>&nbsp;<!-- IF S_SHOW_RECIPIENTS -->{L_RECIPIENTS}<!-- ELSE -->{L_AUTHOR}<!-- ENDIF -->&nbsp;</th>
+ <th>&nbsp;{L_FOLDER}&nbsp;</th>
+ <!-- ELSE -->
+ <th>&nbsp;<!-- IF S_SHOW_RECIPIENTS -->{L_RECIPIENTS}<!-- ELSE -->{L_AUTHOR}<!-- ENDIF -->&nbsp;</th>
+ <!-- ENDIF -->
+ <th>&nbsp;{L_SENT_AT}&nbsp;</th>
+ <th>&nbsp;{L_MARK}&nbsp;</th>
+ </tr>
+
+ <!-- BEGIN messagerow -->
+ <tr>
+ <td class="row1" width="25" align="center" nowrap="nowrap">{messagerow.FOLDER_IMG}</td>
+ <!-- IF S_PM_ICONS -->
+ <td class="row1" width="25" align="center">{messagerow.PM_ICON_IMG}</td>
+ <!-- ENDIF -->
+ <td class="row1">
+ <!-- IF messagerow.S_PM_REPORTED -->
+ <a href="{messagerow.U_MCP_REPORT}">{REPORTED_IMG}</a>&nbsp;
+ <!-- ENDIF -->
+ <!-- IF not messagerow.PM_IMG and messagerow.PM_CLASS -->
+ <span class="{messagerow.PM_CLASS}"><img src="images/spacer.gif" width="10" height="10" alt="" border="0" /></span>&nbsp;
+ <!-- ELSEIF messagerow.PM_IMG -->
+ {messagerow.PM_IMG}&nbsp;
+ <!-- ENDIF -->
+ <p class="topictitle">{messagerow.ATTACH_ICON_IMG} <a href="{messagerow.U_VIEW_PM}">{messagerow.SUBJECT}</a></p></td>
+ <td class="row1" width="100" align="center"><p class="topicauthor"><!-- IF S_SHOW_RECIPIENTS -->{messagerow.RECIPIENTS}<!-- ELSE -->{messagerow.MESSAGE_AUTHOR}<!-- ENDIF --></p></td>
+ <!-- IF S_UNREAD -->
+ <td class="row1" width="100" align="center"><p class="topicauthor"><!-- IF messagerow.FOLDER --><a href="{messagerow.U_FOLDER}">{messagerow.FOLDER}</a><!-- ELSE -->{L_UNKNOWN_FOLDER}<!-- ENDIF --></p></td>
+ <!-- ENDIF -->
+ <td class="row1" width="120" align="center"><p class="topicdetails">{messagerow.SENT_TIME}</p></td>
+ <td class="row1" width="20" align="center"><p class="topicdetails"><input type="checkbox" name="marked_msg_id[]" value="{messagerow.MESSAGE_ID}" /></p></td>
+ </tr>
+ <!-- BEGINELSE -->
+ <tr>
+ <td class="row1" colspan="{$COLSPAN}" height="30" align="center" valign="middle"><span class="gen">{L_NO_MESSAGES}</span></td>
+ </tr>
+ <!-- END messagerow -->
+
+ <input type="hidden" name="cur_folder_id" value="{CUR_FOLDER_ID}" />
+</table>
+<table border="0" cellspacing="0" cellpadding="0" width="100%">
+ <tr>
+ <td class="cat" align="left"><span class="gensmall">{L_DISPLAY_MESSAGES}:</span> {S_SELECT_SORT_DAYS} <span class="gensmall">{L_SORT_BY}</span> {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} <input class="btnlite" type="submit" name="sort" value="{L_GO}" /></td>
+ <td class="cat" align="right"><select name="mark_option">{S_MARK_OPTIONS}</select>&nbsp;<input class="btnlite" type="submit" name="submit_mark" value="{L_GO}" />&nbsp;</td>
+ </tr>
+</table>
+
+<div style="padding: 2px;"></div>
+<!-- INCLUDE ucp_pm_message_footer.html -->
+
+<br clear="all" />
+
+</div>
+
+<!-- INCLUDE ucp_footer.html -->
diff --git a/phpBB/styles/subSilver/template/ucp_pm_viewmessage.html b/phpBB/styles/subSilver/template/ucp_pm_viewmessage.html
new file mode 100644
index 0000000000..ba82081e04
--- /dev/null
+++ b/phpBB/styles/subSilver/template/ucp_pm_viewmessage.html
@@ -0,0 +1,182 @@
+<!-- INCLUDE ucp_header.html -->
+
+<!-- $Id$ -->
+
+<div id="pagecontent">
+
+<!-- INCLUDE ucp_pm_message_header.html -->
+<div style="padding: 2px;"></div>
+
+<table class="tablebg" width="100%" cellspacing="1" cellpadding="4">
+
+ <tr class="row1">
+ <td class="genmed" nowrap="nowrap" width="150"><b>{L_PM_SUBJECT}:</b></td>
+ <td class="gen">{SUBJECT}</td>
+ </tr>
+
+ <tr class="row1">
+ <td class="genmed" nowrap="nowrap" width="150"><b>{L_PM_FROM}:</b></td>
+ <td class="gen"><a href="{U_AUTHOR_PROFILE}">{AUTHOR_NAME}</a></td>
+ </tr>
+
+ <tr class="row1">
+ <td class="genmed" nowrap="nowrap" width="150"><b>{L_SENT_AT}:</b></td>
+ <td class="gen">{SENT_DATE}</td>
+ </tr>
+
+ <!-- IF S_TO_RECIPIENT -->
+ <tr class="row1">
+ <td class="genmed" nowrap="nowrap" width="150"><b>{L_TO}:</b></td>
+ <td class="gen">
+ <!-- BEGIN to_recipient -->
+ <a href="{to_recipient.U_VIEW}"><!-- IF to_recipient.COLOUR --><span style="color:#{to_recipient.COLOUR}"><!-- ELSE --><span<!-- IF to_recipient.IS_GROUP --> class="blue"<!-- ENDIF -->><!-- ENDIF -->{to_recipient.NAME}</span></a>&nbsp;
+ <!-- END to_recipient -->
+ </td>
+ </tr>
+ <!-- ENDIF -->
+
+ <!-- IF S_BCC_RECIPIENT -->
+ <tr class="row1">
+ <td class="genmed" nowrap="nowrap" width="150"><b>{L_BCC}:</b></td>
+ <td class="gen">
+ <!-- BEGIN bcc_recipient -->
+ <a href="{bcc_recipient.U_VIEW}"><!-- IF bcc_recipient.COLOUR --><span style="color:#{bcc_recipient.COLOUR}"><!-- ELSE --><span<!-- IF bcc_recipient.IS_GROUP --> class="blue"<!-- ENDIF -->><!-- ENDIF -->{bcc_recipient.NAME}</span></a>&nbsp;
+ <!-- END bcc_recipient -->
+ </td>
+ </tr>
+ <!-- ENDIF -->
+</table>
+
+<div style="padding: 2px;"></div>
+
+<table class="tablebg" width="100%" cellspacing="1" cellpadding="0">
+
+ <tr>
+ <th width="150" nowrap="nowrap">{L_AUTHOR}</th>
+ <th nowrap="nowrap">{L_MESSAGE}</th>
+ </tr>
+
+ <tr>
+ <td class="spacer" colspan="2" height="1"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
+ </tr>
+
+ <tr class="row1">
+ <td valign="top">
+
+ <div align="center">
+
+ <b class="postauthor">{AUTHOR_NAME}</b><br /><br />
+
+ <table cellspacing="4" align="center">
+ <!-- IF ONLINE_IMG -->
+ <tr>
+ <td>{ONLINE_IMG}</td>
+ </tr>
+ <!-- ENDIF -->
+ <!-- IF AUTHOR_RANK -->
+ <tr>
+ <td class="postdetails">{AUTHOR_RANK}</td>
+ </tr>
+ <!-- ENDIF -->
+ <!-- IF RANK_IMAGE -->
+ <tr>
+ <td>{RANK_IMAGE}</td>
+ </tr>
+ <!-- ENDIF -->
+ <!-- IF AUTHOR_AVATAR -->
+ <tr>
+ <td>{AUTHOR_AVATAR}</td>
+ </tr>
+ <!-- ENDIF -->
+ </table>
+
+ <span class="postdetails">
+ <!-- IF AUTHOR_POSTS --><br /><b>{L_JOINED}:</b> {AUTHOR_JOINED}<!-- ENDIF -->
+ <!-- IF AUTHOR_POSTS --><br /><b>{L_POSTS}:</b> {AUTHOR_POSTS}<!-- ENDIF -->
+ <!-- IF AUTHOR_FROM --><br /><b>{L_LOCATION}:</b> {AUTHOR_FROM}<!-- ENDIF -->
+ </span>
+
+ </div>
+ </td>
+ <td valign="top"><table width="100%" cellspacing="5">
+ <tr>
+ <td>
+
+ <!-- IF S_MESSAGE_REPORTED -->
+ <table width="100%" cellspacing="0">
+ <tr>
+ <td class="gensmall"><b class="postreported">&#187 <a class="postreported" href="{U_MCP_REPORT}">{L_MESSAGE_REPORTED}</a></b></td>
+ </tr>
+ </table>
+
+ <br clear="all" />
+ <!-- ENDIF -->
+
+ <div class="postbody">{MESSAGE}</div>
+
+ <!-- IF S_HAS_ATTACHMENTS -->
+ <br clear="all" /><br />
+
+ <table class="tablebg" width="100%" cellspacing="1">
+ <tr>
+ <td class="row3"><b class="genmed">{L_ATTACHMENTS}: </b></td>
+ </tr>
+ <!-- BEGIN attachment -->
+ <tr>
+ <td class="row2">{attachment.DISPLAY_ATTACHMENT}</td>
+ </tr>
+ <!-- END attachment -->
+ </table>
+ <!-- ENDIF -->
+
+ <!-- IF S_DISPLAY_NOTICE -->
+ <span class="gensmall" style="color:red;"><br /><br />{L_DOWNLOAD_NOTICE}</span>
+ <!-- ENDIF -->
+ <!-- IF SIGNATURE -->
+ <span class="postbody"><br />_________________<br />{SIGNATURE}</span>
+ <!-- ENDIF -->
+ <!-- IF EDITED_MESSAGE -->
+ <span class="gensmall">{EDITED_MESSAGE}</span>
+ <!-- ENDIF -->
+
+ <!-- IF not S_HAS_ATTACHMENTS --><br clear="all" /><br /><!-- ENDIF -->
+
+ <table width="100%" cellspacing="0">
+ <tr valign="middle">
+ <td class="gensmall" align="right"><!-- IF U_REPORT --><a href="{U_REPORT}">{REPORT_IMG}</a> <!-- ENDIF --> <!-- IF U_IP --><a href="{U_IP}">{IP_IMG}</a> <!-- ENDIF --> <!-- IF U_DELETE --><a href="{U_DELETE}">{DELETE_IMG}</a> <!-- ENDIF --></td>
+ </tr>
+ </table>
+
+ </td>
+ </tr>
+ </table></td>
+ </tr>
+
+ <tr class="row1">
+ <td></td>
+ <td><div class="gensmall" style="float:left">&nbsp;<!-- IF U_AUTHOR_PROFILE --><a href="{U_AUTHOR_PROFILE}">{PROFILE_IMG}</a> <!-- ENDIF --> <!-- IF U_EMAIL --><a href="{U_EMAIL}">{EMAIL_IMG}</a> <!-- ENDIF -->&nbsp;</div> <div class="gensmall" style="float:right"><!-- IF U_QUOTE --><a href="{U_QUOTE}">{QUOTE_IMG}</a> <!-- ENDIF --> <!-- IF U_POST_REPLY_PM --><a href="{U_POST_REPLY_PM}">{REPLY_IMG}</a><!-- ENDIF --> <!-- IF U_EDIT --><a href="{U_EDIT}">{EDIT_IMG}</a> <!-- ENDIF -->&nbsp;</div></td>
+ </tr>
+
+ <tr>
+ <td class="spacer" colspan="2" height="1"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
+ </tr>
+</table>
+
+<!--
+<table width="100%" cellspacing="1">
+ <tr>
+ <td align="left" valign="middle" nowrap="nowrap"><a href="{U_POST_REPLY_PM}">{REPLY_IMG}</a></td>
+ </tr>
+</table>
+//-->
+
+<div style="padding: 2px;"></div>
+<!-- INCLUDE ucp_pm_message_footer.html -->
+
+<br clear="all" />
+
+</div>
+
+<!-- IF S_DISPLAY_HISTORY --><!-- INCLUDE ucp_pm_history.html --><!-- ENDIF -->
+
+<!-- INCLUDE ucp_footer.html -->
diff --git a/phpBB/styles/subSilver/template/ucp_pm_viewmessage_print.html b/phpBB/styles/subSilver/template/ucp_pm_viewmessage_print.html
new file mode 100644
index 0000000000..ceb23ccd28
--- /dev/null
+++ b/phpBB/styles/subSilver/template/ucp_pm_viewmessage_print.html
@@ -0,0 +1,127 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html dir="{S_CONTENT_DIRECTION}">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset={S_CONTENT_ENCODING}">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<title>{SITENAME} :: {PAGE_TITLE}</title>
+<style type="text/css">
+<!--
+body {
+ font-family: Verdana,serif;
+ font-size: 10pt;
+}
+
+td {
+ font-family: Verdana,serif;
+ font-size: 10pt;
+ line-height: 150%;
+}
+
+.code, .quote {
+ font-size: smaller;
+ border: black solid 1px;
+}
+
+.forum {
+ font-family: Arial,Helvetica,sans-serif;
+ font-weight: bold;
+ font-size: 18pt;
+}
+
+.topic {
+ font-family: Arial,Helvetica,sans-serif;
+ font-size: 14pt;
+ font-weight: bold;
+}
+
+.gensmall {
+ font-size: 8pt;
+}
+
+hr {
+ color: #888888;
+ height: 3px;
+ border-style: solid;
+}
+
+hr.sep {
+ color: #AAAAAA;
+ height: 1px;
+ border-style: dashed;
+}
+-->
+</style>
+</head>
+<body>
+
+<table width="85%" cellspacing="3" cellpadding="0" border="0" align="center">
+ <tr>
+ <td colspan="2" align="center"><span class="Forum">{SITENAME}</span><br /><span class="gensmall">{L_PRIVATE_MESSAGING}</a></span></td>
+ </tr>
+ <tr>
+ <td colspan="2"><br /></td>
+ </tr>
+ <tr>
+ <td><span class="Topic">{SUBJECT}</span><br /></td>
+ <td align="right" valign="bottom"><span class="gensmall">{PAGE_NUMBER}</span></td>
+ </tr>
+</table>
+
+
+<hr width="85%" />
+
+<table width="85%" cellspacing="3" cellpadding="0" border="0" align="center">
+ <tr>
+ <td width="10%" nowrap="nowrap">{L_PM_FROM}:&nbsp;</td>
+ <td><b>{AUTHOR_NAME}</b> [ {SENT_DATE} ]</td>
+ </tr>
+
+ <!-- IF S_TO_RECIPIENT -->
+ <tr>
+ <td width="10%" nowrap="nowrap">{L_TO}:</td>
+ <td>
+ <!-- BEGIN to_recipient -->
+ <!-- IF to_recipient.COLOUR --><span style="color:#{to_recipient.COLOUR}"><!-- ELSE --><span<!-- IF to_recipient.IS_GROUP --> class="blue"<!-- ENDIF -->><!-- ENDIF -->{to_recipient.NAME}</span>&nbsp;
+ <!-- END to_recipient -->
+ </td>
+ </tr>
+ <!-- ENDIF -->
+
+ <!-- IF S_BCC_RECIPIENT -->
+ <tr>
+ <td width="10%" nowrap="nowrap">{L_BCC}:</td>
+ <td>
+ <!-- BEGIN bcc_recipient -->
+ <!-- IF bcc_recipient.COLOUR --><span style="color:#{bcc_recipient.COLOUR}"><!-- ELSE --><span<!-- IF bcc_recipient.IS_GROUP --> class="blue"<!-- ENDIF -->><!-- ENDIF -->{bcc_recipient.NAME}</span>&nbsp;
+ <!-- END bcc_recipient -->
+ </td>
+ </tr>
+ <!-- ENDIF -->
+ <tr>
+ <td colspan="2"><hr class="sep" />{MESSAGE}</td>
+ </tr>
+</table>
+
+<hr width="85%" />
+<!--
+ We request you retain the full copyright notice below including the link to www.phpbb.com.
+ This not only gives respect to the large amount of time given freely by the developers
+ but also helps build interest, traffic and use of phpBB2. If you (honestly) cannot retain
+ the full copyright we ask you at least leave in place the "Powered by phpBB {PHPBB_VERSION}"
+ line, with phpBB linked to www.phpbb.com. If you refuse to include even this then support on
+ our forums may be affected.
+
+ The phpBB Group : 2002
+// -->
+<table width="85%" cellspacing="3" cellpadding="0" border="0" align="center">
+ <tr>
+ <td><span class="gensmall">{PAGE_NUMBER}</span></td>
+ <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td>
+ </tr>
+ <tr>
+ <td colspan="2" align="center"><span class="gensmall">Powered by phpBB {PHPBB_VERSION} &copy; 2002 phpBB Group<br />http://www.phpbb.com/</span></td>
+ </tr>
+</table>
+
+</body>
+</html> \ No newline at end of file