View source
<?php
function quicktabs_schema() {
$schema['quicktabs'] = array(
'description' => 'The quicktabs table.',
'fields' => array(
'qtid' => array(
'description' => 'The primary identifier for a qt block.',
'type' => 'serial',
'unsigned' => TRUE,
'size' => 'big',
'not null' => TRUE,
'disp-width' => '10',
),
'ajax' => array(
'description' => 'Whether this is an ajax views block.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'hide_empty_tabs' => array(
'description' => 'Whether this tabset hides empty tabs.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'default_tab' => array(
'description' => 'Default tab.',
'type' => 'int',
'unsigned' => TRUE,
'size' => 'tiny',
'not null' => TRUE,
),
'title' => array(
'description' => 'The title of this quicktabs block.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'tabs' => array(
'description' => 'A serialized array of the contents of this qt block.',
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
'serialize' => TRUE,
),
'style' => array(
'description' => 'The tab style.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
),
'primary key' => array(
'qtid',
),
);
return $schema;
}
function quicktabs_install() {
drupal_install_schema('quicktabs');
}
function quicktabs_uninstall() {
drupal_uninstall_schema('quicktabs');
$result = db_query("SELECT name FROM {variable} WHERE name LIKE 'quicktabs_%'");
while ($row = db_fetch_object($result)) {
variable_del($row->name);
}
}
function quicktabs_update_6000() {
$ret = array();
db_drop_primary_key($ret, 'quicktabs');
db_change_field($ret, 'quicktabs', 'qtid', 'qtid', array(
'type' => 'serial',
'not null' => TRUE,
), array(
'primary key' => array(
'qtid',
),
));
return $ret;
}
function quicktabs_update_6001() {
$ret = array();
db_add_field($ret, 'quicktabs', 'ajax', array(
'description' => 'Whether this is an ajax views block',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
return $ret;
}
function quicktabs_update_6002() {
$ret = array();
$result = db_query('SELECT qtid FROM {quicktabs}');
while ($row = db_fetch_object($result)) {
$quicktabs = db_fetch_array(db_query('SELECT tabs, ajax FROM {quicktabs} WHERE qtid = %d', $row->qtid));
$quicktabs['tabs'] = unserialize($quicktabs['tabs']);
foreach ($quicktabs['tabs'] as $key => $tab) {
$newtab = array();
$newtab['type'] = $tab['type'];
$newtab['weight'] = $tab['weight'];
$newtab['title'] = $tab['title'];
switch ($tab['type']) {
case 'view':
if (isset($tab['vid'])) {
$newtab['vid'] = $tab['vid'];
}
else {
if ($quicktabs['ajax']) {
$newtab['vid'] = $tab['bnid'];
}
else {
$newtab['vid'] = $tab['bvid'];
}
}
$newtab['display'] = $tab['display'];
$newtab['args'] = $tab['args'];
break;
case 'block':
if (isset($tab['bid'])) {
$newtab['bid'] = $tab['bid'];
}
else {
$newtab['bid'] = $tab['bvid'];
}
$newtab['hide_title'] = isset($tab['hide_title']) ? $tab['hide_title'] : 0;
break;
case 'node':
if (isset($tab['nid'])) {
$newtab['nid'] = $tab['nid'];
}
else {
$newtab['nid'] = $tab['bnid'];
}
break;
}
$quicktabs['tabs'][$key] = $newtab;
}
$quicktabs['tabs'] = serialize($quicktabs['tabs']);
db_query("UPDATE {quicktabs} SET tabs = '%s' WHERE qtid = %d", $quicktabs['tabs'], $row->qtid);
}
return $ret;
}
function quicktabs_update_6003() {
$ret = array();
db_add_field($ret, 'quicktabs', 'style', array(
'description' => 'The tab style.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'initial' => 'default',
));
return $ret;
}
function quicktabs_update_6004() {
$ret = array();
$result = db_query('SELECT qtid, tabs FROM {quicktabs}');
while ($row = db_fetch_object($result)) {
$tabs_array = unserialize($row->tabs);
foreach ($tabs_array as $key => $tab) {
if ($tab['type'] == 'view') {
$tab['args'] = str_replace(',', '/', $tab['args']);
$tab['args'] = str_replace(' ', '', $tab['args']);
$tabs_array[$key] = $tab;
}
}
$serialized = serialize($tabs_array);
db_query("UPDATE {quicktabs} SET tabs = '%s' WHERE qtid = %d", $serialized, $row->qtid);
}
return $ret;
}
function quicktabs_update_6205() {
$ret = array();
db_add_field($ret, 'quicktabs', 'hide_empty_tabs', array(
'description' => t('Whether this tabset hides empty tabs'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
return $ret;
}
function quicktabs_update_6206() {
$ret = array();
db_add_field($ret, 'quicktabs', 'default_tab', array(
'description' => 'The default tab.',
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
));
return $ret;
}