View source
<?php
function support_pm_schema() {
$schema['support_plan'] = array(
'description' => 'Allows planning of hours required.',
'fields' => array(
'pid' => array(
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
),
'clid' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'uid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'day' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'hours' => array(
'type' => 'float',
'not null' => FALSE,
'unsigned' => TRUE,
'default' => 0.0,
),
'comment' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
),
'primary key' => array(
'pid',
),
'unique keys' => array(
'uid_clid_day' => array(
'uid',
'clid',
'day',
),
),
);
$schema['support_project'] = array(
'description' => 'Assign projects to support clients.',
'fields' => array(
'projid' => array(
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
),
'project' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'path' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'disabled' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => FALSE,
'default' => 0,
),
),
'primary key' => array(
'projid',
),
'keys' => array(
'project' => array(
'project',
'disabled',
'weight',
),
),
'unique keys' => array(
'path' => array(
'path',
),
),
);
$schema['support_project_client'] = array(
'fields' => array(
'projid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'clid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'projid',
'clid',
),
);
$schema['support_project_ticket'] = array(
'description' => 'Stores which projects are assigned to tickets.',
'fields' => array(
'nid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'projid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'nid',
'projid',
),
);
return $schema;
}
function support_pm_install() {
drupal_install_schema('support_pm');
}
function support_pm_uninstall() {
drupal_uninstall_schema('support_pm');
}
function support_pm_update_6001() {
$ret = $schema = array();
$schema['support_project'] = array(
'description' => 'Defines projects that can be assigned to client tickets.',
'fields' => array(
'projid' => array(
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
),
'project' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'disabled' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => FALSE,
'default' => 0,
),
),
'primary key' => array(
'projid',
),
'keys' => array(
'project' => array(
'project',
'disabled',
'weight',
),
),
);
$schema['support_project_client'] = array(
'description' => 'Stores which projects can be assigned to which clients.',
'fields' => array(
'projid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'clid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'projid',
'clid',
),
);
$schema['support_project_ticket'] = array(
'description' => 'Stores which projects are assigned to tickets.',
'fields' => array(
'nid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'projid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'nid',
'projid',
),
);
db_create_table($ret, 'support_project', $schema['support_project']);
db_create_table($ret, 'support_project_client', $schema['support_project_client']);
db_create_table($ret, 'support_project_ticket', $schema['support_project_ticket']);
drupal_flush_all_caches();
menu_rebuild();
return $ret;
}
function support_pm_update_6002() {
$ret = array();
db_add_field($ret, 'support_project', 'path', array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Project path.',
));
$result = db_query('SELECT projid, project FROM {support_project}');
while ($project = db_fetch_object($result)) {
$path = strtolower(preg_replace('/[^0-9a-zA-Z]/', '', $project->project));
$ret[] = update_sql("UPDATE {support_project} SET path = '{$path}' WHERE projid = {$project->projid}");
}
db_add_index($ret, 'support_project', 'path', array(
'path',
));
return $ret;
}