forked from wp-plugins/front-end-pm
/
fep-directory-class.php
99 lines (83 loc) · 3.11 KB
/
fep-directory-class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
//Main CLASS
if (!class_exists('fep_directory_class'))
{
class fep_directory_class
{
private static $instance;
public static function init()
{
if(!self::$instance instanceof self) {
self::$instance = new self;
}
return self::$instance;
}
function actions_filters()
{
if( fep_get_option('hide_directory', 0 ) != '1' || current_user_can('manage_options')){
add_action ('fep_menu_button', array(&$this, 'menu'));
add_action('fep_switch_directory', array(&$this, "directory"));
}
}
function menu() {
$class = 'fep-button';
if (isset($_GET['fepaction']) && $_GET['fepaction'] == 'directory')
$class = 'fep-button-active';
echo "<a class='$class' href='".fep_action_url('directory')."'>".__('Directory', 'fep').'</a>';
}
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'>
<th width='40%'>".__("User", 'fep')."</th>
<th width='30%'>".__("View Messages between", 'fep')."</th>
<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 );
}
} //END CLASS
} //ENDIF
add_action('wp_loaded', array(fep_directory_class::init(), 'actions_filters'));
?>