summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebgeer2006-12-08 08:15:27 (GMT)
committer webgeer2006-12-08 08:15:27 (GMT)
commitb39ba2f25d6049e0a28c9c566be251c98ebf73c5 (patch)
tree168cfebe48bc532c147a424fb77dcdd9a9a97797
parentef66215677ddc9a5ff739674f4ffbfc7eef2fc0a (diff)
An install script (Finally!)
-rw-r--r--gmap_location.install85
1 files changed, 85 insertions, 0 deletions
diff --git a/gmap_location.install b/gmap_location.install
new file mode 100644
index 0000000..dc3edb0
--- /dev/null
+++ b/gmap_location.install
@@ -0,0 +1,85 @@
+<?php
+
+function gmap_location_install() {
+ drupal_set_message('Installing location');
+ switch ($GLOBALS['db_type']) {
+ case 'mysql':
+ case 'mysqli':
+ db_query("
+ CREATE TABLE {location} (
+ eid int unsigned NOT NULL default '0',
+ type varchar(6) NOT NULL default '',
+ name varchar(255) default NULL,
+ street varchar(255) default NULL,
+ additional varchar(255) default NULL,
+ city varchar(255) default NULL,
+ province varchar(16) default NULL,
+ postal_code varchar(16) default NULL,
+ country char(2) default NULL,
+ latitude decimal(10,6) default NULL,
+ longitude decimal(10,6) default NULL,
+ source tinyint default '0',
+ PRIMARY KEY (type,eid)
+ ) /*!40100 DEFAULT CHARACTER SET utf8 */;
+ ");
+
+ $success = TRUE;
+ break;
+ case 'pgsql':
+ db_query("CREATE TABLE {location} (
+ eid int NOT NULL default '0' CHECK (eid >= 0),
+ type varchar(6) NOT NULL default '',
+ name varchar(255) default NULL,
+ street varchar(255) default NULL,
+ additional varchar(255) default NULL,
+ city varchar(255) default NULL,
+ province varchar(16) default NULL,
+ postal_code varchar(16) default NULL,
+ country char(2) default NULL,
+ latitude decimal(10,6) default NULL,
+ longitude decimal(10,6) default NULL,
+ source smallint default '0',
+ PRIMARY KEY (type,eid)
+ )");
+
+ $success = TRUE;
+ break;
+ default:
+ break;
+ } // End case
+
+ if ($success) {
+ drupal_set_message(t('GMap module installed location tables successfully.'));
+ }
+ else {
+ drupal_set_message(t('The installation of GMap module was unsuccessful.'), 'error');
+ }
+}
+
+function gmap_location_update_1() {
+ return _system_update_utf8(array('location'));
+}
+
+function gmap_location_update_2() {
+ $ret = array();
+
+ switch ($GLOBALS['db_type']) {
+ case 'mysql':
+ case 'mysqli':
+ $ret[] = update_sql("ALTER TABLE {location} CHANGE oid eid int unsigned NOT NULL default '0'");
+ break;
+ }
+
+ drupal_set_message("The schema for gmap module (location table) has been updated. The update is such that you may want to re-resave any views you have that may include locations.");
+
+ if(function_exists('views_invalidate_cache')) {
+ views_invalidate_cache();
+ }
+
+ return $ret;
+}
+
+/***************************************************************
+ PostgreSQL must be supported in all updates after this comment
+ ***************************************************************/
+