/[drupal]/drupal/modules/trigger/trigger.install
ViewVC logotype

Contents of /drupal/modules/trigger/trigger.install

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


Revision 1.15 - (show annotations) (download) (as text)
Mon Nov 2 02:38:53 2009 UTC (3 weeks, 4 days ago) by webchick
Branch: MAIN
CVS Tags: DRUPAL-7-0-UNSTABLE-10, HEAD
Changes since 1.14: +9 -9 lines
File MIME type: text/x-php
#539442 by deekayen: Re-order functions in trigger.install so schema comes first.
1 <?php
2 // $Id: trigger.install,v 1.14 2009/09/29 15:13:57 dries Exp $
3
4 /**
5 * @file
6 * Install, update and uninstall functions for the trigger module.
7 */
8
9 /**
10 * Implement hook_schema().
11 */
12 function trigger_schema() {
13 $schema['trigger_assignments'] = array(
14 'description' => 'Maps trigger to hook and operation assignments from trigger.module.',
15 'fields' => array(
16 'hook' => array(
17 'type' => 'varchar',
18 'length' => 32,
19 'not null' => TRUE,
20 'default' => '',
21 'description' => 'Primary Key: The name of the internal Drupal hook; for example, node_insert.',
22 ),
23 'aid' => array(
24 'type' => 'varchar',
25 'length' => 255,
26 'not null' => TRUE,
27 'default' => '',
28 'description' => "Primary Key: Action's {actions}.aid.",
29 ),
30 'weight' => array(
31 'type' => 'int',
32 'not null' => TRUE,
33 'default' => 0,
34 'description' => 'The weight of the trigger assignment in relation to other triggers.',
35 ),
36 ),
37 'primary key' => array('hook', 'aid'),
38 'foreign keys' => array(
39 'aid' => array('actions' => 'aid'),
40 ),
41 );
42 return $schema;
43 }
44
45 /**
46 * Implement hook_install().
47 */
48 function trigger_install() {
49 // Do initial synchronization of actions in code and the database.
50 actions_synchronize();
51 }
52
53 /**
54 * Adds operation names to the hook names and drops the "op" field.
55 */
56 function trigger_update_7000() {
57 $result = db_query("SELECT hook, op, aid FROM {trigger_assignments} WHERE op <> ''");
58
59 foreach ($result as $record) {
60 db_update('trigger_assignments')
61 ->fields(array('hook' => $record->hook . '_' . $record->op))
62 ->condition('hook', $record->hook)
63 ->condition('op', $record->op)
64 ->condition('aid', $record->aid)
65 ->execute();
66 }
67 db_drop_field('trigger_assignments', 'op');
68 }

  ViewVC Help
Powered by ViewVC 1.1.2