18.10.2016 Views

Drupal 7 Module Development

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Building an Admin Interface<br />

'access arguments' takes an array containing a permissions strings. Any user who<br />

has been assigned one of these permissions will be able to access this page. Anyone<br />

else will be given an Access denied page. Permissions are defined by modules using<br />

hook_permission(). You can see a full list of the currently defined permissions at<br />

admin/people/permissions as shown:<br />

You can see the 'administer users' permission at the bottom of this list. In the<br />

preceding example, only the Administrator role has this permission, and as a result<br />

only those users assigned this role will be able to access our page.<br />

Note that the titles of the permissions here do not necessarily match what you will<br />

need to enter in the access arguments array. Unfortunately, the only good way to<br />

find this information is by checking the hook_perm() implementation of the module<br />

in question.<br />

Access rights, permissions, and security will be covered in greater<br />

detail in Chapter 8, <strong>Drupal</strong> Permissions and Security.<br />

The final item defines what type of menu item we are creating:<br />

'type' => MENU_NORMAL_ITEM,<br />

The 'type' is a bitmask of flags that describe what features we want our menu item<br />

to have (for instance, whether it is visible in the breadcrumb trail). <strong>Drupal</strong> defines<br />

over 20 constants for menu items that should cover any situation developers will find<br />

themselves in. The default type is MENU_NORMAL_ITEM, which indicates that this item<br />

will be visible in the menu tree as well as the breadcrumb trail.<br />

[ 124 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!