You are here

function fusion_apply_rule_validate in Fusion Accelerator 7.2

Same name and namespace in other branches
  1. 7 fusion_apply/fusion_apply_rules.module \fusion_apply_rule_validate()

Validate a rule object.

Parameters

$rule: A rule object.

Return value

TRUE on success, FALSE on failure.

1 call to fusion_apply_rule_validate()
fusion_apply_rule_save in fusion_apply/fusion_apply_rules.module
Save a skins rule object.

File

fusion_apply/fusion_apply_rules.module, line 36

Code

function fusion_apply_rule_validate(&$rule) {
  if (empty($rule->title) || empty($rule->rule_type)) {
    return FALSE;
  }
  if (!isset($rule->node_types)) {
    $rule->node_types = array();
  }
  if (!isset($rule->roles)) {
    $rule->roles = array();
  }
  if (!isset($rule->visibility)) {
    $rule->visibility = 0;
  }
  if (!isset($rule->pages)) {
    $rule->pages = '';
  }
  if (!is_array($rule->node_types) || !is_array($rule->roles)) {
    return FALSE;
  }
  if ($rule->visibility !== 0 && $rule->visibility !== 1 && $rule->visibility !== 2) {
    return FALSE;
  }
  return TRUE;
}