You are here

function workbench_access_get_ids_by_scheme in Workbench Access 7

Given an access scheme, return all active sections.

This function will either return an array of section ids, or an associative array of access_id keys and the access scheme data as the value.

Parameters

$access_scheme: The active access scheme.

$keys: Boolean value to return only array keys, or all data.

Return value

An array of access_ids or a data array.

2 calls to workbench_access_get_ids_by_scheme()
workbench_access_get_active_tree in ./workbench_access.module
Load the active tree.
workbench_access_rebuild_scheme in ./workbench_access.module
Rebuild the section access tables.
1 string reference to 'workbench_access_get_ids_by_scheme'
workbench_access_reset_tree in ./workbench_access.module
Reset tree data stored in statics.

File

./workbench_access.module, line 1017
Workbench Access module file.

Code

function workbench_access_get_ids_by_scheme($access_scheme, $keys = FALSE) {
  $data =& drupal_static(__FUNCTION__);

  // If no access types are active, this fails. But return an array.
  if (empty($access_scheme['access_type_id'])) {
    $data = array();
  }
  if (!isset($data)) {
    $data = db_select('workbench_access', 'wa')
      ->addTag('workbench_access')
      ->fields('wa', array(
      'access_id',
      'access_scheme',
      'access_type',
      'access_type_id',
    ))
      ->condition('wa.access_scheme', $access_scheme['access_scheme'])
      ->condition('wa.access_type_id', $access_scheme['access_type_id'])
      ->execute()
      ->fetchAllAssoc('access_id', PDO::FETCH_ASSOC);
  }
  if ($keys) {
    return array_keys($data);
  }
  return $data;
}