You are here

function access_scheme_machine_name_load in Access Control Kit 7

Loads an access scheme by its URL-friendly machine name.

Parameters

string $machine_name: The machine-readable name of a scheme, where '_' may be replaced with '-'.

bool $reset: (optional) Whether to reset the internal cache. Defaults to FALSE.

Return value

object|false An access scheme, or FALSE if the scheme is not found.

19 calls to access_scheme_machine_name_load()
AccessGrantEntityController::attachLoad in ./access_grant_entity_controller.inc
Overrides DrupalDefaultEntityController::attachLoad().
AccessSchemeFunctionTest::testSchemeCRUD in ./access.test
Test basic create, read, update, and delete functions.
access_grant_delete_confirm in ./access_grants.admin.inc
Form constructor for the access grant delete confirmation form.
access_grant_delete_confirm_submit in ./access_grants.admin.inc
Form submission handler for access_grant_delete_confirm().
access_grant_edit in ./access_grants.admin.inc
Menu page callback; edit an access grant.

... See full list

2 string references to 'access_scheme_machine_name_load'
access_scheme_form in ./access_schemes.admin.inc
Form constructor for the access scheme add/edit form.
access_scheme_static_reset in ./access.module
Clear all static cache variables for access schemes.

File

./access.module, line 366
The access control kit module.

Code

function access_scheme_machine_name_load($machine_name, $reset = FALSE) {
  $machine_name = str_replace('-', '_', $machine_name);
  $map =& drupal_static(__FUNCTION__, array());
  if (!isset($map[$machine_name]) || $reset) {
    $map[$machine_name] = db_query('SELECT sid FROM {access_scheme} WHERE machine_name = :machine_name', array(
      ':machine_name' => $machine_name,
    ))
      ->fetchField();
  }

  // If the given machine name does not map to any known scheme ID, abort.
  if (empty($map[$machine_name])) {
    return FALSE;
  }
  $schemes = access_scheme_load_multiple(array(
    $map[$machine_name],
  ), $reset);
  return reset($schemes);
}