mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-07 17:27:16 +02:00
- private messages - not finished yet.
git-svn-id: file:///svn/phpbb/trunk@4908 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
1039
phpBB/includes/functions_privmsgs.php
Normal file
1039
phpBB/includes/functions_privmsgs.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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];
|
||||
}
|
||||
|
||||
|
@@ -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 . '&i=pm&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&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 . '&folder=' . $folder_id . '&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&mode=view_messages&action=view_folder",
|
||||
'S_PM_ACTION' => "$url&mode=$mode&action=$action",
|
||||
|
||||
'U_INBOX' => ($folder_id != PRIVMSGS_INBOX) ? "$url&folder=inbox" : '',
|
||||
'U_OUTBOX' => ($folder_id != PRIVMSGS_OUTBOX) ? "$url&folder=outbox" : '',
|
||||
'U_SENTBOX' => ($folder_id != PRIVMSGS_SENTBOX) ? "$url&folder=sentbox" : '',
|
||||
'U_CREATE_FOLDER' => "$url&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&i=$id&mode=$mode&action=$action")
|
||||
|
1176
phpBB/includes/ucp/ucp_pm_compose.php
Normal file
1176
phpBB/includes/ucp/ucp_pm_compose.php
Normal file
File diff suppressed because it is too large
Load Diff
543
phpBB/includes/ucp/ucp_pm_options.php
Normal file
543
phpBB/includes/ucp/ucp_pm_options.php
Normal file
@@ -0,0 +1,543 @@
|
||||
<?php
|
||||
// -------------------------------------------------------------
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// FILENAME : options.php
|
||||
// STARTED : Mon Apr 19, 2004
|
||||
// COPYRIGHT : <20> 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&i=pm&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&i=pm&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&mode=searchuser&form=ucp&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);
|
||||
}
|
||||
|
||||
?>
|
343
phpBB/includes/ucp/ucp_pm_viewfolder.php
Normal file
343
phpBB/includes/ucp/ucp_pm_viewfolder.php
Normal file
@@ -0,0 +1,343 @@
|
||||
<?php
|
||||
// -------------------------------------------------------------
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// FILENAME : viewfolder.php
|
||||
// STARTED : Sun Apr 11, 2004
|
||||
// COPYRIGHT : <20> 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&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&mode=viewprofile&u=$ug_id\">" : "<a href=\"{$phpbb_root_path}groupcp.$phpEx$SID&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&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&mode=viewprofile&u=" . $row['author_id'] . '">' . $row['username'] . '</a>';
|
||||
$view_message_url = "$url&f=$folder_id&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&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}&mode=reports&pm=$message_id")
|
||||
// 'U_MCP_QUEUE' => "mcp.$phpEx?sid={$user->session_id}&mode=mod_queue&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&mode=view_messages&action=view_folder&f=$folder_id&$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&mode=compose&action=post" : '',
|
||||
'S_PM_ACTION' => "$url&mode=view_messages&action=view_folder&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
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
471
phpBB/includes/ucp/ucp_pm_viewmessage.php
Normal file
471
phpBB/includes/ucp/ucp_pm_viewmessage.php
Normal file
@@ -0,0 +1,471 @@
|
||||
<?php
|
||||
// -------------------------------------------------------------
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// FILENAME : viewmessage.php
|
||||
// STARTED : Mon Apr 12, 2004
|
||||
// COPYRIGHT : <20> 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', "<\\2>", $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&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&mode=pm_details&p=" . $message_row['msg_id'],
|
||||
'U_REPORT' => ($config['auth_report_pm'] && $auth->acl_get('u_pm_report')) ? "{$phpbb_root_path}report.$phpEx$SID&pm=" . $message_row['msg_id'] : '',
|
||||
'U_IP' => ($auth->acl_get('m_') && $message_row['message_reported']) ? "{$phpbb_root_path}mcp.$phpEx?sid=" . $user->session_id . "&mode=pm_details&p=" . $message_row['msg_id'] . '#ip' : '',
|
||||
'U_DELETE' => ($auth->acl_get('u_pm_delete')) ? "$url&mode=compose&action=delete&f=$folder_id&p=" . $message_row['msg_id'] : '',
|
||||
'U_AUTHOR_PROFILE' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&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&mode=compose&action=quote&f=$folder_id&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&mode=compose&action=edit&f=$folder_id&p=" . $message_row['msg_id'] : '',
|
||||
'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $auth->acl_get('u_sendpm')) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $message_row['msg_id'] : '',
|
||||
'U_PREVIOUS_PM' => "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=previous",
|
||||
'U_NEXT_PM' => "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&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&f=$folder_id&p=" . $message_row['msg_id'] . "&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&mode=compose&action=forward&f=$folder_id&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&i=pm&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&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&f=$folder_id&p=" . $row['msg_id'],
|
||||
'U_AUTHOR_PROFILE' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u=$author_id",
|
||||
'U_QUOTE' => ($config['auth_quote_pm'] && $auth->acl_get('u_sendpm') && $author_id != $user->data['user_id']) ? "$url&mode=compose&action=quote&f=" . $folder_id . "&p=" . $row['msg_id'] : '',
|
||||
'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $auth->acl_get('u_sendpm')) ? "$url&mode=compose&action=reply&f=$folder_id&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&p=" . (($next_history_pm) ? $next_history_pm : $msg_id),
|
||||
'U_VIEW_PREVIOUS_HISTORY' => "$url&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&mode=email&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]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user