Marked some unfinished extensions as 'work-in-progress'
[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  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
23  * For more information visit: http://www.mxchange.org                  *
24  *                                                                      *
25  * This program is free software; you can redistribute it and/or modify *
26  * it under the terms of the GNU General Public License as published by *
27  * the Free Software Foundation; either version 2 of the License, or    *
28  * (at your option) any later version.                                  *
29  *                                                                      *
30  * This program is distributed in the hope that it will be useful,      *
31  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
32  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
33  * GNU General Public License for more details.                         *
34  *                                                                      *
35  * You should have received a copy of the GNU General Public License    *
36  * along with this program; if not, write to the Free Software          *
37  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
38  * MA  02110-1301  USA                                                  *
39  ************************************************************************/
40
41 // Some security stuff...
42 if (!defined('__SECURITY')) {
43         die();
44 }
45
46 // Version number
47 setThisExtensionVersion('0.0');
48
49 // Version history array (add more with , '0.1.0' and so on)
50 setExtensionVersionHistory(array('0.0'));
51
52 // Keep this extension always active!
53 setExtensionAlwaysActive('Y');
54
55 // This extension is deprecated!
56 // @TODO Only deprecated when 'network' is ready! setExtensionDeprecated('Y');
57
58 switch (getExtensionMode()) {
59         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
60                 // SQL commands to run
61                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
62                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_sid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
63                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_passwd` VARCHAR(255) NOT NULL DEFAULT ''");
64                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_erotic_allowed` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0");
65                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_tm_max_reload` SMALLINT(6) UNSIGNED NOT NULL DEFAULT ".(24 * 8)."");
66                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_tm_min_wait` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 60");
67                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_tm_clicks_remain` INT(7) UNSIGNED NOT NULL DEFAULT 1000");
68                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_tm_min_pay` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
69                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_requests_total` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 200");
70                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `yoomedia_requests_remain` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 200");
71
72                 // Admin menu
73                 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);
74                 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);
75
76                 // Reload lock table
77                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_yoomedia_reload`");
78                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_yoomedia_reload` (
79 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
80 `type` VARCHAR(255) NOT NULL DEFAULT 'general',
81 `y_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
82 `y_reload` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0,
83 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
84 PRIMARY KEY (`id`),
85 UNIQUE `y_type` (`type`,`y_id`)
86 ) TYPE={?_TABLE_TYPE?} COMMENT='Reload lock reminder for Yoo!Media campaigns'");
87                 break;
88
89         case 'remove': // Do stuff when removing extension
90                 // SQL commands to run
91                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('config_yoomedia','list_yoomedia_tm')");
92                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_yoomedia_reload`");
93                 break;
94
95         case 'activate': // Do stuff when admin activates this extension
96                 // SQL commands to run
97                 break;
98
99         case 'deactivate': // Do stuff when admin deactivates this extension
100                 // SQL commands to run
101                 break;
102
103         case 'update': // Update an extension
104                 switch (getCurrentExtensionVersion())
105                 {
106                         case '0.0.1': // SQL queries for v0.0.1
107                                 addExtensionSql('');
108
109                                 // Update notes (these will be set as task text!)
110                                 setExtensionUpdateNotes('');
111                                 break;
112                 }
113                 break;
114
115         case 'modify': // When the extension got modified
116                 break;
117
118         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
119                 break;
120
121         case 'init': // Do stuff when extension is initialized
122                 // The translation table
123                 // @TODO Can this be moved into a database table?
124                 $GLOBALS['translation_tables']['yoomedia'] = array(
125                         // Error messages
126                         'error_codes' => array(
127                                 1  => 'wrong_pass',
128                                 2  => 'wrong_sid',
129                                 3  => 'website_locked',
130                                 4  => 'api_data_error',
131                                 5  => 'requests_depleted',
132                                 6  => 'zero_result',
133                                 7  => 'no_campaigns_with_interface',
134                                 10 => 'incomplete_request'
135                         ),
136                         // For text mails
137                         'textmail' => array(
138                                 0 => 'id',
139                                 1 => 'name',
140                                 2 => 'reload',
141                                 3 => 'wait',
142                                 4 => 'remain',
143                                 5 => 'pay',
144                                 6 => 'text'
145                         )
146                 );
147                 break;
148
149         default: // Unknown extension mode
150                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
151                 break;
152 }
153
154 // [EOF]
155 ?>