BrendonKoz/CakePHP-Mcrypt-Behavior — pull request #4 by aouchachacha (2013-11-22 14:27:35+00:00)
Title: Update mcrypt.php

Hi,

I think this change makes your code more secure. It was in conflict with the update that I proposed for decrypt associated models on the fly.
In your Model A add this line :
public $actsAs = array('Mcrypt' => array('fields' => array('ModelB.field1', 'ModelB.field2', 'ModelC.field1')));

And then, in your Behavior, in the decryptArray() function, if the $key isn't found in $this->config[$this->modelName]['fields'], test if $curModel.'.'.$key is in array.

Here is my code :

if(in_array($key, $this->config[$this->modelName]['fields']) && $curModel == $this->modelName){
$values[$key] = $this->decryptField($value);
} else {
if(in_array($curModel.'.'.$key, $this->config[$this->modelName]['fields'])){
$values[$key] = $this->_decryptField($value);
}
}

Thanks for all!!