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.

Table of Contents<br />

Simple widget forms 192<br />

Complex widgets 194<br />

Using formatters to display our field 199<br />

Declaring a formatter 200<br />

Single-value formatters 200<br />

Complex formatters 201<br />

Managing non-Field fields 205<br />

Finding entities and fields 206<br />

Summary 210<br />

Chapter 8: <strong>Drupal</strong> Permissions and Security 211<br />

Using user_access() to assert permissions 212<br />

Checking the proper user account 213<br />

Using hook_permission() 217<br />

Defining your module's permissions 218<br />

Writing hook_permission() 219<br />

Declaring your own access functions 221<br />

Responding when access is denied 224<br />

Enabling permissions programmatically 227<br />

Defining roles programmatically 228<br />

Securing forms in <strong>Drupal</strong> 229<br />

The Forms API 229<br />

Disabling form elements 230<br />

Passing secure data via forms 231<br />

Running access checks on forms 233<br />

Handling AJAX callbacks securely 235<br />

Using AJAX in forms 235<br />

Using AJAX in other contexts 236<br />

Summary 240<br />

Chapter 9: Node Access 241<br />

Node Access compared to user_access() and other<br />

permission checks 242<br />

How <strong>Drupal</strong> grants node permissions 242<br />

The node_access() function 244<br />

The access whitelist 246<br />

Caching the result for performance 246<br />

Invoking hook_node_access() 247<br />

Access to a user's own nodes 248<br />

Invoking the node access API 248<br />

hook_node_access() compared to {node_access} 250<br />

[ ]<br />

www.allitebooks.com

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

Saved successfully!

Ooh no, something went wrong!