PluginProbe
Private groups / 2.5
Private groups v2.5
trunk 1.5 1.6 1.7 1.8 1.8.1 1.9.1 1.9.2 2.0 2.0.1 2.2 2.3 2.4 2.5 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 All 116 releases
bbp-private-groups / includes / user_management.php

user_management.php in Private groups 2.5, at includes/user_management.php

255 lines 8.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 //********************************************start of user management
5
6
7 function pg_user_management($group) {
8
9 global $user_ID;
10 global $rpg_groups ;
11 //global $group ;
12
13
14
15 if ( $_POST && 'no-group' == $_POST['action'] && wp_verify_nonce( $_POST['confirm-bulk-action-nonce'], 'confirm-bulk-action' ) ) :
16 pg_no_group_users( $_POST['users'] );
17 elseif ( $_POST && 'group' == (substr($_POST['action'],0,5)) && wp_verify_nonce( $_POST['confirm-bulk-action-nonce'], 'confirm-bulk-action' ) ) :
18 pg_group_users( $_POST['users'] );
19 elseif ('filter' == (substr($_POST['action2'],0,6)) ) :
20 $group=substr($_POST['action2'],6,strlen($_POST['action2'])) ;
21 endif;
22
23 if ($group=='all') $users= get_users () ;
24 if ($group == 'nogroup') $users = get_users( array( 'meta_key' => 'private_group','meta_compare' => 'NOT EXISTS' )) ;
25 if (substr($group,0,5) =='group') {
26 $users1 = get_users( array( 'meta_key' => 'private_group', 'meta_value' => $group )) ;
27 $filtercheck='*'.$group.'*' ;
28 $users2 = get_users( array(
29 'meta_key' => 'private_group',
30 'meta_value' => '*'.$group.'*',
31 'meta_compare' => 'LIKE'
32 )
33 ) ;
34 $users=array_merge($users1,$users2);
35
36 }
37
38 ?>
39
40 <div class="icon32" id="icon-users"><br></div>
41 <p> <b>
42 <?php _e('Warning : The "bulk actions" CANNOT be used to set a multiple groups group against a user or users' , 'bbp-private-groups' ) ; ?></b> </p>
43 <p> <b>
44 <?php _e( 'Edit users at individual level if allocating multiple groups to users.' , 'bbp-private-groups' ) ; ?>
45 </b></p>
46
47
48 <form method="post">
49
50 <?php wp_nonce_field( 'confirm-bulk-action', 'confirm-bulk-action-nonce' ) ?>
51
52 <div class="tablenav top">
53 <select name="action">
54 <option value=""><?php _e( 'Bulk Actions', 'bbp-private-groups' ); ?></option>
55 <option value="no-group"> <?php _e( 'No-Group', 'bbp-private-groups') ?></option>
56 <?php
57 //sets up the groups as actions
58 $count=count ($rpg_groups) ;
59 for ($i = 0 ; $i < $count ; ++$i) {
60 $g=$i+1 ;
61 $name="group".$g ;
62 $item=$name.' '.$rpg_groups[$name] ;
63 $display=__( 'Group', 'bbp-private-groups' ).$g.' '.$rpg_groups[$name] ;
64 ?>
65 <option value="<?php echo $name ?>"><?php echo $display ?></option>
66 <?php
67 }
68 ?>
69 </select>
70 <input type="submit" value="<?php _e( 'Apply' , 'bbp-private-groups' ); ?>" class="button action doaction" name="">
71
72
73 <select name="action2">
74 <option value=""><?php _e( 'Filter user list' , 'bbp-private-groups' ); ?></option>
75 <option value="filterall"> <?php _e( 'All Groups' , 'bbp-private-groups') ?></option>
76 <option value="filternogroup"> <?php _e( 'No-Group-set' , 'bbp-private-groups' ) ?></option>
77 <?php
78 //sets up the groups as actions
79 for ($i = 0 ; $i < $count ; ++$i) {
80 $g=$i+1 ;
81 $name="group".$g ;
82 $name2="filtergroup".$g ;
83 $item=$name.' '.$rpg_groups[$name] ;
84 $display=__( 'Group', 'bbp-private-groups' ).$g.' '.$rpg_groups[$name] ;
85 ?>
86 <option value="<?php echo $name2 ?>"><?php echo $display ?></option>
87 <?php
88 }
89 ?>
90 </select>
91 <input type="submit" value="<?php _e( 'Filter' , 'bbp-private-groups' ); ?>" class="button action doaction" name="" >
92 </div>
93
94 <table class="widefat">
95 <thead>
96 <tr>
97 <th id="cb"><input type="checkbox" name="check-all" valle="Check all"></th>
98 <th id="gravatar"><?php _e( 'Gravatar', 'bbp-private-groups' ); ?></th>
99 <th id="display_name"><?php _e( 'Name', 'bbp-private-groups' ); ?></th>
100 <th id="private_group"><?php _e( 'Private Group(s)', 'bbp-private-groups' ); ?></th>
101 <th id="role"><?php _e( 'Wordpress & bbPress Roles', 'bbp-private-groups' ); ?></th>
102
103
104 </tr>
105 </thead>
106 <tbody>
107 <?php
108 if ( $users ) :
109 $i = 1;
110 foreach ( $users as $user ) :
111 $class = ( $i % 2 == 1 ) ? 'alternate' : 'default';
112 $user_data = get_userdata( $user->ID );
113 $user_registered = mysql2date(get_option('date_format'), $user->user_registered);
114 $private_group = get_user_meta($user->ID, 'private_group', true);
115 ?>
116 <tr id="user-<?php echo $user->ID ?>" class="<?php echo $class ?>">
117 <th>
118 <?php if ( $user->ID != $user_ID ) :?>
119 <input type="checkbox" name="users[]" value="<?php echo $user->ID ?>">
120 <?php endif; ?>
121 </th>
122 <td><img class="gravatar" src="http://www.gravatar.com/avatar/<?php echo md5( $user->user_email ) ?>?s=32"></td>
123 <td>
124 <a href="user-edit.php?user_id=<?php echo $user->ID ?>"><?php echo $user->display_name ?></a>
125 <div class="row-actions">
126 <?php if ( current_user_can( 'edit_user', $user->ID ) ) : ?>
127 <span class="edit"><a href="<?php echo admin_url( 'user-edit.php?user_id=' . $user->ID ) ?>"><?php _e( 'Edit', 'bbp-private-groups' ); ?></a>
128 <?php endif; ?>
129 <?php if ( current_user_can( 'edit_user', $user->ID ) && current_user_can( 'delete_user', $user->ID ) && $user_ID != $user->ID ) : ?>
130 &nbsp;|&nbsp;</span>
131 <?php endif; ?>
132 <?php if ( current_user_can( 'delete_user', $user->ID ) && $user_ID != $user->ID ) : ?>
133 <span class="delete"><a href="<?php echo admin_url( 'users.php?action=delete&user=' . $user->ID . '&_wpnonce=' . wp_create_nonce( 'bulk-users' ) ) ?>"><?php _e( 'Delete' ); ?></a></span>
134 <?php endif; ?>
135 </div>
136 </td>
137
138 <td><?php
139 //if no groups
140 if ($private_group == '') _e ('no group set', 'bbp-private-groups') ;
141 //if multiple groups
142 elseif (strpos($private_group, '*')!== FALSE) {
143 foreach ( $rpg_groups as $group => $details ) {
144 if (strpos($private_group, '*'.$group.'*') !== FALSE) {
145 $groupname=__('Group','bbp-private-groups').substr($group,5,strlen($group)) ;
146 echo $groupname." ".$details.'<br>' ;
147 }
148 }
149 }
150 //if only one group
151
152 else {
153 $groupname=__('Group','bbp-private-groups').substr($private_group,5,strlen($private_group)) ;
154 echo $groupname.' '.$rpg_groups[$private_group] ;
155 }
156 ?>
157 </td>
158 <td>
159 <?php
160 if ( $user_data->roles ) :
161
162 foreach ( $user_data->roles as $role ) :
163 if ((substr($role,0,4)) == 'bbp_') $role = substr($role,4,strlen($role)) ;
164
165 echo _x( ucfirst( $role ), 'bbp-private-groups' ) . '<br>';
166
167 endforeach;
168
169 endif;
170 ?>
171 </td>
172
173
174 </tr>
175 <?php
176 $i++;
177 endforeach;
178
179 else :
180
181 ?>
182 <tr>
183 <td colspan="6"><strong><?php _e( 'No Users found', 'bbp-private-groups' ); ?></strong></td>
184 </tr>
185 <?php
186
187 endif;
188 ?>
189 </tbody>
190 </table>
191
192 </form>
193 <?php
194 }
195
196
197 /**
198 * Bulk no group users
199 * changes users to no-group
200 **/
201 function pg_no_group_users( array $user_ids ) {
202 if ( $user_ids && current_user_can( 'edit_user', $user->ID ) ) :
203
204 foreach ( $user_ids as $user_id ) :
205
206 if ( is_numeric( $user_id ) ) :
207
208 delete_user_meta( $user_id, 'private_group' ) ;
209
210 endif;
211
212 endforeach;
213
214 ?>
215 <div class="updated message">
216 <?php if ( 1 == count( $user_ids) ) : ?>
217 <p><?php _e( '1 user amended', 'bbp-private-groups' ) ?></p>
218 <?php else : ?>
219 <p><?php echo count( $user_ids ) . ' ' . __( 'users amended', 'bbp-private-groups' ) ?></p>
220 <?php endif; ?>
221 </div>
222 <?php
223
224 endif;
225 }
226
227 /**
228 * Bulk group users
229 * changes users to a group
230 **/
231 function pg_group_users( array $user_ids ) {
232 if ( $user_ids && current_user_can( 'edit_user', $user->ID ) ) :
233
234 foreach ( $user_ids as $user_id ) :
235
236 if ( is_numeric( $user_id ) ) :
237
238 update_user_meta( $user_id, 'private_group', $_POST['action']);
239
240 endif;
241
242 endforeach;
243
244 ?>
245 <div class="updated message">
246 <?php if ( 1 == count( $user_ids) ) : ?>
247 <p><?php _e( '1 user amended', 'bbp-private-groups' ) ?></p>
248 <?php else : ?>
249 <p><?php echo count( $user_ids ) . ' ' . __( 'users amended', 'bbp-private-groups' ) ?></p>
250 <?php endif; ?>
251 </div>
252 <?php
253
254 endif;
255 }