Introduced wrapper function addCreateTableSql(), fixed parameter order:
[mailer.git] / inc / extensions / ext-bank.php
index 73b7551c1391f272913e2b48e87228c712ab1fcd..b3ac7785524d16e32c3c0fd3fedb5d010bf2be55 100644 (file)
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * 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 *
@@ -39,7 +38,7 @@
 // Some security stuff...
 if (!defined('__SECURITY')) {
        die();
-}
+} // END - if
 
 // Version number
 setThisExtensionVersion('0.0');
@@ -53,80 +52,80 @@ enableExtensionProductive(false);
 switch (getExtensionMode()) {
        case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
                // SQL commands to run
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_accounts`");
-               addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bank_accounts` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-account_created BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-account_locked BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-locked_reason TINYTEXT,
-status ENUM('NEW','ACTIVE','LOCKED') NOT NULL DEFAULT 'NEW',
-account_balance FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
-output_mode ENUM('LOGIN','EMAIL','DISABLED'),
-pin VARCHAR(50) NOT NULL DEFAULT '',
-tan_mode ENUM('NORMAL','INDEXED'),
-tan_list_status ENUM('PENDING','ACTIVE','INVALID','LOCKED') NOT NULL DEFAULT 'PENDING',
-tan_key VARCHAR(50) NOT NULL DEFAULT '',
-month_transfered BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-last_tan VARCHAR(5) NOT NULL DEFAULT '00000',
-last_tan_stamp BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-last_tan_purpose TINYTEXT,
-account_type ENUM('CHECK','SAVING') NOT NULL DEFAULT 'CHECK',
-overdraft_credit FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
-PRIMARY KEY (id),
-UNIQUE KEY (pin),
-INDEX `userid_type` (userid, account_type),
-INDEX (account_created),
-INDEX (account_locked),
-INDEX (last_tan_stamp)
-) TYPE={?_TABLE_TYPE?}");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_transfers`");
-               addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bank_transfers` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-to_account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-from_account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-points_amount FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
-day_bookkeeping CHAR(4) NOT NULL DEFAULT '0000',
-day_available CHAR(4) NOT NULL DEFAULT '0000',
-transfer_purpose TINYTEXT,
-PRIMARY KEY (id),
-INDEX (to_account_id, from_account_id),
-INDEX (day_bookkeeping, day_available)
-) TYPE={?_TABLE_TYPE?}");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_packages`");
-               addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bank_packages` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-title VARCHAR(255) NOT NULL DEFAULT '',
-description TINYTEXT,
-account_fee FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
-free_transfers INT(7) UNSIGNED NOT NULL DEFAULT 0,
-transfer_fee FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
-available TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
-output_system_mode ENUM('LOGIN','EMAIL','DISABLED'),
-package_active ENUM('Y','N') NOT NULL DEFAULT 'N',
-free_months_no_fee TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
-interest_plus FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.00000,
-interest_minus FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.00000,
-first_payment FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
-free_account_income FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
-free_account_stuff TINYTEXT null,
-tan_lock TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
-PRIMARY KEY (id)
-) TYPE={?_TABLE_TYPE?}");
-               // free_account_stuff will be a list of columns of the table _bank_packages
+               addDropTableSql('bank_accounts');
+               addCreateTableSql('bank_accounts', "(
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`account_created` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`account_locked` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`locked_reason` TINYTEXT,
+`status` ENUM('NEW','ACTIVE','LOCKED') NOT NULL DEFAULT 'NEW',
+`account_balance` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
+`output_mode` ENUM('LOGIN','EMAIL','DISABLED'),
+`pin` VARCHAR(50) NOT NULL DEFAULT '',
+`tan_mode` ENUM('NORMAL','INDEXED'),
+`tan_list_status` ENUM('PENDING','ACTIVE','INVALID','LOCKED') NOT NULL DEFAULT 'PENDING',
+`tan_key` VARCHAR(50) NOT NULL DEFAULT '',
+`month_transfered` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`last_tan` VARCHAR(5) NOT NULL DEFAULT '00000',
+`last_tan_stamp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`last_tan_purpose` TINYTEXT,
+`account_type` ENUM('CHECK','SAVING') NOT NULL DEFAULT 'CHECK',
+`overdraft_credit` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
+PRIMARY KEY (`id`),
+UNIQUE KEY (`pin`),
+INDEX `userid_type` (`userid`, `account_type`),
+INDEX (`account_created`),
+INDEX (`account_locked`),
+INDEX (`last_tan_stamp`)
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'User bank accounts data'");
+               addDropTableSql('bank_transfers');
+               addCreateTableSql('bank_transfers', "(
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`to_account_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`from_account_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`points_amount` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
+`day_bookkeeping` CHAR(4) NOT NULL DEFAULT '0000',
+`day_available` CHAR(4) NOT NULL DEFAULT '0000',
+`transfer_purpose` TINYTEXT,
+PRIMARY KEY (`id`),
+INDEX (`to_account_id`, `from_account_id`),
+INDEX (`day_bookkeeping`, `day_available`)
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Bank user->user transfers'");
+               addDropTableSql('bank_packages');
+               addCreateTableSql('bank_packages', "(
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`title` VARCHAR(255) NOT NULL DEFAULT '',
+`description` TINYTEXT,
+`account_fee` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
+`free_transfers` INT(7) UNSIGNED NOT NULL DEFAULT 0,
+`transfer_fee` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
+`available` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+`output_system_mode` ENUM('LOGIN','EMAIL','DISABLED'),
+`package_active` ENUM('Y','N') NOT NULL DEFAULT 'N',
+`free_months_no_fee` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
+`interest_plus` FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.00000,
+`interest_minus` FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.00000,
+`first_payment` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
+`free_account_income` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
+`free_account_stuff` TINYTEXT null,
+`tan_lock` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
+PRIMARY KEY (`id`)
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Bank account packages'");
+               // Free_account_stuff will be a list of columns of the table _bank_packages
                // what the member shall get for the specified income. output_system_mode
                // must be extended with the mode you get for free: output_system_mode:LOGIN
                // should be fine. More than one entry and not DISABLED ;) are not supported.
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_tanlist`");
-               addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bank_tanlist` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-idx TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
-account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-tan VARCHAR(50) NOT NULL DEFAULT '',
-used ENUM('Y','N') NOT NULL DEFAULT 'N',
-PRIMARY KEY (id),
-UNIQUE (account_id, tan)
-) TYPE={?_TABLE_TYPE?}");
+               addDropTableSql('bank_tanlist');
+               addCreateTableSql('bank_tanlist', "(
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`idx` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
+`account_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`tan` VARCHAR(50) NOT NULL DEFAULT '',
+`used` ENUM('Y','N') NOT NULL DEFAULT 'N',
+PRIMARY KEY (`id`),
+UNIQUE (`account_id`, `tan`)
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Bank TAN lists per user'");
 
                // Admin menu queries
                addAdminMenuSql('bank', NULL, 'Bank-Accounts','Verwalten Sie hier alle Bank-Accounts Ihrer Mitglieder, sowie Angebotspakete und Überweisungen.', 6);
@@ -157,10 +156,10 @@ UNIQUE (account_id, tan)
 
        case 'remove': // Do stuff when removing extension
                // SQL commands to run
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_accounts`");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_transfers`");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_packages`");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_tanlist`");
+               addDropTableSql('bank_accounts');
+               addDropTableSql('bank_transfers');
+               addDropTableSql('bank_packages');
+               addDropTableSql('bank_tanlist');
                addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='bank'");
                addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='bank'");
                break;
@@ -183,22 +182,22 @@ UNIQUE (account_id, tan)
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes('');
                                break;
-               }
+               } // END - switch
                break;
 
        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
                break;
 
        default: // Unknown extension mode
-               logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));
+               logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
                break;
-}
+} // END - switch
 
 // [EOF]
 ?>