View source
<?php
function purl_install() {
drupal_install_schema('purl');
db_query("UPDATE {system} SET weight = -20 WHERE name = 'purl'");
_purl_migrate();
}
function purl_uninstall() {
drupal_uninstall_schema('purl');
}
function purl_schema() {
$schema['purl'] = array(
'description' => t('purl.'),
'fields' => array(
'value' => array(
'description' => t('The string to detect from incoming URLs and to use when rewriting outgoing URLs.'),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'provider' => array(
'description' => t('The provider (usually a module\'s name) of the prefix/id pair.'),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'id' => array(
'description' => t('The ID given by the provider to associate with a corresponding prefix. This might be a group_nid (og), a language code (i18n) or some other unique identifier that the provider is interested in associating with the URL prefix.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'value',
),
'indexes' => array(
'provider_id' => array(
'provider',
'id',
),
),
);
return $schema;
}
function _purl_migrate() {
drupal_get_schema(NULL, TRUE);
if (db_table_exists('purl') && db_table_exists('context_prefix')) {
$result = db_query("SELECT * FROM {context_prefix}");
while ($row = db_fetch_object($result)) {
$exists = db_result(db_query("SELECT id FROM {purl} WHERE provider = '%s' AND id = '%d'", $row->provider, $row->id));
if (!$exists) {
$modifier = array(
'value' => $row->prefix,
'provider' => $row->provider,
'id' => $row->id,
);
drupal_write_record('purl', $modifier);
}
}
$ret = array();
db_drop_table($ret, 'context_prefix');
}
}
function purl_update_6001() {
if ($pair = variable_get('purl_method_path_key', FALSE)) {
variable_set('purl_method_pair_key', $pair);
variable_del('purl_method_path_key');
}
return array();
}
function purl_update_6002() {
drupal_install_modules(array(
'ctools',
));
$modules = module_list();
if (!isset($modules['ctools'])) {
return array(
'#abort' => array(
'success' => FALSE,
'query' => 'Could not enable CTools.',
),
);
}
return array(
array(
'success' => TRUE,
'query' => 'Enabled CTools successfully.',
),
);
}
function purl_update_6003() {
$ret = array();
db_add_index($ret, 'purl', 'provider_id', array(
'provider',
'id',
));
return $ret;
}