function notify_users($message_id, $mgs)
 {
     $domain_name = preg_replace('/^www\\./', '', $_SERVER['SERVER_NAME']);
     $usersarray = get_users("orderby=ID");
     $to = fep_get_option('ann_to', get_bloginfo('admin_email'));
     $from = 'noreply@' . $domain_name;
     $bcc = array();
     foreach ($usersarray as $user) {
         $notify = fep_get_user_option('allow_ann', 1, $user->ID);
         if ($notify == '1') {
             $bcc[] = $user->user_email;
         }
     }
     //var_dump($bcc);
     $chunked_bcc = array_chunk($bcc, 25);
     $subject = get_bloginfo("name") . ': ' . __('New Announcement', 'fep');
     $message = __('A new Announcement is Published in ', 'fep') . "\r\n";
     $message .= get_bloginfo("name") . "\r\n";
     $message .= sprintf(__("Title: %s", 'fep'), $mgs['message_title']) . "\r\n";
     $message .= __('Please Click the following link to view full Announcement.', 'fep') . "\r\n";
     $message .= fep_action_url('announcements') . "\r\n";
     foreach ($chunked_bcc as $bcc_chunk) {
         $headers = array();
         $headers['From'] = 'From: ' . get_bloginfo("name") . '<' . $from . '>';
         $headers['Bcc'] = 'Bcc: ' . implode(', ', $bcc_chunk);
         wp_mail($to, $subject, $message, $headers);
     }
     return;
 }
예제 #2
0
 function actions_filters()
 {
     if ('1' != fep_get_option('disable_new') || current_user_can('manage_options')) {
         add_action('fep_menu_button', array(&$this, 'newmessage'));
     }
     add_action('fep_menu_button', array(&$this, 'messagebox'));
     add_action('fep_menu_button', array(&$this, 'settings'));
 }
 function messages($messages, $action)
 {
     global $wpdb;
     $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);
     if (current_user_can('manage_options')) {
         $messages = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . FEP_MESSAGES_TABLE . " WHERE parent_id = %d AND (status = %d OR status = %d) ORDER BY last_date DESC LIMIT %d, %d", 0, 0, 1, $start, $end));
     } else {
         $messages = array();
     }
     return $messages;
 }
 function directory()
 {
     if (fep_get_option('hide_directory', 0) == '1' && !current_user_can('manage_options')) {
         echo fep_message_box();
         return;
     }
     $page = isset($_GET['feppage']) && $_GET['feppage'] ? absint($_GET['feppage']) : 0;
     $offset = $page * fep_get_option('user_page', 50);
     $args = array('number' => fep_get_option('user_page', 50), 'offset' => $offset, 'orderby' => 'display_name', 'order' => 'ASC');
     $args = apply_filters('fep_directory_arguments', $args);
     // The Query
     $user_query = new WP_User_Query($args);
     $total = $user_query->get_total();
     if (!empty($user_query->results)) {
         $directory = "<p><strong>" . __("Total Users", 'fep') . ": (" . $total . ")</strong></p>";
         $numPgs = $total / fep_get_option('user_page', 50);
         if ($numPgs > 1) {
             $directory .= "<p><strong>" . __("Page", 'fep') . ": </strong> ";
             for ($i = 0; $i < $numPgs; $i++) {
                 if ($_GET['feppage'] != $i) {
                     $directory .= "<a href='" . fep_action_url() . "directory&feppage=" . $i . "'>" . ($i + 1) . "</a> ";
                 } else {
                     $directory .= "[<b>" . ($i + 1) . "</b>] ";
                 }
             }
             $directory .= "</p>";
         }
         $directory .= "<table><tr class='fep-head'>\r\n        <th width='40%'>" . __("User", 'fep') . "</th>\r\n        <th width='30%'>" . __("View Messages between", 'fep') . "</th>\r\n\t\t<th width='30%'>" . __("Send Message", 'fep') . "</th></tr>";
         $a = 0;
         foreach ($user_query->results as $u) {
             $directory .= "<tr class='fep-trodd" . $a . "'><td>" . $u->display_name . "</td>";
             $directory .= "<td><a href='" . fep_action_url() . "between&with={$u->user_login}'>" . __("View Messages between", 'fep') . "</a></td>";
             $directory .= "<td><a href='" . fep_action_url() . "newmessage&to={$u->user_login}'>" . __("Send Message", 'fep') . "</a></td></tr>";
             if ($a) {
                 $a = 0;
             } else {
                 $a = 1;
             }
         }
         $directory .= "</table>";
     } else {
         $directory = "<div id='fep-error'>" . __("No users found.", 'fep') . "</div>";
     }
     echo apply_filters('fep_directory_output', $directory);
 }
 function admin_settings()
 {
     $token = fep_create_nonce();
     $url = 'https://shamimbiplob.wordpress.com/contact-us/';
     $actionURL = admin_url('admin.php?page=fep-admin-settings');
     $ReviewURL = 'https://wordpress.org/support/view/plugin-reviews/front-end-pm';
     $capUrl = 'http://codex.wordpress.org/Roles_and_Capabilities';
     if (isset($_POST['fep-admin-settings_submit'])) {
         $errors = $this->admin_settings_action();
         if (count($errors->get_error_messages()) > 0) {
             echo fep_error($errors);
         } else {
             echo '<div id="message" class="updated fade">' . __("Options successfully saved.", 'fep') . ' </div>';
         }
     }
     echo "<div id='poststuff'>\r\n\r\n\t\t<div id='post-body' class='metabox-holder columns-2'>\r\n\r\n\t\t<!-- main content -->\r\n\t\t<div id='post-body-content'>\r\n\t\t<div class='postbox'><div class='inside'>\r\n\t  \t  <h2>" . __("Front End PM Settings", 'fep') . "</h2>\r\n\t\t  <h5>" . sprintf(__("If you like this plugin please <a href='%s' target='_blank'>Review in Wordpress.org</a> and give 5 star", 'fep'), esc_url($ReviewURL)) . "</h5>\r\n          <form method='post' action='{$actionURL}'>\r\n          <table class='widefat'>\r\n          <thead>\r\n          <tr><th width='50%'>" . __("Setting", 'fep') . "</th><th width='50%'>" . __("Value", 'fep') . "</th></tr>\r\n          </thead>\r\n          <tr><td>" . __("Max messages a user can keep in box? (0 = Unlimited)", 'fep') . "<br /><small>" . __("Admins always have Unlimited", 'fep') . "</small></td><td><input type='text' name='num_messages' value='" . fep_get_option('num_messages', 50) . "' /><br/> " . __("Default", 'fep') . ": 50</td></tr>\r\n          <tr><td>" . __("Messages to show per page", 'fep') . "<br/><small>" . __("Do not set this to 0!", 'fep') . "</small></td><td><input type='text' name='messages_page' value='" . fep_get_option('messages_page', 15) . "' /><br/> " . __("Default", 'fep') . ": 15</td></tr>\r\n\t\t  <tr><td>" . __("Maximum user per page in Directory", 'fep') . "<br/><small>" . __("Do not set this to 0!", 'fep') . "</small></td><td><input type='text' name='user_page' value='" . fep_get_option('user_page', 50) . "' /><br/> " . __("Default", 'fep') . ": 50</td></tr>\r\n\t\t  <tr><td>" . __("Time delay between two messages send by a user in minutes (0 = No delay required)", 'fep') . "<br/><small>" . __("Admins have no restriction", 'fep') . "</small></td><td><input type='text' name='time_delay' value='" . fep_get_option('time_delay', 5) . "' /><br/> " . __("Default", 'fep') . ": 5</td></tr>\r\n\t\t  <tr><td>" . __("Block Username", 'fep') . "<br /><small>" . __("Separated by comma", 'fep') . "</small></td><td><TEXTAREA name='have_permission'>" . fep_get_option('have_permission') . "</TEXTAREA></td></tr>\r\n\t\t  <tr><td>" . __("Custom CSS", 'fep') . "<br /><small>" . __("add or override", 'fep') . "</small></td><td><TEXTAREA name='custom_css'>" . trim(fep_get_option('custom_css')) . "</TEXTAREA></td></tr>\r\n\t\t  \r\n\t\t  <tr><td>" . __("Editor Type", 'fep') . "<br /><small>" . __("Admin alwayes have Wp Editor", 'fep') . "</small></td><td><select name='editor_type'>\r\n\t\t  <option value='wp_editor' " . selected(fep_get_option('editor_type', 'teeny'), 'wp_editor', false) . ">Wp Editor</option>\r\n\t\t  <option value='teeny' " . selected(fep_get_option('editor_type', 'teeny'), 'teeny', false) . ">Wp Editor (Teeny)</option>\r\n\t\t  <option value='textarea' " . selected(fep_get_option('editor_type', 'teeny'), 'textarea', false) . ">Textarea</option></select></td></tr>\r\n\t\t  \r\n\t\t  <tr><td>" . __("Minimum Capability to use messaging", 'fep') . "<br /><small>" . sprintf(__("see <a href='%s' target='_blank'>WORDPRESS CAPABILITIES</a> to get capabilities (use only one capability)", 'fep'), esc_url($capUrl)) . "</small></td><td><input type='text' size='30' name='min_cap' value='" . fep_get_option('min_cap', 'read') . "' /><br /><small>" . __("Keep blank if allowed for all users", 'fep') . "</small></td></tr>";
     do_action('fep_admin_setting_form');
     echo "\r\n\t\t  <tr><td>" . __("Valid email address for \"to\" field of announcement email", 'fep') . "<br /><small>" . __("All users email will be in \"Bcc\" field", 'fep') . "</small></td><td><input type='text' size='30' name='ann_to' value='" . fep_get_option('ann_to', get_bloginfo('admin_email')) . "' /></td></tr>\r\n\t\t  <tr><td colspan='2'><input type='checkbox' name='notify_ann' value='1' " . checked(fep_get_option('notify_ann', 0), '1', false) . " /> " . __("Send email to all users when a new announcement is published?", 'fep') . "</td></tr>\r\n\t\t  <tr><td colspan='2'><input type='checkbox' name='hide_directory' value='1' " . checked(fep_get_option('hide_directory', 0), '1', false) . " /> " . __("Hide Directory from front end?", 'fep') . "<br /><small>" . __("Always shown to Admins", 'fep') . "</small></td></tr>\r\n\t\t  <tr><td colspan='2'><input type='checkbox' name='hide_autosuggest' value='1' " . checked(fep_get_option('hide_autosuggest', 0), '1', false) . " /> " . __("Hide Autosuggestion when typing recipient name?", 'fep') . "<br /><small>" . __("Always shown to Admins", 'fep') . "</small></td></tr>\r\n\t\t  <tr><td colspan='2'><input type='checkbox' name='disable_new' value='1' " . checked(fep_get_option('disable_new', 0), '1', false) . " /> " . __("Disable \"send new message\" for all users except admins?", 'fep') . "<br /><small>" . __("Users can send reply", 'fep') . "</small></td></tr>\r\n\t\t  <tr><td colspan='2'><input type='checkbox' name='hide_notification' value='1' " . checked(fep_get_option('hide_notification', 0), '1', false) . " /> " . __("Hide site wide notification in header?", 'fep') . "</td></tr>\r\n          <tr><td colspan='2'><input type='checkbox' name='hide_branding' value='1' " . checked(fep_get_option('hide_branding', 0), '1', false) . " /> " . __("Hide Branding Footer?", 'fep') . "</td></tr>\r\n          <tr><td colspan='2'><span><input class='button-primary' type='submit' name='fep-admin-settings_submit' value='" . __("Save Options", 'fep') . "' /></span></td><td><input type='hidden' name='token' value='{$token}' /></td></tr>\r\n          </table>\r\n\t\t  </form>\r\n\t\t  <ul>" . sprintf(__("For paid support pleasse visit <a href='%s' target='_blank'>Front End PM</a>", 'fep'), esc_url($url)) . "</ul>\r\n          </div></div></div>\r\n\t\t  " . $this->fep_admin_sidebar() . "\r\n\t\t  </div></div>";
 }
 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 form()
 {
     global $user_ID;
     $token = fep_create_nonce('add_announcement');
     $message_title = isset($_REQUEST['message_title']) ? esc_html($_REQUEST['message_title']) : '';
     $message_content = isset($_REQUEST['message_content']) ? esc_textarea($_REQUEST['message_content']) : '';
     $form = "<form action='" . fep_action_url('addannouncement') . "' method='post' enctype='multipart/form-data'>\r\n      " . __("Subject", 'fep') . ":<br/>\r\n      <input type='text' name='message_title' value='{$message_title}' /><br/>";
     ob_start();
     do_action('fep_announcement_form_before_content');
     echo __("Message", 'fep') . ":<br/>";
     if ('wp_editor' == fep_get_option('editor_type') || current_user_can('manage_options')) {
         wp_editor($message_content, 'message_content', array('teeny' => false, 'media_buttons' => false, 'textarea_rows' => 8));
     } elseif ('teeny' == fep_get_option('editor_type', 'teeny')) {
         wp_editor($message_content, 'message_content', array('teeny' => true, 'media_buttons' => false, 'textarea_rows' => 8));
     } else {
         echo "<textarea name='message_content' placeholder='Message Content'>{$message_content}</textarea>";
     }
     do_action('fep_announcement_form_after_content');
     $form .= ob_get_contents();
     ob_end_clean();
     $form .= "<input type='hidden' name='message_from' value='{$user_ID}' />\r\n\t  <input type='hidden' name='token' value='{$token}' /><br/>\r\n      <input type='submit' name='add-announcement' value='" . __("Submit", 'fep') . "' />\r\n      </form>";
     return $form;
 }
function fep_reply_form($args = '')
{
    global $user_ID;
    $defaults = array('message_from' => $user_ID, 'message_to' => '', 'message_top' => '', 'message_title' => '', 'parent_id' => 0, 'token' => fep_create_nonce('new_message'));
    $args = wp_parse_args($args, $defaults);
    $reply_form = "\r\n      <p><strong>" . __("Add Reply", 'fep') . ":</strong></p>\r\n      <form action='" . fep_action_url('checkmessage') . "' method='post' enctype='multipart/form-data'><br/>";
    ob_start();
    do_action('fep_reply_form_before_content');
    if ('wp_editor' == fep_get_option('editor_type') || current_user_can('manage_options')) {
        wp_editor('', 'message_content', array('teeny' => false, 'media_buttons' => false));
    } elseif ('teeny' == fep_get_option('editor_type', 'teeny')) {
        wp_editor('', 'message_content', array('teeny' => true, 'media_buttons' => false));
    } else {
        echo "<textarea name='message_content' placeholder='" . __('Message Content', 'fep') . "'></textarea>";
    }
    do_action('fep_reply_form_after_content');
    $reply_form .= ob_get_contents();
    ob_end_clean();
    $reply_form .= "\r\n      <input type='hidden' name='message_to' value='" . $args['message_to'] . "' />\r\n\t  <input type='hidden' name='message_top' value='" . $args['message_top'] . "' />\r\n      <input type='hidden' name='message_title' value='" . $args['message_title'] . "' />\r\n      <input type='hidden' name='message_from' value='" . $args['message_from'] . "' />\r\n      <input type='hidden' name='parent_id' value='" . $args['parent_id'] . "' />\r\n\t  <input type='hidden' name='token' value='" . $args['token'] . "' /><br/>\r\n      <input type='submit' name='new_message' value='" . __("Send Message", 'fep') . "' />\r\n      </form>";
    return apply_filters('fep_reply_form', $reply_form);
}
 function upload_attachment($message_id, $message)
 {
     if (!isset($_FILES['fep_upload'])) {
         return false;
     }
     add_filter('upload_dir', array(&$this, 'upload_dir'));
     $fields = (int) fep_get_option('attachment_no', 4);
     for ($i = 0; $i < $fields; $i++) {
         $tmp_name = isset($_FILES['fep_upload']['tmp_name'][$i]) ? basename($_FILES['fep_upload']['tmp_name'][$i]) : '';
         //if ( $file_name ) {
         if ($tmp_name) {
             $upload = array('name' => $_FILES['fep_upload']['name'][$i], 'type' => $_FILES['fep_upload']['type'][$i], 'tmp_name' => $_FILES['fep_upload']['tmp_name'][$i], 'error' => $_FILES['fep_upload']['error'][$i], 'size' => $_FILES['fep_upload']['size'][$i]);
             $this->upload_file($upload, $message_id);
         }
         //file exists
     }
     // end for
     //}
     remove_filter('upload_dir', array(&$this, 'upload_dir'));
 }
예제 #10
0
 function check_message()
 {
     global $wpdb, $user_ID;
     $errors = new WP_Error();
     $message = $_POST;
     // print var_dump($_POST);
     if (!empty($message['message_to'])) {
         $preTo = $message['message_to'];
     } else {
         $preTo = isset($message['message_top']) ? esc_html($message['message_top']) : '';
     }
     $preTo = apply_filters('fep_preto_filter', $preTo);
     $message['to'] = fep_get_userdata($preTo);
     $message['send_date'] = current_time('mysql');
     //Check for errors first
     if (!$message['to']) {
         $errors->add('invalidTo', __('You must enter a valid recipient!', 'fep'));
     }
     if (!$message['message_title']) {
         $errors->add('invalidSub', __('You must enter subject.', 'fep'));
     }
     if (!$message['message_content']) {
         $errors->add('invalidMgs', __('You must enter some message content!', 'fep'));
     }
     if ($message['message_from'] != $user_ID || $message['to'] == $user_ID) {
         $errors->add('NoPermission', __("You do not have permission to send this message!", 'fep'));
     }
     if (fep_get_user_option('allow_messages', 1, $message['to']) != '1') {
         $errors->add('ToDisallow', __("This user does not want to receive messages!", 'fep'));
     }
     if (fep_is_message_box_full($message['to'], fep_get_option('num_messages', 50), $message['parent_id'])) {
         $errors->add('MgsBoxFull', __("Your or Recipients Message Box Is Full!", 'fep'));
     }
     if (fep_is_user_blocked()) {
         $errors->add('Blocked', __("You cannot send messages because you are blocked by administrator!", 'fep'));
     }
     $timeDelay = $this->TimeDelay(fep_get_option('time_delay', 0));
     if ($timeDelay['diffr'] < fep_get_option('time_delay') && !current_user_can('manage_options')) {
         $errors->add('TimeDiff', sprintf(__("Please wait at least more %s to send another message!", 'fep'), $timeDelay['time']));
     }
     if (!fep_verify_nonce($message['token'], 'new_message')) {
         $errors->add('InvalidToken', __("Invalid Token. Please try again!", 'fep'));
     }
     if ($message['parent_id'] != 0) {
         $mgsInfo = $wpdb->get_row($wpdb->prepare("SELECT to_user, from_user FROM " . FEP_MESSAGES_TABLE . " WHERE id = %d", $message['parent_id']));
         if ($mgsInfo->to_user != $user_ID && $mgsInfo->from_user != $user_ID && !current_user_can('manage_options')) {
             $errors->add('OthersMgs', __("You do not have permission to send this message!", 'fep'));
         }
         do_action('fep_before_send_new_reply', $errors);
     } else {
         do_action('fep_before_send_new_message', $errors);
     }
     // This action hook is DEPRECATED since version 3.4. Use following filter hook instead
     do_action('fep_action_message_before_send', $errors);
     $message = apply_filters('fep_filter_message_before_send', $message, $errors);
     //arg $errors added since version 3.4
     //If no errors then continue on
     if (count($errors->get_error_codes()) == 0) {
         if ($message['parent_id'] == 0) {
             $wpdb->insert(FEP_MESSAGES_TABLE, array('from_user' => $message['message_from'], 'to_user' => $message['to'], 'message_title' => $message['message_title'], 'message_contents' => $message['message_content'], 'parent_id' => $message['parent_id'], 'last_sender' => $message['message_from'], 'send_date' => $message['send_date'], 'last_date' => $message['send_date']), array('%d', '%d', '%s', '%s', '%d', '%d', '%s', '%s'));
             $message_id = $wpdb->insert_id;
             do_action('fep_after_send_new_message', $message_id);
         } else {
             $wpdb->insert(FEP_MESSAGES_TABLE, array('from_user' => $message['message_from'], 'to_user' => $message['to'], 'message_title' => $message['message_title'], 'message_contents' => $message['message_content'], 'parent_id' => $message['parent_id'], 'send_date' => $message['send_date']), array('%d', '%d', '%s', '%s', '%d', '%s'));
             $message_id = $wpdb->insert_id;
             $wpdb->update(FEP_MESSAGES_TABLE, array('status' => 0, 'last_sender' => $message['message_from'], 'last_date' => $message['send_date'], 'to_del' => 0, 'from_del' => 0), array('id' => $message['parent_id']), array('%d', '%d', '%s', '%d', '%d'), array('%d'));
             do_action('fep_after_send_new_reply', $message_id);
         }
         do_action('fep_action_message_after_send', $message_id, $message);
     }
     return $errors;
 }
예제 #11
0
function fep_notification_div()
{
    if (!is_user_logged_in()) {
        return;
    }
    if (fep_get_option('hide_notification', 0) == 1) {
        return;
    }
    wp_enqueue_script('fep-notification-script');
    $notification = fep_notification();
    if ($notification) {
        echo "<div id='fep-notification-bar'>{$notification}</div>";
    } else {
        echo "<div id='fep-notification-bar' style='display: none'></div>";
    }
}