Page 1 of 1

Joining Actions with their required access levels

Posted: Wed Jul 29, 2009 3:51 pm
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

Re: Joining Actions with their required access levels

Posted: Wed Jul 29, 2009 4:06 pm
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.

Re: Joining Actions with their required access levels

Posted: Wed Jul 29, 2009 4:27 pm
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!