]> git.mxchange.org Git - mailer.git/blobdiff - inc/extensions/ext-country.php
addCreateTableSql() is now more encapsulated
[mailer.git] / inc / extensions / ext-country.php
index c19e879b59257fafe4cac6f4774d3ceb9e857998..a8a8fe739294ff1da0fd5c1219d5d322cdb65b9e 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -43,24 +43,26 @@ if (!defined('__SECURITY')) {
 // Version number
 setThisExtensionVersion('0.0.4');
 
-// Version history array (add more with , '0.1.0' and so on)
-setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4'));
+// Version history array (add more with , '0.0.1' and so on)
+setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4'));
 
 // Keep this extension always active!
 setExtensionAlwaysActive('Y');
 
 switch (getExtensionMode()) {
-       case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
+       case 'register': // Do stuff when installation is running
                // SQL commands to run
-               addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_countries`');
-               addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_countries` (
+               addDropTableSql('countries');
+               addCreateTableSql('countries', "
 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 `code` CHAR(2) NOT NULL DEFAULT 'DE',
 `descr` VARCHAR(255) NOT NULL DEFAULT 'Deutschland',
 `is_active` ENUM('Y','N') NOT NULL DEFAULT 'N',
-KEY (`code`),
-PRIMARY KEY (`id`)
-) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci");
+PRIMARY KEY (`id`),
+UNIQUE KEY (`code`)",
+                       'Country codes and their full-length descriptions');
+
+               // Insert first (Germany) country
                addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_countries` (code, descr, is_active) VALUES ('DE','Deutschland','Y')");
 
                // Admin menu
@@ -73,7 +75,7 @@ PRIMARY KEY (`id`)
 
        case 'remove': // Do stuff when removing extension
                // SQL commands to run
-               addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_countries`');
+               addDropTableSql('countries');
                addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='country'");
                break;
 
@@ -115,7 +117,7 @@ PRIMARY KEY (`id`)
        case 'modify': // When the extension got modified
                break;
 
-       case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
+       case 'test': // For testing purposes
                break;
 
        case 'init': // Do stuff when extension is initialized