sneakyBlog


Drupal permissions & filters

Posted in Drupal by Wim Leers on the February 4th, 2007

While I’m learning Drupal, I will share my experiences on this blog, hoping that it may be of any use for others. This post would be the first of this newly established tradition.

I wanted to set up the book content type with wiki-like editing abilities for all registered users. So I enabled the edit book pages and edit own book pages permissions on the Access Control page (of course that’s not all you have to do to get the book content type wiki-ish). Only to find out it did not work: the “Edit” button would not appear for book pages, no matter what I tried. After disabling modules that could possibly cause this, checking the logs and further playing with permissions, I still did not find the cause. Only after some “print $var; exit;“-ing I was able to narrow down the cause to this line in modules/node/node.module:


// If the node is in a restricted format, disallow editing.
if ($op == 'update' && !filter_access($node->format)) {
return FALSE;
}

And then things became clear.

When first playing with Drupal, I had created a book page, entered using the Filtered HTML input format. But later, I had installed the BBCode input format and made this the only allowed input format for all users. Which means filter_access() would return a FALSE when checking if a user has access to the Filtered HTML filter, and thus the Edit button would not appear for any regular user!

Moral of the story: choose your input format before creating content (even before creating content for testing purposes)!