[eluser]theprodigy[/eluser]
a quick update to my issue (the decrypt get_rules thing):
I was able to get it to work, but I had to move the setting of my decryption key outside the constructor. For some reason, either the constructor is not being run (which I HIGHLY doubt), or maybe the object attributes are being over-written or something. I noticed that when I was getting the CI instance, and trying to load the encrypt library in the constructor, then using it in the encrypt and decrypt functions. I kept getting an error of trying to call a function on a non-object. When I moved it all down into the functions, it worked just fine. The same thing happens with the decrypt key. I am now setting it when instantiating it instead of in the constructor, and it all works just fine.
Visual Aid time. this works
Code:
class User extends DataMapper {
var $pass_key = "[removed]";
var $has_one = array('group');
var $has_many = array('maillist','email','sent_email','signature');
//.....
function __construct($id = NULL)
{
parent::__construct($id);
}
//.....
function _encrypt($field)
{
if (!empty($this->{$field}))
{
$CI = get_instance();
$CI->load->library('encrypt');
$this->{$field} = $CI->encrypt->encode($this->{$field}, $this->pass_key);
}
}
function _decrypt($field)
{
if (!empty($this->{$field}))
{
$CI = get_instance();
$CI->load->library('encrypt');
$this->{$field} = $CI->encrypt->decode($this->{$field}, $this->pass_key);
}
}
this DOES NOT work:
Code:
class User extends DataMapper {
var $pass_key;
var $CI;
var $has_one = array('group');
var $has_many = array('maillist','email','sent_email','signature');
//.....
function __construct($id = NULL)
{
parent::__construct($id);
$this->pass_key = "[removed]";
$this->CI = get_instance();
$this->CI->load->library('encrypt');
}
//.....
function _encrypt($field)
{
if (!empty($this->{$field}))
{
$this->{$field} = $this->CI->encrypt->encode($this->{$field}, $this->pass_key);
}
}
function _decrypt($field)
{
if (!empty($this->{$field}))
{
$this->{$field} = $this->CI->encrypt->decode($this->{$field}, $this->pass_key);
}
}
Can you think of any reason it wouldn't work the other way?