8313a04b948ff272e1362d1f531e01ef69f945f1
[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                 // All required tables for this extension:
58                 // - Ads
59                 addDropTableSql('forced_ads');
60                 addCreateTableSql('forced_ads', "(
61 `forced_ads_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
62 `forced_ads_ad_url` VARCHAR( 255 ) NULL DEFAULT NULL ,
63 `forced_ads_click_url` VARCHAR( 255 ) NOT NULL ,
64 `forced_ads_width` SMALLINT( 3 ) UNSIGNED NULL DEFAULT NULL ,
65 `forced_ads_height` SMALLINT( 3 ) UNSIGNED NULL DEFAULT NULL ,
66 `forced_ads_alt_text` VARCHAR( 255 ) NULL DEFAULT NULL ,
67 `forced_ads_framebreaker` ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'Y',
68 `forced_ads_views_counter` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0,
69 `forced_ads_clicks_counter` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0,
70 `forced_ads_reload_lock` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0,
71 `forced_ads_min_stay` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0,
72 PRIMARY KEY ( `forced_ads_id` )
73 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Ads Data'");
74
75                 // - Campaigns
76                 addDropTableSql('forced_campaigns');
77                 addCreateTableSql('forced_campaigns', "(
78 `forced_campaign_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
79 `forced_campaign_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
80 `forced_campaign_status` ENUM( 'ACTIVE', 'PENDING', 'EXPIRED', 'LOCKED' ) NOT NULL DEFAULT 'PENDING',
81 `forced_campaign_lock_reason` VARCHAR( 255 ) NULL DEFAULT NULL ,
82 `forced_campaign_lock_timetstamp` TIMESTAMP NULL DEFAULT NULL ,
83 `forced_campaign_expired` TIMESTAMP NULL DEFAULT NULL ,
84 `forced_campaign_ordered_clicks` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT 0,
85 `forced_campaign_costs_api` FLOAT( 20 , 5 ) UNSIGNED NULL DEFAULT NULL,
86 `forced_campaign_price_api` FLOAT( 20 , 5 ) UNSIGNED NULL DEFAULT NULL,
87 `forced_costs_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL,
88 INDEX ( `forced_costs_id` ) ,
89 PRIMARY KEY ( `forced_campaign_id` )
90 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Campaign Data'");
91
92                 // - Campaigns <-> Ads
93                 addDropTableSql('forced_campaigns_ads');
94                 addCreateTableSql('forced_campaigns_ads', "(
95 `forced_campaign_ads_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
96 `forced_campaign_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
97 `forced_ads_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
98 UNIQUE `ads_campaign` ( `forced_campaign_id` , `forced_ads_id` ) ,
99 PRIMARY KEY ( `forced_campaign_ads_id` )
100 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Campaigns<->Ads'");
101
102                 // - Campaigns <-> User
103                 addDropTableSql('forced_campaigns_user');
104                 addCreateTableSql('forced_campaigns_user', "(
105 `forced_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
106 `forced_campaign_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
107 `forced_user_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
108 `forced_user_type` ENUM( 'MEMBER', 'SPONSOR', 'ADMIN', 'API' ) NULL DEFAULT NULL ,
109 UNIQUE `forced_campaign_user` ( `forced_campaign_id` , `forced_user_id` , `forced_user_type` ) ,
110 INDEX ( `forced_user_id` ) ,
111 PRIMARY KEY ( `forced_id` )
112 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Campaigns<->User'");
113
114                 // - Campaign costs
115                 addDropTableSql('forced_costs');
116                 addCreateTableSql('forced_costs', "(
117 `forced_costs_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
118 `forced_costs_price_click` FLOAT( 20, 5 ) UNSIGNED NULL DEFAULT NULL ,
119 `forced_costs_payment_click` FLOAT( 20, 5 ) UNSIGNED NULL DEFAULT NULL ,
120 `forced_costs_visibility` ENUM( 'MEMBER', 'SPONSOR', 'ALL', 'NONE' ) NOT NULL DEFAULT 'NONE',
121 PRIMARY KEY ( `forced_costs_id` )
122 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Campaign Costs'");
123
124                 // - Campaign Statistics
125                 addDropTableSql('forced_stats');
126                 addCreateTableSql('forced_stats', "(
127 `forced_stats_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
128 `forced_stats_campaign_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
129 `forced_stats_user_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL ,
130 `forced_stats_viewed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
131 `forced_stats_clicked` TIMESTAMP NULL DEFAULT NULL ,
132 `forced_stats_real_ip` VARCHAR( 15 ) NOT NULL DEFAULT '0.0.0.0' ,
133 `forced_stats_remote_addr` VARCHAR( 15 ) NOT NULL DEFAULT '0.0.0.0' ,
134 `forced_stats_ua` VARCHAR( 255 ) NULL DEFAULT NULL ,
135 `forced_stats_is_proxy` ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'N' ,
136 `forced_stats_session_id` VARCHAR( 100 ) NULL DEFAULT NULL ,
137 INDEX ( `forced_stats_campaign_id` ) ,
138 INDEX ( `forced_stats_user_id` ) ,
139 PRIMARY KEY ( `forced_stats_id` )
140 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Forced Campaign Statistics'");
141
142                 // Menu system
143                 // - Administrator
144                 addAdminMenuSql('forced',NULL,'Forced-Ads','Verwalten Sie hier bequem alle laufenden Forced-Banner und -Textlinks und deren Kampgnen. Sie k&ouml;nnen hier auch neue Werbmittel (Ads) hinzuf&uuml;gen oder laufende Forced-Kampagnen bei z.B. Regelverst&ouml;ssen sperren oder l&ouml;schen. Auch das natr&auml;gliche Editieren von Ads und Kampagnen ist jederzeit m&ouml;glich. Kampagnen dienen der einfacheren Verwaltung und der Trennung von dem Werbemittel selbst dienen. Sie brauchen also z.B. einen Forced-Banner nur einmal einf&uuml;gen und k&ouml;nnen dann bei Bedarf weitere Kampagnen starten.',5);
145                 addAdminMenuSql('forced','list_forced_ads','Werbemittel verwalten','Listet alle eingetragenen Werbmittel (Ads) auf. Sie k&ouml;nnen hier diese nachtr&auml;glich editieren falls Sie mal eine falsche URL eingegeben haben oder den Text &auml;ndern wollen. L&ouml;schen Sie hier auch Forced-Banner, die nicht mehr g&uuml;ltig sind (z.B. abgelaufen sind). Sollten doch mit dem Werbmittel verkn&uuml;pfte Kampagnen vorhanden sein, erhalten Sie einen Warnheis. Neue Werbmittel k&ouml;nnen Sie hier ebenfalls hinzuf&uuml;gen. Denken Sie aber daran, dass ohne Kampagne dieses nicht angezeigt wird. Achten Sie hier auch die Reload-Sperre.',1);
146                 addAdminMenuSql('forced','list_forced_campaigns','Kampagnen verwalten','Listet alle Kampagnen auf und zeigt deren Status an. Jederzeit k&ouml;nnen Sie Kampagnen stoppen, falls Sie dies w&uuml;nschen oder ein Regelverstoss vorliegt. Haben Sie ein Werbemittel hinzugef&uuml;gt, so f&uuml;gen Sie bitte unbedingt eine Kampagne hinzu, da es sonst nicht angezeigt wird.',2);
147                 addAdminMenuSql('forced','list_forced_costs','Kosten verwalten','Legen Sie die Preise pro Klick zum Buchen Forced-Werbemittel fest und wie viele {OPEN_CONFIG}POINTS{CLOSE_CONFIG} Ihre Mitglieder erhalten sollen. Generell sollten Sie bei Mitgliederbuchungen h&ouml;here Kosten pro Klick als was Ihre Mitglieder pro Klick erhalten einstellen, da so die {OPEN_CONFIG}POINTS{CLOSE_CONFIG} abgebaut werden (Sie k&ouml;nnen an Accountaufladungen z.B. verdienen).',3);
148                 addAdminMenuSql('forced','stats_forced','Statistiken','Zeigt Gesamtstatistiken und zu den einzelnen Kampagnen und Werbmitteln an. Die hier angezeigte Statistik kann jedoch nicht manuell gel&ouml;scht werden (bitte auch nicht selber tun) da sie auch gleichzeitigt als Reload-Sperre dient.',4);
149
150                 // - Members
151                 addMemberMenuSql('earn','forced_banner','Forced-Banner','Y','N',2);
152                 addMemberMenuSql('earn','forced_textlink','Forced-Textlinks','Y','N',3);
153                 break;
154
155         case 'remove': // Do stuff when removing extension
156                 // SQL commands to run
157                 addDropTableSql('forced_ads');
158                 addDropTableSql('forced_campaigns');
159                 addDropTableSql('forced_campaigns_ads');
160                 addDropTableSql('forced_campaigns_user');
161                 addDropTableSql('forced_costs');
162                 addDropTableSql('forced_stats');
163
164                 // Menu systems
165                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='forced' LIMIT 5");
166                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what` IN ('forced_banner','forced_textlink') LIMIT 2");
167                 break;
168
169         case 'activate': // Do stuff when admin activates this extension
170                 // SQL commands to run
171                 break;
172
173         case 'deactivate': // Do stuff when admin deactivates this extension
174                 // SQL commands to run
175                 break;
176
177         case 'update': // Update an extension
178                 switch (getCurrentExtensionVersion()) {
179                         case '0.0.1': // SQL queries for v0.0.1
180                                 addExtensionSql('');
181
182                                 // Update notes (these will be set as task text!)
183                                 setExtensionUpdateNotes('');
184                                 break;
185                 } // END - switch
186                 break;
187
188         case 'modify': // When the extension got modified
189                 break;
190
191         case 'test': // For testing purposes
192                 break;
193
194         case 'init': // Do stuff when extension is initialized
195                 break;
196
197         default: // Unknown extension mode
198                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
199                 break;
200 } // END - switch
201
202 // [EOF]
203 ?>