M_Comments

The Membership 2 M Comments class.

Defined (1)

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

/app_old/membershipincludes/includes/default.rules.php  
  1. class M_Comments extends M_Rule { 
  2.  
  3. var $name = 'comments'; 
  4. var $label = 'Comments'; 
  5. var $description = 'Allows the display of, or ability to comment on posts to be protected.'; 
  6.  
  7. var $rulearea = 'public'; 
  8.  
  9. function admin_main($data) { 
  10. if(!$data) $data = array(); 
  11. ?> 
  12. <div class='level-operation' id='main-comments'> 
  13. <h2 class='sidebar-name'><?php _e('Comments', 'membership');?><span><a href='#remove' id='remove-comments' class='removelink' title='<?php _e("Remove Comments from this rules area.", 'membership'); ?>'><?php _e('Remove', 'membership'); ?></a></span></h2> 
  14. <div class='inner-operation'> 
  15. <p><strong><?php _e('Positive : ', 'membership'); ?></strong><?php _e('User gets read and make comments of posts.', 'membership'); ?></p> 
  16. <p><strong><?php _e('Negative : ', 'membership'); ?></strong><?php _e('User can not read or comment on posts.', 'membership'); ?></p> 
  17. <input type='hidden' name='comments[]' value='yes' /> 
  18. </div> 
  19. </div> 
  20. <?php 
  21.  
  22. function on_positive($data) { 
  23.  
  24. $this->data = $data; 
  25.  
  26. add_filter('comments_open', array(&$this, 'open_comments'), 99, 2); 
  27.  
  28.  
  29. function on_negative($data) { 
  30.  
  31. $this->data = $data; 
  32.  
  33. add_filter('comments_open', array(&$this, 'close_comments'), 99, 2); 
  34.  
  35. if(defined('MEMBERSHIP_VIEW_COMMENTS') && MEMBERSHIP_VIEW_COMMENTS == true) { 
  36. // We want users to be able to see the comments but not add to them 
  37. } else { 
  38. add_filter( 'comments_array', array(&$this, 'hide_comments'), 99, 2 ); 
  39.  
  40.  
  41. function hide_comments($comments, $post_id) { 
  42.  
  43. return array(); 
  44.  
  45.  
  46. function close_comments($open, $postid) { 
  47.  
  48. return false; 
  49.  
  50.  
  51. function open_comments($open, $postid) { 
  52.  
  53. return $open; 
  54.  
  55.