New wrapper functions introduced, some one-line parameter monsters killed:
[mailer.git] / inc / extensions / ext-forced.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 03/09/2010 *
4  * ===================                          Last change: 03/09/2010 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-forced.php                                   *
8  * -------------------------------------------------------------------- *
9  * Short description : Clickable forced banner or text links            *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Klickbare Forced-Banner oder -Textlinks          *
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');
45
46 // Version history array (add more with , '0.1.0' and so on)
47 setExtensionVersionHistory(array('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 (modules.php?module=admin is called)
54                 // This depends on 'sponsor' now
55                 addExtensionDependency('sponsor');
56
57                 // - Ads
58                 addDropTableSql('forced_ads');
59                 addExtensionSql("CREATE TABLE IF NOT EXIST `{?_MYSQL_PREFIX?}_forced_ads` (
60 `forced_ads_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
61 `forced_ads_ad_url` VARCHAR( 255 ) NULL DEFAULT NULL ,
62 `forced_ads_click_url` VARCHAR( 255 ) NOT NULL ,
63 `forced_ads_width` SMALLINT( 3 ) UNSIGNED NULL DEFAULT NULL ,
64 `forced_ads_height` SMALLINT( 3 ) UNSIGNED NULL DEFAULT NULL ,
65 `forced_ads_alt_text` VARCHAR( 255 ) NULL DEFAULT NULL ,
66 `forced_ads_framebreaker` ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'Y',
67 `forced_ads_views_counter` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0,
68 `forced_ads_clicks_counter` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0,
69 `forced_ads_reload_lock` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0,
70 `forced_ads_min_stay` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0,
71 PRIMARY KEY ( `forced_ads_id` )
72 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Ads Data'");
73
74                 // - Campaigns
75                 addDropTableSql('forced_campaigns');
76                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_forced_campaigns` (
77 `forced_campaign_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
78 `forced_campaign_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
79 `forced_campaign_status` ENUM( 'ACTIVE', 'PENDING', 'EXPIRED', 'LOCKED' ) NOT NULL DEFAULT 'PENDING',
80 `forced_campaign_lock_reason` VARCHAR( 255 ) NULL DEFAULT NULL ,
81 `forced_campaign_lock_timetstamp` TIMESTAMP NULL DEFAULT NULL ,
82 `forced_campaign_expired` TIMESTAMP NULL DEFAULT NULL ,
83 `forced_campaign_ordered_clicks` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0,
84 `forced_campaign_costs_api` FLOAT( 20 , 5 ) UNSIGNED NULL DEFAULT NULL,
85 `forced_campaign_price_api` FLOAT( 20 , 5 ) UNSIGNED NULL DEFAULT NULL,
86 `forced_costs_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL,
87 INDEX ( `forced_costs_id` ) ,
88 PRIMARY KEY ( `forced_campaign_id` )
89 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Campaign Data'");
90
91                 // - Campaigns <-> Ads
92                 addDropTableSql('forced_campaigns_ads');
93                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_forced_campaigns_ads` (
94 `forced_campaign_ads_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
95 `forced_campaign_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
96 `forced_ads_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
97 UNIQUE `ads_campaign` ( `forced_campaign_id` , `forced_ads_id` ) ,
98 PRIMARY KEY ( `forced_campaign_ads_id` )
99 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Campaigns<->Ads'");
100
101                 // - Campaigns <-> User
102                 addDropTableSql('forced_campaigns_user');
103                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_forced_campaigns_user` (
104 `forced_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
105 `forced_campaign_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
106 `forced_user_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
107 `forced_user_type` ENUM( 'MEMBER', 'SPONSOR', 'ADMIN', 'API' ) NULL DEFAULT NULL ,
108 UNIQUE `forced_campaign_user` ( `forced_campaign_id` , `forced_user_id` , `forced_user_type` ) ,
109 INDEX ( `forced_user_id` ) ,
110 PRIMARY KEY ( `forced_id` )
111 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Campaigns<->User'");
112
113                 // - Campaign costs
114                 addDropTableSql('forced_costs');
115                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_forced_costs` (
116 `forced_costs_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
117 `forced_costs_price_click` FLOAT( 20, 5 ) UNSIGNED NULL DEFAULT NULL ,
118 `forced_costs_payment_click` FLOAT( 20, 5 ) UNSIGNED NULL DEFAULT NULL ,
119 `forced_costs_visibility` ENUM( 'MEMBER', 'SPONSOR', 'ALL', 'NONE' ) NOT NULL DEFAULT 'NONE',
120 PRIMARY KEY ( `forced_costs_id` )
121 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Campaign Costs'");
122
123                 // - Campaign Statistics
124                 addDropTableSql('forced_stats');
125                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_forced_stats` (
126 `forced_stats_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
127 `forced_stats_campaign_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
128 `forced_stats_user_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
129 `forced_stats_viewed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
130 `forced_stats_clicked` TIMESTAMP NULL DEFAULT NULL ,
131 `forced_stats_real_ip` VARCHAR ( 15 ) NOT NULL DEFAULT '0.0.0.0' ,
132 `forced_stats_remote_addr` VARCHAR ( 15 ) NOT NULL DEFAULT '0.0.0.0' ,
133 `forced_stats_ua` VARCHAR ( 255 ) NULL DEFAULT NULL ,
134 `forced_stats_is_proxy` ENUM ( 'Y', 'N' ) NOT NULL DEFAULT 'N' ,
135 `forced_stats_session_id` VARCHAR ( 100 ) NULL DEFAULT NULL ,
136 INDEX ( `forced_stats_campaign_id` ) ,
137 INDEX ( `forced_stats_user_id` ) ,
138 PRIMARY KEY ( `forced_stats_id` )
139 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Campaign Statistics'");
140                 break;
141
142         case 'remove': // Do stuff when removing extension
143                 // SQL commands to run
144                 addDropTableSql('forced_ads');
145                 addDropTableSql('forced_campaigns');
146                 addDropTableSql('forced_campaigns_ads');
147                 addDropTableSql('forced_campaigns_user');
148                 addDropTableSql('forced_costs');
149                 addDropTableSql('forced_stats');
150                 break;
151
152         case 'activate': // Do stuff when admin activates this extension
153                 // SQL commands to run
154                 break;
155
156         case 'deactivate': // Do stuff when admin deactivates this extension
157                 // SQL commands to run
158                 break;
159
160         case 'update': // Update an extension
161                 switch (getCurrentExtensionVersion()) {
162                         case '0.0.1': // SQL queries for v0.0.1
163                                 addExtensionSql('');
164
165                                 // Update notes (these will be set as task text!)
166                                 setExtensionUpdateNotes('');
167                                 break;
168                 } // END - switch
169                 break;
170
171         case 'modify': // When the extension got modified
172                 break;
173
174         case 'test': // For testing purposes
175                 break;
176
177         case 'init': // Do stuff when extension is initialized
178                 break;
179
180         default: // Unknown extension mode
181                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
182                 break;
183 } // END - switch
184
185 // [EOF]
186 ?>