Comments fixed, ext-network continued, fix for mod stats:
[mailer.git] / inc / extensions / ext-yoomedia.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * $Revision::                                                        $ *
15  * $Date::                                                            $ *
16  * $Tag:: 0.2.1-FINAL                                                 $ *
17  * $Author::                                                          $ *
18  * Needs to be in all Files and every File needs "svn propset           *
19  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
20  * -------------------------------------------------------------------- *
21  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
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.                                  *
28  *                                                                      *
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.                         *
33  *                                                                      *
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,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42         die();
43 }
44
45 // Version number
46 setThisExtensionVersion('0.0');
47
48 // Version history array (add more with , '0.1.0' and so on)
49 setExtensionVersionHistory(array('0.0'));
50
51 // Keep this extension always active!
52 setExtensionAlwaysActive('Y');
53
54 // This extension is deprecated!
55 // @TODO Only deprecated when 'network' is ready! setExtensionDeprecated('Y');
56
57 switch (getExtensionMode()) {
58         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
59                 // SQL commands to run
60                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
61                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_sid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
62                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_passwd` VARCHAR(255) NOT NULL DEFAULT ''");
63                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_erotic_allowed` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0");
64                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_tm_max_reload` SMALLINT(6) UNSIGNED NOT NULL DEFAULT ".(24 * 8)."");
65                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_tm_min_wait` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 60");
66                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_tm_clicks_remain` INT(7) UNSIGNED NOT NULL DEFAULT 1000");
67                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_tm_min_pay` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
68                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_requests_total` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 200");
69                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_requests_remain` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 200");
70
71                 // Admin menu
72                 addAdminMenuSql('setup','config_yoomedia','Yoo!Media Interface 2.0','Einstellungen zum Yoo!Media Interface 2.0, wie Affiliate-Id, Interface-Passwort und vieles mehr.',17);
73                 addAdminMenuSql('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);
74
75                 // Reload lock table
76                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_yoomedia_reload`");
77                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_yoomedia_reload` (
78 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
79 `type` VARCHAR(255) NOT NULL DEFAULT 'general',
80 `y_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
81 `y_reload` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0,
82 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
83 PRIMARY KEY (`id`),
84 UNIQUE `y_type` (`type`,`y_id`)
85 ) TYPE={?_TABLE_TYPE?} COMMENT='Reload lock reminder for Yoo!Media campaigns'");
86                 break;
87
88         case 'remove': // Do stuff when removing extension
89                 // SQL commands to run
90                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('config_yoomedia','list_yoomedia_tm')");
91                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_yoomedia_reload`");
92                 break;
93
94         case 'activate': // Do stuff when admin activates this extension
95                 // SQL commands to run
96                 break;
97
98         case 'deactivate': // Do stuff when admin deactivates this extension
99                 // SQL commands to run
100                 break;
101
102         case 'update': // Update an extension
103                 switch (getCurrentExtensionVersion())
104                 {
105                         case '0.0.1': // SQL queries for v0.0.1
106                                 addExtensionSql('');
107
108                                 // Update notes (these will be set as task text!)
109                                 setExtensionUpdateNotes('');
110                                 break;
111                 }
112                 break;
113
114         case 'modify': // When the extension got modified
115                 break;
116
117         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
118                 break;
119
120         case 'init': // Do stuff when extension is initialized
121                 // The translation table
122                 // @TODO Can this be moved into a database table?
123                 $GLOBALS['translation_tables']['yoomedia'] = array(
124                         // Error messages
125                         'error_codes' => array(
126                                 1  => 'wrong_pass',
127                                 2  => 'wrong_sid',
128                                 3  => 'website_locked',
129                                 4  => 'api_data_error',
130                                 5  => 'requests_depleted',
131                                 6  => 'zero_result',
132                                 7  => 'no_campaigns_with_interface',
133                                 10 => 'incomplete_request'
134                         ),
135                         // For text mails
136                         'textmail' => array(
137                                 0 => 'id',
138                                 1 => 'name',
139                                 2 => 'reload',
140                                 3 => 'wait',
141                                 4 => 'remain',
142                                 5 => 'pay',
143                                 6 => 'text'
144                         )
145                 );
146                 break;
147
148         default: // Unknown extension mode
149                 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));
150                 break;
151 }
152
153 // [EOF]
154 ?>