You are here

function _lockr_set_key in Lockr 7.2

Same name and namespace in other branches
  1. 7.3 lockr.module \_lockr_set_key()
  2. 7 lockr.module \_lockr_set_key()

Sets a key value in lockr.

Parameters

string $key_name: The key name.

string $key_value: The key value.

string $key_label: The key label.

string|NULL $encoded: The encryption settings to use, or let Lockr generate new ones.

Return value

bool TRUE if they key set successfully, FALSE if not.

2 calls to _lockr_set_key()
key_provider_lockr_set_key_value in plugins/key_provider/lockr.inc
Set callback for key_provider plugin.
lockr_migrate_keys_batch_op in ./lockr.forms.inc

File

./lockr.module, line 242
Hook implementations and callbacks for lockr.

Code

function _lockr_set_key($key_name, $key_value, $key_label, $encoded = NULL) {
  $client = lockr_key_client();
  if ($client === FALSE) {
    return FALSE;
  }
  $client = $client
    ->encrypted();
  try {
    return $client
      ->set($key_name, $key_value, $key_label, $encoded);
  } catch (LockrClientException $e) {
    watchdog_exception('lockr', $e);
    if ($e->title === 'Not paid') {
      drupal_set_message(t('NOTE: Key was not set. Please go to <a href="@link">Lockr</a> and add a payment method.', array(
        '@link' => 'https://lockr.io/user/add-card',
      )), 'error');
    }
  } catch (\Exception $e) {
    watchdog_exception('lockr', $e);
  }
  return FALSE;
}