Internet CreatorsServicesServicesPortfolioPortfolioSEO BlogSEO BlogPHP BlogPHP BlogAbout UsAbout UsContact Us

Automate Drupal Permissions Checking

One of the more arduous manual tasks with the Drupal permissions system is when you need to create a user role with most or all of the permissions selected. To do this manually is a pain; for our simple site with ViewsCCK, and several optional core modules enabled we have 60+ permission checkboxes. To click all of those is unnecessary manual work. That’s what we have computers for!

To automate clicking all of the checkboxes on a page, we use a combination of the invaluable Firefox developer toolFirebug and a small bit of jQuery magic. When you install and open Firebug, you are greeted with this screen:

On the right of that screen there is an area where you can insert and execute bits of javascript. A good ol’ fashioned command line in the browser! We’re going to be running a bit of jQuery that will select all of the checkboxes on the screen.

We don’t want to do this from the main permissions pages (admin/user/permissions), since it will select all of the checkboxes for all roles, which isn’t what we want (we don’t want to give full admin access to anonymous user now, do we?). So instead, go to the permissions page for a specific role by going to the roles page and clicking “edit permissions”:

Once there, open up firebug, and paste the following bit of javascript into the command line:

$('input:checkbox').attr('checked', 'true');

and click “Run”. Now all checkboxes will be checked!

If you’re interested in having a dedicated “admin” role with full permissions, check out the Admin Role module, which will give a specific role all permissions, all the time. I prefer to have a bit more control over what permissions I give to admins (usually it’s most).

Leave a Reply