function quotes_update_6104 in Quotes 6
Implementation of hook_update_N(). Moving block variables to quotes_blocks table.
File
- ./
quotes.install, line 399 - Handles installation and updates for the quotes module.
Code
function quotes_update_6104() {
$ret = array();
db_change_field($ret, 'quotes_blocks', 'show_titles', 'show_titles', array(
'type' => 'int',
'size' => 'small',
));
// 5.x-1.2 added 'citation'.
if (!db_column_exists('quotes_blocks', 'show_citation')) {
db_add_field($ret, 'quotes_blocks', 'show_citation', array(
'description' => t('Show citation.'),
'type' => 'int',
'size' => 'small',
'not null' => FALSE,
'default' => 0,
));
db_add_field($ret, 'quotes_blocks', 'max_length', array(
'description' => t('Maximum length of quote in block.'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
));
db_add_field($ret, 'quotes_blocks', 'view_weight', array(
'description' => t('Weight for the view link.'),
'type' => 'int',
'size' => 'small',
'not null' => FALSE,
'default' => 1,
));
db_add_field($ret, 'quotes_blocks', 'more_text', array(
'description' => t('Text for the "more" link.'),
'type' => 'varchar',
'length' => 64,
'not null' => FALSE,
));
db_add_field($ret, 'quotes_blocks', 'view_text', array(
'description' => t('Text for the "view" link.'),
'type' => 'varchar',
'length' => 64,
'not null' => FALSE,
));
}
// Incorrectly set per block.
$max_len = variable_get('quotes_block_max_length', 0);
// Set globally in admin page.
$view_text = variable_get('quotes_block_view_text', t('View'));
$view_weight = variable_get('quotes_block_view_weight', 1);
$show_citation = variable_get('quotes_block_citation', TRUE);
$ret[] = update_sql("UPDATE {quotes_blocks} SET view_text='" . $view_text . "', view_weight=" . $view_weight . ", show_citation=" . $show_citation . ", max_length=" . $max_len . " WHERE 1=1");
// "more" text is per block already, but in a variable.
$result = db_query('SELECT bid FROM {quotes_blocks}');
while ($block = db_fetch_array($result)) {
$more_text = variable_get('quotes_more_' . $block['bid'], NULL);
$ret[] = update_sql("UPDATE {quotes_blocks} SET more_text='" . $more_text . "' WHERE bid=" . $block['bid']);
}
// Don't delete variables in case the update fails.
return $ret;
}