2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 08/02/2011 *
4 * =================== Last change: 08/02/2011 *
6 * -------------------------------------------------------------------- *
7 * File : ext-earning.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Extra earnings for members *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Zusatzverdienste fuer Mitglieder *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
44 setThisExtensionVersion('0.0.0');
46 // Version history array (add more with , '0.0.1' and so on)
47 setExtensionVersionHistory(array('0.0.0'));
49 // This extension is in development (non-productive)
50 enableExtensionProductive(false);
52 switch (getExtensionMode()) {
53 case 'register': // Do stuff when installation is running
55 addMemberMenuSql('earn', 'earning', 'Zusatzverdienste', 2);
58 addAdminMenuSql('setup', 'list_earning', 'Zusatzverdienste...', 'Veralten Sie hier bequem alle Zusatzverdienste (wie z.B. vergütete PopUps usw.).', 6);
61 addDropTableSql('earning_data');
62 addCreateTableSql('earning_data', "
63 `earning_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
64 `earning_group` VARCHAR(255) NOT NULL DEFAULT 'INVALID',
65 `earning_provider` VARCHAR(255) NOT NULL DEFAULT 'INVALID',
66 `earning_sorting` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
67 PRIMARY KEY (`earning_id`),
68 UNIQUE INDEX `earning_group_name` (`earning_group`,`earning_provider`)",
69 'Registered (extra) earnings');
71 // User->earnings connection table
72 addDropTableSql('user_earning');
73 addCreateTableSql('user_earning', "
74 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
75 `earning_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
76 `earning_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
77 `earning_active` ENUM('Y','N') NOT NULL DEFAULT 'Y',
78 `earning_added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
79 `earning_canceled` TIMESTAMP NULL DEFAULT NULL,
80 `earning_daily_amount` SMALLINT(7) NOT NULL DEFAULT 0,
81 `earning_current_amount` SMALLINT(7) NOT NULL DEFAULT 0,
82 `earning_points` FLOAT(20,5) NOT NULL DEFAULT 0.00000,
84 UNIQUE INDEX `user_earning` (`earning_id`,`earning_userid`),
85 INDEX (`earning_userid`)",
86 'User->Earning connections');
89 registerFilter('member_footer_extras', 'ADD_EARNING_GROUP_POPUP', false, true, isExtensionDryRun());
92 case 'remove': // Do stuff when removing extension
94 addDropTableSql('earning_data');
95 addDropTableSql('user_earning');
97 // Delete entries in menus
98 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='earning' LIMIT 1");
99 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='list_earning' LIMIT 1");
102 unregisterFilter(__FUNCTION__, __LINE__, 'member_footer_extras', 'ADD_EARNING_GROUP_POPUP', true, isExtensionDryRun());
105 case 'activate': // Do stuff when admin activates this extension
106 // SQL commands to run
107 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `what`='earning' LIMIT 1");
110 case 'deactivate': // Do stuff when admin deactivates this extension
111 // SQL commands to run
112 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N',`locked`='Y' WHERE `what`='earning' LIMIT 1");
115 case 'update': // Update an extension
116 switch (getCurrentExtensionVersion()) {
117 case '0.0.1': // SQL queries for v0.0.1
120 // Update notes (these will be set as task text!)
121 setExtensionUpdateNotes('');
126 case 'modify': // When the extension got modified
129 case 'test': // For testing purposes
132 case 'init': // Do stuff when extension is initialized
135 default: // Unknown extension mode
136 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));