Hello,

I'm looking at using Acl in 1.2 and came across some behaviour which
is either a bug or I haven't understood how to use the component
properly. I don't have a lot of experience with Acl and maybe I have
set it up wrong, but maybe someone has come across or can explain the
behaviour? (I have changed the code so it works for me, given below)

(I've tried this on the latest 1.2.x.x_16.08.2007 build)

I have set up some aros and acos, next I try to assign permissions as
follows;

$aroKey = array('model' => 'Group', 'foreign_key' => 5);
$acoKey = array('model' => 'ControllerAco', 'foreign_key' => 6);

$this->Acl->allow($aroKey, $acoKey, 'create');

This allows 'create' as expected but also allows 'read', 'update' and
'delete' for the $acoKey by $aroKey.

If I then do

$this->Acl->deny($aroKey, $acoKey, 'create');

it denies 'create' as expected but also 'read', 'update' and 'delete'
for the $acoKey by $aroKey even if they are not specified.

I have looked at the code and it seems to me the problem is in
DB_ACL::allow()


/*************** The Original code *******************************/

if (isset($perms[0])) {
                        //$save = $perms[0]['Permission'];
$save = $perms['link'][0]['Permission'];    <--------- My edit
                }

                if ($actions == "*") {
                        $permKeys = 
$this->_getAcoKeys($this->Aro->Permission->loadInfo());

                        foreach ($permKeys as $key) {
                                $save[$key] = $value;
                        }
                } else {
                        if (!is_array($actions)) {
                                $actions = array('_' . $actions);
                                $actions = am($permKeys, $actions);
                        }
                        if (is_array($actions)) {
                                foreach ($actions as $action) {
                                        if ($action{0} != '_') {
                                                $action = '_' . $action;
                                        }
                                        if (in_array($action, $permKeys)) {
                                                $save[$action] = $value;
                                        }
                                }
                        }
                }

/*************** Code that works for me and what I want to do
*******************************/

        if (isset($perms['link'][0])) {
                        $save = $perms['link'][0]['Permission'];    <--------- 
My edit
                }

                if ($actions == "*") {
                        $permKeys = 
$this->_getAcoKeys($this->Aro->Permission->loadInfo());

                        foreach ($permKeys as $key) {
                                $save[$key] = $value;
                        }
                } else {
                        if (!is_array($actions)) {
                                $actions = array('_' . $actions);
                                //$actions = am($permKeys, $actions);   
<--------- My edit
                        }
                        if (is_array($actions)) {
                                foreach ($actions as $action) {
                                        if ($action{0} != '_') {
                                                $action = '_' . $action;
                                        }
                                        if (in_array($action, $permKeys)) {
                                                $save[$action] = $value;
                                        }
                                }
                        }
                }


/
***************************************************************************/

At least in the original code for my use "$save = $perms[0]
['Permission'];" always ends up as NULL.

I realise that if this is a bug it should be in trac, but a second
opinion would be good to avoid making unnecessary bug reports.

Thanks

Adrian


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to