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.

Chapter 9<br />

It is a good idea to write out such rules and review them with the project sponsor,<br />

because doing so can reveal the implications of applying the logic you have defined.<br />

In this case, rule #4 becomes key, because we will explicitly deny access to edit<br />

content, even for users who might have the edit any Article content permission.<br />

Doing so might lead to confusion for some users, so we should ensure that this is the<br />

rule that we want.<br />

We should point out, from a security perspective, that these rules will<br />

place all 'authenticated users' into the same group. This behavior may be<br />

desirable, or it may open a risk that all registered site users can edit all<br />

content. For the purpose of our demonstration module, let's assume that<br />

this behavior is desired, and that users who need their content protected<br />

will be given an additional role.<br />

Since this is the behavior we want, the functionality is pretty easy to enforce. Let's<br />

create a role_edit.module file for this behavior. Our module starts out much like<br />

the Delay module.<br />

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

Saved successfully!

Ooh no, something went wrong!