コード例 #1
0
function fep_message_box($action = '', $title = '', $total_message = false, $messages = false)
{
    global $user_ID;
    if (!$action) {
        $action = isset($_GET['fepaction']) && $_GET['fepaction'] ? $_GET['fepaction'] : 'messagebox';
    }
    if (!$title) {
        $title = __('Your Messages', 'fep');
    }
    $title = apply_filters('fep_message_headline', $title, $action);
    if (false === $total_message) {
        $total_message = fep_get_user_total_message($action);
    }
    if (false === $messages) {
        $messages = fep_get_user_messages($action);
    }
    $msgsOut = '';
    if ($total_message) {
        $msgsOut .= "<p><strong>{$title}: ({$total_message})</strong></p>";
        $numPgs = $total_message / fep_get_option('messages_page', 50);
        if ($numPgs > 1) {
            $msgsOut .= "<p><strong>" . __("Page", 'fep') . ": </strong> ";
            for ($i = 0; $i < $numPgs; $i++) {
                if ($_GET['feppage'] != $i) {
                    $msgsOut .= "<a href='" . esc_url(fep_action_url($action)) . "&feppage=" . $i . "'>" . ($i + 1) . "</a> ";
                } else {
                    $msgsOut .= "[<b>" . ($i + 1) . "</b>] ";
                }
            }
            $msgsOut .= "</p>";
        }
        $msgsOut .= "<table><tr class='fep-head'>\r\n        <th width='20%'>" . __("Started By", 'fep') . "</th>\r\n\t\t<th width='20%'>" . __("To", 'fep') . "</th>\r\n        <th width='40%'>" . __("Subject", 'fep') . "</th>\r\n        <th width='20%'>" . __("Last Reply By", 'fep') . "</th></tr>";
        $a = 0;
        foreach ($messages as $msg) {
            if ($msg->status == 0 && $msg->last_sender != $user_ID) {
                $status = "<font color='#FF0000'>" . __("Unread", 'fep') . "</font>";
            } else {
                $status = __("Read", 'fep');
            }
            $status = apply_filters('fep_filter_status_display', $status, $msg, $action);
            $msgsOut .= "<tr class='fep-trodd" . $a . "'>";
            if ($msg->from_user != $user_ID) {
                $msgsOut .= "<td><a href='" . fep_action_url() . "between&with=" . fep_get_userdata($msg->from_user, 'user_login', 'id') . "'>" . fep_get_userdata($msg->from_user, 'display_name', 'id') . "</a><br/><small>" . fep_format_date($msg->send_date) . "</small></td>";
            } else {
                $msgsOut .= "<td>" . fep_get_userdata($msg->from_user, 'display_name', 'id') . "<br/><small>" . fep_format_date($msg->send_date) . "</small></td>";
            }
            if ($msg->to_user != $user_ID) {
                $msgsOut .= "<td><a href='" . fep_action_url() . "between&with=" . fep_get_userdata($msg->to_user, 'user_login', 'id') . "'>" . fep_get_userdata($msg->to_user, 'display_name', 'id') . "</a></td>";
            } else {
                $msgsOut .= "<td>" . fep_get_userdata($msg->to_user, 'display_name', 'id') . "</td>";
            }
            $msgsOut .= "<td><a href='" . fep_action_url() . "viewmessage&id=" . $msg->id . "'>" . fep_output_filter($msg->message_title, true) . "</a><br/><small>" . $status . "</small></td>";
            $msgsOut .= "<td>" . fep_get_userdata($msg->last_sender, 'display_name', 'id') . "<br/><small>" . fep_format_date($msg->last_date) . "</small></td>";
            $msgsOut .= "</tr>";
            //Alternate table colors
            if ($a) {
                $a = 0;
            } else {
                $a = 1;
            }
        }
        $msgsOut .= "</table>";
        return apply_filters('fep_messagebox', $msgsOut, $action);
    } else {
        return "<div id='fep-error'>" . sprintf(__("%s empty", 'fep'), $title) . "</div>";
    }
}
コード例 #2
0
 function dispAnnouncement()
 {
     global $wpdb, $user_ID;
     $id = isset($_GET['id']) && $_GET['id'] ? absint($_GET['id']) : 0;
     $announcement = $this->getAnnouncements_by_id($id);
     if ($announcement) {
         $this->make_seen($id);
         echo "<p><strong>" . __("Announcement", 'fep') . ":</strong></p>";
         echo "<table>";
         echo "<tr class='fep-trodd1'><td class='fep-pmtext'><strong>" . __("Subject", 'fep') . ":</strong> " . fep_output_filter($announcement->message_title, true) . "<br/><strong>" . __("Date", 'fep') . ":</strong> " . fep_format_date($announcement->send_date);
         if (current_user_can('manage_options')) {
             echo "<br/><strong>" . __("Added by", 'fep') . ":</strong> " . fep_get_userdata($announcement->from_user, 'display_name', 'id');
             echo "<br/><strong>" . __("Total Seen", 'fep') . ":</strong> " . $this->total_seen($id);
         }
         do_action('fep_display_after_announcement_subject', $id);
         echo "</td></tr>";
         echo "<tr class='fep-trodd0'><td class='fep-pmtext'><strong>" . __("Message", 'fep') . ":</strong><br/>" . fep_output_filter($announcement->message_contents);
         do_action('fep_display_after_announcement_content', $id);
         echo "</td></tr></table>";
     } else {
         echo "<div id='fep-error'>" . __("Announcement is empty!", 'fep') . "</div>";
     }
 }
コード例 #3
0
 function view_message()
 {
     global $wpdb, $user_ID;
     $pID = absint($_GET['id']);
     $order = isset($_GET['order']) && strtoupper($_GET['order']) == 'DESC' ? 'DESC' : 'ASC';
     if ('ASC' == $order) {
         $anti_order = 'DESC';
     } else {
         $anti_order = 'ASC';
     }
     if (!$pID) {
         return "<div id='fep-error'>" . __("You do not have permission to view this message!", 'fep') . "</div>";
     }
     $wholeThread = $this->getWholeThread($pID, $order);
     $threadOut = "<p><strong>" . __("Message Thread", 'fep') . ":</strong></p>";
     ob_start();
     do_action('fep_display_in_message_header', $pID, $wholeThread);
     $threadOut .= ob_get_contents();
     ob_end_clean();
     $threadOut .= "\r\n      <table><tr><th width='15%'>" . __("Sender", 'fep') . "</th><th width='85%'>" . __("Message", 'fep') . "</th></tr>";
     foreach ($wholeThread as $post) {
         //Check for privacy errors first
         if ($post->to_user != $user_ID && $post->from_user != $user_ID && !current_user_can('manage_options')) {
             return "<div id='fep-error'>" . __("You do not have permission to view this message!", 'fep') . "</div>";
         }
         //setup info for the reply form
         if ($post->parent_id == 0) {
             $to = $post->from_user;
             if ($to == $user_ID) {
                 //Make sure user doesn't send a message to himself
                 $to = $post->to_user;
             }
             $message_title = $post->message_title;
             if (substr_count($message_title, __("Re:", 'fep')) < 1) {
                 //Prevent all the Re:'s from happening
                 $re = __("Re:", 'fep');
             } else {
                 $re = "";
             }
         }
         $threadOut .= "<tr><td><a href='" . fep_action_url() . "between&with=" . fep_get_userdata($post->from_user, 'user_login', 'id') . "'>" . fep_get_userdata($post->from_user, 'display_name', 'id') . "</a><br/><small><a href='" . fep_action_url() . "viewmessage&id={$pID}&order={$anti_order}'>" . fep_format_date($post->send_date) . "</a></small><br/>" . get_avatar($post->from_user, 60) . "</td>";
         if ($post->parent_id == 0) {
             $threadOut .= "<td class='fep-pmtext'><strong>" . __("Subject", 'fep') . ": </strong>" . fep_output_filter($post->message_title, true) . "<hr/>" . fep_output_filter($post->message_contents) . "";
             ob_start();
             do_action('fep_display_after_parent_message', $post->id);
             $threadOut .= ob_get_contents();
             ob_end_clean();
             $threadOut .= "</td></tr>";
             if ($post->status == 0 && $user_ID != $post->last_sender && ($user_ID == $post->from_user || $user_ID == $post->to_user)) {
                 //Update only if the reader is not last sender
                 $wpdb->update(FEP_MESSAGES_TABLE, array('status' => 1), array('id' => $post->id), array('%d'), array('%d'));
             }
         } else {
             $threadOut .= "<td class='fep-pmtext'>" . fep_output_filter($post->message_contents) . "";
             ob_start();
             do_action('fep_display_after_reply_message', $post->id);
             $threadOut .= ob_get_contents();
             ob_end_clean();
             $threadOut .= "</td></tr>";
         }
     }
     $threadOut .= "</table>";
     //SHOW THE REPLY FORM
     if (fep_is_user_blocked()) {
         $threadOut .= "<div id='fep-error'>" . __("You cannot send messages because you are blocked by administrator!", 'fep') . "</div>";
     } else {
         $reply_args = array('message_to' => fep_get_userdata($to, 'user_login', 'id'), 'message_top' => fep_get_userdata($to, 'display_name', 'id'), 'message_title' => $re . $message_title, 'message_from' => $user_ID, 'parent_id' => $pID);
         $threadOut .= fep_reply_form($reply_args);
     }
     return $threadOut;
 }