function actions_function_lookup

actions_function_lookup($hash)

Returns an action array key (function or ID), given its hash.

Faster than actions_actions_map() when you only need the function name or ID.

Parameters

$hash: Hash of a function name or action ID array key. The array key is a key into the return value of actions_list() (array key is the action function name) or actions_get_all_actions() (array key is the action ID).

Return value

The corresponding array key, or FALSE if no match is found.

File

includes/actions.inc, line 241
This is the actions engine for executing stored actions.

Code

function actions_function_lookup($hash) {
  // Check for a function name match.
  $actions_list = actions_list();
  foreach ($actions_list as $function => $array) {
    if (drupal_hash_base64($function) == $hash) {
      return $function;
    }
  }
  $aid = FALSE;
  // Must be a configurable action; check database.
  $result = db_query("SELECT aid FROM {actions} WHERE parameters <> ''")->fetchAll(PDO::FETCH_ASSOC);
  foreach ($result as $row) {
    if (drupal_hash_base64($row['aid']) == $hash) {
      $aid = $row['aid'];
      break;
    }
  }
  return $aid;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!actions.inc/function/actions_function_lookup/7.x