<?php
// $Id: event.install,v 1.2.2.4 2006/05/22 13:35:07 killes Exp $ 

function event_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {event} (nid int(10) unsigned NOT NULL default '0',
                event_start int(10) unsigned NOT NULL default '0',
                event_end int(10) unsigned NOT NULL default '0',
                timezone int(10) NOT NULL default '0',
                PRIMARY KEY (nid),
                KEY event_start (event_start)
                ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {event} (
                nid int NOT NULL default '0',
                event_start int NOT NULL default '0',
                event_end int NOT NULL default '0',
                timezone int NOT NULL default '0',
                PRIMARY KEY (nid));");
      break;
  }

  // Enable basicevent by default
  db_query("UPDATE {system} SET status = 1 WHERE name = 'basicevent'");

  // Enable event view and location on basicevent
  variable_set('event_nodeapi_event', 'all');

  if (module_exist('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);
  }

  // Notify of changes
  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/settings/content-types/event'))));

}

function event_update_1() {
  return _system_update_utf8(array('event'));
}
