Monday, May 18, 2009

Update to Webform and Node Administration in Drupal

After my previous post, I did some more work on the same site, and came across the issue I talked about before. Unfortunately the fix I used last time didn't work for a new situation I came across, so I had to do some more rummaging in the Drupal modules and forums to see if I could find a better way around it.

Looking at what I was wanting to achieve, I wanted to be able to allow a role to look at the list of content and then add, edit or delete this content. However, I didn't want to give the role Node Administration access, because that would mean the user has access to create new WebForms, which I didn't want to give.

I came across a module called Content Management Filter, or cmf. This module creates a single page that roles can be given access to. This page does everything that the Administer Nodes page does as well as allow more control over the filters to view the content in the site. Also, this module exposes a number of permissions that give an administrator finer control over what each role can do on the page.

I simply included this module, tweaked the permissions for it and then removed the Administer Nodes permission. Now, it works exactly as I want it - the particular role can not create webforms, but they can view a list of all content and add, edit or remove this content!

It's pretty bad that Drupal doesn't let you do this straight out of the box, but thankfully this module gives you all the control you'll need to give roles permission to edit content.

Sunday, May 10, 2009

Combining Webforms and Node administration in Drupal

I started a new job a few weeks ago, so despite my best efforts, I haven't had time to add anything more to this blog since I opened it.

Earlier today I was working on an almost complete site in Drupal. The site is almost ready to go live, it's just a matter of a few last minute configuration changes. I was working on the permissions for a content editor role. Basically, this role was to be able to create, edit and delete any content on the site, as well as manage the sites users. The caveat is that one of the modules that is installed is the WebForms module. This module allows an administrator to create forms for users to fill in. It has a bunch of useful features, and installs a new content type to facilitate the creation of these forms.

What I wanted to do was remove access to this content type for a content editor. Because the webforms content type is only really a psuedo content type, it doesn't have the permissions set up in the same way. The webforms module exposes a bunch of other permissions, one of which is "allowed to create new WebForms". This would seem to be the permission I am looking for. However, when I remove permissions to the role and then log in as a user who is part of the role, I am still able to create webforms.

A little digging through the forums, and some playing around, and I come across the problem. A user who has the permission 'Administer Nodes' is automatically given permission to create WebForms. This makes the create WebForms permission reduntant, or at least in the context that I'm using it in. I could take away Administer Nodes permission, but then my content editor would not be given permission to access the list of all nodes. This is obviously not a workable solution, as the editor really needs access to a list of content to edit.

The best solution I've come up with is to disable the WebForms menu option. It no longer shows up in the navigation menu, and also does not show up on the create content page. The disadvantage with this is that an administrator can not see the option either. Also, a content editor can create a WebForm, if they know the path to the correct page.

In the context of my site, neither of these are of a huge concern, because the layout of the site will remain largely unchanged when it goes live. Also, there are only likely to be two or three content editors, and they will all be trustworthy. Moreover, the users are almost certainly going to be either Dentists or their receptionists, neither of which are in the high danger zone for being hackers!