You are here

function _votingapi_validate_action_set in Voting API 5

2 calls to _votingapi_validate_action_set()
votingapi_actions_admin_import_page_submit in ./votingapi_actions_ui.inc
votingapi_actions_admin_import_page_validate in ./votingapi_actions_ui.inc

File

./votingapi_actions.module, line 382

Code

function _votingapi_validate_action_set($set) {
  $errors = array();
  if (!is_array($set)) {
    $errors[] = "The action set is not an array!";
    return $errors;
  }
  if (!isset($set['content_type']) && !isset($set['parent'])) {
    $errors[] = "The action set must have a content_type.";
  }
  if ($set['condition_mask'] != 'AND' && $set['condition_mask'] != 'OR') {
    $errors[] = "The action set must define a condition_mask of 'AND' or 'OR'.";
  }
  if (empty($set['conditions'])) {
    $errors[] = "The action set has no conditions defined.";
  }
  foreach ($set['conditions'] as $condition) {
    $errors = array_merge($errors, _votingapi_validate_action_condition($condition));
  }
  if (is_array($set['sets'])) {
    foreach ($set['sets'] as $subset) {
      $errors = array_merge($errors, _votingapi_validate_action_set($subset));
    }
  }
  return $errors;
}