BP_Roles

The BuddyPress BP Roles class.

Defined (1)

The class is defined in the following location(s).

/bp-forums/bbpress/bb-includes/backpress/class.bp-roles.php  
  1. class BP_Roles { 
  2. var $role_objects = array(); 
  3. var $role_names = array(); 
  4.  
  5. function __construct() { 
  6. do_action_ref_array('init_roles', array(&$this) ); 
  7.  
  8. function BP_Roles() { 
  9. $this->__construct(); 
  10.  
  11. function add_role($role, $display_name, $capabilities = '') { 
  12. if ( isset($this->role_objects[$role]) ) 
  13. return; 
  14.  
  15. $this->role_objects[$role] = new BP_Role($role, $capabilities, $this); 
  16. $this->role_names[$role] = $display_name; 
  17. return $this->role_objects[$role]; 
  18.  
  19. function remove_role($role) { 
  20. if ( ! isset($this->role_objects[$role]) ) 
  21. return; 
  22.  
  23. unset($this->role_objects[$role]); 
  24. unset($this->role_names[$role]); 
  25.  
  26. function add_cap($role, $cap, $grant = true) { 
  27. if ( isset($this->role_objects[$role]) ) 
  28. $this->role_objects[$role]->add_cap($cap, $grant); 
  29.  
  30. function remove_cap($role, $cap) { 
  31. if ( isset($this->role_objects[$role]) ) 
  32. $this->role_objects[$role]->remove_cap($cap, $grant); 
  33.  
  34. function &get_role($role) { 
  35. if ( isset($this->role_objects[$role]) ) 
  36. return $this->role_objects[$role]; 
  37. else 
  38. return null; 
  39.  
  40. function get_names() { 
  41. return $this->role_names; 
  42.  
  43. function is_role($role) { 
  44. return isset($this->role_names[$role]); 
  45.  
  46. function map_meta_cap( $cap, $user_id ) { 
  47. $args = array_slice(func_get_args(), 2); 
  48. return apply_filters( 'map_meta_cap', array( $cap ), $cap, $user_id, $args );