After poking around a bit a cobbled together a custom Views 3 field_handler for your module.

It's based on this views field handler template

There are 2 ways to implement it:

  • Below is listed the basics required to set it up on a module per module basis. (Some tweaking may be required.)
  • A better option would be for AES module could create a custom `aes_handler_aes_decrypt.inc` from the below info. Then other modules could then use a `views_data_alter` hook to access it. That is why I labelled this post with a "needs review" status.

Place into file `YOUR_MODULE_handler_aes_decrypt.inc`

<?php
/**
 * Views Handler integration with AES decryption.
 */
class YOUR_MODULE_handler_aes_decrypt extends views_handler_field {

  function

option_definition() {
   
$options = parent::option_definition();
     
$options['decrypt_aes'] = array('default' => FALSE);
    return
$options;
  }
 
  function
options_form(&$form, &$form_state) {
   
parent::options_form($form, $form_state);
 
   
$form['decrypt_aes'] = array(
     
'#type' => 'checkbox',
     
'#title' => t('Decrypt field'),
     
'#description' => t('Check here to decrypt AES encrypted field.'),
     
'#default_value' => $this->options['decrypt_aes'],
    );

   

parent::options_form($form, $form_state);
  }
 
  function
pre_render($values) {
    return
$values;
  }
 
  function
render($values) {
   
$value = $this->get_value($values);
   
    if (!empty(
$this->options['decrypt_aes'])) {
      return
aes_decrypt($value);
    }
    else {
      return
$value;
    }
  }
}

?>

This goes into your YOUR_MODULE.info file.

;// This is the custom field handler. Change "YOUR_MODULE" name in file.
files[] = views/YOUR_MODULE_handler_aes_decrypt.inc

;// This is the specific Views data that requires the name and field of the table to be decrypted.
;// This file needs to be altered per use basis.
files[] = views/YOUR_MODULE_views.inc

And the last piece of the puzzle would be to create the YOUR_MODULE_views.inc file.
Note: This is the custom code where you identify the exact table and field that require this specific handler.
This piece would need to be altered to your specific module. You may also want to check out HOOK_views_data_alter()

<?php
/**
 * Implements hook_views_data()
 *
 * For describing table data to views.
 */
function YOUR_MODULE_views_data() {
 
//Your Data here.
 
$data['YOUR_CUSTOM_TABLE']['ENCRYPT_FIELD_HERE'] = array(
   
'title' => t('Secure Field'),
   
'help' => t('AES Ecncrypted field.'),
   
'field' => array(
     
'handler' => 'ad_payment_handler_aes_decrypt',
     
'click sortable' => TRUE,
    ),
   
'sort' => array(
     
'handler' => 'views_handler_sort',
    ),
  );
 return
$data;

?>

>

Hope this helps others.

Comments

dpovshed’s picture

Version:7.x-1.5» 7.x-1.x-dev
Category:Task» Feature request
Status:Needs review» Needs work

If this one is still actual, would be nice if changes become a patch against current dev version, so it can be reviewed.