Changeset 4164 for branches/plugin/bbp-admin/bbp-users.php
- Timestamp:
- 08/21/2012 06:40:18 AM (14 years ago)
- File:
-
- 1 edited
-
branches/plugin/bbp-admin/bbp-users.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-admin/bbp-users.php
r4053 r4164 21 21 class BBP_Users_Admin { 22 22 23 /** Variables *************************************************************/24 25 /** Functions *************************************************************/26 27 23 /** 28 24 * The bbPress users admin loader … … 33 29 * @uses BBP_Users_Admin::setup_actions() Setup the hooks and actions 34 30 */ 35 function __construct() { 36 $this->setup_globals(); 31 public function __construct() { 37 32 $this->setup_actions(); 38 33 } … … 47 42 */ 48 43 function setup_actions() { 44 45 // Admin styles 46 add_action( 'admin_head', array( $this, 'admin_head' ) ); 49 47 50 48 // User profile edit/display actions … … 56 54 add_action( 'edit_user_profile_update', array( $this, 'user_profile_update' ) ); 57 55 } 58 59 /**60 * Admin globals61 *62 * @since bbPress (r2646)63 * @access private64 */65 function setup_globals() { }66 56 67 57 /** … … 75 65 * @uses sanitize_html_class() To sanitize the classes 76 66 */ 77 function admin_head() { } 67 public function admin_head() { 68 ?> 69 70 <style type="text/css" media="screen"> 71 /*<![CDATA[*/ 72 div.bbp-user-capabilities { 73 float: left; 74 margin: 0 20px 0 0; 75 } 76 body.rtl div.bbp-user-capabilities { 77 float: right; 78 margin: 0 0 0 20px; 79 } 80 81 div.bbp-user-capabilities h4 { 82 margin: 0 0 10px; 83 } 84 85 p.bbp-default-caps-wrapper { 86 clear: both; 87 margin: 80px -10px 0; 88 } 89 /*]]>*/ 90 </style> 91 92 <?php 93 } 78 94 79 95 /** … … 86 102 * @return bool Always false 87 103 */ 88 function user_profile_update( $user_id ) { } 104 public function user_profile_update( $user_id ) { 105 106 // Bail if no user 107 if ( empty( $user_id ) ) 108 return; 109 110 // Load up the user 111 $user = new WP_User( $user_id ); 112 $user_role = bbp_get_user_role( $user_id ); 113 114 // Either reset caps for role 115 if ( ! empty( $_POST['bbp-default-caps'] ) ) { 116 117 // Remove all caps 118 foreach ( bbp_get_capability_groups() as $group ) { 119 foreach ( bbp_get_capabilities_for_group( $group ) as $capability ) { 120 $user->remove_cap( $capability ); 121 } 122 } 123 124 // Maybe use users new role 125 if ( ! empty( $_POST['role'] ) ) { 126 $new_role = get_role( $_POST['role'] ); 127 $new_role = isset( $new_role->name ) ? $new_role->name : ''; 128 129 if ( $new_role != $user_role ) { 130 $user_role = $new_role; 131 } 132 } 133 134 // Add back caps for current role 135 if ( !empty( $user_role ) ) { 136 foreach ( bbp_get_caps_for_role( $user_role ) as $capability ) { 137 $user->add_cap( $capability ); 138 } 139 } 140 141 // Or set caps individually 142 } else { 143 144 // Loop through capability groups 145 foreach ( bbp_get_capability_groups() as $group ) { 146 147 // Loop through capabilities 148 foreach ( bbp_get_capabilities_for_group( $group ) as $capability ) { 149 150 // Maybe add cap 151 if ( ! empty( $_POST['_bbp_' . $capability] ) && ! $user->has_cap( $capability ) ) { 152 $user->add_cap( $capability ); 153 154 // Maybe remove cap 155 } elseif ( empty( $_POST['_bbp_' . $capability] ) && $user->has_cap( $capability ) ) { 156 $user->remove_cap( $capability ); 157 } 158 } 159 } 160 } 161 } 89 162 90 163 /** … … 97 170 * @return bool Always false 98 171 */ 99 function user_profile_forums( $profileuser ) { } 172 public function user_profile_forums( $profileuser ) { 173 174 // Bail if current user cannot edit users 175 if ( ! current_user_can( 'edit_user', $profileuser->ID ) ) 176 return; 177 178 // Noop WordPress additional caps output area 179 add_filter( 'additional_capabilities_display', '__return_false' ); ?> 180 181 <h3><?php _e( 'Forum Capabilities', 'bbpress' ); ?></h3> 182 183 <table class="form-table"> 184 <tbody> 185 <tr> 186 <th><?php _e( 'This user can:', 'bbpress' ); ?></th> 187 188 <td> 189 <fieldset> 190 <legend class="screen-reader-text"><span><?php _e( 'Additional Capabilities', 'bbpress' ); ?></span></legend> 191 192 <?php foreach ( bbp_get_capability_groups() as $group ) : ?> 193 194 <div class="bbp-user-capabilities"> 195 <h4><?php bbp_capability_group_title( $group ); ?></h4> 196 197 <?php foreach ( bbp_get_capabilities_for_group( $group ) as $capability ) : ?> 198 199 <label for="_bbp_<?php echo $capability; ?>"> 200 <input id="_bbp_<?php echo $capability; ?>" name="_bbp_<?php echo $capability; ?>" type="checkbox" id="_bbp_<?php echo $capability; ?>" value="1" <?php checked( user_can( $profileuser->ID, $capability ) ); ?> /> 201 <?php bbp_capability_title( $capability ); ?> 202 </label> 203 <br /> 204 205 <?php endforeach; ?> 206 207 </div> 208 209 <?php endforeach; ?> 210 211 <p class="bbp-default-caps-wrapper"> 212 <input type="submit" name="bbp-default-caps" class="button" value="<?php _e( 'Reset to Default', 'bbpress' ); ?>"/> 213 </p> 214 215 </fieldset> 216 </td> 217 </tr> 218 219 </tbody> 220 </table> 221 222 <?php 223 } 100 224 } 225 new BBP_Users_Admin(); 101 226 endif; // class exists
Note: See TracChangeset
for help on using the changeset viewer.