Welcome Guest, Not a member yet? Register   Sign In
Khaos :: KhACL
#91

[eluser]Neophyte[/eluser]
link for this one also updated
#92

[eluser]allentseng[/eluser]
[quote author="Neophyte" date="1214502847"]I've finally been able to make some free time for working on my own projects so i'll be looking to fix the issues which have been brought up over the past few posts.

Also in the hopes of keeping things a little more organised ive put the code into an SVN repos and setup Trac

http://khaos.neophyte.me.uk/

I'll also try my hand at building up some proper documentation instead of having people depend entirely on the function reference. (Much of trac including the wiki is open to all for now and depending on how well the spam filter works should remain so)

KhACL - Known Issues[/quote]

link is down ??
#93

[eluser]Tominator[/eluser]
Hi guys!

If you need (as I needed) to set all permissions to admin group, and you have many ACO's (subjects) and many AXO's (actions), you are in big trouble Smile

Feature: $this->acl->allow('admin', 'website', 'all') will be great, won't it?

Ok, I have solution Smile I know, it isn't best but it partially works Smile

So, here we go:

1, Open khacl.php
2, Find line 196 - 208:
Code:
if ($axo !== null)
        {
            if (!($rs = $this->_CI->db->get_where($this->_Tables['axos'], array('name' => $axo), 1)))
                return false;    
            
            if ($rs->num_rows() == 1)
            {
                $row    = $rs->row();
                $axo_id = $row->id;
            }
            else
                return false;    
        }

Replace with:
Code:
if ($axo !== null)
        {
            if ($axo !== 'all')
            {
                if (!($rs = $this->_CI->db->get_where($this->_Tables['axos'], array('name' => $axo), 1)))
                    return false;    
                
                if ($rs->num_rows() == 1)
                {
                    $row    = $rs->row();
                    $axo_id = $row->id;
                }
                else
                    return false;
            }
            
            else
            {
                if (!($rs = $this->_CI->db->get_where($this->_Tables['axos'])))
                    return false;    
                
                if ($rs->num_rows() > 0)
                {
                    $axo = array();
                    
                    foreach ($rs->result() as $row)
                    {
                        $axo[]    = $row->id;
                    }
                }
                else
                    return false;
            }
        }

3. Find line 277 - 303:
Code:
if ($axo !== null)
        {
            
            if (($rs = $this->_CI->db->get_where($this->_Tables['access_actions'], array('access_id' => $access_id, 'axo_id' => $axo_id))) !== false)
            {
                if ($rs->num_rows() === 0) // create link
                {
                    if (!$this->_CI->db->insert($this->_Tables['access_actions'], array('access_id' => $access_id, 'axo_id' => $axo_id, 'allow' => $allow)))
                        return false;
                }
                else // Modify existing link
                {
                    $row = $rs->row();
                    
                    if ($row->allow != $allow)
                        if (!$this->_CI->db->update($this->_Tables['access_actions'], array('allow' => $allow), array('id' => $row->id)))
                            return false;
                }
                
                return true;
            }
            else
                return false;
        }
        else
            return true;
}

Replace with:
Code:
if ($axo !== null)
        {
            if (is_array($axo))
            {
                foreach ($axo as $axo_id)
                {
                    $this->_set_helper($access_id, $axo_id, $allow);
                }
            }
            
            else
                $this->_set_helper($access_id, $axo_id, $allow);
            
        }
        else
            return true;
    }  
    
    function _set_helper($access_id, $axo_id, $allow)
    {
        if (($rs = $this->_CI->db->get_where($this->_Tables['access_actions'], array('access_id' => $access_id, 'axo_id' => $axo_id))) !== false)
        {
               if ($rs->num_rows() === 0) // create link
            {
                if (!$this->_CI->db->insert($this->_Tables['access_actions'], array('access_id' => $access_id, 'axo_id' => $axo_id, 'allow' => $allow)))
                    return false;
            }
            else // Modify existing link
            {
                $row = $rs->row();
                
                if ($row->allow != $allow)
                    if (!$this->_CI->db->update($this->_Tables['access_actions'], array('allow' => $allow), array('id' => $row->id)))
                        return false;
            }
            
            return true;
        }
        else
            return false;
    }

If you make new AXOs or ACOs you have to allow them (you can use 'all' again).

Tom.




Theme © iAndrew 2016 - Forum software by © MyBB