summaryrefslogtreecommitdiff
path: root/modules/trigger/trigger.install
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-09-19 11:07:37 +0000
committerDries Buytaert <dries@buytaert.net>2009-09-19 11:07:37 +0000
commitfd1c63b5c0ce91849d6088b7aad40b27ea7bb96f (patch)
tree7742fc7fdc55f819c066be08a3419995b591439b /modules/trigger/trigger.install
parenta557b0de2ac5d0b2048a456f94f9b8047afa71b9 (diff)
downloadbrdo-fd1c63b5c0ce91849d6088b7aad40b27ea7bb96f.tar.gz
brdo-fd1c63b5c0ce91849d6088b7aad40b27ea7bb96f.tar.bz2
- Patch ##525540 by jvandyk, sun, jhodgdon, fago | webchick, TheRec, Dave Reid, brianV, sun.core, cweagans, Dries: gave trigger.module and includes/actions.inc an API overhaul. Simplified definitions of actions and triggers and removed dependency on the combination of hooks and operations. Triggers now directly map to module hooks.
Diffstat (limited to 'modules/trigger/trigger.install')
-rw-r--r--modules/trigger/trigger.install24
1 files changed, 15 insertions, 9 deletions
diff --git a/modules/trigger/trigger.install b/modules/trigger/trigger.install
index 2e014d071..b8553e48c 100644
--- a/modules/trigger/trigger.install
+++ b/modules/trigger/trigger.install
@@ -26,14 +26,7 @@ function trigger_schema() {
'length' => 32,
'not null' => TRUE,
'default' => '',
- 'description' => 'Primary Key: The name of the internal Drupal hook upon which an action is firing; for example, node.',
- ),
- 'op' => array(
- 'type' => 'varchar',
- 'length' => 32,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Primary Key: The specific operation of the hook upon which an action is firing: for example, presave.',
+ 'description' => 'Primary Key: The name of the internal Drupal hook; for example, node_insert.',
),
'aid' => array(
'type' => 'varchar',
@@ -49,7 +42,7 @@ function trigger_schema() {
'description' => 'The weight of the trigger assignment in relation to other triggers.',
),
),
- 'primary key' => array('hook', 'op', 'aid'),
+ 'primary key' => array('hook', 'aid'),
'foreign keys' => array(
'aid' => array('actions' => 'aid'),
),
@@ -57,4 +50,17 @@ function trigger_schema() {
return $schema;
}
+/**
+ * Adds operation names to the hook names and drops the "op" field.
+ */
+function trigger_update_7000() {
+ $ret = array();
+ $result = db_query("SELECT hook, op, aid FROM {trigger_assignments} WHERE op <> ''");
+ while ($row = db_fetch_object($result)) {
+ $ret[] = update_sql("UPDATE {trigger_assignments} SET hook = '%s' WHERE hook = '%s' AND op = '%s' AND aid = '%s'", $row->hook . '_' . $row->op, $row->hook, $row->op, $row->aid);
+ }
+ $ret[] = update_sql("ALTER TABLE {trigger_assignments} DROP op");
+
+ return $ret;
+}