| 1 |
<?php
|
| 2 |
// $Id: context_prefix.install,v 1.3 2008/07/17 16:57:19 jmiccolis Exp $
|
| 3 |
|
| 4 |
function context_prefix_install() {
|
| 5 |
drupal_install_schema('context_prefix');
|
| 6 |
db_query("UPDATE {system} SET weight = -20 WHERE name = 'context_prefix'");
|
| 7 |
}
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_uninstall().
|
| 11 |
*/
|
| 12 |
function context_prefix_uninstall() {
|
| 13 |
drupal_uninstall_schema('context_prefix');
|
| 14 |
}
|
| 15 |
|
| 16 |
/**
|
| 17 |
* Implementation of hook_schema().
|
| 18 |
*/
|
| 19 |
function context_prefix_schema() {
|
| 20 |
$schema['context_prefix'] = array(
|
| 21 |
'description' => t('context_prefix.'),
|
| 22 |
'fields' => array(
|
| 23 |
'prefix' => array(
|
| 24 |
'description' => t('?'),
|
| 25 |
'type' => 'varchar',
|
| 26 |
'length' => 255,
|
| 27 |
'not null' => TRUE,
|
| 28 |
'default' => '',
|
| 29 |
),
|
| 30 |
'provider' => array(
|
| 31 |
'description' => t('?'),
|
| 32 |
'type' => 'varchar',
|
| 33 |
'length' => 255,
|
| 34 |
'not null' => TRUE,
|
| 35 |
'default' => '',
|
| 36 |
),
|
| 37 |
'id' => array(
|
| 38 |
'description' => t('?'),
|
| 39 |
'type' => 'int',
|
| 40 |
'unsigned' => TRUE,
|
| 41 |
'not null' => TRUE,
|
| 42 |
'default' => 0,
|
| 43 |
),
|
| 44 |
),
|
| 45 |
'primary key' => array('prefix'),
|
| 46 |
);
|
| 47 |
|
| 48 |
return $schema;
|
| 49 |
}
|
| 50 |
|
| 51 |
function context_prefix_update_1() {
|
| 52 |
$items = array();
|
| 53 |
$items[] = update_sql("UPDATE {system} SET weight = -20 WHERE name = 'context_prefix'");
|
| 54 |
return $items;
|
| 55 |
}
|
| 56 |
|
| 57 |
function context_prefix_update_2() {
|
| 58 |
$items = array();
|
| 59 |
$items[] = update_sql("CREATE TABLE {context_prefix} (space VARCHAR(255) NOT NULL, path VARCHAR(255) NOT NULL, id INT(10) NOT NULL, PRIMARY KEY (path))");
|
| 60 |
$paths = variable_get('context_paths', array());
|
| 61 |
if ($paths) {
|
| 62 |
foreach ($paths as $space => $p) {
|
| 63 |
foreach ($p as $path => $nid) {
|
| 64 |
db_query("REPLACE INTO {context_prefix} (space, path, id) VALUES('%s', '%s', %d)", $space, $path, $nid);
|
| 65 |
}
|
| 66 |
}
|
| 67 |
variable_del('context_paths');
|
| 68 |
}
|
| 69 |
return $items;
|
| 70 |
}
|
| 71 |
|
| 72 |
function context_prefix_update_3() {
|
| 73 |
$items = array();
|
| 74 |
$items[] = update_sql("ALTER TABLE {context_prefix} CHANGE COLUMN space space VARCHAR(255) NOT NULL;");
|
| 75 |
$items[] = update_sql("ALTER TABLE {context_prefix} CHANGE COLUMN path path VARCHAR(255) NOT NULL;");
|
| 76 |
$items[] = update_sql("ALTER TABLE {context_prefix} CHANGE COLUMN id id VARCHAR(255) NOT NULL;");
|
| 77 |
return $items;
|
| 78 |
}
|
| 79 |
|
| 80 |
function context_prefix_update_4() {
|
| 81 |
$items = array();
|
| 82 |
$items[] = update_sql("ALTER TABLE {context_prefix} CHANGE COLUMN space module VARCHAR(255) NOT NULL;");
|
| 83 |
$items[] = update_sql("ALTER TABLE {context_prefix} CHANGE COLUMN path prefix VARCHAR(255) NOT NULL;");
|
| 84 |
return $items;
|
| 85 |
}
|
| 86 |
|
| 87 |
function context_prefix_update_5() {
|
| 88 |
$items = array();
|
| 89 |
$items[] = update_sql("ALTER TABLE {context_prefix} CHANGE COLUMN module provider VARCHAR(255) NOT NULL;");
|
| 90 |
return $items;
|
| 91 |
}
|