tags:

views:

144

answers:

1

I'm working on an app that will have 6 ARO groups in order to cover the required permissions spectrum. It is really best practice to have *_add, *_edit, *_index, *_view, etc. methods for each? That seems like a bit of code overload and maintenance headache. The "cheapest" way I can imagine to handle it with routing is something like:

// core: edit
function _edit($id = null)
{
  // do stuff
}

function admin_edit($id = null)
{
  $this->_edit($id);
}

function manager_edit($id = null)
{
  $this->_edit($id);
}

function clerk_edit($id = null)
{
  $this->_edit($id);
}

/* ...and on and on... */

And toss in restrictions where necessary for, say, a group being allowed to only edit user's own items, or something similar.

Is there another recommended technique or is this really the best practice?

A: 

Presumably you want to offer different functionality for each group?

If that's not the case, there is no need for different CRUD methods for each group.

If, on the other hand, it is the case, look into switch statements within the CRUD methods to sort out who has what capability.

There is no need to have a method for each group.

Leo
Not necessarily different functionality aside from "own" access. Consider this contrived example privilege structure where the privileges stack: clients: index own, view own, edit own clerks: index all, add managers: view all, edit all admins: full accessI should have provided something like that in the original post for clarification.
tomws
Crap... just noticed that didn't format as expected. Trying again. Clients: index own, view own, edit own. Clerks: index all, add. Managers: view all, edit all. Admins: full access.
tomws
I get the idea [I don't think you can format comments]. I would do (and have done) it the way I suggest. Use ACL to filter method access, then further fine tune the access within that method feeding into a conditional - either switch or if depending on your preference.
Leo