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 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
46 setThisExtensionVersion('0.2.0');
48 // Version history array (add more with , '0.1.0' and so on)
49 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'));
51 // This extension is in development (non-productive)
52 enableExtensionProductive(false);
54 switch (getExtensionMode()) {
55 case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
56 // SQL commands to run
60 case 'remove': // Do stuff when removing extension
61 // SQL commands to run
62 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='newsletter'");
63 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='newsletter'");
64 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_data`');
65 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_topics`');
66 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_orders`');
69 case 'activate': // Do stuff when admin activates this extension
72 case 'deactivate': // Do stuff when admin deactivates this extension
75 case 'update': // Update an extension
76 switch (getCurrentExtensionVersion()) {
77 case '0.0.1': // SQL queries for v0.0.1
78 addAdminMenuSql('newsletter', NULL, 'Newsletter','Einstellungen am Newsletter, Newsletter versenden, usw.', 3);
79 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN ('newsletter','config_newsletter') LIMIT 1");
80 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `nl_receive` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
82 // Update notes (these will be set as task text!)
83 setExtensionUpdateNotes('Menüpunkte hinzufügen und Mitgliedereinstellung.');
86 case '0.0.2': // SQL queries for v0.0.2
87 // Update notes (these will be set as task text!)
88 setExtensionUpdateNotes('URL im Versendeformular und Option <em>Immer aktiv</em> für diese Erweiterung deaktiviert.');
91 case '0.0.3': // SQL queries for v0.0.3
92 // Update notes (these will be set as task text!)
93 setExtensionUpdateNotes('Wörter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.');
96 case '0.0.4': // SQL queries for v0.0.4
97 // Update notes (these will be set as task text!)
98 setExtensionUpdateNotes('HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.');
101 case '0.0.5': // SQL queries for v0.0.5
102 // Update notes (these will be set as task text!)
103 setExtensionUpdateNotes('Abspeichern von Einstellungen repariert.');
106 case '0.0.6': // SQL queries for v0.0.6
107 // Update notes (these will be set as task text!)
108 setExtensionUpdateNotes('Bitte Script inc/monthly_newsletter.php löschen!');
111 case '0.0.7': // SQL queries for v0.0.7
112 // Update notes (these will be set as task text!)
113 setExtensionUpdateNotes('Script <strong>inc/monthly/monthly_newsletter.php</strong> wird nicht mehr ausgeführt, wenn die Erweiterung nicht aktiviert ist.');
116 case '0.0.8': // SQL queries for v0.0.8
117 // Update notes (these will be set as task text!)
118 setExtensionUpdateNotes('Sicherheitsupdate für die Include-Befehle.');
121 case '0.0.9': // SQL queries for v0.0.9
122 // Update notes (these will be set as task text!)
123 setExtensionUpdateNotes('Nur bei installierter Erweiterung <strong>html_mail</strong> können Sie auch HTML-Mails versenden.');
126 case '0.1.0': // SQL queries for v0.2.1
127 // Update notes (these will be set as task text!)
128 setExtensionUpdateNotes('Nur bei installierter Erweiterung <strong>html_mail</strong> können Sie auch HTML-Mails versenden.');
131 case '0.1.1': // SQL queries for v0.1.1
132 // Update notes (these will be set as task text!)
133 setExtensionUpdateNotes('Währung auf die Erweiterung <a href="#"><strong>ext-other.zip</strong></a> verlagert. Bitte auch diese aktualisieren.');
136 case '0.1.2': // SQL queries for v0.1.2
137 // Update notes (these will be set as task text!)
138 setExtensionUpdateNotes('Fehlerhinweis bei deaktivierter Erweiterung verbessert.');
141 case '0.2.0': // SQL queries for v0.2.0
144 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_data`');
145 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_newsletter_data` (
146 `nl_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
147 `nl_subject` VARCHAR(255) NOT NULL DEFAULT '{OPEN_CONFIG}nl_default_subject{CLOSE_CONFIG}',
148 `nl_header_text` MEDIUMTEXT,
149 `nl_footer_text` MEDIUMTEXT,
150 `nl_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
151 `nl_send` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
152 `nl_ready` ENUM('Y','N') NOT NULL DEFAULT 'N',
153 `nl_sent` ENUM('Y','N') NOT NULL DEFAULT 'N',
154 `nl_expired` ENUM('Y','N') NOT NULL DEFAULT 'N',
155 `nl_do_archive` ENUM('Y','N') NOT NULL DEFAULT 'Y',
156 `nl_recipients` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
157 `nl_received` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
158 `nl_total_clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
159 PRIMARY KEY (`nl_id`)
160 ) TYPE={?_TABLE_TYPE?} COMMENT='General newsletter data'");
162 // - Topics data table
163 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_topics`');
164 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_newsletter_topics` (
165 `nl_topic_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
166 `nl_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
167 `nl_topic_title` VARCHAR(255) NOT NULL DEFAULT '',
168 `nl_topic_text` MEDIUMTEXT,
169 `nl_topic_clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
170 INDEX `newsletter_id` (`nl_id`),
171 PRIMARY KEY (`nl_topic_id`)
172 ) TYPE={?_TABLE_TYPE?} COMMENT='Newsletter topics'");
174 // - Sponsor orders data table
175 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_orders`');
176 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_newsletter_orders` (
177 `nl_order_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
178 `nl_sponsor_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
179 `nl_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
180 `nl_topic_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
181 `nl_order_placed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
182 `nl_order_accepted` ENUM('Y','N') NOT NULL DEFAULT 'N',
183 UNIQUE KEY `sponsor_nl_topic` (`nl_sponsor_id`,`nl_id`,`nl_topic_id`),
184 INDEX `topic` (`nl_topic_id`),
185 PRIMARY KEY (`nl_order_id`)
186 ) TYPE={?_TABLE_TYPE?} COMMENT='Newsletter orders'");
189 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_expire` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('ONE_DAY') * 7)."");
190 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_archive_expire` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('ONE_DAY') * 14)."");
191 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_default_subject` VARCHAR(255) NOT NULL DEFAULT 'Newsletter vom {OPEN_CONFIG}CURRENT_DATE{CLOSE_CONFIG}'");
192 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_default_header` MEDIUMTEXT");
193 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_default_footer` MEDIUMTEXT");
194 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_archive` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
197 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);
198 addAdminMenuSql('newsletter', 'list_newsletter_topic', 'Thema verwalten', 'Legen Sie hier ein weiteres Thema an oder editieren bzw. löschen Sie bestehende.', 2);
199 addAdminMenuSql('newsletter', 'list_newsletter_ordrs', 'Buchungen verwalten', 'Verwalten Sie hier die Buchungen im Newsletter von Ihren Sponsoren.', 3);
200 addAdminMenuSql('newsletter', 'config_newsletter', 'Einstellungen', 'Einstellungen am Newsletter vornehmen.', 4);
202 // Remove member menu
203 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='newsletter' LIMIT 1");
205 // Update notes (these will be set as task text!)
206 setExtensionUpdateNotes('Komplettüberarbeitung der Erweiterung, siehe neuer Beschreibungstext.');
211 case 'modify': // When the extension got modified
214 case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
217 case 'init': // Do stuff when extension is initialized
218 // URL ends which are used to indentify the end of an URL or email link
219 // Don't use these chars in links... ;-)
220 // @TODO Move these into configuration
221 $GLOBALS['url_ends'] = array(
228 // Valid email chars (without @, or do you want to have another @ inside your email addresses?)
229 $GLOBALS['valid_email_chars'] = array(
230 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
231 't','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
232 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','-','.','_','0','1',
233 '2','3','4','5','6','7','8','9'
237 default: // Unknown extension mode
238 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));