| Commit | Line | Data |
|---|---|---|
| 2ace3f91 | 1 | <?php |
| a15e7f88 AB |
2 | /** |
| 3 | * @file | |
| 4 | * Install hooks for Data module. | |
| 5 | */ | |
| 2ace3f91 AB |
6 | |
| 7 | /** | |
| 8 | * Implementation of hook_schema(). | |
| 9 | */ | |
| 10 | function data_schema() { | |
| 11 | $schema['data_tables'] = array( | |
| 12 | 'description' => 'Tables managed by Data module.', | |
| 72ba49d9 AB |
13 | 'export' => array( |
| 14 | 'key' => 'name', | |
| 15 | 'identifier' => 'data_table', | |
| 16 | 'default hook' => 'data_default', // Function hook name. | |
| 17 | 'api' => array( | |
| 18 | 'owner' => 'data', | |
| 19 | 'api' => 'data_default', // Base name for api include files. | |
| 20 | 'minimum_version' => 1, | |
| 21 | 'current_version' => 1, | |
| 22 | ), | |
| 23 | ), | |
| 2ace3f91 AB |
24 | 'fields' => array( |
| 25 | 'title' => array( | |
| 26 | 'type' => 'varchar', | |
| 27 | 'length' => '255', | |
| 28 | 'not null' => TRUE, | |
| 29 | 'default' => '', | |
| 30 | 'description' => 'Natural name of the table.', | |
| 31 | ), | |
| 32 | 'name' => array( | |
| 33 | 'type' => 'varchar', | |
| 34 | 'length' => '255', | |
| 35 | 'not null' => TRUE, | |
| 36 | 'default' => '', | |
| 37 | 'description' => 'Table name.', | |
| 38 | ), | |
| 39 | 'table_schema' => array( | |
| 40 | 'type' => 'text', | |
| 41 | 'not null' => FALSE, | |
| 42 | 'description' => 'Table schema.', | |
| 43 | 'serialize' => TRUE, | |
| 44 | ), | |
| 45 | 'meta' => array( | |
| 46 | 'type' => 'text', | |
| 47 | 'not null' => FALSE, | |
| 48 | 'description' => 'Meta information about the table and its fields.', | |
| 49 | 'serialize' => TRUE, | |
| 50 | ), | |
| 51 | ), | |
| 52 | 'indexes' => array( | |
| 53 | 'name' => array('name'), | |
| 54 | ), | |
| 55 | ); | |
| 2ace3f91 AB |
56 | return $schema; |
| 57 | } | |
| 58 | ||
| 59 | /** | |
| 60 | * Implementation of hook_install(). | |
| 61 | */ | |
| 62 | function data_install() { | |
| 63 | // Create tables. | |
| 64 | drupal_install_schema('data'); | |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * Implementation of hook_uninstall(). | |
| 69 | */ | |
| 70 | function data_uninstall() { | |
| 71 | // Remove tables. | |
| 72 | drupal_uninstall_schema('data'); | |
| 73 | } | |
| 70a595f9 AB |
74 | |
| 75 | /** | |
| 76 | * Move join information into meta fields. | |
| 77 | */ | |
| 78 | function data_update_6001() { | |
| 79 | $ret = array(); | |
| 80 | $result = db_query('SELECT * FROM {data_join}'); | |
| 81 | while ($row = db_fetch_object($result)) { | |
| 82 | if ($table = data_get_table($row->right_table)) { | |
| 83 | $table->link($row->left_table, $row->left_field, $row->right_field, $row->inner_join ? TRUE : FALSE); | |
| 84 | } | |
| 85 | } | |
| 86 | db_drop_table($ret, 'data_join'); | |
| 87 | return $ret; | |
| 88 | } |