View source
<?php
function event_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {event} (nid int(10) unsigned NOT NULL default '0',\n event_start int(10) unsigned NOT NULL default '0',\n event_end int(10) unsigned NOT NULL default '0',\n timezone int(10) NOT NULL default '0',\n PRIMARY KEY (nid),\n KEY event_start (event_start)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
db_query("CREATE TABLE {event} (\n nid int NOT NULL default '0',\n event_start int NOT NULL default '0',\n event_end int NOT NULL default '0',\n timezone int NOT NULL default '0',\n PRIMARY KEY (nid));");
break;
}
db_query("UPDATE {system} SET status = 1 WHERE name = 'basicevent'");
variable_set('event_nodeapi_event', 'all');
if (module_exists('location')) {
variable_set('location_event', 1);
variable_set('location_collapsible_event', 1);
variable_set('location_collapsed_event', 0);
variable_set('location_name_event', 1);
variable_set('location_street_event', 1);
variable_set('location_city_event', 1);
variable_set('location_province_event', 1);
variable_set('location_postal_code_event', 1);
}
drupal_set_message(t('Event module was successfully installed with default options. To customize event and/or location settings for events, please view the <a href="!settings">event content type settings page</a>.', array(
'!settings' => url('admin/content/types/event'),
)));
}
function event_update_1() {
return _system_update_utf8(array(
'event',
));
}
function event_uninstall() {
db_query('DROP TABLE {event}');
variable_del('event_timezone_input');
variable_del('event_timezone_display');
variable_del('event_ampm');
variable_del('event_upcoming_limit');
variable_del('event_overview');
variable_del('event_table_duration');
variable_del('event_taxonomy_control');
variable_del('event_type_control');
variable_del('event_range_prev');
variable_del('event_range_next');
foreach (node_get_types() as $type => $info) {
variable_del('event_nodeapi_' . $type);
}
drupal_set_message(t('Event module successfully uninstalled'));
}
function event_update_2() {
$result = db_query('SELECT * FROM {event} LIMIT 1');
if (db_num_rows($result) == 0) {
$ret = array();
db_query("DROP TABLE {event}");
event_install();
return $ret;
}
$fields = db_fetch_array($result);
switch ($GLOBALS['db_type']) {
case 'pgsql':
if (isset($fields['start'])) {
db_change_column($ret, 'event', 'start', 'event_start', 'int', array(
'not null' => TRUE,
'default' => 0,
));
db_change_column($ret, 'event', 'end', 'event_end', 'int', array(
'not null' => TRUE,
'default' => 0,
));
db_change_column($ret, 'event', 'tz', 'timezone', 'int', array(
'not null' => TRUE,
'default' => 0,
));
$ret[] = update_sql("DROP INDEX {event}_start_idx");
$ret[] = update_sql("CREATE INDEX {event}_event_start_idx ON {event}(event_start)");
}
db_change_column($ret, 'event', 'timezone', 'timezone', 'int', array(
'not null' => TRUE,
'default' => 0,
));
break;
case 'mysql':
case 'mysqli':
if (isset($fields['start'])) {
$ret[] = update_sql("ALTER TABLE {event} CHANGE start event_start int(10) unsigned NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {event} CHANGE end event_end int(10) unsigned NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {event} CHANGE tz timezone int(10) NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {event} DROP INDEX start");
$ret[] = update_sql("ALTER TABLE {event} ADD INDEX (event_start)");
}
$ret[] = update_sql("ALTER TABLE {event} CHANGE timezone timezone int(10) NOT NULL default '0'");
break;
}
return $ret;
}