|
Server IP : 10.2.73.233 / Your IP : 216.73.216.223 Web Server : Apache/2.4.59 (Debian) System : Linux polon 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 User : www-data ( 33) PHP Version : 5.6.40-64+0~20230107.71+debian10~1.gbp673146 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/ilpnowa/../baltic/web/modules/trigger/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
/**
* @file
* Install, update and uninstall functions for the trigger module.
*/
/**
* Implements hook_schema().
*/
function trigger_schema() {
// The total index length (hook and aid) must be less than 333. Since the aid
// field is 255 characters, the hook field can have a maximum length of 78.
$schema['trigger_assignments'] = array(
'description' => 'Maps trigger to hook and operation assignments from trigger.module.',
'fields' => array(
'hook' => array(
'type' => 'varchar',
'length' => 78,
'not null' => TRUE,
'default' => '',
'description' => 'Primary Key: The name of the internal Drupal hook; for example, node_insert.',
),
'aid' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => "Primary Key: Action's {actions}.aid.",
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The weight of the trigger assignment in relation to other triggers.',
),
),
'primary key' => array('hook', 'aid'),
'foreign keys' => array(
'action' => array(
'table' => 'actions',
'columns' => array('aid' => 'aid'),
),
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function trigger_install() {
// Do initial synchronization of actions in code and the database.
actions_synchronize();
}
/**
* Alter the "hook" field and drop the "op field" of {trigger_assignments}.
*
* Increase the length of the "hook" field to 78 characters and adds operation
* names to the hook names, and drops the "op" field.
*/
function trigger_update_7000() {
db_drop_primary_key('trigger_assignments');
db_change_field('trigger_assignments', 'hook', 'hook', array('type' => 'varchar', 'length' => 78, 'not null' => TRUE, 'default' => '', 'description' => 'Primary Key: The name of the internal Drupal hook; for example, node_insert.'));
$result = db_query("SELECT hook, op, aid FROM {trigger_assignments} WHERE op <> ''");
foreach ($result as $record) {
db_update('trigger_assignments')
->fields(array('hook' => $record->hook . '_' . $record->op))
->condition('hook', $record->hook)
->condition('op', $record->op)
->condition('aid', $record->aid)
->execute();
}
db_drop_field('trigger_assignments', 'op');
db_add_primary_key('trigger_assignments', array('hook', 'aid'));
}
/**
* @addtogroup updates-7.x-extra
* @{
*/
/**
* Increase the length of the "hook" field to 78 characters.
*
* This is a separate function for those who ran an older version of
* trigger_update_7000() that did not do this.
*/
function trigger_update_7001() {
db_drop_primary_key('trigger_assignments');
db_change_field('trigger_assignments', 'hook', 'hook', array('type' => 'varchar', 'length' => 78, 'not null' => TRUE, 'default' => '', 'description' => 'Primary Key: The name of the internal Drupal hook; for example, node_insert.', ), array('primary key' => array('hook', 'aid')));
}
/**
* Renames nodeapi to node.
*/
function trigger_update_7002() {
$result = db_query("SELECT hook, aid FROM {trigger_assignments}");
foreach($result as $record) {
$new_hook = str_replace('nodeapi', 'node', $record->hook);
db_update('trigger_assignments')
->fields(array('hook' => $new_hook))
->condition('hook', $record->hook)
->condition('aid', $record->aid)
->execute();
}
}
/**
* @} End of "addtogroup updates-7.x-extra".
*/