function send_email($message_id, $mgs) { $notify = fep_get_user_option('allow_emails', 1, $mgs['to']); if ($notify == '1') { $sendername = get_bloginfo("name"); $sendermail = get_bloginfo("admin_email"); $headers = "MIME-Version: 1.0\r\n" . "From: " . $sendername . " " . "<" . $sendermail . ">\r\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\r\n"; $subject = get_bloginfo("name") . ': ' . __('New Message', 'fep'); $message = __('You have received a new message in', 'fep') . "\r\n"; $message .= get_bloginfo("name") . "\r\n"; $message .= sprintf(__("From: %s", 'fep'), fep_get_userdata($mgs['message_from'], 'display_name', 'id')) . "\r\n"; $message .= sprintf(__("Subject: %s", 'fep'), $mgs['message_title']) . "\r\n"; $message .= __('Please Click the following link to view full Message.', 'fep') . "\r\n"; $message .= fep_action_url('messagebox') . "\r\n"; $mailTo = fep_get_userdata($mgs['to'], 'user_email', 'id'); //wp_mail($mailTo, $subject, $message, $headers); // uncomment this line if you want blog name in message from, comment following line wp_mail($mailTo, $subject, $message); } }
function messages($messages, $action) { global $wpdb, $user_ID; $page = isset($_GET['feppage']) && $_GET['feppage'] ? absint($_GET['feppage']) : 0; $start = $page * fep_get_option('messages_page', 50); $end = fep_get_option('messages_page', 50); $with = fep_get_userdata($_GET['with']); $another = fep_get_userdata(isset($_GET['another']) ? $_GET['another'] : ''); if ($another && current_user_can('manage_options')) { $user = $another; } else { $user = $user_ID; } if ($with) { $messages = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . FEP_MESSAGES_TABLE . " WHERE ((to_user = %d AND from_user = %d AND parent_id = 0 AND to_del = 0) OR (from_user = %d AND to_user = %d AND parent_id = 0 AND from_del = 0)) AND (status = 0 OR status = 1) ORDER BY last_date DESC LIMIT %d, %d", $user, $with, $user, $with, $start, $end)); } else { $messages = array(); } return $messages; }
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>"; } }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { global $user_ID; echo $args['before_widget']; if (!empty($instance['title'])) { echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; } $show_messagebox = isset($instance['show_messagebox']) ? $instance['show_messagebox'] : false; $show_announcement = isset($instance['show_announcement']) ? $instance['show_announcement'] : false; echo "Welcome " . fep_get_userdata($user_ID, 'display_name', 'id') . '<br />'; echo __('You have', 'fep'); if ($show_messagebox) { $New_mgs = fep_get_new_message_number(); $sm = $New_mgs > 1 ? 's' : ''; echo "<a href='" . fep_action_url('messagebox') . "'>" . sprintf(__(" %d new message%s", 'fep'), $New_mgs, $sm) . '</a>'; } if ($show_messagebox && $show_announcement) { echo __(' and', 'fep'); } if ($show_announcement) { $New_ann = 0; if (class_exists('fep_announcement_class')) { $New_ann = fep_announcement_class::init()->getAnnouncementsNum(); } $sa = $New_ann > 1 ? 's' : ''; echo "<a href='" . fep_action_url('announcements') . "'>" . sprintf(__(" %d new announcement%s", 'fep'), $New_ann, $sa) . '</a>'; } do_action('fep_text_widget'); echo $args['after_widget']; }
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>"; } }
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; }