]> git.mxchange.org Git - mailer.git/blob - inc/extensions/ext-earning.php
a4b61dddd433bdd5e7ea892d2e42a216d600ef60
[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 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.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 'register': // Do stuff when installation is running
54                 // Add member menu
55                 addMemberMenuSql('earn', 'earnings', 'Zusatzverdienste', 2);
56
57                 // Admin menu
58                 addAdminMenuSql('setup', 'list_earnings', '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_name` VARCHAR(255) NOT NULL DEFAULT 'INVALID',
66 `earning_sorting` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
67 PRIMARY KEY (`earning_id`),
68 UNIQUE `earning_group_name` (`earning_group`,`earning_name`)",
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_cancelled` TIMESTAMP NULL DEFAULT NULL,
80 `earning_daily_amount` SMALLINT(7) NOT NULL DEFAULT 0,
81 `earning_points` FLOAT(20,5) NOT NULL DEFAULT 0.00000,
82 PRIMARY KEY (`id`),
83 UNIQUE `user_earning` (`earning_id`,`earning_userid`),
84 INDEX (`earning_userid`)",
85                         'User->Earning connections');
86                 break;
87
88         case 'remove': // Do stuff when removing extension
89                 // Drop tables
90                 addDropTableSql('earning_data');
91                 addDropTableSql('user_earning');
92
93                 // Delete entries in menus
94                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='earnings' LIMIT 1");
95                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='list_earnings' LIMIT 1");
96                 break;
97
98         case 'activate': // Do stuff when admin activates this extension
99                 // SQL commands to run
100                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='earnings' LIMIT 1");
101                 break;
102
103         case 'deactivate': // Do stuff when admin deactivates this extension
104                 // SQL commands to run
105                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='earnings' LIMIT 1");
106                 break;
107
108         case 'update': // Update an extension
109                 switch (getCurrentExtensionVersion()) {
110                         case '0.0.1': // SQL queries for v0.0.1
111                                 addExtensionSql('');
112
113                                 // Update notes (these will be set as task text!)
114                                 setExtensionUpdateNotes('');
115                                 break;
116                 } // END - switch
117                 break;
118
119         case 'modify': // When the extension got modified
120                 break;
121
122         case 'test': // For testing purposes
123                 break;
124
125         case 'init': // Do stuff when extension is initialized
126                 break;
127
128         default: // Unknown extension mode
129                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
130                 break;
131 } // END - switch
132
133 // [EOF]
134 ?>