| 1 |
<?php
|
| 2 |
// $Id: member_list.module,v 1.4 2007/04/08 15:45:11 pwolanin Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Example module to show simple implementations of object_diver hooks.
|
| 6 |
*/
|
| 7 |
|
| 8 |
/**
|
| 9 |
* implementation of object_driver module hook:
|
| 10 |
* hook_data_classes(): returns an array of class info arrays
|
| 11 |
*
|
| 12 |
*/
|
| 13 |
function member_list_data_classes() {
|
| 14 |
return array('household');
|
| 15 |
}
|
| 16 |
|
| 17 |
/**
|
| 18 |
* implementation of object_driver module hook:
|
| 19 |
* classhook_class_define()
|
| 20 |
*
|
| 21 |
*/
|
| 22 |
function household_class_define() {
|
| 23 |
$def = array();
|
| 24 |
$def['description'] = t('Address and number of members');
|
| 25 |
|
| 26 |
$def['auto_menu'] = TRUE;
|
| 27 |
|
| 28 |
$def['table'] = 'household'; // This is the default, shown as an example.
|
| 29 |
|
| 30 |
$def['columns']['address'] = array('name' => t('Address'), 'form type' => 'textfield', 'maxlength' => '128', 'default' => '', 'required' => TRUE);
|
| 31 |
$def['columns']['city'] = array('name' => t('City'), 'form type' => 'textfield', 'maxlength' => '128', 'default' => '');
|
| 32 |
$def['columns']['state'] = array('name' => t('State'), 'form type' => 'textfield', 'maxlength' => '4', 'default' => '');
|
| 33 |
$def['columns']['zip'] = array('name' => t('ZIP'), 'form type' => 'textfield', 'maxlength' => '10', 'default' => '');
|
| 34 |
$def['columns']['howmany'] = array('name' => t('Number of people'), 'data type' => 'int', 'form type' => 'textfield', 'maxlength' => '5', 'default' => 1);
|
| 35 |
$def['columns']['member'] = array('name' => t('Membership status'), 'form type' => 'select',
|
| 36 |
'options' => array('paid' => t('Paid'), 'courtesy' => t('Courtesy'), 'past due' => t('Past due')));
|
| 37 |
$def['columns']['mail'] = array('name' => t('Send mail?'), 'form type' => 'radios', 'options' => array(t('No'), t('Yes')), 'default' => 1);
|
| 38 |
|
| 39 |
return $def;
|
| 40 |
}
|
| 41 |
|
| 42 |
|
| 43 |
/**
|
| 44 |
* implementation of object_driver module hook:
|
| 45 |
* classhook_class_access($op): $op = 'create', 'view', 'update', 'delete'
|
| 46 |
*
|
| 47 |
*/
|
| 48 |
function household_class_access($op) {
|
| 49 |
if ($op == 'view') {
|
| 50 |
return user_access('view member list');
|
| 51 |
}
|
| 52 |
else {
|
| 53 |
return user_access('update member list');
|
| 54 |
}
|
| 55 |
}
|
| 56 |
|
| 57 |
/**
|
| 58 |
* Implementation of hook_perm().
|
| 59 |
*
|
| 60 |
* By implementing this, you can assign permissions to user roles, and then
|
| 61 |
* regulate per role the access to CRUD functions in classhook_class_access().
|
| 62 |
*/
|
| 63 |
function member_list_perm() {
|
| 64 |
return array('view member list', 'update member list');
|
| 65 |
}
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|