View source
<?php
function context_install() {
drupal_install_schema('context');
}
function context_uninstall() {
drupal_uninstall_schema('context');
}
function context_schema() {
$schema['context'] = array(
'description' => t('Storage for normal (user-defined) contexts.'),
'fields' => array(
'cid' => array(
'description' => t('The primary identifier for a context.'),
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'namespace' => array(
'description' => t('The namespace for a context.'),
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'attribute' => array(
'description' => t('The attribute for a context.'),
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'value' => array(
'description' => t('The value for a context.'),
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'data' => array(
'description' => t('Serialized storage of all associated context items.'),
'type' => 'text',
'size' => 'big',
),
),
'unique keys' => array(
'key1' => array(
'namespace',
'attribute',
'value',
),
),
'primary key' => array(
'cid',
),
);
return $schema;
}
function context_update_6001() {
$ret = array();
if (!db_table_exists('context')) {
drupal_install_schema('context');
}
if (db_table_exists('context_ui')) {
drupal_get_schema(NULL, TRUE);
$result = db_query("SELECT * FROM {context_ui}");
while ($context = db_fetch_object($result)) {
$setter_result = db_query("SELECT * FROM {context_ui_setter} WHERE cid = %d", $context->cid);
while ($row = db_fetch_object($setter_result)) {
$context->{$row->type}[$row->id] = $row->id;
}
$getter_result = db_query("SELECT * FROM {context_ui_getter} WHERE cid = %d", $context->cid);
while ($row = db_fetch_object($getter_result)) {
$context->{$row->type} = unserialize($row->data);
}
$block_result = db_query("SELECT module, delta, region, weight FROM {context_ui_block} WHERE cid = %d", $context->cid);
while ($block = db_fetch_object($block_result)) {
if (!isset($context->block)) {
$context->block = array();
}
$block->bid = $block->module . "_" . $block->delta;
$context->block[$block->bid] = $block;
}
unset($context->cid);
context_save_context($context);
}
}
module_enable(array(
'context_contrib',
));
return $ret;
}
function context_update_6002() {
$contexts = context_enabled_contexts();
foreach ($contexts as $context) {
if (($context->type == CONTEXT_STORAGE_NORMAL || $context->type == CONTEXT_STORAGE_OVERRIDDEN) && (!empty($context->path) && is_array($context->path))) {
$changed = FALSE;
foreach ($context->path as $k => $v) {
if ($v != '<front>' && strpos($v, '*') === FALSE) {
$changed = TRUE;
$context->path[$k] = "{$v}*";
}
}
if ($changed) {
context_save_context($context);
}
}
}
return array();
}
function context_update_6003() {
$ret = array();
$tables = array(
'context_ui',
'context_ui_setter',
'context_ui_getter',
'context_ui_block',
);
foreach ($tables as $table) {
if (db_table_exists($table)) {
db_drop_table($ret, $table);
}
}
return $ret;
}