D
D
Dmitry Sergeev2011-10-20 12:27:21
PHP
Dmitry Sergeev, 2011-10-20 12:27:21

ACL (access controll list) implementation. Blurred eye on the algorithm?

I am developing my own bike that needs acl. I looked at the implementation in drupal, cake, etc. nothing fits.
The bicycle works on the MVC paradigm, there is an entity and an activity (for example, the forum entity, the topic activity). It is not difficult to distribute access by user groups within the whole module:

class Acl
{
    function __construct()
    {
         $module = $this->router->fetchCurrentModule();
         $gid    = $this->user->getGroupId();

        $query = $db->query('SELECT perm FROM groups_permission WHERE module='.$db->escape($module).' AND gid='.$gid);


        if($query->num_rows())
            $perm = $query->row()->perm;
        else
            $perm = '';
        
        if (strpos($perm, 'access') === FALSE) { // пока ограничение связаны только с доступом, потом можно ввести edit delete и тд.
            show_message('You have no access to this module');
        }
    }
}

But what if I want to distribute access to a specific forum? You can enter an additional forum_permission table with the user_id and perm fields, but what about other modules if they do not have such a table. In general, I am looking for an algorithm for implementing ACL

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anatoly, 2011-10-20
@taliban

"You can enter an additional forum_permission table with user_id and perm fields, but what about other modules if they do not have such a table."
You remove the forum_ prefix in the table, and add the `entity_id` field
and add the entities table where there will be all the entities, and forums, and topics, and whatever you want, up to pressing the button.

O
ostapbender, 2011-10-20
@ostapbender

Zed Shaw

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question