You are here

function workbench_email_validate_workbench_access_configuration in Workbench Email 7.3

Checks the workbench access configuration.

Parameters

string $op: The operation being performed.

array $data: The array of data being passed (form or node).

Return value

bool True or False depending on if configuration.

1 call to workbench_email_validate_workbench_access_configuration()
workbench_email_get_all_transition_users in ./workbench_email.module
Returns all available users for an email transition.

File

./workbench_email.module, line 707
Code for the Workbench Email Module.

Code

function workbench_email_validate_workbench_access_configuration($op, $data = array()) {
  $configured = TRUE;
  if ($op == 'node') {
    if (isset($data['data']->type) && !variable_get('workbench_access_node_type_' . $data['data']->type, 1)) {
      $configured = FALSE;
    }
    return $configured;
  }

  // Do not fire if this content type is not under our control.
  if (!variable_get('workbench_access_node_type_' . $data['data']['form']['#node']->type, 1)) {
    $configured = FALSE;
  }

  // If no workbench access sections defined, don't even try.
  if (!workbench_access_get_active_tree()) {
    $configured = FALSE;
  }

  // Determine which form element to target.
  if (variable_get('workbench_access_custom_form', 1)) {

    // If there are no options and the 'workbench_access' variable
    // has not been set then it seems that Workbench Access
    // has not been configured.
    if (empty($options) && !variable_get('workbench_access', FALSE)) {
      $configured = FALSE;
    }
  }
  else {

    // Try to find the form element(s) to target.
    workbench_access_find_form_elements($data['data']['form']);
    if (empty($data['data']['form']['workbench_access_fields']['#value'])) {
      $configured = FALSE;
    }
  }
  return $configured;
}