I've been tasked to work out a model which will introduce restrictions or levels in an existing webapplication. The application is not consequently build to easily implement this feature. Serverside is PHP, clientside is jQuery.
These restrictions are associated with plans or subscriptions a user has bought.
I've come up with a model where:
- Functions are mapped with actions.
- An Action is a meaningful definition of an act a user can do on the application.
- A plan is a list of actions with a meaningful restrictive value.
A real world example
- requestIntroduction() is mapped with 'requesting' <-> 'introduction'
- The action is a 'request' of an 'introduction'
- Current plan allows user to request 5 introductions
- Do the check
I'm looking for a generic way to control restrictions as much as possible in one place in the code because:
- Plans will be added, removed and adjusted frequently
- Restrictions will be added, removed and adjusted frequently (to a plan)
- Adjusting restrictions and plans will be a feature in an admin console in the future.
My question is : Is there a better way to achieve the same generic approach to handle restrictions and to minimize coding future changes to plans and/or restrictions ?