Updated copyright notice as there are changes in this year
[mailer.git] / inc / extensions / ext-newsletter.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 02/26/2005 *
4  * ===================                          Last change: 02/26/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-newsletter.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : Extension for sending newsletters                *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Erweiterung zum Versenden von Newslettern        *
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 - 2013 by Mailer Developer Team                   *
20  * For more information visit: http://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.2.0');
45
46 // Version history array (add more with , '0.0.1' and so on)
47 setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.2.0'));
48
49 // This extension is in development (non-productive)
50 enableExtensionProductive(FALSE);
51
52 switch (getExtensionMode()) {
53         case 'setup': // Do stuff when installation is running
54                 // SQL commands to run
55                 addExtensionSql('');
56                 break;
57
58         case 'remove': // Do stuff when removing extension
59                 // SQL commands to run
60                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='newsletter'");
61                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='newsletter'");
62                 addDropTableSql('newsletter_data');
63                 addDropTableSql('newsletter_topics');
64                 addDropTableSql('newsletter_orders');
65                 break;
66
67         case 'activate': // Do stuff when admin activates this extension
68                 break;
69
70         case 'deactivate': // Do stuff when admin deactivates this extension
71                 break;
72
73         case 'update': // Update an extension
74                 switch (getCurrentExtensionVersion()) {
75                         case '0.0.1': // SQL queries for v0.0.1
76                                 addAdminMenuSql('newsletter', NULL, 'Newsletter','Einstellungen am Newsletter, Newsletter versenden, usw.', 3);
77                                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN ('newsletter','config_newsletter') LIMIT 1");
78                                 addExtensionAddTableColumnSql('user_data', 'nl_receive', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
79
80                                 // Update notes (these will be set as task text!)
81                                 setExtensionUpdateNotes('Men&uuml;punkte hinzuf&uuml;gen und Mitgliedereinstellung.');
82                                 break;
83
84                         case '0.0.2': // SQL queries for v0.0.2
85                                 // Update notes (these will be set as task text!)
86                                 setExtensionUpdateNotes('URL im Versendeformular und Option <span class="bad">Immer aktiv</span> f&uuml;r diese Erweiterung deaktiviert.');
87                                 break;
88
89                         case '0.0.3': // SQL queries for v0.0.3
90                                 // Update notes (these will be set as task text!)
91                                 setExtensionUpdateNotes('W&ouml;rter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.');
92                                 break;
93
94                         case '0.0.4': // SQL queries for v0.0.4
95                                 // Update notes (these will be set as task text!)
96                                 setExtensionUpdateNotes('HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.');
97                                 break;
98
99                         case '0.0.5': // SQL queries for v0.0.5
100                                 // Update notes (these will be set as task text!)
101                                 setExtensionUpdateNotes('Abspeichern von Einstellungen repariert.');
102                                 break;
103
104                         case '0.0.6': // SQL queries for v0.0.6
105                                 // Update notes (these will be set as task text!)
106                                 setExtensionUpdateNotes('Bitte Script inc/monthly_newsletter.php l&ouml;schen!');
107                                 break;
108
109                         case '0.0.7': // SQL queries for v0.0.7
110                                 // Update notes (these will be set as task text!)
111                                 setExtensionUpdateNotes('Script <strong>inc/monthly/monthly_newsletter.php</strong> wird nicht mehr ausgef&uuml;hrt, wenn die Erweiterung nicht aktiviert ist.');
112                                 break;
113
114                         case '0.0.8': // SQL queries for v0.0.8
115                                 // Update notes (these will be set as task text!)
116                                 setExtensionUpdateNotes('Sicherheitsupdate f&uuml;r die Include-Befehle.');
117                                 break;
118
119                         case '0.0.9': // SQL queries for v0.0.9
120                                 // Update notes (these will be set as task text!)
121                                 setExtensionUpdateNotes('Nur bei installierter Erweiterung <strong>html_mail</strong> k&ouml;nnen Sie auch HTML-Mails versenden.');
122                                 break;
123
124                         case '0.1.0': // SQL queries for v0.2.1
125                                 // Update notes (these will be set as task text!)
126                                 setExtensionUpdateNotes('Nur bei installierter Erweiterung <strong>html_mail</strong> k&ouml;nnen Sie auch HTML-Mails versenden.');
127                                 break;
128
129                         case '0.1.1': // SQL queries for v0.1.1
130                                 // Update notes (these will be set as task text!)
131                                 setExtensionUpdateNotes('W&auml;hrung auf die Erweiterung <a href="#"><strong>ext-other.zip</strong></a> verlagert. Bitte auch diese aktualisieren.');
132                                 break;
133
134                         case '0.1.2': // SQL queries for v0.1.2
135                                 // Update notes (these will be set as task text!)
136                                 setExtensionUpdateNotes('Fehlerhinweis bei deaktivierter Erweiterung verbessert.');
137                                 break;
138
139                         case '0.2.0': // SQL queries for v0.2.0
140                                 // Tables:
141                                 // - Main data table
142                                 addDropTableSql('newsletter_data');
143                                 addCreateTableSql('newsletter_data', "
144 `nl_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
145 `nl_subject` VARCHAR(255) NOT NULL DEFAULT '{OPEN_CONFIG}nl_default_subject{CLOSE_CONFIG}',
146 `nl_header_text` MEDIUMTEXT NOT NULL,
147 `nl_footer_text` MEDIUMTEXT NOT NULL,
148 `nl_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
149 `nl_send` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
150 `nl_ready` ENUM('Y','N') NOT NULL DEFAULT 'N',
151 `nl_sent` ENUM('Y','N') NOT NULL DEFAULT 'N',
152 `nl_expired` ENUM('Y','N') NOT NULL DEFAULT 'N',
153 `nl_do_archive` ENUM('Y','N') NOT NULL DEFAULT 'Y',
154 `nl_recipients` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
155 `nl_received` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
156 `nl_total_clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
157 PRIMARY KEY (`nl_id`)",
158                                         'General newsletter data');
159
160                                 // - Topics data table
161                                 addDropTableSql('newsletter_topics');
162                                 addCreateTableSql('newsletter_topics', "
163 `nl_topic_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
164 `nl_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
165 `nl_topic_title` VARCHAR(255) NOT NULL DEFAULT '',
166 `nl_topic_text` MEDIUMTEXT NOT NULL,
167 `nl_topic_clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
168 PRIMARY KEY (`nl_topic_id`),
169 INDEX `newsletter_id` (`nl_id`)",
170                                         'Newsletter topics');
171
172                                 // - Sponsor orders data table
173                                 addDropTableSql('newsletter_orders');
174                                 addCreateTableSql('newsletter_orders', "
175 `nl_order_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
176 `nl_sponsor_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
177 `nl_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
178 `nl_topic_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
179 `nl_order_placed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
180 `nl_order_accepted` ENUM('Y','N') NOT NULL DEFAULT 'N',
181 PRIMARY KEY (`nl_order_id`),
182 UNIQUE INDEX `sponsor_nl_topic` (`nl_sponsor_id`, `nl_id`, `nl_topic_id`),
183 INDEX `topic` (`nl_topic_id`)",
184                                         'Newsletter orders');
185
186                                 // Configuration
187                                 addConfigAddSql('nl_expire', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 7));
188                                 addConfigAddSql('nl_archive_expire', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 14));
189                                 addConfigAddSql('nl_default_subject', "VARCHAR(255) NOT NULL DEFAULT 'Newsletter vom {OPEN_CONFIG}CURRENT_DATE{CLOSE_CONFIG}'");
190                                 addConfigAddSql('nl_default_header', 'MEDIUMTEXT NOT NULL,');
191                                 addConfigAddSql('nl_default_footer', 'MEDIUMTEXT NOT NULL,');
192                                 addConfigAddSql('nl_archive', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
193
194                                 // Admin menu
195                                 addAdminMenuSql('newsletter', 'list_newsletter', 'Newsletter Verwalten', 'Legen Sie hier einen neuen Newsletter mit Betreff und Verfallsdatum an und listen Sie bestehende auf. Die Grunddaten lassen sich hier ebenfalls &auml;ndern.', 1);
196                                 addAdminMenuSql('newsletter', 'list_newsletter_topic', 'Thema verwalten', 'Legen Sie hier ein weiteres Thema an oder editieren bzw. l&ouml;schen Sie bestehende.', 2);
197                                 addAdminMenuSql('newsletter', 'list_newsletter_ordrs', 'Buchungen verwalten', 'Verwalten Sie hier die Buchungen im Newsletter von Ihren Sponsoren.', 3);
198                                 addAdminMenuSql('newsletter', 'config_newsletter', 'Einstellungen', 'Einstellungen am Newsletter vornehmen.', 4);
199
200                                 // Remove member menu
201                                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='newsletter' LIMIT 1");
202
203                                 // Update notes (these will be set as task text!)
204                                 setExtensionUpdateNotes('Komplett&uuml;berarbeitung der Erweiterung, siehe neuer Beschreibungstext.');
205                                 break;
206                 } // END - switch
207                 break;
208
209         case 'modify': // When the extension got modified
210                 break;
211
212         case 'test': // For testing purposes
213                 break;
214
215         case 'init': // Do stuff when extension is initialized
216                 // URL ends which are used to indentify the end of an URL or email link
217                 // Don't use these chars in links... ;-)
218                 // @TODO Move these into configuration
219                 $GLOBALS['url_ends'] = array(
220                         ' ',
221                         PHP_EOL,
222                         chr(13),
223                         ')',
224                 );
225
226                 // Valid email chars (without @, or do you want to have another @ inside your email addresses?)
227                 $GLOBALS['valid_email_chars'] = array(
228                         'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
229                         't','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
230                         'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','-','.','_','0','1',
231                         '2','3','4','5','6','7','8','9'
232                 );
233                 break;
234
235         default: // Unknown extension mode
236                 reportBug(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
237                 break;
238 } // END - switch
239
240 // [EOF]
241 ?>