Extension loader rewritten and no more needed cache elements removed
[mailer.git] / inc / extensions / ext-yoomedia.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 08/27/2008 *
4  * ================                             Last change: 08/27/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-yoomedia.php                                 *
8  * -------------------------------------------------------------------- *
9  * Short description : Extension for contacting the API of Yoo!Media    *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Erweitertung zur Anbindung an die API von        *
12  *                     Yoo!Media                                        *
13  * -------------------------------------------------------------------- *
14  *                                                                      *
15  * -------------------------------------------------------------------- *
16  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
17  * For more information visit: http://www.mxchange.org                  *
18  *                                                                      *
19  * This program is free software; you can redistribute it and/or modify *
20  * it under the terms of the GNU General Public License as published by *
21  * the Free Software Foundation; either version 2 of the License, or    *
22  * (at your option) any later version.                                  *
23  *                                                                      *
24  * This program is distributed in the hope that it will be useful,      *
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
27  * GNU General Public License for more details.                         *
28  *                                                                      *
29  * You should have received a copy of the GNU General Public License    *
30  * along with this program; if not, write to the Free Software          *
31  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
32  * MA  02110-1301  USA                                                  *
33  ************************************************************************/
34
35 // Some security stuff...
36 if (!defined('__SECURITY')) {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40
41 // Version number
42 $EXT_VERSION = "0.0";
43
44 // Auto-set extension version
45 if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;
46
47 // Version history array (add more with , "0.1" and so on)
48 $EXT_VER_HISTORY = array("0.0");
49
50 print "<pre>";
51 debug_print_backtrace();
52 print "<pre>";
53
54 switch ($EXT_LOAD_MODE)
55 {
56 case "register": // Do stuff when installation is running (modules.php?module=admin&action=login is called)
57         // SQL commands to run
58         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `yoomedia_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0";
59         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `yoomedia_sid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0";
60         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `yoomedia_passwd` VARCHAR(255) NOT NULL DEFAULT ''";
61         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `yoomedia_erotic_allowed` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0";
62         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `yoomedia_tm_max_reload` SMALLINT(6) UNSIGNED NOT NULL DEFAULT ".(24 * 8)."";
63         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `yoomedia_tm_min_wait` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 60";
64         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `yoomedia_tm_clicks_remain` INT(7) UNSIGNED NOT NULL DEFAULT 1000";
65         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `yoomedia_tm_min_pay` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000";
66         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `yoomedia_requests_total` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 200";
67         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `yoomedia_requests_remain` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 200";
68
69         // Admin menu
70         $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('setup','config_yoomedia','Yoo!Media Interface 2.0','Einstellungen zum Yoo!Media Interface 2.0, wie User-ID, Interface-Passwort und vieles mehr.',17)";
71         $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('email','list_yoomedia_tm','Yoo!Media Textmails','Listet Textmail-Buchungen &uuml;ber das Interface 2.0 von Yoo!Media nach Ihren eingestellten Kriterien auf. <strong>Vorsicht:</strong> Jede Aktualisierung dieser Liste kostet Ihnen eine Abfrage!',10)";
72
73         // Reload lock table
74         $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_yoomedia_reload`";
75         $SQLs[] = "CREATE TABLE `"._MYSQL_PREFIX."_yoomedia_reload` (
76 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
77 `type` VARCHAR(255) NOT NULL DEFAULT 'general',
78 `y_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
79 `y_reload` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0,
80 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
81 PRIMARY KEY (`id`),
82 UNIQUE `y_type` (`type`,`y_id`)
83 ) TYPE=MyISAM COMMENT='Reload lock reminder for Yoo!Media campaigns'";
84         break;
85
86 case "remove": // Do stuff when removing extension
87         // SQL commands to run
88         $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_admin_menu` WHERE `what` IN('config_yoomedia','list_yoomedia_tm') LIMIT 2";
89         $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_yoomedia_reload`";
90         break;
91
92 case "activate": // Do stuff when admin activates this extension
93         // SQL commands to run
94         break;
95
96 case "deactivate": // Do stuff when admin deactivates this extension
97         // SQL commands to run
98         break;
99
100 case "update": // Update an extension
101         switch ($EXT_VER)
102         {
103         case "0.0.1": // SQL queries for v0.0.1
104                 $SQLs[] = "";
105
106                 // Update notes (these will be set as task text!)
107                 $UPDATE_NOTES = "";
108                 break;
109         }
110         break;
111
112 default: // Do stuff when extension is loaded
113         // The translation table
114         $yoomediaTranslationTable = array(
115                 // Error messages
116                 'error_codes' => array(
117                         1  => 'wrong_pass',
118                         2  => 'wrong_sid',
119                         3  => 'website_locked',
120                         4  => 'api_data_error',
121                         5  => 'requests_depleted',
122                         6  => 'zero_result',
123                         10 => 'incomplete_request'
124                 ),
125                 // For text mails
126                 'textmail' => array(
127                         0 => 'id',
128                         1 => 'name',
129                         2 => 'reload',
130                         3 => 'wait',
131                         4 => 'remain',
132                         5 => 'pay',
133                         6 => 'text'
134                 )
135         );
136         break;
137 }
138
139 // Keep this extension always active!
140 $EXT_ALWAYS_ACTIVE = "Y";
141
142 //
143 ?>