| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* $Id: $
|
| 4 |
* @author Bruno Massa
|
| 5 |
* @file address_user.module
|
| 6 |
* You can associate a geographic address with users.
|
| 7 |
*/
|
| 8 |
|
| 9 |
define('ADDRESS_USER_PATH' , drupal_get_path('module', 'address_user'));
|
| 10 |
|
| 11 |
/**
|
| 12 |
* Implementation of hook_address_fields_api().
|
| 13 |
*/
|
| 14 |
function address_user_address_fields_api($op) {
|
| 15 |
if ($op == 'field') {
|
| 16 |
}
|
| 17 |
elseif ($op == 'group') {
|
| 18 |
return array(
|
| 19 |
'user' => array(
|
| 20 |
'is_primary' => ADDRESS_FIELD_SHOW,
|
| 21 |
'aname' => ADDRESS_FIELD_SHOW,
|
| 22 |
'street' => ADDRESS_FIELD_SHOW,
|
| 23 |
'city' => ADDRESS_FIELD_SHOW,
|
| 24 |
'province' => ADDRESS_FIELD_SHOW,
|
| 25 |
'postal_code' => ADDRESS_FIELD_SHOW,
|
| 26 |
'country' => ADDRESS_FIELD_SHOW
|
| 27 |
)
|
| 28 |
);
|
| 29 |
}
|
| 30 |
}
|
| 31 |
|
| 32 |
/**
|
| 33 |
* Implementation of hook_menu().
|
| 34 |
*/
|
| 35 |
function address_user_menu() {
|
| 36 |
// Add tab for address book.
|
| 37 |
$items['user/%user/address'] = array(
|
| 38 |
'page callback' => '_address_user_address',
|
| 39 |
'file' => 'address_user.inc',
|
| 40 |
'title' => t('Address Book'),
|
| 41 |
'type' => MENU_LOCAL_TASK,
|
| 42 |
'weight' => 1,
|
| 43 |
);
|
| 44 |
|
| 45 |
return $items;
|
| 46 |
}
|
| 47 |
|
| 48 |
/**
|
| 49 |
* Implementation of hook_theme().
|
| 50 |
*/
|
| 51 |
function address_user_theme() {
|
| 52 |
return array(
|
| 53 |
'address_user_overview' => array(
|
| 54 |
'arguments' => array('uid', 'addresses'),
|
| 55 |
'file' => 'address.inc',
|
| 56 |
),
|
| 57 |
);
|
| 58 |
}
|
| 59 |
|
| 60 |
/**
|
| 61 |
* Implementation of hook_user().
|
| 62 |
*/
|
| 63 |
function address_user_user($op, &$edit, &$user) {
|
| 64 |
if ($op == 'delete') {
|
| 65 |
include_once ADDRESS_PATH .'/address.inc';
|
| 66 |
_address_address_delete($user->uid, 'user');
|
| 67 |
}
|
| 68 |
}
|