Introduced wrapper function addCreateTableSql(), fixed parameter order:
[mailer.git] / inc / extensions / ext-coupon.php
index eba4c347135aaf0699a7394573d30c3826aa6778..f173b2c4f8261f639cc7b1a02b017263d9675071 100644 (file)
@@ -53,13 +53,41 @@ enableExtensionProductive(false);
 
 switch (getExtensionMode()) {
        case 'register': // Do stuff when installtion is running (modules.php?module=admin&action=login is called)
-               // SQL commands to run
-               addExtensionSql('');
+               // Coupon data
+               addDropTableSql('coupons');
+               addCreateTableSql('coupons', "(
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`timestamp_created` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
+`timestamp_expired` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
+`coupon_type` ENUM('CODE','API') NOT NULL DEFAULT 'CODE',
+`coupon_code` VARCHAR(30) NULL DEFAULT NULL,
+`total_created` UNSIGNED BIGINT(20) NOT NULL DEFAULT 0,
+`total_used` UNSIGNED BIGINT(20) NOT NULL DEFAULT 0,
+`coupon_description` TEXT,
+PRIMARY KEY (`id`),
+UNIQUE KEY (`coupon_code`)
+) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Created coupons'");
+
+               // Coupon->user connection table
+               addDropTableSql('user_coupons');
+               addCreateTableSql('coupons', "(
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`coupon_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`userid` BIGINT(2) UNSIGNED NOT NULL DEFAULT 0,
+PRIMARY KEY (`id`),
+UNIQUE KEY `coupon_user` (`coupon_id`,`userid`)
+) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Coupon->user connection'");
+
+               // Configuration entries
+
+               // Admin menus
+               addAdminMenuSql('setup','config_coupon','Gutscheine','Allgemeine Einstellungen zu Code-Gutscheinen und Gutscheinen von Sponsoren (z.B. per API) können hier vorgenommen werden.', 15);
                break;
 
        case 'remove': // Do stuff when removing extension
                // SQL commands to run
-               addExtensionSql('');
+               addDropTableSql('coupons');
+               addDropTableSql('user_coupons');
                break;
 
        case 'activate': // Do stuff when admin activates this extension