2 /************************************************************************
3 * Mailer-Project 0.2.1-FINAL Start: 06/04/2004 *
4 * ========================== Last change: 08/08/2004 *
6 * -------------------------------------------------------------------- *
7 * File : ext-shop.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Shop system with referal and reseller programs *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Shop-System mit Referal- und Reseller-Programmen *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
17 * $Tag:: 0.2.1-FINAL $ *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
46 setThisExtensionVersion('0.0.0');
48 // Version history array (add more with , '0.1' and so on)
49 setExtensionVersionHistory(array('0.0.0'));
51 // This extension is in development (non-productive)
52 enableExtensionProductive(false);
54 switch (getExtensionMode()) {
55 case 'register': // Do stuff when installtion is running
57 addDropTableSql('shop_config');
58 addCreateTableSql('shop_config', "
59 `config` TINYINT(1) UNSIGNED NOT NULL AUTO_INCREMENT,
60 `allow_item_history` ENUM('Y','N') NOT NULL DEFAULT 'Y',
61 `allow_item_gallery` ENUM('Y','N') NOT NULL DEFAULT 'Y',
62 `allow_votes` ENUM('Y','N') NOT NULL DEFAULT 'Y',
63 `allow_vote_comments` ENUM('Y','N') NOT NULL DEFAULT 'Y',
64 `allow_save_search` ENUM('Y','N') NOT NULL DEFAULT 'Y',
65 `allow_points_system` ENUM('Y','N') NOT NULL DEFAULT 'Y',
66 `enable_reseller` ENUM('Y','N') NOT NULL DEFAULT 'Y',
67 `enable_search` ENUM('Y','N') NOT NULL DEFAULT 'Y',
68 `enable_member_preview` ENUM('Y','N') NOT NULL DEFAULT 'Y',
69 `shop_title` VARCHAR(255) NOT NULL DEFAULT '{?MAIN_TITLE?} Shop',
70 `points_ref` BIGINT(20) UNSIGNED NOT NULL DEFAULT '100',
71 `num_preview_guest` TINYINT(4) UNSIGNED NOT NULL DEFAULT '3',
72 `num_preview_member` TINYINT(4) UNSIGNED NOT NULL DEFAULT '3',
73 `show_links_num` ENUM('Y','N') NOT NULL DEFAULT 'Y',
74 PRIMARY KEY (`config`)",
75 'Shop configuration data');
77 addExtensionSql("INSERT INTO {?_MYSQL_PREFIX?}_shop_config (`config`) VALUES (0)");
79 addDropTableSql('shop_basket');
80 addCreateTableSql('shop_basket', "
81 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
82 `item_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
83 `customer_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
84 `guest_session` VARCHAR(32) NOT NULL DEFAULT '',
85 `amount` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
87 INDEX (`customer_id`),
91 addDropTableSql('shop_cats');
92 addCreateTableSql('shop_cats', "
93 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
94 `parent_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
95 `active` ENUM('Y','N') NOT NULL DEFAULT 'N',
96 `title` VARCHAR(255) NOT NULL DEFAULT '',
97 `short_descr` MEDIUMTEXT,
98 `long_descr` LONGTEXT,
99 `cat_icon` VARCHAR(255),
100 `counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
101 `show_links_num` ENUM('Y','N') NOT NULL DEFAULT 'Y',
104 'Shopping categories');
106 addDropTableSql('shop_items');
107 addCreateTableSql('shop_items', "
108 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
109 `catid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
110 `required_by` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
111 `suggested_by` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
112 `active` ENUM('Y','N') NOT NULL DEFAULT 'N',
113 `title` VARCHAR(255) NOT NULL DEFAULT '',
114 `version_no` VARCHAR(255) NOT NULL DEFAULT '',
115 `licence` VARCHAR(255) NOT NULL DEFAULT '',
116 `default_price` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
117 `short_descr` MEDIUMTEXT,
118 `long_descr` LONGTEXT,
119 `item_icon` VARCHAR(255) NOT NULL DEFAULT 0,
120 `item_created` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
121 `item_amount` BIGINT(20) UNSIGNED NOT NULL DEFAULT '-1',
122 `admin_created` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
123 `admin_unlock` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
124 `tax_type` VARCHAR(255) NOT NULL DEFAULT '',
125 `tax_rate` INT(3) UNSIGNED NOT NULL DEFAULT 0,
126 `counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
127 `point_costs` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
128 `point_earned` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
129 INDEX (`suggested_by`),
130 INDEX (`required_by`),
131 INDEX (`admin_unlock`),
132 INDEX (`admin_created`),
133 INDEX (`default_price`),
138 addDropTableSql('shop_item_gallery');
139 addCreateTableSql('shop_item_gallery', "
140 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
141 `item_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
142 `item_pic_url` VARCHAR(255) NOT NULL DEFAULT '',
143 `item_pic_descr` MEDIUMTEXT,
144 `is_private` ENUM('Y','N') NOT NULL DEFAULT 'N',
145 `counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
148 'Optional item gallery');
150 addDropTableSql('shop_item_votes');
151 addCreateTableSql('shop_item_votes', "
152 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
153 `item_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
154 `vote_value` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
157 'Votings on the items');
159 addDropTableSql('shop_customers');
160 addCreateTableSql('shop_customers', "
161 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
162 `reseller_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
163 `salut` ENUM('M','F') NOT NULL DEFAULT 'M',
164 `company` VARCHAR(255) NOT NULL DEFAULT '',
165 `surname` VARCHAR(255) NOT NULL DEFAULT '',
166 `family` VARCHAR(255) NOT NULL DEFAULT '',
167 `street_nr` VARCHAR(255) NOT NULL DEFAULT '',
168 `street_nr2` VARCHAR(255) NOT NULL DEFAULT '',
169 `zip` VARCHAR(7) NOT NULL DEFAULT '',
170 `city` VARCHAR(255) NOT NULL DEFAULT '',
171 `country` VARCHAR(2) NOT NULL DEFAULT 'DE',
172 `email` VARCHAR(255) NOT NULL DEFAULT '',
173 `phone` VARCHAR(255) NOT NULL DEFAULT '',
174 `fax` VARCHAR(255) NOT NULL DEFAULT '',
175 `b_surname` VARCHAR(255) NOT NULL DEFAULT '',
176 `b_family` VARCHAR(255) NOT NULL DEFAULT '',
177 `b_street_nr` VARCHAR(255) NOT NULL DEFAULT '',
178 `b_street_nr2` VARCHAR(255) NOT NULL DEFAULT '',
179 `b_zip` VARCHAR(7) NOT NULL DEFAULT '',
180 `b_city` VARCHAR(255) NOT NULL DEFAULT '',
181 `b_country` VARCHAR(2) NOT NULL DEFAULT 'DE',
182 `b_email` VARCHAR(255) NOT NULL DEFAULT '',
183 `b_phone` VARCHAR(255) NOT NULL DEFAULT '',
184 `b_fax` VARCHAR(255) NOT NULL DEFAULT '',
185 `joined` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
186 `updated` TIMESTAMP NULL DEFAULT NULL,
187 `status` ENUM('UNCONFIRMED','CONFIRMED','LOCKED') NOT NULL DEFAULT 'UNCONFIRMED',
188 `unlock_key` VARCHAR(255) NULL NULL,
189 `points_amount` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
190 INDEX (`reseller_id`),
191 UNIQUE KEY (`unlock_key`),
193 'Shop customer data');
195 addDropTableSql('shop_resellers');
196 addCreateTableSql('shop_resellers', "
197 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
198 `reseller_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
199 `salut` ENUM('M','F') NOT NULL DEFAULT 'M',
200 `company` VARCHAR(255) NOT NULL DEFAULT '',
201 `surname` VARCHAR(255) NOT NULL DEFAULT '',
202 `family` VARCHAR(255) NOT NULL DEFAULT '',
203 `street_nr` VARCHAR(255) NOT NULL DEFAULT '',
204 `street_nr2` VARCHAR(255) NOT NULL DEFAULT '',
205 `zip` VARCHAR(7) NOT NULL DEFAULT '',
206 `city` VARCHAR(255) NOT NULL DEFAULT '',
207 `country` VARCHAR(2) NOT NULL DEFAULT 'DE',
208 `email` VARCHAR(255) NOT NULL DEFAULT '',
209 `phone` VARCHAR(255) NOT NULL DEFAULT '',
210 `fax` VARCHAR(255) NOT NULL DEFAULT '',
211 `joined` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
212 `updated` TIMESTAMP NULL DEFAULT NULL,
213 `status` ENUM('UNCONFIRMED','CONFIRMED','LOCKED') NOT NULL DEFAULT 'UNCONFIRMED',
214 `unlock_key` VARCHAR(255) NULL NULL,
215 INDEX (`reseller_id`),
216 UNIQUE KEY (`unlock_key`),
218 'Shop reseller data');
220 addDropTableSql('shop_saved_searches');
221 addCreateTableSql('shop_saved_searches', "
222 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
223 `customer_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
224 `reseller_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
225 `timestamp` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
226 `catid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
227 `search_words` VARCHAR(255) NOT NULL DEFAULT '',
229 INDEX (`customer_id`),
230 INDEX (`reseller_id`),
232 'Saved shop searched for customers and resellers');
234 addDropTableSql('shop_price_types');
235 addCreateTableSql('shop_price_types', "
236 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
237 `price_type` VARCHAR(255) NOT NULL DEFAULT '',
238 `rate` FLOAT (20,5) NOT NULL DEFAULT '0.0000',
242 // Add admin menu system
243 addAdminMenuSql('shop', NULL, 'Shop-Verwaltung', 'Stellen Sie hier alles am Shop-System ein. Hier können Sie auch die Kunden verwalten.', '6');
244 addAdminMenuSql('shop', 'config_shop', 'Shop-Einstellungen', 'Allgemeine Einstellungen zum Shop.', 1);
245 addAdminMenuSql('shop', 'add_shop_cat', 'Warenkategorien hinzufügen', 'Neue Warenkategorien hinzufügen.', 2);
246 addAdminMenuSql('shop', 'edit_shop_cat', 'Warenkategorien ändern', 'Bestehende Warenkategorien ändern.', 3);
247 addAdminMenuSql('shop', 'add_shop_items', 'Neue Ware hinzufügen', 'Neue Waren in die Warenkategorien einsortieren.', 5);
248 addAdminMenuSql('shop', 'edit_shop_items', 'Ware ändern', 'Bestehende Ware ändern oder verschieben.', 6);
249 addAdminMenuSql('shop', 'add_shop_ptypes', 'Buchungspaket hinzufügen', 'Fügen Sie eine Bezahlungalternative zum direkten Geld hinzu. Beispiele: Klammlose, MyPoints, Wedis, usw.', 8);
250 addAdminMenuSql('shop', 'edit_shop_ptypes', 'Buchungspaket ändern', 'Bestehende Buchungspakete ändern.', 9);
251 addAdminMenuSql('shop', 'import_shop_ptyes', 'Import Buchungspakete', 'Importieren Sie bei installierter payout-Erweiterung die bestehenden Auszahlungsarten als Buchungspakete! Banner-Auszahlungsarten werden dabei ignoriert.', 11);
253 // Add guest and member menu entries (just redirects)
254 addGuestMenuSql('main', 'shop', 'Zum Shop...', 'Y', 'Y', 7);
255 addMemberMenuSql('main', 'shop', 'Zum Shop...', 'Y', 'Y', 7);
258 case 'remove': // Do stuff when removing extension
259 // SQL commands to run
260 addDropTableSql('shop_basket');
261 addDropTableSql('shop_config');
262 addDropTableSql('shop_cats');
263 addDropTableSql('shop_items');
264 addDropTableSql('shop_item_gallery');
265 addDropTableSql('shop_item_votes');
266 addDropTableSql('shop_saved_searches');
267 addDropTableSql('shop_customers');
268 addDropTableSql('shop_resellers');
269 addDropTableSql('shop_price_types');
271 // Admin / guest / member menu
272 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='shop' LIMIT 12");
273 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `what`='shop' LIMIT 1");
274 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='shop' LIMIT 1");
277 case 'activate': // Do stuff when admin activates this extension
278 // SQL commands to run
279 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y', `locked`='N' WHERE `what`='shop' LIMIT 1");
280 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='shop' LIMIT 1");
283 case 'deactivate': // Do stuff when admin deactivates this extension
284 // SQL commands to run
285 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y', `locked`='Y' WHERE `what`='shop' LIMIT 1");
286 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='Y' WHERE `what`='shop' LIMIT 1");
289 case 'update': // Update an extension
290 switch (getCurrentExtensionVersion()) {
291 case '0.0.1': // SQL queries for v0.0.1
294 // Update notes (these will be set as task text!)
295 setExtensionUpdateNotes('');
300 case 'modify': // When the extension got modified
303 case 'test': // For testing purposes
306 case 'init': // Do stuff when extension is initialized
309 default: // Unknown extension mode
310 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));