
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Enums in PHP</title>
	<atom:link href="http://www.drewcking.com/2008/08/enums-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.drewcking.com/2008/08/enums-in-php/</link>
	<description>My projects, code snippets, and miscellaneous ideas</description>
	<lastBuildDate>Wed, 28 Jan 2009 14:54:37 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9-rare</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Drew</title>
		<link>http://www.drewcking.com/2008/08/enums-in-php/comment-page-1/#comment-10</link>
		<dc:creator>Drew</dc:creator>
		<pubDate>Fri, 15 Aug 2008 17:19:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.drewcking.com/?p=37#comment-10</guid>
		<description>Man you&#039;re seriously a mind reader.  A few days after coming across apc_load_constants() my RBAC system ended up evolving into a very similar kind of OR&#039;d bitfield system you&#039;re describing (roles, task groups, and tasks).  

It became unwieldy though; this project doesn&#039;t need quite that amount of flexibility so I scrapped most of it, including the cool APC constant stuff.  I&#039;m sure I&#039;ll come back to it down the road, but for now, it makes for decent blog fodder :P</description>
		<content:encoded><![CDATA[<p>Man you&#8217;re seriously a mind reader.  A few days after coming across apc_load_constants() my RBAC system ended up evolving into a very similar kind of OR&#8217;d bitfield system you&#8217;re describing (roles, task groups, and tasks).  </p>
<p>It became unwieldy though; this project doesn&#8217;t need quite that amount of flexibility so I scrapped most of it, including the cool APC constant stuff.  I&#8217;m sure I&#8217;ll come back to it down the road, but for now, it makes for decent blog fodder <img src='http://www.drewcking.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Goodman</title>
		<link>http://www.drewcking.com/2008/08/enums-in-php/comment-page-1/#comment-6</link>
		<dc:creator>Peter Goodman</dc:creator>
		<pubDate>Fri, 15 Aug 2008 15:25:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.drewcking.com/?p=37#comment-6</guid>
		<description>It sounds like what you need is a sort of access control lists, but maybe not as full blown as is usually done with a large tree structure.

A little while ago my brother made such a system. It was split into three parts: roles, objects, and permissions.

Permissions are defined only as the names you give to something, much like what is in an enum. A permissions are contextually relevant to objects.

A permission object is something like a blog post or a forum thread. Its permissions would be read, write, edit, etc.

Finally, a role is a state that the user is in, eg: guest, member, admin.

The way this is laid out in a database is as such:
there is a many-to-many relationship between users and roles; roles each have a unique permission level that is a power of two (1, 2, 4, 8, ...); objects are interesting because they are what contain the permissions in a very non-relational way (a comma-separated list of permissions). This order of permissions is important as each permission is implied to have a value that is a power of two. Finally, the permissions table is all numbers; there is a one-to-one relationship between permissions and roles, a one-to-one relationship between permissions and objects, and each permission has a &#039;grant&#039; and &#039;deny&#039; value. These values are just the implied values of the permissions that are in the CSV list in each row of the objects table ORd together.

How does this all end up working? Given a user id, you can find all permissions (from the permissions table) and join on the objects to build up a multidimensional array of bitfields. You can then perform queries of sorts on those to find out if a user can do a certain operation or not.

If you would like further info, feel free to email me. You obviously have my email address stored in your WP db.</description>
		<content:encoded><![CDATA[<p>It sounds like what you need is a sort of access control lists, but maybe not as full blown as is usually done with a large tree structure.</p>
<p>A little while ago my brother made such a system. It was split into three parts: roles, objects, and permissions.</p>
<p>Permissions are defined only as the names you give to something, much like what is in an enum. A permissions are contextually relevant to objects.</p>
<p>A permission object is something like a blog post or a forum thread. Its permissions would be read, write, edit, etc.</p>
<p>Finally, a role is a state that the user is in, eg: guest, member, admin.</p>
<p>The way this is laid out in a database is as such:<br />
there is a many-to-many relationship between users and roles; roles each have a unique permission level that is a power of two (1, 2, 4, 8, &#8230;); objects are interesting because they are what contain the permissions in a very non-relational way (a comma-separated list of permissions). This order of permissions is important as each permission is implied to have a value that is a power of two. Finally, the permissions table is all numbers; there is a one-to-one relationship between permissions and roles, a one-to-one relationship between permissions and objects, and each permission has a &#8216;grant&#8217; and &#8216;deny&#8217; value. These values are just the implied values of the permissions that are in the CSV list in each row of the objects table ORd together.</p>
<p>How does this all end up working? Given a user id, you can find all permissions (from the permissions table) and join on the objects to build up a multidimensional array of bitfields. You can then perform queries of sorts on those to find out if a user can do a certain operation or not.</p>
<p>If you would like further info, feel free to email me. You obviously have my email address stored in your WP db.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
