Welcome Guest, Not a member yet? Register   Sign In
Basic Permissions System - Permission Class (on wiki)
#1

[eluser]Stu Green[/eluser]
Hey guys,

Ok i've uploaded my Permission Class on the wiki. Thought I'd create a new discussion for it.

When I have more time I'll upload some more example controllers and view files, the wiki isn't really complete, but at least the library is there.

You will need to put the permission keys in to the DB manually, or you could create a page that adds these keys. But basically just add in the permissions table, the name of the permission, the key and category is optional.

Then in your controller (see example) you can use an IF statement to say if that new key is in the array or not.

Enjoy, and if anyone has any feedback or ways to improve it feel free.

Here it is http://codeigniter.com/wiki/Permission_Class/


Cheers
#2

[eluser]drewbee[/eluser]
Hey, very nice. This looks very similar to something I have done. On top of this, mine does the following:

- User specific permissions (based off of account ID) take precedence over any group permissions. Might be a nice little trinket to throw in.

- the 'systems' in mine are completely based off of the directory > controller > method > {arg}1, {arg}2..., with method having the highest say in permissions (ex. it will over ride directory if view is set to false at directory level but set to true at method level).

As an example, lets say we have the structure admin/edit_user/profile/{id}

I can set the usergroup 'administrators' to have the permission 'view' at the system level of 'admin/', which will now be inherited all the way down to {id}.

This is nice because I do not have to define each directory, controller, method etc with permissions (unless I want too), as it is simply inherited down the path.

I could also set it up to have the administrators be able to view the edit user profile page except for ID 23 as an example.

Only downside to my little system here is though it is all done in 1 query, the complexity of the query increases with each 'ci' directory that exists (figuring out what takes precedence etc).


Just some thoughts for you to mull around in your head!! Smile
#3

[eluser]pankaj[/eluser]
[quote author="haloweb" date="1237475201"]Hey guys,

Ok i've uploaded my Permission Class on the wiki. Thought I'd create a new discussion for it.

When I have more time I'll upload some more example controllers and view files, the wiki isn't really complete, but at least the library is there.

You will need to put the permission keys in to the DB manually, or you could create a page that adds these keys. But basically just add in the permissions table, the name of the permission, the key and category is optional.

Then in your controller (see example) you can use an IF statement to say if that new key is in the array or not.

Enjoy, and if anyone has any feedback or ways to improve it feel free.

Here it is http://codeigniter.com/wiki/Permission_Class/


Cheers[/quote]

Hi, I want to use this class but it has many bugs and methods like $post = $this->CI->easysite->get_post(); is used which is not define in class do you have its new version.

do you have its manual to explain how it work?

and please explain what is meaning or 'key' and 'category' in permission table.
#4

[eluser]Stu Green[/eluser]
Hiya,

I apologise for the 'incompleteness' of this class. I kind of just posted hoping people would be able to work it out - it's not really standalone, but more work in progress.

At some point I'll upload the DB Schema and also some examples.

Regarding that method, replace it with just $_POST. All it does is extract XSS cleaned POST variables.

Oh and the key is whatever you want (e.g. forums_edit, forums_add) then you'll need to do an in_array('forums_edit', $permissions) to check. The category can be null.

S
#5

[eluser]pankaj[/eluser]
Thanks for your reply, you have done good work but I want to use it in my project so can you please explain me the table Permissions and the over all how functionality works like how to give key names and category names.

please explain this code

Code:
$post = $this->CI->input->post();  //I changed this to take post variables
        foreach ($post as $key => $value)
        {
            if (preg_match('/^perm([0-9]+)/i', $key, $matches))
            {
                $this->CI->db->set('groupID', $groupID);
                $this->CI->db->set('permissionID', $matches[1]);
                $this->CI->db->insert('permission_map');
            }
        }
your help will be really appreciated.




Theme © iAndrew 2016 - Forum software by © MyBB