anojgoel wrote on Wednesday, January 28, 2009:
hi jason
it appears that phpgacl does not work with php5???
see the following post on the net.
http://www.codingforums.com/showthread.php?t=152966
part of the post is copied below for referance
>>>>> I’ve been working on a project where I needed an access control system and decided to used phpgacl 3.3.7, only to find out that using the configuration file didn’t work quite right. I did some debugging, and discovered a few issues, which I’ve fixed. You may have already gotten past these things, but in case not…
When I installed phpgacl, the admin interface worked fine. But when I tried to use it in my application, things didn’t work. I found a few things which got me past the problems.
The first issue was that when I put phpgacl into a subdirectory, when I loaded the class library, the config file (gacl.ini.php - which really isn’t a php file by the way) could not be found during class initialization. To fix it, I just created a symlink in my app directory to gacl.ini.php in the phpgacl subdirectory.
The second thing I found was a use of "array_merge()" which was incompatible with PHP5 in gacl.class.php on line 119. Here is the original code:
if ( is_array($config) ) {
$gacl_options = array_merge($config, $options);
}
I had to typecast "$options" - the changed code is:
if ( is_array($config) ) {
$gacl_options = array_merge($config, (array) $options);
}
The third issue was an outright bug - I’'m not sure how the developer originally tested the code, but using gacl.ini.php flat out didn’t work. While there is a workaround, this kind of makes the gacl.ini.php file less useful. The problem was a reference to the wrong array name on lines 125 & 126:
if (is_array($options)) {
foreach ($options as $key => $value) {
The way things are setup, the above code only works if $options is passed in via the constructor - this is the case with the admin interface, so that works. But when we initialize the class from an app, we must construct our own options array and pass it in - it cannot be null. In the code, I can see that the intent was for the constructor to work with a null options list - in which case it should pull them from the config file. While I can certainly pass options in to the constructor, it really should be able to use options from the config file. (I really don’t understand why the admin stuff doesn’t just let the gacl class constructor read the config file, but it reads it itself instead.).
To fix this so that the config file works correctly for both the app and the admin interface, I just added a check and set $options to the right thing before the if test on line 125:
if ($options == NULL)
$options = &$gacl_options;
These two lines needed to be changed to:
if (is_array($gacl_options)) {
foreach ($gacl_options as $key => $value) {
After making the above changes, things appear to work properly.
Mind you, I haven’t run a full battery of tests on this - there could be other issues lurking. But with these changes, I managed to get phpgacl 3.3.7 working a whole lot better.
I’m really surprised that these problems had not been discovered much sooner - I did some searches and basically found that many folks had concluded that phpgacl was PHP4 only and had abandoned it (I’m using it with PHP5). That seems unfortunate, because it seems to be quite a useful package for apps in need of this kind of capability.>>>>>
let me know if this is the problem and i can try to make these changes and report back.