PluginProbe
Private groups / 2.2
Private groups v2.2
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.2, at includes/user_management.php

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