Example #1
0
/**
 * The HTML form to display the inbox
 * 
 * @global $current_user
 * @return string
 */
function cpm_page_inbox()
{
    $html = '<h2>' . __('Inbox', 'cubepm') . '</h2>';
    global $current_user;
    get_currentuserinfo();
    $user_id = $current_user->ID;
    $thread_ids = cpm_getUserInboxThreads($user_id);
    if (count($thread_ids) > 0) {
        $html .= '<table class="cpm-inbox">';
        $html .= '<thead>';
        $html .= '<tr>';
        $html .= '<th class="cpm-inbox-subject">' . __('Subject', 'cubepm') . '</th>';
        $html .= '<th class="cpm-inbox-from">' . __('From', 'cubepm') . '</th>';
        $html .= '<th class="cpm-inbox-received">' . __('Received', 'cubepm') . '</th>';
        $html .= '</tr>';
        $html .= '</thead>';
        $html .= '<tbody>';
        $count = 0;
        foreach ($thread_ids as $thread_id) {
            $count++;
            $thread = cpm_getThreadInfo($thread_id);
            $from = array();
            foreach ($thread['users'] as $thread_user_id) {
                if ($thread_user_id != $user_id) {
                    $user = get_user_by('id', $thread_user_id);
                    if ($user) {
                        $from[] = '<span class="cpm-user" style="background-image:url(https://secure.gravatar.com/avatar/' . md5(strtolower(trim($user->user_email))) . '?s=16);"><a href="' . apply_filters('cpm_user_link', '#', $user) . '">' . $user->display_name . '</a></span>';
                    }
                }
            }
            if (count($from) > 0) {
                $from = implode('<span class="cpm-user-separator">, </span>', $from);
            } else {
                $from = '<i>' . __('Nobody', 'cubepm') . '</i>';
            }
            $html .= '<tr class="' . ($count % 2 == 0 ? 'even' : 'odd') . ' ' . (cpm_userCheckOpenedThread($user_id, $thread_id) ? 'opened' : 'unopened') . '">';
            $html .= '<td class="cpm-inbox-subject"><a href="' . cpm_buildURL(array('cpm_action' => 'read', 'cpm_id' => $thread['thread_id'])) . '">' . $thread['subject'] . '</a></td>';
            $html .= '<td class="cpm-inbox-from">' . $from . '</td>';
            $html .= '<td class="cpm-inbox-received">' . cpm_relativeTime($thread['freshness']) . '</td>';
            $html .= '</tr>';
        }
        $html .= '</tbody>';
        $html .= '</table>';
    } else {
        $html .= cpm_htmlMessage(__('You do not have any messages in your inbox!', 'cubepm'));
    }
    return $html;
}
Example #2
0
/**
 * The HTML form to post a new thread
 * 
 * @return string
 */
function cpm_page_new()
{
    $html = '<h2>' . __('Send PM', 'cubepm') . '</h2>';
    if ($_POST['cpm_form_submit'] != '') {
        $cpm_errors = cpm_page_new_process();
        if (count($cpm_errors->get_error_messages()) > 0) {
            $html .= cpm_htmlError($cpm_errors);
            $html .= cpm_page_new_form();
        } else {
            $html .= cpm_htmlMessage(__('Your PM has been sent!', 'cubepm'), __('Success', 'cubepm'));
        }
    } else {
        $html .= cpm_page_new_form();
    }
    return $html;
}
Example #3
0
/**
 * Build HTML to show reply form
 * 
 * @todo Add reply form here
 * 
 * @param int $thread_id
 * @param int $user_id
 * @return string
 */
function cpm_page_read_buildReply($thread_id, $user_id, $cpm_errors = null)
{
    $html = '<a name="cpm-reply"></a>';
    $html .= '<h3>' . __('Reply', 'cubepm') . '</h3>';
    if ($cpm_errors != null) {
        if (count($cpm_errors->get_error_messages()) > 0) {
            $html .= cpm_htmlError($cpm_errors);
        } else {
            $html .= cpm_htmlMessage('Reply sent!', 'Success');
        }
    }
    $html .= '<table class="cpm-thread-reply">';
    $html .= '<tbody><tr><td>';
    $html .= '<form method="post" action="' . cpm_buildURL(array('cpm_action' => 'read', 'cpm_id' => $thread_id)) . '#cpm-reply">';
    $html .= '<input type="hidden" name="cpm_form_submit" value="1" />';
    $html .= '<p><textarea name="cpm_message" id="cpm_message">' . $cpm_message . '</textarea></p>';
    $html .= '<p><input type="submit" name="cpm_submit" id="cpm_submit" value="' . __('Reply', 'cubepm') . ' &raquo;" /></p>';
    $html .= '</form>';
    $html .= '</td></tr></tbody>';
    $html .= '</table>';
    return $html;
}