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 />

In this chapter we will create a module with an administrative interface. This module<br />

will build upon many of the module creation concepts that were introduced in<br />

Chapter 2. Some of the concepts we will cover in this chapter are:<br />

• Mapping <strong>Drupal</strong> functions to menu items using hook_menu()<br />

• Creating basic forms with the Form API<br />

• Managing <strong>Drupal</strong> settings using variable_set() and variable_get()<br />

• Sending mail using drupal_mail() and hook_mail()<br />

• Using <strong>Drupal</strong> 7's new token system<br />

After this chapter is finished you should have a good handle on many concepts that<br />

are at the core of almost every module you will write in the future.<br />

The User Warn module<br />

In this chapter we will be creating the User Warn module. This module allows<br />

administrators to send users a warning via e-mail when that user violates a site's<br />

terms of service or otherwise behaves in a way that is inappropriate. The User<br />

Warn module will implement the following features:<br />

• The module will expose configuration settings to site administrators,<br />

including default mail text<br />

• This e-mail will include <strong>Drupal</strong> tokens, which allow the admin to replace<br />

and/or add site-specific variables to the e-mail<br />

• Site administrators will be able to send a user mail via a new tab on their user<br />

profile page<br />

• Warning e-mails will be sent using <strong>Drupal</strong>'s default mail implementation

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

Saved successfully!

Ooh no, something went wrong!