]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/network/users.php
WordPress 4.4
[autoinstalls/wordpress.git] / wp-admin / network / users.php
1 <?php
2 /**
3  * Multisite users administration panel.
4  *
5  * @package WordPress
6  * @subpackage Multisite
7  * @since 3.0.0
8  */
9
10 /** Load WordPress Administration Bootstrap */
11 require_once( dirname( __FILE__ ) . '/admin.php' );
12
13 if ( ! is_multisite() )
14         wp_die( __( 'Multisite support is not enabled.' ) );
15
16 if ( ! current_user_can( 'manage_network_users' ) )
17         wp_die( __( 'You do not have permission to access this page.' ), 403 );
18
19 if ( isset( $_GET['action'] ) ) {
20         /** This action is documented in wp-admin/network/edit.php */
21         do_action( 'wpmuadminedit' );
22
23         switch ( $_GET['action'] ) {
24                 case 'deleteuser':
25                         if ( ! current_user_can( 'manage_network_users' ) )
26                                 wp_die( __( 'You do not have permission to access this page.' ), 403 );
27
28                         check_admin_referer( 'deleteuser' );
29
30                         $id = intval( $_GET['id'] );
31                         if ( $id != '0' && $id != '1' ) {
32                                 $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle with arrays
33                                 $title = __( 'Users' );
34                                 $parent_file = 'users.php';
35                                 require_once( ABSPATH . 'wp-admin/admin-header.php' );
36                                 echo '<div class="wrap">';
37                                 confirm_delete_users( $_POST['allusers'] );
38                                 echo '</div>';
39                                 require_once( ABSPATH . 'wp-admin/admin-footer.php' );
40                         } else {
41                                 wp_redirect( network_admin_url( 'users.php' ) );
42                         }
43                         exit();
44
45                 case 'allusers':
46                         if ( !current_user_can( 'manage_network_users' ) )
47                                 wp_die( __( 'You do not have permission to access this page.' ), 403 );
48
49                         if ( ( isset( $_POST['action']) || isset($_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) {
50                                 check_admin_referer( 'bulk-users-network' );
51
52                                 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
53                                 $userfunction = '';
54
55                                 foreach ( (array) $_POST['allusers'] as $user_id ) {
56                                         if ( !empty( $user_id ) ) {
57                                                 switch ( $doaction ) {
58                                                         case 'delete':
59                                                                 if ( ! current_user_can( 'delete_users' ) )
60                                                                         wp_die( __( 'You do not have permission to access this page.' ), 403 );
61                                                                 $title = __( 'Users' );
62                                                                 $parent_file = 'users.php';
63                                                                 require_once( ABSPATH . 'wp-admin/admin-header.php' );
64                                                                 echo '<div class="wrap">';
65                                                                 confirm_delete_users( $_POST['allusers'] );
66                                                                 echo '</div>';
67                                                                 require_once( ABSPATH . 'wp-admin/admin-footer.php' );
68                                                                 exit();
69
70                                                         case 'spam':
71                                                                 $user = get_userdata( $user_id );
72                                                                 if ( is_super_admin( $user->ID ) )
73                                                                         wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) );
74
75                                                                 $userfunction = 'all_spam';
76                                                                 $blogs = get_blogs_of_user( $user_id, true );
77                                                                 foreach ( (array) $blogs as $details ) {
78                                                                         if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam !
79                                                                                 update_blog_status( $details->userblog_id, 'spam', '1' );
80                                                                 }
81                                                                 update_user_status( $user_id, 'spam', '1' );
82                                                         break;
83
84                                                         case 'notspam':
85                                                                 $userfunction = 'all_notspam';
86                                                                 $blogs = get_blogs_of_user( $user_id, true );
87                                                                 foreach ( (array) $blogs as $details )
88                                                                         update_blog_status( $details->userblog_id, 'spam', '0' );
89
90                                                                 update_user_status( $user_id, 'spam', '0' );
91                                                         break;
92                                                 }
93                                         }
94                                 }
95
96                                 wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) );
97                         } else {
98                                 $location = network_admin_url( 'users.php' );
99
100                                 if ( ! empty( $_REQUEST['paged'] ) )
101                                         $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
102                                 wp_redirect( $location );
103                         }
104                         exit();
105
106                 case 'dodelete':
107                         check_admin_referer( 'ms-users-delete' );
108                         if ( ! ( current_user_can( 'manage_network_users' ) && current_user_can( 'delete_users' ) ) )
109                                 wp_die( __( 'You do not have permission to access this page.' ), 403 );
110
111                         if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) {
112                                 foreach ( $_POST['blog'] as $id => $users ) {
113                                         foreach ( $users as $blogid => $user_id ) {
114                                                 if ( ! current_user_can( 'delete_user', $id ) )
115                                                         continue;
116
117                                                 if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] )
118                                                         remove_user_from_blog( $id, $blogid, $user_id );
119                                                 else
120                                                         remove_user_from_blog( $id, $blogid );
121                                         }
122                                 }
123                         }
124                         $i = 0;
125                         if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) )
126                                 foreach ( $_POST['user'] as $id ) {
127                                         if ( ! current_user_can( 'delete_user', $id ) )
128                                                 continue;
129                                         wpmu_delete_user( $id );
130                                         $i++;
131                                 }
132
133                         if ( $i == 1 )
134                                 $deletefunction = 'delete';
135                         else
136                                 $deletefunction = 'all_delete';
137
138                         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), network_admin_url( 'users.php' ) ) );
139                         exit();
140         }
141 }
142
143 $wp_list_table = _get_list_table('WP_MS_Users_List_Table');
144 $pagenum = $wp_list_table->get_pagenum();
145 $wp_list_table->prepare_items();
146 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
147
148 if ( $pagenum > $total_pages && $total_pages > 0 ) {
149         wp_redirect( add_query_arg( 'paged', $total_pages ) );
150         exit;
151 }
152 $title = __( 'Users' );
153 $parent_file = 'users.php';
154
155 add_screen_option( 'per_page' );
156
157 get_current_screen()->add_help_tab( array(
158         'id'      => 'overview',
159         'title'   => __('Overview'),
160         'content' =>
161                 '<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' .
162                 '<p>' . __('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to their Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.') . '</p>' .
163                 '<p>' . __('You can also go to the user&#8217;s profile page by clicking on the individual username.') . '</p>' .
164                 '<p>' . __('You can sort the table by clicking on any of the bold headings and switch between list and excerpt views by using the icons in the upper right.') . '</p>' .
165                 '<p>' . __('The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.') . '</p>' .
166                 '<p>' . __('You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.') . '</p>'
167 ) );
168
169 get_current_screen()->set_help_sidebar(
170         '<p><strong>' . __('For more information:') . '</strong></p>' .
171         '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Users_Screen" target="_blank">Documentation on Network Users</a>') . '</p>' .
172         '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
173 );
174
175 get_current_screen()->set_screen_reader_content( array(
176         'heading_views'      => __( 'Filter users list' ),
177         'heading_pagination' => __( 'Users list navigation' ),
178         'heading_list'       => __( 'Users list' ),
179 ) );
180
181 require_once( ABSPATH . 'wp-admin/admin-header.php' );
182
183 if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
184         ?>
185         <div id="message" class="updated notice is-dismissible"><p>
186                 <?php
187                 switch ( $_REQUEST['action'] ) {
188                         case 'delete':
189                                 _e( 'User deleted.' );
190                         break;
191                         case 'all_spam':
192                                 _e( 'Users marked as spam.' );
193                         break;
194                         case 'all_notspam':
195                                 _e( 'Users removed from spam.' );
196                         break;
197                         case 'all_delete':
198                                 _e( 'Users deleted.' );
199                         break;
200                         case 'add':
201                                 _e( 'User added.' );
202                         break;
203                 }
204                 ?>
205         </p></div>
206         <?php
207 }
208         ?>
209 <div class="wrap">
210         <h1><?php esc_html_e( 'Users' );
211         if ( current_user_can( 'create_users') ) : ?>
212                 <a href="<?php echo network_admin_url('user-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a><?php
213         endif;
214
215         if ( !empty( $usersearch ) )
216         printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $usersearch ) );
217         ?>
218         </h1>
219
220         <?php $wp_list_table->views(); ?>
221
222         <form method="get" class="search-form">
223                 <?php $wp_list_table->search_box( __( 'Search Users' ), 'all-user' ); ?>
224         </form>
225
226         <form id="form-user-list" action="users.php?action=allusers" method="post">
227                 <?php $wp_list_table->display(); ?>
228         </form>
229 </div>
230
231 <?php require_once( ABSPATH . 'wp-admin/admin-footer.php' ); ?>