View source
<?php
function scheduler_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {scheduler} (\n nid int(10) unsigned NOT NULL,\n publish_on int(11) NOT NULL default '0',\n unpublish_on int(11) NOT NULL default '0',\n PRIMARY KEY (nid)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
db_query("CREATE TABLE {scheduler} (\n nid integer NOT NULL default '0',\n publish_on integer NOT NULL default '0',\n unpublish_on integer NOT NULL default '0',\n PRIMARY KEY (nid));");
break;
}
}
function scheduler_uninstall() {
db_query('DROP TABLE {scheduler}');
db_query("DELETE FROM {variable} WHERE name LIKE '%s_%%'", 'scheduler');
}
function scheduler_update_1() {
return _system_update_utf8(array(
'scheduler',
));
}
function scheduler_update_2() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {scheduler} CHANGE timestamp_posted publish_on int(11) NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {scheduler} CHANGE timestamp_hidden unpublish_on int(11) NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {scheduler} ADD timezone int(6) NOT NULL default '0'");
break;
case 'pgsql':
db_change_column($ret, 'scheduler', 'timestamp_posted', 'publish_on', 'integer', array(
'not null' => TRUE,
'default' => "0",
));
db_change_column($ret, 'scheduler', 'timestamp_hidden', 'unpublish_on', 'integer', array(
'not null' => TRUE,
'default' => "0",
));
db_add_column($ret, 'scheduler', 'timezone', 'integer', array(
'not null' => TRUE,
'default' => "0",
));
break;
}
return $ret;
}
function scheduler_update_3() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
case 'pgsql':
$ret[] = update_sql("UPDATE {scheduler} SET publish_on=publish_on-timezone WHERE publish_on<>0");
$ret[] = update_sql("UPDATE {scheduler} SET unpublish_on=unpublish_on-timezone WHERE unpublish_on<>0");
$ret[] = update_sql("ALTER TABLE {scheduler} DROP COLUMN timezone");
break;
}
return $ret;
}