/app/addon/buddypress/rule/class-ms-addon-buddypress-rule.php

  1. <?php 
  2.  
  3. class MS_Addon_BuddyPress_Rule extends MS_Controller { 
  4.  
  5. /** 
  6. * The rule ID. 
  7. * 
  8. * @type string 
  9. */ 
  10. const RULE_ID = 'buddypress'; 
  11.  
  12. const PROTECT_ALL = 'buddypress_all'; 
  13. const PROTECT_FRIENDSHIP = 'buddypress_friendship'; 
  14. const PROTECT_GROUP_CREATION = 'buddypress_add_group'; 
  15. const PROTECT_PRIVATE_MSG = 'buddypress_priv_msg'; 
  16. const PROTECT_MEMBERS = 'buddypress_members'; 
  17.  
  18.  
  19. /** 
  20. * Setup the rule. 
  21. * 
  22. * @since 1.0.0 
  23. */ 
  24. public function prepare_obj() { 
  25. MS_Model_Rule::register_rule( 
  26. self::RULE_ID,  
  27. __CLASS__,  
  28. __( 'BuddyPress', 'membership2' ),  
  29. 40 // must be lower than 50 (pages-rule is 50) 
  30. ); 
  31.  
  32. $this->add_filter( 
  33. 'ms_view_protectedcontent_define-' . self::RULE_ID,  
  34. 'handle_render_callback', 10, 2 
  35. ); 
  36.  
  37. /** 
  38. * Tells Membership2 Admin to display this form to manage this rule. 
  39. * 
  40. * @since 1.0.0 
  41. * 
  42. * @param array $callback (Invalid callback) 
  43. * @param array $data The data collection. 
  44. * @return array Correct callback. 
  45. */ 
  46. public function handle_render_callback( $callback, $data ) { 
  47. $view = MS_Factory::load( 'MS_Addon_BuddyPress_Rule_View' ); 
  48.  
  49. $view->data = $data; 
  50. $callback = array( $view, 'to_html' ); 
  51.  
  52. return $callback; 
  53.  
.