diff --git a/payment/uc_credit/uc_credit.admin.inc b/payment/uc_credit/uc_credit.admin.inc index 292b59e6..6edeb442 100644 --- a/payment/uc_credit/uc_credit.admin.inc +++ b/payment/uc_credit/uc_credit.admin.inc @@ -71,6 +71,10 @@ function uc_credit_settings_form($form, &$form_state) { '#description' => t('The card type, expiration date and last four digits of the card number are encrypted and stored temporarily while the customer is in the process of checking out.
You must enable encryption by following the encryption instructions in order to accept credit card payments.
In short, you must enter the path of a directory outside of your document root where the encryption key may be stored.
Relative paths will be resolved relative to the Drupal installation directory.
Once this directory is set, you should not change it.', array('!url' => 'http://drupal.org/node/1309226')), '#default_value' => uc_credit_encryption_key() ? variable_get('uc_credit_encryption_path', t('Not configured.')) : t('Not configured.'), ); + if (array_key_exists('key_select', module_invoke_all('element_info'))) { + $form['cc_security']['uc_credit_encryption_path']['#type'] = 'key_select'; + $form['cc_security']['uc_credit_encryption_path']['#default_value'] = variable_get('uc_credit_encryption_path'); + } // Form elements that deal with the type of data requested at checkout. $form['cc_fields'] = array( @@ -236,6 +240,11 @@ function uc_credit_settings_form($form, &$form_state) { * @see uc_credit_settings_form_submit() */ function uc_credit_settings_form_validate($form, &$form_state) { + if (array_key_exists('key_select', module_invoke_all('element_info'))) { + // we're using a key value from the key module, no need for path validation + unset($form_state['uc_credit']['update_cc_encrypt_dir']); + return; + } // Trim trailing whitespace and any trailing / or \ from the key path name. $key_path = rtrim(trim($form_state['values']['uc_credit_encryption_path']), '/\\'); diff --git a/payment/uc_credit/uc_credit.module b/payment/uc_credit/uc_credit.module index f5293070..8505c243 100644 --- a/payment/uc_credit/uc_credit.module +++ b/payment/uc_credit/uc_credit.module @@ -918,10 +918,16 @@ function _uc_credit_valid_card_issue($issue) { * FALSE if no encryption key is found. */ function uc_credit_encryption_key() { + $var_value = variable_get('uc_credit_encryption_path', ''); + + if (module_exists('key') && ($key = key_get_key_value($var_value))) { + return $key; + } + static $key = FALSE; if (empty($key)) { - $key_file = variable_get('uc_credit_encryption_path', '') . '/' . UC_CREDIT_KEYFILE_NAME; + $key_file = $var_value . '/' . UC_CREDIT_KEYFILE_NAME; $contents = @file_get_contents($key_file); if (strlen($contents) == 32) { $key = $contents;