rotor.install in Rotor Banner 5
Same filename and directory in other branches
Provides install and uninstall functions for rotor.
@author Nestor Mata Cuthbert, nestor@achieveinternet.com. http://www.achieveinternet.com
File
rotor.installView source
<?php
/**
* @file
* Provides install and uninstall functions for rotor.
*
* @author Nestor Mata Cuthbert, nestor@achieveinternet.com. http://www.achieveinternet.com
*/
/**
* Implementation of hook_install().
*/
function rotor_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {rotor_item} (\n nid int(10) unsigned NOT NULL,\n fid int(10) unsigned NOT NULL,\n alt_text varchar(255) NULL,\n url varchar(255) NULL,\n link_target varchar(255) NULL,\n PRIMARY KEY (nid));");
drupal_set_message(t('Rotor Banner installed.'));
break;
}
}
/**
* Implementation of hook_uninstall().
*/
function rotor_uninstall() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("DROP TABLE {rotor_item};");
variable_del('rotor_max_items');
variable_del('rotor_seconds');
variable_del('rotor_show_tabs');
variable_del('rotor_group_tabs');
drupal_set_message(t('Rotor Banner unistalled.'));
break;
}
}
/**
* Implementation of hook_update_N().
*/
function rotor_update_5000() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {rotor_item} ADD COLUMN url varchar(255) NULL AFTER file_path");
$ret[] = update_sql("ALTER TABLE {rotor_item} ADD COLUMN alt_text varchar(255) NULL AFTER file_path");
break;
}
return $ret;
}
function rotor_update_5001() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {rotor_item} ADD COLUMN link_target varchar(255) NULL AFTER url");
break;
}
return $ret;
}
function rotor_update_5101() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret = array();
$result = db_fetch_object(db_query('SELECT * from {rotor_item} LIMIT 1'));
if ($result->file_path) {
$result = db_query('SELECT * from {rotor_item}');
$ret[] = update_sql("ALTER TABLE {rotor_item} CHANGE file_path fid int(10) unsigned NOT NULL");
while ($rotor_item = db_fetch_object($result)) {
$filename = basename($rotor_item->file_path);
$fid = db_next_id('{files}_fid');
db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize)\n \t\t VALUES (%d, %d, '%s', '%s', '%s', %d)", $fid, $rotor_item->nid, $filename, $rotor_item->file_path, '', filesize($rotor_item->file_path));
db_query('UPDATE {rotor_item} set fid = %d WHERE nid = %d', $fid, $rotor_item->nid);
}
}
break;
}
return $ret;
}
Functions
Name![]() |
Description |
---|---|
rotor_install | Implementation of hook_install(). |
rotor_uninstall | Implementation of hook_uninstall(). |
rotor_update_5000 | Implementation of hook_update_N(). |
rotor_update_5001 | |
rotor_update_5101 |