Book Image

Learning Drupal 6 Module Development

By : Dries Buytaert, Matt Butcher
Book Image

Learning Drupal 6 Module Development

By: Dries Buytaert, Matt Butcher

Overview of this book

Table of Contents (14 chapters)
Learning Drupal 6 Module Development
About the Author
About the Reviewers

Access Controls

In the last chapter, we took a quick look at access controls as a way to allow some users the ability to send email messages, while denying others such capabilities.

Here, we will be doing something similar. We will create one hook to register three new permissions, and then we will create a second hook that will test a user to see if she or he can access a biography.

First, let's look at hook_perm(), which is responsible for registering new permissions:

* Implements hook_perm()
function biography_perm() {
return array(
'create biography node',
'edit biography nodes',
'delete biography nodes',

An implementation of hook_perm() simply returns an array of permission strings. Our implementation, biography_perm(), registers three new permissions: create biography node, edit biography nodes, and delete biography nodes.

These permissions will now show up on Administer | User management | Permissions:

Using this screen, an administrator can choose which roles to assign...