| 1 |
An example module for how to generalize Drupal object CRUD functions- for Drupal |
An utility module providing generalized Drupal object CRUD functions- |
| 2 |
5.x |
for Drupal 5.x |
| 3 |
|
|
| 4 |
|
To use this module you must create another small module that defines your |
| 5 |
|
data. An example module (member_list) is included for demonstration purposes. |
| 6 |
|
The .install file is not needed if you already have a data table in your |
| 7 |
|
database. |
| 8 |
|
|
| 9 |
|
The object driver module defines a single permission 'access object driver data' |
| 10 |
|
User roles without this permission will not be able to see any data regardless |
| 11 |
|
of whatever permissions your module defines. This may be useful, for example, |
| 12 |
|
to prevent anonymous users from seeing that you have custom data tables. |
| 13 |
|
|
| 14 |
|
Hooks this module looks for are named with the convention: |
| 15 |
|
(hook -> module name, classhook -> class name) |
| 16 |
|
|
| 17 |
|
See the object_driver.module comments for a full list of hooks. At the minimum, |
| 18 |
|
your module must implement these hooks: |
| 19 |
|
|
| 20 |
|
hook_data_classes(): returns an array of class names |
| 21 |
|
|
| 22 |
|
classhook_class_define(): return a definition for the object's data table. |
| 23 |
|
classhook_class_access($op): $op = 'create', 'view', 'update', 'delete' |
| 24 |
|
|
| 25 |
|
The integer primary key of the data table must have the name classhook_id. |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
The array returned by classhook_class_define() can have these elements: |
| 29 |
|
|
| 30 |
|
required: |
| 31 |
|
|
| 32 |
|
'columns' - an array of the columns in your table. The key is the column name, |
| 33 |
|
the value is an array with infomation about the type of data: |
| 34 |
|
|
| 35 |
|
required element for each column entry: |
| 36 |
|
|
| 37 |
|
'name' - a human-readable name for the column |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
optional elements: |
| 41 |
|
|
| 42 |
|
'data type' - 'varchar', 'int', etc. Default treats data as text |
| 43 |
|
'form type' - 'select', 'radios', 'textfield', or 'textarea' |
| 44 |
|
defaults to 'textfield'.. |
| 45 |
|
'options' - an array of options for select or radio elements. |
| 46 |
|
'maxlength' - a max length for a textfield. Defaults to 128. |
| 47 |
|
'rows' - a number of rows for a textarea. Defaults to 5. |
| 48 |
|
'default' - a default value for this column for new objects |
| 49 |
|
'required' - TRUE or FALSE; If TRUE makes this a required form |
| 50 |
|
field. defaults to FALSE. |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
optional: |
| 54 |
|
|
| 55 |
|
'table' - the name of the SQL table- if not defined, defaults to the |
| 56 |
|
class name. |
| 57 |
|
|
| 58 |
|
'description' - a description of this data class. |
| 59 |
|
|
| 60 |
|
'auto_menu' - TRUE or FALSE; If TRUE, object_driver will automatically create |
| 61 |
|
menu items with appropriate callbacks for you. You'll almost |
| 62 |
|
always want to define this as TRUE. |
| 63 |
|
|