function rotor_update_6200 in Rotor Banner 6.2
Same name and namespace in other branches
- 7 rotor.install \rotor_update_6200()
File
- ./
rotor.install, line 110 - Provides install and uninstall functions for rotor.
Code
function rotor_update_6200() {
$ret = array();
$modules = array(
'upload_element' => t('Upload element'),
'jquery_plugin' => t('jQuery plugin'),
'views_ui' => t('Views UI'),
);
// Prevent the update and warn if the new required modules aren't enabled.
if ($ret = rotor_check_update_abort($modules, 6200)) {
return $ret;
}
// grab all the existing rotor items
$old_items = db_query('SELECT * from {rotor_item}');
db_change_field($ret, 'rotor_item', 'file_path', 'fid', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {files}.fid.',
));
db_add_field($ret, 'rotor_item', 'image_title', array(
'type' => 'varchar',
'not null' => FALSE,
'length' => 255,
'description' => 'The image title.',
));
// update rotor items to use {files} table correctly
while ($old_item = db_fetch_object($old_items)) {
$file = db_fetch_object(db_query("SELECT * from {files} where filepath='%s'", $old_item->file_path));
$result = db_query("UPDATE {rotor_item} set fid=%d where nid=%d", $file->fid, $old_item->nid);
$ret[] = array(
'success' => $result !== FALSE,
'query' => 'Update entries in {rotor_item} table to use reference to fid in {files} table',
);
}
// update the blocks entry
update_sql("UPDATE {blocks} set module='views', delta='rotor-block_1' where module='rotor'");
return $ret;
}