Here's how I'd do it. I'd go over to http://framework.zend.com and download their 1.6 release (requires that you register for some ungodly reason). Then extract just Zend/Acl.php, Zend/Acl/* and Zend/Exception.php. Those few files allows you to then do something similar (albeit better) to what bretticus was trying to explain.
With a properly set up Access Control List (ACL) you can define as many roles as you want, and customize them based upon what they can do. You say you have 4 roles: Guest, User, Moderator, Admin. Effectively you can say "Guests can only view posts" and Users can do anything a guest can do PLUS create posts in their specific blog and comment on other blogs. With that, we can say Moderators can do all of what a User can do PLUS modify posts and comments in any blog (or whichever blogs they're associated with if you want to limit them). Finally Admin has all the Moderator's powers, except they can do anything globally plus create new blogs.
So you can see how the power tree works:
| | Guest | User | Moderator | Administrator |
+-----------------+---------+--------+-------------+-----------------+
| View | Yes | Yes | Yes | Yes |
| Comment | No | Yes | Yes | Yes |
| Post | No | Yes | Yes | Yes |
| Edit Own | No | Yes | Yes | Yes |
| Edit Others | No | No | Yes | Yes |
| Edit Comments | No | No | Yes | Yes |
| Create Blogs | No | No | No | Yes |
+-----------------+---------+--------+-------------+-----------------+
User inherits guest; Moderator inherits User; Administrator inherits Moderator. So now you can generate your ACL properly. Here's a short example:
<?php
include('Zend/Acl.php');
// Create a new access control list
$acl = new Zend_Acl();
// Create our roles
$guest = new Zend_Acl_Role('guest');
$user = new Zend_Acl_Role('user');
$moderator = new Zend_Acl_Role('moderator');
$administrator = new Zend_Acl_Role('administrator');
// Add our roles to the ACL
$acl->addRole($guest);
$acl->addRole($user, $guest);
$acl->addRole($moderator, $user);
$acl->addRole($administrator, $moderator);
// Set up the permissions:
// "null" means "any resource"...
$acl->allow($guest, null, 'view');
$acl->allow($user, null, array('post', 'edit-own', 'comment'));
$acl->allow($moderator, null, array('edit-any', 'edit-comments'));
$acl->allow($administrator, null, array('create'));
/* Alternatively the above could be written:
$acl->allow($guest, 'post', 'view');
$acl->allow($user, 'post', array('create', 'edit-own'));
$acl->allow($user, 'comment', 'create');
$acl->allow($moderator', 'comment', 'edit');
$acl->allow($moderator', 'post', 'edit-all');
$acl->allow($administrator', 'blog', 'create');
*/
Now you can query it like:
$acl->isAllowed($userrole, null, $permission);
That will return a boolean true or false. If you set up your permissions the alternative way (specifying resources) then you would query it like:
$acl->isAllowed($userrole, $resource, $permission);
For example...
// First way
$acl->isAllowed('guest', null, 'comment'); // False
$acl->isAllowed('moderator', null, 'edit-own'); // True
$acl->isAllowed('user', null, 'post'); // True
$acl->isAllowed('user', null, 'create'); // False
$acl->isAllowed('administrator', null, 'edit-any'); // True
// Alternative way
$acl->isAllowed('guest', 'post', 'edit'); // False
$acl->isAllowed('moderator', 'comment', 'create'); // True
$acl->isAllowed('user', 'blog', 'create'); // False
$acl->isAllowed('user', 'post', 'edit-own'); // True
$acl->isAllowed('administrator', 'blog', 'create'); // True
Much more flexible, and you can even set these up in a database. Have one table be user roles, and another table with resources, and a third table with the mapping of role to resource and if it's permitted or not.
Just another alternative.