by John

private_number_project.pngPrivate Number defines a CCK field type for numbers which should be kept private, such as Government-issued Identification or Bank Account numbers. These numbers are displayed as 'Ending in 123' for users without view private number access permissions, and optionally encrypted with a md5 block cipher in 128bit CFB mode. Private Number fields can optionally have a validation pattern, which will both validate input and provide a human-readable form of the pattern for field descriptions and error messages.

Features
* Access permissions

Private Number introduces (yet another) access permission, view private number. Private numbers are displayed as 'Ending in 123' for users without this permission. The number of digits displayed can be changed in Site Configuration, and can optionally be set to 0 which would show <hidden>.

* md5 block cipher encryption

private_number_admin_0.png

Private Number data can optionally be stored in the database with md5 block cipher encryption. This setting is recommended enabled to help thwart identity theft if access to your database becomes compromised. A unique cipher key for your site can be set in Site Configuration.

Note: changing your cipher key will make previously stored Private Numbers unreadable!

* Validation patterns

Validation patterns can optionally be added for any Private Number field. Validation patterns are passed through preg_match with start and end of string delimiters automatically appended. In addition, validation patterns will (usually) output a human-readable form for field descriptions and error messages. This feature has been tested only with simple numeric entries, and will produce garbage if using alphanumeric or complex regular expressions.

Example:

For a U.S. telephone number, the pattern would be:
$pattern='\(\d{3}\) \d{3}\-\d{4}';

which would output in human-readable form as:
(999) 999-9999

For a U.S. social security number, the pattern would be:
$pattern='\d{3}\-\d{2}\-\d{4}';

which would output in human-readable form as:
999-99-9999

We chose to use phrases for quantifiers because it provided more understandable output than the 9 notation, but can quickly get cumbersome when more than one quantifier is used in an expression.

\d? 0 or 1 digit
\d+ 1 or more digits
\d* 0 or more digits
\d{1,3} 1 to 3 digits

So for an IP address, the pattern might be:
$pattern='\d+\.\d+\.\d+\.\d+';

which would output in human-readable form as:
1 or more digits.1 or more digits.1 or more digits.1 or more digits

Be sure to escape meta characters in your validation pattern. For more information on preg_match, visit this page:
http://us.php.net/manual/en/function.preg-match.php

Prerequisites
The Content Contruction Kit content.module is enabled.

Installation

  1. Copy the private_number directory and all its contents to your modules directory
  2. Enable the module: admin/build/modules
  3. Configure the module: admin/settings/private_number
  4. Set access permissions for roles: admin/user/access

Download
Download package and report bugs, feature requests, or submit a patch from the project page on the Drupal web site.

Todo List

  • use human-readable patterns to automatically generate appropriate form entry fields

Credits
Module development sponsored by LifeWire, a subsidiary of The New York Times Company.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Highlighted PHP code can be posted with <?php ... ?> tags.

More information about formatting options

Captcha
We're only human... Captcha is a simple challenge-response test to make sure you are too.
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.