Changeset 2898
- Timestamp:
- 09/20/2005 11:48:28 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/upgrade-schema.php
r2897 r2898 238 238 239 239 function populate_roles() { 240 global $table_prefix; 241 242 $roles = array ('administrator' => 243 array('name' => __('Administrator'), 244 'capabilities' => array( 245 'edit_posts' => true, 246 'edit_others_posts' => true, 247 'edit_published_posts' => true, 248 'publish_posts' => true, 249 'edit_pages' => true, 250 'moderate_comments' => true, 251 'manage_categories' => true, 252 'manage_links' => true, 253 'upload_files' => true, 254 'manage_options' => true, 255 'switch_themes' => true, 256 'edit_themes' => true, 257 'activate_plugins' => true, 258 'edit_plugins' => true, 259 'edit_users' => true, 260 'edit_files' => true, 261 'unfiltered_html' => true, 262 'import' => true, 263 'read' => true, 264 'level_10' => true, 265 'level_9' => true, 266 'level_8' => true, 267 'level_7' => true, 268 'level_6' => true, 269 'level_5' => true, 270 'level_4' => true, 271 'level_3' => true, 272 'level_2' => true, 273 'level_1' => true, 274 'level_0' => true 275 )), 276 277 'editor' => 278 array('name' => __('Editor'), 279 'capabilities' => array( 280 'edit_posts' => true, 281 'edit_others_posts' => true, 282 'edit_published_posts' => true, 283 'publish_posts' => true, 284 'edit_pages' => true, 285 'moderate_comments' => true, 286 'manage_categories' => true, 287 'manage_links' => true, 288 'upload_files' => true, 289 'unfiltered_html' => true, 290 'read' => true, 291 'level_7' => true, 292 'level_6' => true, 293 'level_5' => true, 294 'level_4' => true, 295 'level_3' => true, 296 'level_2' => true, 297 'level_1' => true, 298 'level_0' => true 299 )), 300 301 'author' => 302 array('name' => __('Author'), 303 'capabilities' => array( 304 'edit_posts' => true, 305 'publish_posts' => true, 306 'upload_files' => true, 307 'read' => true, 308 'level_2' => true, 309 'level_1' => true, 310 'level_0' => true 311 )), 312 313 'contributor' => 314 array('name' => __('Contributor'), 315 'capabilities' => array( 316 'edit_posts' => true, 317 'read' => true, 318 'level_1' => true, 319 'level_0' => true 320 )), 321 322 'subscriber' => 323 array('name' => __('Subscriber'), 324 'capabilities' => array( 325 'read' => true, 326 'level_0' => true 327 )) 328 ); 329 // FIXME: Temporary code to reset roles and caps if flag is set. 330 if ( defined('RESET_CAPS') ) 331 update_option($table_prefix . 'user_roles', $roles); 332 else 333 add_option($table_prefix . 'user_roles', $roles); 240 global $wp_roles; 241 242 // Add roles 243 $wp_roles->add_role('administrator', __('Administrator')); 244 $wp_roles->add_role('editor', __('Editor')); 245 $wp_roles->add_role('author', __('Author')); 246 $wp_roles->add_role('contributor', __('Contributor')); 247 $wp_roles->add_role('subscriber', __('Subscriber')); 248 249 // Add caps for Administrator role 250 $role = $wp_roles->get_role('administrator'); 251 $role->add_cap('switch_themes'); 252 $role->add_cap('edit_themes'); 253 $role->add_cap('activate_plugins'); 254 $role->add_cap('edit_plugins'); 255 $role->add_cap('edit_users'); 256 $role->add_cap('edit_files'); 257 $role->add_cap('manage_options'); 258 $role->add_cap('moderate_comments'); 259 $role->add_cap('manage_categories'); 260 $role->add_cap('manage_links'); 261 $role->add_cap('upload_files'); 262 $role->add_cap('import'); 263 $role->add_cap('unfiltered_html'); 264 $role->add_cap('edit_posts'); 265 $role->add_cap('edit_others_posts'); 266 $role->add_cap('edit_published_posts'); 267 $role->add_cap('publish_posts'); 268 $role->add_cap('edit_pages'); 269 $role->add_cap('read'); 270 $role->add_cap('level_10'); 271 $role->add_cap('level_9'); 272 $role->add_cap('level_8'); 273 $role->add_cap('level_7'); 274 $role->add_cap('level_6'); 275 $role->add_cap('level_6'); 276 $role->add_cap('level_4'); 277 $role->add_cap('level_3'); 278 $role->add_cap('level_2'); 279 $role->add_cap('level_1'); 280 $role->add_cap('level_0'); 281 282 // Add caps for Editor role 283 $role = $wp_roles->get_role('editor'); 284 $role->add_cap('moderate_comments'); 285 $role->add_cap('manage_categories'); 286 $role->add_cap('manage_links'); 287 $role->add_cap('upload_files'); 288 $role->add_cap('unfiltered_html'); 289 $role->add_cap('edit_posts'); 290 $role->add_cap('edit_others_posts'); 291 $role->add_cap('edit_published_posts'); 292 $role->add_cap('publish_posts'); 293 $role->add_cap('edit_pages'); 294 $role->add_cap('read'); 295 $role->add_cap('level_7'); 296 $role->add_cap('level_6'); 297 $role->add_cap('level_6'); 298 $role->add_cap('level_4'); 299 $role->add_cap('level_3'); 300 $role->add_cap('level_2'); 301 $role->add_cap('level_1'); 302 $role->add_cap('level_0'); 303 304 // Add caps for Author role 305 $role = $wp_roles->get_role('author'); 306 $role->add_cap('upload_files'); 307 $role->add_cap('edit_posts'); 308 $role->add_cap('publish_posts'); 309 $role->add_cap('read'); 310 $role->add_cap('level_2'); 311 $role->add_cap('level_1'); 312 $role->add_cap('level_0'); 313 314 // Add caps for Contributor role 315 $role = $wp_roles->get_role('contributor'); 316 $role->add_cap('edit_posts'); 317 $role->add_cap('read'); 318 $role->add_cap('level_1'); 319 $role->add_cap('level_0'); 320 321 // Add caps for Subscriber role 322 $role = $wp_roles->get_role('subscriber'); 323 $role->add_cap('read'); 324 $role->add_cap('level_0'); 334 325 } 326 335 327 ?> -
trunk/wp-includes/capabilities.php
r2851 r2898 23 23 } 24 24 25 function add_role($role, $capabilities, $display_name) { 25 function add_role($role, $display_name, $capabilities = '') { 26 if ( isset($this->roles[$role]) ) 27 return; 28 26 29 $this->roles[$role] = array('name' => $display_name, 27 30 'capabilities' => $capabilities); … … 42 45 } 43 46 44 function add_cap($role, $cap, $grant ) {47 function add_cap($role, $cap, $grant = true) { 45 48 $this->roles[$role]['capabilities'][$cap] = $grant; 46 49 update_option($this->role_key, $this->roles); … … 78 81 } 79 82 80 function add_cap($cap, $grant ) {83 function add_cap($cap, $grant = true) { 81 84 global $wp_roles; 82 85
Note: See TracChangeset
for help on using the changeset viewer.