| 1 |
<?php
|
| 2 |
// $Id: transformer.install,v 1.11 2008/01/04 18:26:47 dopry Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install
|
| 6 |
*/
|
| 7 |
|
| 8 |
function transformer_install() {
|
| 9 |
switch ($GLOBALS['db_type']) {
|
| 10 |
case 'mysql':
|
| 11 |
case 'mysqli':
|
| 12 |
$ret1 = db_query('
|
| 13 |
CREATE TABLE {transformer_macro} (
|
| 14 |
macro_id INTEGER NOT NULL,
|
| 15 |
macro_name VARCHAR(255) NOT NULL DEFAULT \'\',
|
| 16 |
PRIMARY KEY (macro_id),
|
| 17 |
KEY (macro_name)
|
| 18 |
) /*!40100 DEFAULT CHARACTER SET utf8 */
|
| 19 |
');
|
| 20 |
|
| 21 |
$ret2 = db_query('
|
| 22 |
CREATE TABLE {transformer_transform} (
|
| 23 |
transform_id INT UNSIGNED NOT NULL DEFAULT 0,
|
| 24 |
macro_id INT UNSIGNED NOT NULL DEFAULT 0,
|
| 25 |
weight INT NOT NULL DEFAULT 0,
|
| 26 |
data TEXT NOT NULL DEFAULT \'\',
|
| 27 |
base TEXT NOT NULL DEFAULT \'\',
|
| 28 |
PRIMARY KEY (transform_id),
|
| 29 |
KEY (macro_id)
|
| 30 |
) /*!40100 DEFAULT CHARACTER SET utf8 */
|
| 31 |
');
|
| 32 |
|
| 33 |
$ret3 = db_query('
|
| 34 |
create table {transformer_queue} (
|
| 35 |
transformer_queue_id int not null default 0,
|
| 36 |
macro_id int not null default 0,
|
| 37 |
src varchar(255) not null default \'\',
|
| 38 |
dst varchar(255) not null default \'\',
|
| 39 |
step int not null default 0,
|
| 40 |
status int not null default 0,
|
| 41 |
PRIMARY KEY (transformer_queue_id),
|
| 42 |
KEY (macro_id),
|
| 43 |
KEY (status)
|
| 44 |
) /*!40100 DEFAULT CHARACTER SET utf8 */
|
| 45 |
');
|
| 46 |
break;
|
| 47 |
}
|
| 48 |
|
| 49 |
if ($ret1 && $ret2 && $ret3 && $ret4) {
|
| 50 |
drupal_set_message(t('Transformer module installed succesfully.'));
|
| 51 |
} else {
|
| 52 |
drupal_set_message(t('Transformer module installation was unsuccessfull. Necessary database tables should be created by hand.', 'error'));
|
| 53 |
}
|
| 54 |
return $ret;
|
| 55 |
}
|