Joining Actions with their required access levels

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Joining Actions with their required access levels

Post by andyhoneycutt »

Hello everyone. I have a feeling that this is a topic that perhaps has been covered before, but I am unsure how to go about finding any reference for it. What I'm attempting to develop, at the most basic, is an event handler that has the access levels built-in to the event constant. I'm not sure if that makes sense at all, so here's an example of what I'm trying to do.

Admin access level = 1
Client Admin access level = 2
Executive Access level = 4
User Access level = 8
Agent Access level = 16, and so on...

Action_Edit_User = (all | allowed | access | levels) <joined with> (the_number_representing_the_action)

If that makes sense. I figure If I can join the two together, pass as an integer, I can use a bitmask to pull out all the information I need. Is this even worth doing, or is there a much better approach to something like this?

Thanks much, sorry if this is just a bunch of babble!

-Andy
chinstroker
Forum Newbie
Posts: 5
Joined: Sun Apr 26, 2009 3:01 pm

Re: Joining Actions with their required access levels

Post by chinstroker »

If the maximum number of access levels is known, you could just store your event identifier at higher bit numbers. eg reserve bits 1-8 for access permissions, then shift whatever number you are using to identify the event 8 bits to the left and add together. You would then have an integer which uniquely stores the access level and event type.
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Joining Actions with their required access levels

Post by andyhoneycutt »

chinstroker wrote:If the maximum number of access levels is known, you could just store your event identifier at higher bit numbers. eg reserve bits 1-8 for access permissions, then shift whatever number you are using to identify the event 8 bits to the left and add together. You would then have an integer which uniquely stores the access level and event type.
Very nice :) Thanks much for the suggestion!
Post Reply