]> git.mxchange.org Git - mailer.git/blobdiff - inc/extensions/ext-funcoins.php
These are all handlers
[mailer.git] / inc / extensions / ext-funcoins.php
index 6a548003ab4b8a398021d71a2af1206b844c5013..bf544b460244e5a18b0b81dacb419bbd9099cf27 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * Mailer v0.2.1-FINAL                                Start: 19/08/2010 *
- * ===================                          Last change: 19/08/2010 *
+ * Mailer v0.2.1-FINAL                                Start: 08/19/2010 *
+ * ===================                          Last change: 08/19/2010 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : ext-funcoins.php                                 *
@@ -9,7 +9,7 @@
  * Short description : Extension for the FunCoins API integration       *
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Erweiterung fuer die Integration der             *
- *                     FunCoins-API (                                   *
+ *                     FunCoins-API (FoCo-Ex&#178;)                          *
  * -------------------------------------------------------------------- *
  * $Revision::                                                        $ *
  * $Date::                                                            $ *
@@ -18,7 +18,7 @@
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
- * For more information visit: http://www.mxchange.org                  *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -52,19 +52,74 @@ enableExtensionProductive(false);
 
 switch (getExtensionMode()) {
        case 'register': // Do stuff when installation is running
+               // This depends on ext-sql_patches
+               addExtensionDependency('sql_patches');
+
                // SQL commands to run
+               addDropTableSql('user_funcoins');
+               addCreateTableSql('user_funcoins', "
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Record identification',
+`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Local userid',
+`funcoins_account` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'FunCoins account',
+`funcoins_amount` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000 COMMENT 'Transfered amount',
+`funcoins_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Booking timestamp',
+`funcoins_type` ENUM('WITHDRAW','PAYOUT','FAILED') NOT NULL DEFAULT 'FAILED' COMMENT 'Transaction type',
+`funcoins_tan` VARCHAR(255) NULL DEFAULT NULL COMMENT 'TAN from API',
+`funcoins_api_response` TINYTEXT COMMENT 'Clear text API response (only for debugging)',
+`funcoins_api_status` INT(4) NULL DEFAULT NULL COMMENT 'Status code from API',
+PRIMARY KEY (`id`),
+UNIQUE (`funcoins_tan`),
+INDEX (`userid`)",
+                       'Transfered FunCoins per user');
+
+               // Confiuration
+               addConfigAddSql('funcoins_min_payout', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 40000');
+               addConfigAddSql('funcoins_min_withdraw', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 5000');
+               addConfigAddSql('funcoins_api_id', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+               addConfigAddSql('funcoins_api_password', "VARCHAR(255) NOT NULL DEFAULT ''");
+               addConfigAddSql('funcoins_refid', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+               addConfigAddSql('funcoins_payout_active', "ENUM ('Y','N') NOT NULL DEFAULT 'Y'");
+               addConfigAddSql('funcoins_withdraw_active', "ENUM ('Y','N') NOT NULL DEFAULT 'Y'");
+               addConfigAddSql('funcoins_payout_factor', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 1.00000');
+               addConfigAddSql('funcoins_withdraw_factor', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 1.00000');
+               addConfigAddSql('funcoins_payout_fee_percent', 'FLOAT(8,5) UNSIGNED NOT NULL DEFAULT 0.00000');
+               addConfigAddSql('funcoins_withdraw_fee_percent', 'FLOAT(8,5) UNSIGNED NOT NULL DEFAULT 0.00000');
+               addConfigAddSql('funcoins_payout_fee_fix', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+               addConfigAddSql('funcoins_withdraw_fee_fix', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+
+               // Points data
+               addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`,`column_name`,`locked_mode`,`payment_method`) VALUES ('funcoins_withdraw','order_points','LOCKED','DIRECT')");
+
+               // User data
+               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `funcoins_userid` BIGINT(20) NULL DEFAULT NULL");
+
+               // Admin menu
+               addAdminMenuSql('funcoins', NULL, 'FunCoins-Management', 'Konfiguration zur FuCo-Ex&#178; einstellen, Auszahlungen auflisten usw..', 15);
+               addAdminMenuSql('funcoins', 'config_funcoins', 'FuCo-Ex&#178;-Einstellungen', 'Konfiguration zur FuCo-Ex&#178; einstellen.', 1);
+               addAdminMenuSql('funcoins', 'list_funcoins', 'Anfragen auflisten', 'Listet alle FunCoins-Ein- und -Auszahlungsanfragen Ihrer Mitglieder und Sponsoren auf.', 2);
+
+               // Member menu
+               addMemberMenuSql('main', 'funcoins', 'FunCoins-Ein-/Auszahlungen', 11);
                break;
 
        case 'remove': // Do stuff when removing extension
                // SQL commands to run
+               addDropTableSql('user_funcoins');
+               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='funcoins'");
+               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='funcoins' LIMIT 1");
+               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `what`='funcoins_portal' LIMIT 1");
                break;
 
        case 'activate': // Do stuff when admin activates this extension
                // SQL commands to run
+               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y',`locked`='N' WHERE `what`='funcoins_portal' LIMIT 1");
+               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `what`='funcoins' LIMIT 1");
                break;
 
        case 'deactivate': // Do stuff when admin deactivates this extension
                // SQL commands to run
+               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='N',`locked`='Y' WHERE `what`='funcoins_portal' LIMIT 1");
+               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N',`locked`='Y' WHERE `what`='funcoins' LIMIT 1");
                break;
 
        case 'update': // Update an extension
@@ -85,6 +140,8 @@ switch (getExtensionMode()) {
                break;
 
        case 'init': // Do stuff when extension is initialized
+               // Init array
+               $GLOBALS['funcoins_data'] = array();
                break;
 
        default: // Unknown extension mode