/[drupal]/contributions/modules/object_driver/member_list.module
ViewVC logotype

Diff of /contributions/modules/object_driver/member_list.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Fri Jan 26 02:50:59 2007 UTC revision 1.2.2.1, Thu Sep 13 02:06:13 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: member_list.module,v 1.1 2007/01/26 02:39:48 pwolanin Exp $  // $Id: member_list.module,v 1.5 2007/04/08 16:45:03 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() {  function household_class_define() {
23    $def = array();    $def = array();
24      $def['description'] = t('Address and number of members');
25    
26    $def['auto_menu'] = TRUE;    $def['auto_menu'] = TRUE;
27    
28    $def['table'] = 'household';    $def['table'] = 'household'; // This is the default, shown as an example.
29    
30    $def['columns']['address'] = array('data_type' => 'varchar', 'type_extra' => '128', 'NULL' => FALSE, 'default' => '');    $def['columns']['address'] = array('name' => t('Address'), 'form type' => 'textfield', 'maxlength' => '128', 'default' => '', 'required' => TRUE);
31    $def['columns']['city'] = array('data_type' => 'varchar', 'type_extra' => '128', 'NULL' => FALSE, 'default' => '');    $def['columns']['city'] = array('name' => t('City'), 'form type' => 'textfield', 'maxlength' => '128', 'default' => '');
32    $def['columns']['state'] = array('data_type' => 'varchar', 'type_extra' => '4', 'NULL' => FALSE, 'default' => '');    $def['columns']['state'] = array('name' => t('State'), 'form type' => 'textfield', 'maxlength' => '4', 'default' => '');
33    $def['columns']['zip'] = array('data_type' => 'varchar', 'type_extra' => '10', 'NULL' => FALSE, 'default' => '');    $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    return $attrib;    $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  function member_list_drupal_classes() {    return $def;
   return array('household');  
40  }  }
41    
42    
43  function member_list_drupal_help() {  /**
44    return '';   * 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    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.2.2.1

  ViewVC Help
Powered by ViewVC 1.1.2