2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 02/26/2005 *
4 * =================== Last change: 02/26/2005 *
6 * -------------------------------------------------------------------- *
7 * File : ext-newsletter.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Extension for sending newsletters *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Erweiterung zum Versenden von Newslettern *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
44 setThisExtensionVersion('0.2.0');
46 // Version history array (add more with , '0.1.0' and so on)
47 setExtensionVersionHistory(array('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'));
49 // This extension is in development (non-productive)
50 enableExtensionProductive(false);
52 switch (getExtensionMode()) {
53 case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
54 // SQL commands to run
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');
67 case 'activate': // Do stuff when admin activates this extension
70 case 'deactivate': // Do stuff when admin deactivates this extension
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 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `nl_receive` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
80 // Update notes (these will be set as task text!)
81 setExtensionUpdateNotes('Menüpunkte hinzufügen und Mitgliedereinstellung.');
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 <em>Immer aktiv</em> für diese Erweiterung deaktiviert.');
89 case '0.0.3': // SQL queries for v0.0.3
90 // Update notes (these will be set as task text!)
91 setExtensionUpdateNotes('Wörter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.');
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.');
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.');
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öschen!');
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ührt, wenn die Erweiterung nicht aktiviert ist.');
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ür die Include-Befehle.');
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önnen Sie auch HTML-Mails versenden.');
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önnen Sie auch HTML-Mails versenden.');
129 case '0.1.1': // SQL queries for v0.1.1
130 // Update notes (these will be set as task text!)
131 setExtensionUpdateNotes('Währung auf die Erweiterung <a href="#"><strong>ext-other.zip</strong></a> verlagert. Bitte auch diese aktualisieren.');
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.');
139 case '0.2.0': // SQL queries for v0.2.0
142 addDropTableSql('newsletter_data');
143 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_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,
147 `nl_footer_text` MEDIUMTEXT,
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 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'General newsletter data'");
160 // - Topics data table
161 addDropTableSql('newsletter_topics');
162 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_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,
167 `nl_topic_clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
168 INDEX `newsletter_id` (`nl_id`),
169 PRIMARY KEY (`nl_topic_id`)
170 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Newsletter topics'");
172 // - Sponsor orders data table
173 addDropTableSql('newsletter_orders');
174 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_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 UNIQUE KEY `sponsor_nl_topic` (`nl_sponsor_id`,`nl_id`,`nl_topic_id`),
182 INDEX `topic` (`nl_topic_id`),
183 PRIMARY KEY (`nl_order_id`)
184 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Newsletter orders'");
187 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_expire` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getOneDay() * 7)."");
188 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_archive_expire` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getOneDay() * 14)."");
189 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_default_subject` VARCHAR(255) NOT NULL DEFAULT 'Newsletter vom {OPEN_CONFIG}CURRENT_DATE{CLOSE_CONFIG}'");
190 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_default_header` MEDIUMTEXT");
191 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_default_footer` MEDIUMTEXT");
192 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_archive` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
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 ändern.', 1);
196 addAdminMenuSql('newsletter', 'list_newsletter_topic', 'Thema verwalten', 'Legen Sie hier ein weiteres Thema an oder editieren bzw. lö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);
200 // Remove member menu
201 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='newsletter' LIMIT 1");
203 // Update notes (these will be set as task text!)
204 setExtensionUpdateNotes('Komplettüberarbeitung der Erweiterung, siehe neuer Beschreibungstext.');
209 case 'modify': // When the extension got modified
212 case 'test': // For testing purposes
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(
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'
235 default: // Unknown extension mode
236 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));