2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 08/19/2010 *
4 * =================== Last change: 08/19/2010 *
6 * -------------------------------------------------------------------- *
7 * File : ext-funcoins.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Extension for the FunCoins API integration *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Erweiterung fuer die Integration der *
12 * FunCoins-API (FoCo-Ex²) *
13 * -------------------------------------------------------------------- *
16 * $Tag:: 0.2.1-FINAL $ *
18 * -------------------------------------------------------------------- *
19 * Copyright (c) 2003 - 2009 by Roland Haeder *
20 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
21 * For more information visit: http://mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
45 setThisExtensionVersion('0.0.0');
47 // Version history array (add more with , '0.0.1' and so on)
48 setExtensionVersionHistory(array('0.0.0'));
50 // This extension is in development (non-productive)
51 enableExtensionProductive(false);
53 switch (getExtensionMode()) {
54 case 'register': // Do stuff when installation is running
55 // This depends on ext-sql_patches
56 addExtensionDependency('sql_patches');
58 // SQL commands to run
59 addDropTableSql('user_funcoins');
60 addCreateTableSql('user_funcoins', "
61 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Record identification',
62 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Local userid',
63 `funcoins_account` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'FunCoins account',
64 `funcoins_amount` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000 COMMENT 'Transfered amount',
65 `funcoins_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Booking timestamp',
66 `funcoins_type` ENUM('WITHDRAW','PAYOUT','FAILED') NOT NULL DEFAULT 'FAILED' COMMENT 'Transaction type',
67 `funcoins_tan` VARCHAR(255) NULL DEFAULT NULL COMMENT 'TAN from API',
68 `funcoins_api_response` TINYTEXT COMMENT 'Clear text API response (only for debugging)',
69 `funcoins_api_status` INT(4) NULL DEFAULT NULL COMMENT 'Status code from API',
71 UNIQUE (`funcoins_tan`),
73 'Transfered FunCoins per user');
76 addConfigAddSql('funcoins_min_payout', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 40000');
77 addConfigAddSql('funcoins_min_withdraw', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 5000');
78 addConfigAddSql('funcoins_api_id', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
79 addConfigAddSql('funcoins_api_password', "VARCHAR(255) NOT NULL DEFAULT ''");
80 addConfigAddSql('funcoins_refid', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
81 addConfigAddSql('funcoins_payout_active', "ENUM ('Y','N') NOT NULL DEFAULT 'Y'");
82 addConfigAddSql('funcoins_withdraw_active', "ENUM ('Y','N') NOT NULL DEFAULT 'Y'");
83 addConfigAddSql('funcoins_payout_factor', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 1.00000');
84 addConfigAddSql('funcoins_withdraw_factor', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 1.00000');
85 addConfigAddSql('funcoins_payout_fee_percent', 'FLOAT(8,5) UNSIGNED NOT NULL DEFAULT 0.00000');
86 addConfigAddSql('funcoins_withdraw_fee_percent', 'FLOAT(8,5) UNSIGNED NOT NULL DEFAULT 0.00000');
87 addConfigAddSql('funcoins_payout_fee_fix', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
88 addConfigAddSql('funcoins_withdraw_fee_fix', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
91 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`,`column_name`,`locked_mode`,`payment_method`) VALUES ('funcoins_withdraw','order_points','LOCKED','DIRECT')");
94 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `funcoins_userid` BIGINT(20) NULL DEFAULT NULL");
97 addAdminMenuSql('funcoins', NULL, 'FunCoins-Management', 'Konfiguration zur FuCo-Ex² einstellen, Auszahlungen auflisten usw..', 15);
98 addAdminMenuSql('funcoins', 'config_funcoins', 'FuCo-Ex²-Einstellungen', 'Konfiguration zur FuCo-Ex² einstellen.', 1);
99 addAdminMenuSql('funcoins', 'list_funcoins', 'Anfragen auflisten', 'Listet alle FunCoins-Ein- und -Auszahlungsanfragen Ihrer Mitglieder und Sponsoren auf.', 2);
102 addMemberMenuSql('main', 'funcoins', 'FunCoins-Ein-/Auszahlungen', 11);
105 case 'remove': // Do stuff when removing extension
106 // SQL commands to run
107 addDropTableSql('user_funcoins');
108 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='funcoins'");
109 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='funcoins' LIMIT 1");
110 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `what`='funcoins_portal' LIMIT 1");
113 case 'activate': // Do stuff when admin activates this extension
114 // SQL commands to run
115 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y',`locked`='N' WHERE `what`='funcoins_portal' LIMIT 1");
116 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `what`='funcoins' LIMIT 1");
119 case 'deactivate': // Do stuff when admin deactivates this extension
120 // SQL commands to run
121 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='N',`locked`='Y' WHERE `what`='funcoins_portal' LIMIT 1");
122 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N',`locked`='Y' WHERE `what`='funcoins' LIMIT 1");
125 case 'update': // Update an extension
126 switch (getCurrentExtensionVersion()) {
127 case '0.0.1': // SQL queries for v0.0.1
130 // Update notes (these will be set as task text!)
131 setExtensionUpdateNotes('');
136 case 'modify': // When the extension got modified
139 case 'test': // For testing purposes
142 case 'init': // Do stuff when extension is initialized
144 $GLOBALS['funcoins_data'] = array();
147 default: // Unknown extension mode
148 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));