[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 class BP_Roles { 4 var $role_objects = array(); 5 var $role_names = array(); 6 7 function __construct() { 8 do_action_ref_array('init_roles', array(&$this) ); 9 } 10 11 function BP_Roles() { 12 $this->__construct(); 13 } 14 15 function add_role($role, $display_name, $capabilities = '') { 16 if ( isset($this->role_objects[$role]) ) 17 return; 18 19 $this->role_objects[$role] = new BP_Role($role, $capabilities, $this); 20 $this->role_names[$role] = $display_name; 21 return $this->role_objects[$role]; 22 } 23 24 function remove_role($role) { 25 if ( ! isset($this->role_objects[$role]) ) 26 return; 27 28 unset($this->role_objects[$role]); 29 unset($this->role_names[$role]); 30 } 31 32 function add_cap($role, $cap, $grant = true) { 33 if ( isset($this->role_objects[$role]) ) 34 $this->role_objects[$role]->add_cap($cap, $grant); 35 } 36 37 function remove_cap($role, $cap) { 38 if ( isset($this->role_objects[$role]) ) 39 $this->role_objects[$role]->remove_cap($cap, $grant); 40 } 41 42 function &get_role($role) { 43 if ( isset($this->role_objects[$role]) ) 44 return $this->role_objects[$role]; 45 else 46 return null; 47 } 48 49 function get_names() { 50 return $this->role_names; 51 } 52 53 function is_role($role) { 54 return isset($this->role_names[$role]); 55 } 56 57 function map_meta_cap( $cap, $user_id ) { 58 $args = array_slice(func_get_args(), 2); 59 return apply_filters( 'map_meta_cap', array( $cap ), $cap, $user_id, $args ); 60 } 61 } 62 63 class BP_Role { 64 var $name; 65 var $capabilities; 66 67 function __construct($role, $capabilities) { 68 $this->name = $role; 69 $this->capabilities = $capabilities; 70 } 71 72 function BP_Role($role, $capabilities) { 73 $this->__construct($role, $capabilities); 74 } 75 76 function add_cap($cap, $grant = true) { 77 $this->capabilities[$cap] = $grant; 78 } 79 80 function remove_cap($cap) { 81 unset($this->capabilities[$cap]); 82 } 83 84 function has_cap($cap) { 85 $capabilities = apply_filters('role_has_cap', $this->capabilities, $cap, $this->name); 86 $grant = !empty( $capabilities[$cap] ); 87 return apply_filters("{$this->name}_has_cap", $grant); 88 } 89 90 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 24 01:00:53 2024 | Cross-referenced by PHPXref 0.7.1 |