2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 11/24/2009 *
4 * =================== Last change: 11/24/2009 *
6 * -------------------------------------------------------------------- *
7 * File : ext-grade.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Grades for your members *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Einstufungen Ihrer 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://www.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
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,
61 INDEX (`grade_parent_id`)
62 ) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Grade general data'");
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,
74 ) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Grade data if the grade have been \"cashed\"'");
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,
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'");
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',
95 UNIQUE KEY (`userid`,`grade_id`),
97 ) TYPE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Grade<->user connection'");
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');
108 case 'activate': // Do stuff when admin activates this extension
109 // SQL commands to run
112 case 'deactivate': // Do stuff when admin deactivates this extension
113 // SQL commands to run
116 case 'update': // Update an extension
117 switch (getCurrentExtensionVersion()) {
118 case '0.0.1': // SQL queries for v0.0.1
121 // Update notes (these will be set as task text!)
122 setExtensionUpdateNotes('');
127 case 'modify': // When the extension got modified
130 case 'test': // For testing purposes
133 case 'init': // Do stuff when extension is initialized
136 default: // Unknown extension mode
137 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));