View source
<?php
define('NODE_IMPORT_MINIMUM_DRUPAL', '6.5');
define('NODE_IMPORT_MINIMUM_DATEAPI', '5.2');
function node_import_install() {
drupal_install_schema('node_import');
}
function node_import_uninstall() {
drupal_uninstall_schema('node_import');
variable_del('node_import:ftp:directory');
variable_del('node_import:directory');
variable_del('node_import:ftp:enabled');
variable_del('node_import:ftp:user');
variable_del('node_import:ftp:extensions');
variable_del('node_import:fgets:length');
variable_del('node_import:number_of_samples');
variable_del('node_import:length_of_samples');
variable_del('node_import:preview_count');
variable_del('node_import:set_time_limit');
variable_del('node_import:cron:unit');
variable_del('node_import:cron:count');
variable_del('node_import:multiple_separator');
variable_del('node_import:hierarchy_separator');
variable_del('node_import:annoy');
variable_del('node_import:debug:row_count');
variable_del('node_import:detect:row_count');
}
function node_import_update_6000() {
$result = array();
if (db_table_exists('node_import_mappings')) {
db_drop_table($result, 'node_import_mappings');
}
$schema = array();
$schema['node_import_tasks'] = array(
'description' => t('Stores the details of each import task.'),
'fields' => array(
'taskid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'type' => 'varchar',
'length' => '64',
'not null' => TRUE,
'default' => '',
),
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'created' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'fid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'has_headers' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
'file_options' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'headers' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'type' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'map' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'defaults' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'options' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'offset' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'row_done' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'row_error' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'taskid',
),
);
$schema['node_import_status'] = array(
'description' => t('Stores status of an imported (or not) row.'),
'fields' => array(
'taskid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'offset' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'errors' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'objid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'taskid',
'offset',
),
);
foreach ($schema as $name => $table) {
if (!db_table_exists($name)) {
db_create_table($result, $name, $table);
}
}
return $result;
}
function node_import_update_6100() {
$result = array();
menu_rebuild();
return $result;
}
function node_import_update_6101() {
$result = array();
db_change_field($result, 'node_import_tasks', 'offset', 'file_offset', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
db_drop_primary_key($result, 'node_import_status');
db_change_field($result, 'node_import_status', 'offset', 'file_offset', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
), array(
'primary key' => array(
'taskid',
'file_offset',
),
));
return $result;
}
function node_import_update_6102() {
$result = array();
menu_rebuild();
return $result;
}
function node_import_schema() {
$schema = array();
$schema['node_import_tasks'] = array(
'description' => t('Stores the details of each import task.'),
'fields' => array(
'taskid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'type' => 'varchar',
'length' => '64',
'not null' => TRUE,
'default' => '',
),
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'created' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'fid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'has_headers' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
'file_options' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'headers' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'type' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'map' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'defaults' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'options' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'file_offset' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'row_done' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'row_error' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'taskid',
),
);
$schema['node_import_status'] = array(
'description' => t('Stores status of an imported (or not) row.'),
'fields' => array(
'taskid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'file_offset' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'errors' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'objid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'taskid',
'file_offset',
),
);
return $schema;
}
function node_import_requirements($phase) {
$requirements = array();
$t = get_t();
if (($phase == 'install' || $phase == 'runtime') && version_compare(VERSION, NODE_IMPORT_MINIMUM_DRUPAL) < 0) {
$requirements['node_import:minimum_drupal'] = array(
'title' => $t('Drupal version'),
'description' => $t('Node import module requires Drupal %version or later (currently %drupal_version installed).', array(
'%version' => NODE_IMPORT_MINIMUM_DRUPAL,
'%drupal_version' => VERSION,
)),
'value' => VERSION,
'severity' => REQUIREMENT_ERROR,
);
}
if ($phase == 'runtime' && variable_get('date_api_version', 0) < NODE_IMPORT_MINIMUM_DATEAPI) {
$requirements['node_import:minimum_dateapi'] = array(
'title' => $t('DateAPI version'),
'description' => $t('Node import module requires DateAPI module %version or later (currently %date_version installed).', array(
'%version' => NODE_IMPORT_MINIMUM_DATEAPI,
'%date_version' => variable_get('date_api_version', 0),
)),
'value' => variable_get('date_api_version', 0),
'severity' => REQUIREMENT_ERROR,
);
}
return $requirements;
}