Inactive developer 'profi-concept' moved to inactive section
[mailer.git] / inc / extensions / ext-grade.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 11/24/2009 *
4  * ===================                          Last change: 11/24/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-grade.php                                    *
8  * -------------------------------------------------------------------- *
9  * Short description : Grades for your members                          *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Einstufungen Ihrer 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                 // General and grade level data
55                 addDropTableSql('grade_data');
56                 addCreateTableSql('grade_data', "(
57 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
58 `grade_name` VARCHAR(255) NOT NULL DEFAULT '',
59 `grade_parent_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
60 PRIMARY KEY (`id`),
61 INDEX (`grade_parent_id`)
62 ) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Grade general data'");
63
64                 // Data for if a grade level has been reached
65                 addDropTableSql('grade_cash_data');
66                 addCreateTableSql('grade_cash_data', "(
67 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
68 `grade_cash_name` VARCHAR(255) NOT NULL DEFAULT '',
69 `grade_cash_type` ENUM('DISCOUNT','BONUS') NOT NULL DEFAULT 'DISCOUNT',
70 `reached_points` FLOAT(20,5) UNSIGNED NULL DEFAULT NULL,
71 `reached_mails` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
72 `time_valid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
73 PRIMARY KEY (`id`),
74 ) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Grade data if the grade have been \"cashed\"'");
75
76                 // Connection grade<->cash data
77                 addDropTableSql('grade_cash_connect');
78                 addCreateTableSql('grade_cash_conenct', "(
79 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
80 `grade_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
81 `grade_cash_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
82 PRIMARY KEY (`id`),
83 UNIQUE KEY `grade_cash` (`grade_id`,`grade_cash_id`),
84 INDEX (`grade_cash_id`)
85 ) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Grade<->cash data connection'");
86
87                 // Connection grade<->user data
88                 addDropTableSql('grade_user_connect');
89                 addCreateTableSql('grade_user_connect', "(
90 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
91 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
92 `grade_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
93 `grade_expired TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
94 PRIMARY KEY (`id`),
95 UNIQUE KEY (`userid`,`grade_id`),
96 INDEX (`grade_id`)
97 ) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Grade<->user connection'");
98                 break;
99
100         case 'remove': // Do stuff when removing extension
101                 // SQL commands to run
102                 addDropTableSql('grade_data');
103                 addDropTableSql('grade_cash_data');
104                 addDropTableSql('grade_cash_connect');
105                 addDropTableSql('grade_user_connect');
106                 break;
107
108         case 'activate': // Do stuff when admin activates this extension
109                 // SQL commands to run
110                 break;
111
112         case 'deactivate': // Do stuff when admin deactivates this extension
113                 // SQL commands to run
114                 break;
115
116         case 'update': // Update an extension
117                 switch (getCurrentExtensionVersion()) {
118                         case '0.0.1': // SQL queries for v0.0.1
119                                 addExtensionSql('');
120
121                                 // Update notes (these will be set as task text!)
122                                 setExtensionUpdateNotes('');
123                                 break;
124                 } // END - switch
125                 break;
126
127         case 'modify': // When the extension got modified
128                 break;
129
130         case 'test': // For testing purposes
131                 break;
132
133         case 'init': // Do stuff when extension is initialized
134                 break;
135
136         default: // Unknown extension mode
137                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
138                 break;
139 } // END - switch
140
141 // [EOF]
142 ?>