/** * Handles rule's stuff initialization. * * @access public */ public function on_creation() { parent::on_creation(); $this->name = 'bpgroupcreation'; $this->label = _x('Group Creation', 'The rule title which restricts the ability to create BuddyPress rules.', 'membership'); $this->description = _x('Allows group creation to be allowed to members only.', 'The rule description which restricts the ability to create BuddyPress groups.', 'membership'); $this->rulearea = 'public'; }
/** * Handles rule's stuff initialization. * * @access public */ public function on_creation() { parent::on_creation(); $this->name = 'bpfriendship'; $this->label = __('Friend Connections', 'membership'); $this->description = __('Allows the sending friendship requests to be limited to members.', 'membership'); $this->rulearea = 'public'; }
/** * Handles rule's stuff initialization. * * @access public */ public function on_creation() { parent::on_creation(); $this->name = 'bpprivatemessage'; $this->label = __('Private Messaging', 'membership'); $this->description = __('Allows the sending of private messages to be limited to members.', 'membership'); $this->rulearea = 'public'; }
function validate_positive() { $page = get_queried_object(); return is_a($page, 'WP_Post') && $page->post_type == 'wplms-assignment' ? in_array($page->ID, $this->data) : parent::validate_positive(); }
/** * Validates the rule on positive assertion. * * @access public * @return boolean TRUE if assertion is successfull, otherwise FALSE. */ public function validate_positive($args = null) { $page = get_queried_object(); $page_ids = $this->get_dripped_page_ids($this->data); if (is_array($args) && $args[0]['cascade'] && isset($page->ID)) { if ($this->validate_parent($page->ID, $page_ids)) { return true; } } return is_a($page, 'WP_Post') && $page->post_type == 'page' ? in_array($page->ID, $page_ids) : parent::validate_positive(); }
function update() { $this->dirty = true; if ($this->id < 0) { return $this->add(); } else { $return = $this->db->update($this->membership_levels, array('level_title' => $_POST['level_title'], 'level_slug' => sanitize_title($_POST['level_title'])), array('id' => $this->id)); // Remove the existing rules for this membership level $this->db->query($this->db->prepare("DELETE FROM {$this->membership_rules} WHERE level_id = %d", $this->id)); $filter_rules = array('menu'); // Process the new rules if (!empty($_POST['in-positive-rules'])) { $rules = explode(',', $_POST['in-positive-rules']); $count = 1; foreach ((array) $rules as $rule) { if (!empty($rule)) { // Check if the rule has any information for it. if (isset($_POST[$rule])) { $rule_array = $_POST[$rule]; if (in_array($rule, $filter_rules)) { $rule_array = Membership_Model_Rule::filter_rule_array($rule_array); } $ruleval = maybe_serialize($rule_array); // write it to the database $this->db->insert($this->membership_rules, array("level_id" => $this->id, "rule_ive" => 'positive', "rule_area" => $rule, "rule_value" => $ruleval, "rule_order" => $count++)); // Hit an action - two methods of hooking do_action('membership_update_positive_rule', $rule, $_POST, $this->id); do_action('membership_update_positive_rule_' . $rule, $_POST, $this->id); } } } } if (!empty($_POST['in-negative-rules'])) { $rules = explode(',', $_POST['in-negative-rules']); $count = 1; foreach ((array) $rules as $rule) { if (!empty($rule)) { // Check if the rule has any information for it. if (isset($_POST[$rule])) { $rule_array = $_POST[$rule]; if (in_array($rule, $filter_rules)) { $rule_array = Membership_Model_Rule::filter_rule_array($rule_array); } $ruleval = maybe_serialize($_POST[$rule]); // write it to the database $this->db->insert($this->membership_rules, array("level_id" => $this->id, "rule_ive" => 'negative', "rule_area" => $rule, "rule_value" => $ruleval, "rule_order" => $count++)); // Hit an action - two methods of hooking do_action('membership_update_negative_rule', $rule, $_POST, $this->id); do_action('membership_update_negative_rule_' . $rule, $_POST, $this->id); } } } } do_action('membership_level_update', $this->id); } return true; // for now }
/** * Validates the rule on positive assertion. * * @access public * @return boolean TRUE if assertion is successfull, otherwise FALSE. */ public function validate_positive($args = null) { $this->cat_ids = $this->get_dripped_category_ids($this->data); if ($this->is_post_valid($args)) { return true; } if (is_single() && in_array('category', get_object_taxonomies(get_post_type()))) { $categories = wp_get_post_categories(get_the_ID()); $intersect = array_intersect($categories, $this->cat_ids); return !empty($intersect); } if (is_category()) { return in_array(get_queried_object_id(), $this->cat_ids); } return parent::validate_positive(); }
public function validate_positive($args = null) { global $bp; if (bp_current_component() != 'groups') { return parent::validate_positive(); } return isset($bp->groups->current_group) && is_a($bp->groups->current_group, 'BP_Groups_Group') ? in_array($bp->groups->current_group, $this->data) : parent::validate_positive(); }
public function on_creation() { parent::on_creation(); $this->name = 'submenus'; $this->label = __('Sub Menus', 'membership'); $this->description = __('Allows admin side sub menus to be protected.', 'membership'); $this->rulearea = 'admin'; }
public function validate_positive($args = null) { $component = bp_current_component(); if ($component) { $pages = bp_core_get_directory_page_ids(); if (!empty($pages[$component])) { return in_array($pages[$component], $this->data); } } return parent::validate_positive(); }
public function validate_positive($args = null) { if ($this->is_category_valid($args)) { return true; } $page = get_queried_object(); $this->post_ids = $this->get_dripped_post_ids($this->data); return is_a($page, 'WP_Post') && $page->post_type == 'post' ? in_array($page->ID, $this->post_ids) : parent::validate_positive(); }