Danfreak: Bloody fantastic system you have made here. I love it.
To the rest of the community: Great work guys. It is good to see so much support for this application, and the CI framework in general.
Thanks Steve. This fix really helped me.
stevepaperjam - 19 February 2007 09:10 AM
Thanks to Dan for getting this updated version out so quickly.
I was going to post this in a separate thread, but it shouldn’t take long: any PHP4 users had a go with a new version yet?
I had a problem when opening the view user (or admins) page, which the log file tracked down to line 1139 in libraries/Freakauth_light.php
$db_fields =$this->CI->userprofile->getTableFields();
In discussion with Dan last night, I thought it might be my set-up (PHP4.4.0, Apache 2.something).
I’ve just had a bit more of a fiddle with it, and moving the loading of the model (just above that line) to the constructor seems to fix the issue.
This change also still works in PHP5.0.4 as well. (I’m using MAMP to flip between PHP versions, by the way…)
I had two postgres related issues with using FreakAuth and have come up with a solution for both. Hope these help any postgres users out there. These fixes are probably only relevant for people using v7.x of postgres.
Bug 1
Not sure if this is caused by postgres or by my verison of php 4, but when trying to add a new user it would constantly try to add the user with an id = 0 seeing as that is what the ‘add user’ form uses to denote a new user.
My fix was to remove the id=0 from the array just before it gets passed to the insert function. That way the SERIAL id field will automatically get a new id for this user record.
$values=$this->_get_form_values();
/* Fix for the Add new user routine.
* in php4 and postgres < 8 sending this is setting
* id = 0 for all new records.
* If the id key is removed completely a new ID will be generated.
* - Gerard
* */
if($values['user']['id'] == 0){
unset($values['user']['id']);
}
//insert data in DB
$this->usermodel->insertUser($values['user']);
Bug 2
I discovered that for a postgres database 7.x the insert_id() function doesn’t work as it is being used in the adding of profiles when a user is being created. The only way for 7.x to tell what the previous id of an insert is, is to check the sequence responsible for the SERIAL id value. The CI Postgres driver already allows for this, but a slight modification needs to be made to freakauth to take advantage of this 7.x way of doing things. To do this, I had to change the code in the application/controllers/admin/auth.php file as follows:
if($this->config->item('FAL_create_user_profile'))
{
//let's get the last insert id
//FIX - add fa_user_id_seq in the line below
$values['user_profile']['id']= $this->db->insert_id('fa_user_id_seq');
}
Also, if anyone wants it, I wrote a converted PostgreSQL script for installing the base tables for FreakAuth.
Please let me know if there is a way of fixing the above bugs better than I have done.
Cheers,
Gerard