71cb125397bce3bd0b9867b0313e62e2761fdaeb
[mailer.git] / inc / extensions / ext-earning.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 08/02/2011 *
4  * ===================                          Last change: 08/02/2011 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-earning.php                                  *
8  * -------------------------------------------------------------------- *
9  * Short description : Extra earnings for members                       *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Zusatzverdienste fuer Mitglieder                 *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
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.                                  *
26  *                                                                      *
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.                         *
31  *                                                                      *
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,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Version number
44 setThisExtensionVersion('0.0.0');
45
46 // Version history array (add more with , '0.0.1' and so on)
47 setExtensionVersionHistory(array('0.0.0'));
48
49 // This extension is in development (non-productive)
50 enableExtensionProductive(FALSE);
51
52 switch (getExtensionMode()) {
53         case 'setup': // Do stuff when installation is running
54                 // Add member menu
55                 addMemberMenuSql('earn', 'earning', 'Zusatzverdienste', 2);
56
57                 // Admin menu
58                 addAdminMenuSql('setup', 'list_earning', 'Zusatzverdienste...', 'Veralten Sie hier bequem alle Zusatzverdienste (wie z.B. verg&uuml;tete PopUps usw.).', 6);
59
60                 // Earning data table
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');
70
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,
83 PRIMARY KEY (`id`),
84 UNIQUE INDEX `user_earning` (`earning_id`, `earning_userid`),
85 INDEX (`earning_userid`)",
86                         'User->Earning connections');
87
88                 // Register filter
89                 registerFilter(__FILE__, __LINE__, 'member_footer_extras', 'ADD_EARNING_GROUP_POPUP', FALSE, TRUE, isExtensionDryRun());
90                 break;
91
92         case 'remove': // Do stuff when removing extension
93                 // Drop tables
94                 addDropTableSql('earning_data');
95                 addDropTableSql('user_earning');
96
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");
100
101                 // Unregister filter
102                 unregisterFilter(__FILE__, __LINE__, 'member_footer_extras', 'ADD_EARNING_GROUP_POPUP', TRUE, isExtensionDryRun());
103                 break;
104
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");
108                 break;
109
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");
113                 break;
114
115         case 'update': // Update an extension
116                 switch (getCurrentExtensionVersion()) {
117                         case '0.0.1': // SQL queries for v0.0.1
118                                 addExtensionSql('');
119
120                                 // Update notes (these will be set as task text!)
121                                 setExtensionUpdateNotes('');
122                                 break;
123                 } // END - switch
124                 break;
125
126         case 'modify': // When the extension got modified
127                 break;
128
129         case 'test': // For testing purposes
130                 break;
131
132         case 'init': // Do stuff when extension is initialized
133                 break;
134
135         default: // Unknown extension mode
136                 reportBug(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
137                 break;
138 } // END - switch
139
140 // [EOF]
141 ?>