You are here

function workbench_access_get_user_tree in Workbench Access 7

Build an access tree for a user account.

Parameters

$account: An optional account object.

Return value

An access tree representing the user's active sections.

4 calls to workbench_access_get_user_tree()
menu_workbench_access_default_form_alter in modules/menu.workbench_access.inc
Executes a form alter on a specific FieldAPI form element.
workbench_access_active_options in ./workbench_access.module
Build an array of form options for the currently active workbench access tree.
workbench_access_query_term_access_alter in modules/taxonomy.workbench_access.inc
Implements hook_query_TAG_alter().
workbench_access_taxonomy_autocomplete_validate in modules/taxonomy.workbench_access.inc
Form element validate handler for taxonomy term autocomplete element.
2 string references to 'workbench_access_get_user_tree'
workbench_access_reset_tree in ./workbench_access.module
Reset tree data stored in statics.
workbench_access_user_load in ./workbench_access.module
Implements hook_user_load().

File

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

Code

function workbench_access_get_user_tree($account = NULL) {
  $accounts =& drupal_static(__FUNCTION__, array());
  if (is_null($account)) {
    global $user;
    $account = $user;
  }
  if (isset($accounts[$account->uid])) {
    return $accounts[$account->uid];
  }

  // Make sure we prepared the user.
  if (!isset($account->workbench_access)) {
    workbench_access_user_load_data($account);
  }

  // Prepare the form element.
  $active = workbench_access_get_active_tree();
  $tree = $active['tree'];

  // We should never get this far, really.
  if (empty($account->workbench_access)) {
    $tree = array();
  }
  else {
    workbench_access_build_tree($tree, array_keys($account->workbench_access));
  }

  // Set the static lookup.
  $accounts[$account->uid] = $tree;
  return $accounts[$account->uid];
}