Commit 019572b1 by Scott

Add PMs to user submenu

parent ba6464b5
......@@ -1304,6 +1304,11 @@
'url' => qa_path_html('user/'.$handle.'/wall'),
),
'messages' => array(
'label' => qa_lang_html('misc/nav_user_pms'),
'url' => qa_path_html('messages'),
),
'activity' => array(
'label' => qa_lang_html('misc/nav_user_activity'),
'url' => qa_path_html('user/'.$handle.'/activity'),
......@@ -1332,6 +1337,33 @@
if (!$ismyuser)
unset($navigation['favorites']);
if (!$ismyuser || !qa_opt('allow_private_messages') || !qa_opt('show_message_history'))
unset($navigation['messages']);
return $navigation;
}
function qa_messages_sub_navigation($selected=null)
/*
Return the sub navigation structure for private message pages
*/
{
$navigation = array(
'inbox' => array(
'label' => qa_lang_html('misc/inbox'),
'url' => qa_path_html('messages'),
),
'outbox' => array(
'label' => qa_lang_html('misc/outbox'),
'url' => qa_path_html('messages/sent'),
)
);
if (isset($navigation[$selected]))
$navigation[$selected]['selected'] = true;
return $navigation;
}
......
......@@ -74,6 +74,7 @@
'nav_my_favorites' => 'My favorites',
'nav_user_activity' => 'Recent activity',
'nav_user_as' => 'All answers',
'nav_user_pms' => 'Private messages',
'nav_user_qs' => 'All questions',
'nav_user_wall' => 'Wall',
'no_activity_from_x' => 'No activity from ^',
......
......@@ -223,6 +223,8 @@
foreach ($showmessages as $message)
$qa_content['message_list']['messages'][] = qa_message_html_fields($message, $options);
}
$qa_content['navigation']['sub'] = qa_messages_sub_navigation();
}
......
......@@ -39,7 +39,13 @@
// Check which box we're showing (inbox/sent), we're not using Q2A's single-sign on integration and that we're logged in
$showingInbox = qa_request_part(1) !== 'sent';
$req = qa_request_part(1);
if ($req === null)
$showBox = 'inbox';
else if ($req === 'sent')
$showBox = 'outbox';
else
return include QA_INCLUDE_DIR.'qa-page-not-found.php';
if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code');
......@@ -50,23 +56,21 @@
return $qa_content;
}
if ( !qa_opt('allow_private_messages') )
if (!qa_opt('allow_private_messages') || !qa_opt('show_message_history'))
return include QA_INCLUDE_DIR.'qa-page-not-found.php';
// Find the user profile and questions and answers for this handle
$pmSpec = $showingInbox
? qa_db_messages_inbox_selectspec('private', $loginUserId, true)
: qa_db_messages_outbox_selectspec('private', $loginUserId, true);
$func = 'qa_db_messages_'.$showBox.'_selectspec';
$pmSpec = $func('private', $loginUserId, true);
$userMessages = qa_db_select_with_pending($pmSpec);
// Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = $showingInbox ? qa_lang_html('misc/pm_inbox_title') : qa_lang_html('misc/pm_outbox_title');
$qa_content['title'] = qa_lang_html('misc/pm_'.$showBox.'_title');
$qa_content['message_list'] = array(
'tags' => 'id="privatemessages"',
......@@ -74,26 +78,12 @@
);
$htmlDefaults = qa_message_html_defaults();
if (!$showingInbox) {
if ($showBox === 'outbox')
$htmlDefaults['towhomview'] = true;
}
foreach ($userMessages as $message) {
foreach ($userMessages as $message)
$qa_content['message_list']['messages'][] = qa_message_html_fields($message, $htmlDefaults);
}
$qa_content['navigation']['sub'] = array(
'inbox' => array(
'label' => qa_lang_html('misc/inbox'),
'url' => qa_path_html('messages'),
'selected' => $showingInbox,
),
'outbox' => array(
'label' => qa_lang_html('misc/outbox'),
'url' => qa_path_html('messages/sent'),
'selected' => !$showingInbox,
)
);
$qa_content['navigation']['sub'] = qa_messages_sub_navigation($showBox);
return $qa_content;
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