Introduced wrapper function addCreateTableSql(), fixed parameter order:
[mailer.git] / inc / extensions / ext-transfer.php
index 0f168541df2e221b4dfe348884ba2d258ca9b72f..e5988f9d878ea39a22942f4e13f59ce83d77881d 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 10/07/2004 *
- * ================                             Last change: 07/08/2007 *
+ * Mailer v0.2.1-FINAL                                Start: 10/07/2004 *
+ * ===================                          Last change: 07/08/2007 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : ext-transfer.php                                 *
  * $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.2.9');
@@ -49,37 +48,35 @@ setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0
 
 switch (getExtensionMode()) {
        case 'register': // Do stuff when installation is running
-               // SQL commands to run
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_transfers_in`");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_transfers_out`");
-
                // Transfer from a member
-               addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_user_transfers_in` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-from_userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-reason VARCHAR(255) NOT NULL DEFAULT '',
-time_trans VARCHAR(14) NOT NULL DEFAULT 0,
-trans_id VARCHAR(12) NOT NULL DEFAULT '',
-KEY (userid),
-KEY (from_userid),
-PRIMARY KEY (id)
-) Type={?_TABLE_TYPE?}");
+               addDropTableSql('user_transfers_in');
+               addCreateTableSql('user_transfers_in', "(
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`from_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`reason` VARCHAR(255) NOT NULL DEFAULT '',
+`time_trans` VARCHAR(14) NOT NULL DEFAULT 0,
+`trans_id` VARCHAR(12) NOT NULL DEFAULT '',
+KEY (`userid`),
+KEY (`from_userid`),
+PRIMARY KEY (`id`)
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Ingoing points transfers'");
 
                // Transfers to a member
-               addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_user_transfers_out` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-to_userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-reason VARCHAR(255) NOT NULL DEFAULT '',
-time_trans VARCHAR(14) NOT NULL DEFAULT 0,
-trans_id VARCHAR(12) NOT NULL DEFAULT '',
-KEY (userid),
-KEY (to_userid),
-PRIMARY KEY (id)
-) Type={?_TABLE_TYPE?}");
+               addDropTableSql('user_transfers_out');
+               addCreateTableSql('user_transfers_out', "(
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`to_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`reason` VARCHAR(255) NOT NULL DEFAULT '',
+`time_trans` VARCHAR(14) NOT NULL DEFAULT 0,
+`trans_id` VARCHAR(12) NOT NULL DEFAULT '',
+KEY (`userid`),
+KEY (`to_userid`),
+PRIMARY KEY (`id`)
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Outgoing points transfers'");
 
                // Admin menu
                addAdminMenuSql('transfer', NULL, '{OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Transfer','Verwalten Sie hier die {OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Transaktionen zwischen Ihren Mitgliedern.', 7);
@@ -91,11 +88,11 @@ PRIMARY KEY (id)
                addMemberMenuSql('main','transfer','{OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Transfer','N','Y', 5);
 
                // Add config values
-               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD transfer_max BIGINT(20) UNSIGNED NOT NULL DEFAULT '50'");
-               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD transfer_age BIGINT(20) UNSIGNED NOT NULL DEFAULT '".(getConfig('ONE_DAY')*28)."'");
-               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD transfer_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT '".getConfig('ONE_DAY')."'");
-               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD transfer_balance BIGINT(20) UNSIGNED NOT NULL DEFAULT 100");
-               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD transfer_code BIGINT(20) UNSIGNED NOT NULL DEFAULT 5");
+               addConfigAddSql('transfer_max', "BIGINT(20) UNSIGNED NOT NULL DEFAULT 50");
+               addConfigAddSql('transfer_age', "BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getOneDay()*28));
+               addConfigAddSql('transfer_timeout', "BIGINT(20) UNSIGNED NOT NULL DEFAULT {?ONE_DAY?}");
+               addConfigAddSql('transfer_balance', "BIGINT(20) UNSIGNED NOT NULL DEFAULT 100");
+               addConfigAddSql('transfer_code', "BIGINT(20) UNSIGNED NOT NULL DEFAULT 5");
 
                // Add row(s) to user's data
                addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD opt_in ENUM('Y','N') NOT NULL DEFAULT 'N'");
@@ -103,8 +100,8 @@ PRIMARY KEY (id)
 
        case 'remove': // Do stuff when removing extension
                // SQL commands to run
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_transfers_in`");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_transfers_out`");
+               addDropTableSql('user_transfers_in');
+               addDropTableSql('user_transfers_out');
                addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='transfer'");
                addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='transfer'");
                addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` DROP `opt_in`");
@@ -124,7 +121,7 @@ PRIMARY KEY (id)
                switch (getCurrentExtensionVersion()) {
                        case '0.0.2': // SQL queries for v0.0.2
                                // Update notes (these will be set as task text!)
-                               setExtensionUpdateNotes("Fehler <div class=\"admin_failed\">Warning: Missing argument 2 for create_timestamp_from_selections() in {?PATH?}inc/libs/pro_functions.php on line 227</div> behoben.");
+                               setExtensionUpdateNotes("Fehler <div class=\"notice\">Warning: Missing argument 2 for create_timestamp_from_selections() in {?PATH?}inc/libs/pro_functions.php on line 227</div> behoben.");
                                break;
 
                        case '0.0.3': // SQL queries for v0.0.3
@@ -138,7 +135,7 @@ PRIMARY KEY (id)
                                break;
 
                        case '0.0.5': // SQL queries for v0.0.5
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD ap_transfer ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+                               addConfigAddSql('ap_transfer', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Link <em>Auflisten</em> im Admin-Bereich hatte das eingeloggte Mitglied und nicht den eingeloggten Admin abgefragt. Automatisches L&ouml;schen von veraltete Eintr&auml;gen kann unabh&auml;ngig von der autopurge-Erweiterung de-/aktiviert werden. Bitte aktualisieren Sie auch die beiden Admin-Templates!");
@@ -230,12 +227,12 @@ PRIMARY KEY (id)
                                break;
 
                        case '0.2.3': // SQL queries for v0.2.3
-                               addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (la_id, la_action, la_what) VALUES ('member', '', 'list_transfer')");
-                               addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (la_id, la_action, la_what) VALUES ('member', '', 'del_transfer')");
-                               addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (la_id, la_action, la_what) VALUES ('config', '', 'config_transfer')");
+                               addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (`la_id`, `la_action`, `la_what`) VALUES ('member', '', 'list_transfer')");
+                               addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (`la_id`, `la_action`, `la_what`) VALUES ('member', '', 'del_transfer')");
+                               addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (`la_id`, `la_action`, `la_what`) VALUES ('config', '', 'config_transfer')");
 
                                // Depends on sql_patches (or you have to execute these both SQL statements by phpMyAdmin
-                               addExtensionUpdateDependency('sql_patches');
+                               addExtensionDependency('sql_patches');
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Erweiterung in's neue Men&uuml;system integriert.");
@@ -278,7 +275,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': // When extension is initialized
@@ -289,7 +286,7 @@ PRIMARY KEY (id)
                break;
 
        default: // Unknown extension mode
-               DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));
+               logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
                break;
 }