You are here

function webform_encrypt_webform_submission_load in Webform Encrypt 7

Implementation of hook_webform_submission_load(). Decrypt values if encrypted

File

./webform_encrypt.module, line 101
Main module file for the Webform Encrypt module.

Code

function webform_encrypt_webform_submission_load($submissions) {
  foreach ($submissions as $submission) {
    $node = node_load($submission->nid);
    foreach ($submission->data as $cid => $entry) {
      if (!empty($node->webform['components'][$cid]['extra']['encrypt'])) {
        foreach ($submission->data[$cid] as $delta => $value) {
          if (!empty($entry[$delta]) && @unserialize($entry[$delta]) !== FALSE) {
            $submission->data[$cid][$delta] = user_access('view encrypted values') ? decrypt($entry[$delta], array(
              'base64' => TRUE,
            )) : t('[Value Encrypted]');
          }
        }
      }
    }
  }
}