Commit 82a68650 by Scott

Splits PMs into inbox and sent items

parent d5c5c2a7
......@@ -58,6 +58,7 @@
'form_security_reload' => 'Please reload the page then try again',
'hide_all_ip_button' => 'Hide all posts from this IP',
'host_name' => 'Host name:',
'inbox' => 'Inbox',
'matches_blocked_ips' => 'Matches blocked IP addresses:',
'message_empty' => 'Please enter your message to send to this user',
'message_explanation' => 'This will be sent as a notification from ^. Your email address will not be revealed unless you include it in the message.',
......@@ -83,8 +84,10 @@
'no_recent_updates' => 'No recent updates',
'no_updates_content' => 'No recent updates for my content',
'no_updates_favorites' => 'No updates for my favorites',
'outbox' => 'Sent items',
'private_message_title' => 'Send a private message',
'private_messages_title' => 'Private messages',
'pm_inbox_title' => 'Private messages received',
'pm_outbox_title' => 'Private messages sent',
'recent_activity_from_x' => 'Recent activity from ^',
'recent_updates_content' => 'Recent updates for my content',
'recent_updates_favorites' => 'Recent updates for my favorites',
......
......@@ -34,59 +34,62 @@
require_once QA_INCLUDE_DIR.'qa-app-format.php';
require_once QA_INCLUDE_DIR.'qa-app-limits.php';
$loginuserid = qa_get_logged_in_userid();
$loginUserId = qa_get_logged_in_userid();
// Check we have a handle, we're not using Q2A's single-sign on integration and that we're logged in
// Check which box we're showing (inbox/sent), we're not using Q2A's single-sign on integration and that we're logged in
$showInbox = qa_request_part(1) !== 'sent';
if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code');
if (!isset($loginuserid)) {
if (!isset($loginUserId)) {
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request());
return $qa_content;
}
// Find the user profile and questions and answers for this handle
list($toaccount, $usermessages) = qa_db_select_with_pending(
qa_db_user_account_selectspec(qa_get_logged_in_handle(), false),
// qa_db_recent_messages_selectspec($loginuserid, true, null, null)
qa_db_messages_inbox_selectspec('private', $loginuserid, true)
// qa_db_messages_outbox_selectspec('private', $loginuserid, true)
);
// Check the user exists and work out what can and can't be set (if not using single sign-on)
if ( !qa_opt('allow_private_messages') )
return include QA_INCLUDE_DIR.'qa-page-not-found.php';
// Find the user profile and questions and answers for this handle
$pmSpec = $showInbox
? qa_db_messages_inbox_selectspec('private', $loginUserId, true)
: qa_db_messages_outbox_selectspec('private', $loginUserId, true);
$userMessages = qa_db_select_with_pending($pmSpec);
// Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('misc/private_messages_title');
$qa_content['error'] = @$pageerror;
$qa_content['raw']['account'] = $toaccount; // for plugin layers to access
$qa_content['title'] = $showInbox ? qa_lang_html('misc/pm_inbox_title') : qa_lang_html('misc/pm_outbox_title');
$qa_content['message_list'] = array(
// 'title' => '<a name="pms">'.qa_lang_html('misc/private_messages_title').'</a>',
'tags' => 'id="privatemessages"',
'messages' => array(),
);
$options = qa_message_html_defaults();
foreach ($usermessages as $message) {
foreach ($userMessages as $message) {
$qa_content['message_list']['messages'][] = qa_message_html_fields($message, $options);
}
$qa_content['navigation']['sub'] = array(
'inbox' => array(
'label' => qa_lang_html('misc/inbox'),
'url' => qa_path_html('messages'),
'selected' => $showInbox,
),
'outbox' => array(
'label' => qa_lang_html('misc/outbox'),
'url' => qa_path_html('messages/sent'),
'selected' => !$showInbox,
)
);
return $qa_content;
......@@ -422,7 +422,7 @@
'ip/' => 'qa-page-ip.php',
'login' => 'qa-page-login.php',
'logout' => 'qa-page-logout.php',
'messages' => 'qa-page-messages.php',
'messages/' => 'qa-page-messages.php',
'message/' => 'qa-page-message.php',
'questions/' => 'qa-page-questions.php',
'register' => 'qa-page-register.php',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment