Example #1
0
 function main_shortcode_output()
 {
     global $user_ID;
     if ($user_ID) {
         if (fep_get_option('min_cap', 'read') != '') {
             //Required capability
             $cap = trim(fep_get_option('min_cap', 'read'));
             if (!current_user_can($cap)) {
                 return "<div id='fep-error'>" . sprintf(__("Messaging is only allowed for users at least %s capability!", 'fep'), $cap) . "</div>";
             }
         }
         //Add header
         $out = $this->Header();
         //Add Menu
         $out .= $this->Menu();
         //Start the guts of the display
         $switch = isset($_GET['fepaction']) && $_GET['fepaction'] ? $_GET['fepaction'] : 'messagebox';
         switch ($switch) {
             case has_action("fep_switch_{$switch}"):
                 ob_start();
                 do_action("fep_switch_{$switch}");
                 $out .= ob_get_contents();
                 ob_end_clean();
                 break;
             case 'newmessage':
                 $out .= $this->new_message();
                 break;
             case 'checkmessage':
                 $out .= $this->new_message_action();
                 break;
             case 'viewmessage':
                 $out .= $this->view_message();
                 break;
             case 'between':
                 $out .= fep_message_box();
                 break;
             case 'deletemessage':
                 $out .= $this->delete();
                 break;
             case 'settings':
                 $out .= $this->user_settings();
                 break;
             default:
                 //Message box is shown by Default
                 $out .= fep_message_box();
                 break;
         }
         //Add footer
         $out .= $this->Footer();
     } else {
         $out = "<div id='fep-error'>" . __("You must be logged-in to view your message.", 'fep') . "</div>";
     }
     return apply_filters('fep_main_shortcode_output', $out);
 }
 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);
 }