You are here

function encrypt_get_methods in Encrypt 6

Same name and namespace in other branches
  1. 7 includes/encrypt.crypt.inc \encrypt_get_methods()

Get Encryption Methods

Parameters

$format: String of format to return. Can be the following:

  • "simple": A simple key/value pair for selects
  • "full": An array of all method data

$reset: Boolean of whether to invoke modules again

Return value

Formatted array

4 calls to encrypt_get_methods()
EncryptTest::testCheckEncryptionMethodsKeys in ./encrypt.test
Test to check encryption methods
encrypt_admin_settings in includes/encrypt.admin.inc
Menu callback; displays the encrypt module settings page.
encrypt_check_method in includes/encrypt.crypt.inc
Check Method
_encrypt_decrypt in includes/encrypt.crypt.inc
Private Encrypt and Decrypt

File

includes/encrypt.crypt.inc, line 22
This file holds the functions necessary to encrypt and decrypt

Code

function encrypt_get_methods($format = 'simple', $reset = FALSE) {
  static $methods = array();
  static $simple = array();
  static $full = array();

  // Check format
  if (empty($methods) || $reset == TRUE) {

    // Invoke the encrypt_method_info hook
    $methods = module_invoke_all('encrypt_method_info');
  }

  // Check if format variable has data
  if (empty(${$format}) || $reset == TRUE) {
    $return = array();

    // Go through results
    foreach ($methods as $name => $method) {

      // Determine how to format data
      switch ($format) {
        case 'simple':
          $return[$name] = $method['title'];
          break;
        case 'full':
          $return[$name] = $method;
          break;
      }
    }

    // Set the variable for static caching.
    ${$format} = $return;
    return $return;
  }
  else {
    return ${$format};
  }
}