Example #1
0
}
if (!qa_opt('allow_private_messages') || !qa_opt('show_message_history')) {
    return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
//	Find the messages for this user
$start = qa_get_start();
$pagesize = qa_opt('page_size_pms');
// get number of messages then actual messages for this page
$func = $showOutbox ? 'qa_db_messages_outbox_selectspec' : 'qa_db_messages_inbox_selectspec';
$pmSpecCount = qa_db_selectspec_count($func('private', $loginUserId, true));
$pmSpec = $func('private', $loginUserId, true, $start, $pagesize);
list($numMessages, $userMessages) = qa_db_select_with_pending($pmSpecCount, $pmSpec);
$count = $numMessages['count'];
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html($showOutbox ? 'misc/pm_outbox_title' : 'misc/pm_inbox_title');
$qa_content['script_rel'][] = 'qa-content/qa-user.js?' . QA_VERSION;
$qa_content['message_list'] = array('tags' => 'id="privatemessages"', 'messages' => array(), 'form' => array('tags' => 'name="pmessage" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'hidden' => array('qa_click' => '', 'handle' => qa_html($loginUserHandle), 'start' => qa_html($start), 'code' => qa_get_form_security_code('pm-' . $loginUserHandle))));
$htmlDefaults = qa_message_html_defaults();
if ($showOutbox) {
    $htmlDefaults['towhomview'] = true;
}
foreach ($userMessages as $message) {
    $msgFormat = qa_message_html_fields($message, $htmlDefaults);
    $replyHandle = $showOutbox ? $message['tohandle'] : $message['fromhandle'];
    $msgFormat['form'] = array('style' => 'light', 'buttons' => array('reply' => array('tags' => 'onclick="window.location.href=\'' . qa_path_html('message/' . $replyHandle) . '\';return false"', 'label' => qa_lang_html('question/reply_button')), 'delete' => array('tags' => 'name="m' . qa_html($message['messageid']) . '_dodelete" onclick="return qa_pm_click(' . qa_js($message['messageid']) . ', this, ' . qa_js($showOutbox ? 'outbox' : 'inbox') . ');"', 'label' => qa_lang_html('question/delete_button'), 'popup' => qa_lang_html('profile/delete_pm_popup'))));
    $qa_content['message_list']['messages'][] = $msgFormat;
}
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub'] = qa_messages_sub_navigation($showOutbox ? 'outbox' : 'inbox');
return $qa_content;
Example #2
0
$qa_content['form_message'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'ok' => $messagesent ? qa_lang_html('misc/message_sent') : null, 'fields' => array('message' => array('type' => $hideForm ? 'static' : '', 'label' => qa_lang_html_sub('misc/message_for_x', qa_get_one_user_html($handle, false)), 'tags' => 'name="message" id="message"', 'value' => qa_html(@$inmessage, $messagesent), 'rows' => 8, 'note' => qa_lang_html_sub('misc/message_explanation', qa_html(qa_opt('site_title'))), 'error' => qa_html(@$errors['message']))), 'buttons' => array('send' => array('tags' => 'onclick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('main/send_button'))), 'hidden' => array('domessage' => '1', 'code' => qa_get_form_security_code('message-' . $handle)));
$qa_content['focusid'] = 'message';
if ($hideForm) {
    unset($qa_content['form_message']['buttons']);
    if (qa_opt('show_message_history')) {
        unset($qa_content['form_message']['fields']['message']);
    } else {
        unset($qa_content['form_message']['fields']['message']['note']);
        unset($qa_content['form_message']['fields']['message']['label']);
    }
}
//	If relevant, show recent message history
if (qa_opt('show_message_history')) {
    $recent = array_merge($torecent, $fromrecent);
    qa_sort_by($recent, 'created');
    $showmessages = array_slice(array_reverse($recent, true), 0, QA_DB_RETRIEVE_MESSAGES);
    if (count($showmessages)) {
        $qa_content['message_list'] = array('title' => qa_lang_html_sub('misc/message_recent_history', qa_html($toaccount['handle'])));
        $options = qa_message_html_defaults();
        foreach ($showmessages as $message) {
            $qa_content['message_list']['messages'][] = qa_message_html_fields($message, $options);
        }
    }
    $qa_content['navigation']['sub'] = qa_messages_sub_navigation();
}
$qa_content['raw']['account'] = $toaccount;
// for plugin layers to access
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/