]> git.mxchange.org Git - mailer.git/blobdiff - inc/extensions/ext-coupon.php
Extension ext-coupon continued, naming convention, many improvements:
[mailer.git] / inc / extensions / ext-coupon.php
index 6d3671a88e8f2b2a729f907eead7b60f5d835622..7d8755c03bd148ef4230554c9d37a867ae401002 100644 (file)
@@ -52,13 +52,16 @@ setExtensionVersionHistory(array('0.0'));
 enableExtensionProductive(false);
 
 switch (getExtensionMode()) {
-       case 'register': // Do stuff when installtion is running (modules.php?module=admin&action=login is called)
+       case 'register': // Do stuff when installtion is running
+               // This extension requires an up-to-date user
+               addExtensionDependency('user');
+
                // Coupon data
                addDropTableSql('coupon_data');
                addCreateTableSql('coupon_data', "(
 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-`timestamp_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
-`timestamp_expired` TIMESTAMP NULL DEFAULT NULL,
+`coupon_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+`coupon_expired` TIMESTAMP NULL DEFAULT NULL,
 `coupon_type` ENUM('CODE','API') NOT NULL DEFAULT 'CODE',
 `total_created` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 `total_used` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
@@ -83,6 +86,11 @@ UNIQUE KEY (`coupon_code`)
                // Configuration entries
                addConfigAddSql('coupon_default_time', 'BIGINT(20) NOT NULL DEFAULT ' . (getOneDay() * 7));
                addConfigAddSql('coupon_default_points', 'FLOAT(20,5) NOT NULL DEFAULT 100.00000');
+               addConfigAddSql('coupon_points_account', "ENUM('ORDER','GENERAL') NOT NULL DEFAULT 'ORDER'");
+               addConfigAddSql('coupon_payment_method', "ENUM('DIRECT','REF') NOT NULL DEFAULT 'DIRECT'");
+               addConfigAddSql('coupon_locked_points_mode', "ENUM('LOCKED','UNLOCKED') NOT NULL DEFAULT 'LOCKED'");
+               addConfigAddSql('coupon_autopurge_time', 'BIGINT(20) NOT NULL DEFAULT ' . (getOneDay() * 7));
+               addConfigAddSql('coupon_userid', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
 
                // User data table
                addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `receiving_coupons` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
@@ -97,6 +105,9 @@ UNIQUE KEY (`coupon_code`)
                addMemberMenuSql('coupon', NULL, 'Gutscheine', 'N', 'Y', 3);
                addMemberMenuSql('coupon', 'cash_coupon', 'Gutschein einlösen', 'N', 'Y', 1);
                addMemberMenuSql('coupon', 'list_coupon', 'Eingelöste auflisten', 'N', 'Y', 2);
+
+               // Add filter (for changing user_points column dynamically
+               registerFilter('determine_points_column_name', 'COUPON_CHANGE_POINTS_COLUMN_NAME', false, true, isExtensionDryRun());
                break;
 
        case 'remove': // Do stuff when removing extension
@@ -105,6 +116,9 @@ UNIQUE KEY (`coupon_code`)
                addDropTableSql('user_coupons');
                addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='coupon' LIMIT 4");
                addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='coupon' LIMIT 3");
+
+               // Remove all filters
+               unregisterFilter(__FUNCTION__, __LINE__, 'determine_points_column_name', 'COUPON_CHANGE_POINTS_COLUMN_NAME', true, isExtensionDryRun());
                break;
 
        case 'activate': // Do stuff when admin activates this extension