You are here

function commerce_ups_decrypt_vars in Commerce UPS 7

Same name and namespace in other branches
  1. 7.2 commerce_ups.module \commerce_ups_decrypt_vars()

Decrypt all api variables in one function call.

2 calls to commerce_ups_decrypt_vars()
commerce_ups_build_rate_request in ./commerce_ups.xml.inc
commerce_ups_settings_form in ./commerce_ups.admin.inc

File

./commerce_ups.module, line 207

Code

function commerce_ups_decrypt_vars($include_password) {
  $user_vars = array();
  $encrypted = variable_get('commerce_ups_encrypt', FALSE) && function_exists('aes_decrypt');
  $user_vars['ups_accountid'] = variable_get('commerce_ups_account_id', '');
  $user_vars['ups_userid'] = variable_get('commerce_ups_user_id', '');
  $user_vars['ups_accesskey'] = variable_get('commerce_ups_access_key', '');
  if ($include_password) {
    $user_vars['ups_password'] = variable_get('commerce_ups_password', '');
  }
  if ($encrypted) {
    $user_vars['ups_accountid'] = aes_decrypt($user_vars['ups_accountid']);
    $user_vars['ups_userid'] = aes_decrypt($user_vars['ups_userid']);
    $user_vars['ups_accesskey'] = aes_decrypt($user_vars['ups_accesskey']);
    if ($include_password) {
      $user_vars['ups_password'] = aes_decrypt($user_vars['ups_password']);
    }
  }
  return $user_vars;
}