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 switch (getExtensionMode()) {
52 case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
53 // SQL commands to run
57 case 'remove': // Do stuff when removing extension
58 // SQL commands to run
59 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='newsletter'");
60 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='newsletter'");
61 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_data`");
62 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_topics`");
63 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_orders`");
66 case 'activate': // Do stuff when admin activates this extension
67 // SQL commands to run
68 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `locked`='N', `visible`='Y' WHERE `what`='newsletter' LIMIT 1");
71 case 'deactivate': // Do stuff when admin deactivates this extension
72 // SQL commands to run
73 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `locked`='Y', `visible`='N' WHERE `what`='newsletter' LIMIT 1");
76 case 'update': // Update an extension
77 switch (getCurrentExtensionVersion()) {
78 case '0.0.1': // SQL queries for v0.0.1
79 addAdminMenuSql('newsletter', NULL, 'Newsletter','Einstellungen am Newsletter, Newsletter versenden, usw.', 3);
80 addAdminMenuSql('newsletter','config_newsletter','Einstellungen','Einstellungen am Newsletter vornehmen.', 3);
81 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='newsletter' LIMIT 1");
82 addMemberMenuSql('main','newsletter','Newsletter-Empfang','N','Y', 10);
83 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `nl_receive` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
85 // Update notes (these will be set as task text!)
86 setExtensionUpdateNotes("Menüpunkte hinzufügen und Mitgliedereinstellung.");
89 case '0.0.2': // SQL queries for v0.0.2
90 // Update notes (these will be set as task text!)
91 setExtensionUpdateNotes("URL im Versendeformular und Option <em>Immer aktiv</em> für diese Erweiterung deaktiviert.");
94 case '0.0.3': // SQL queries for v0.0.3
95 // Update notes (these will be set as task text!)
96 setExtensionUpdateNotes("Wörter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.");
99 case '0.0.4': // SQL queries for v0.0.4
100 // Update notes (these will be set as task text!)
101 setExtensionUpdateNotes("HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.");
104 case '0.0.5': // SQL queries for v0.0.5
105 // Update notes (these will be set as task text!)
106 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
109 case '0.0.6': // SQL queries for v0.0.6
110 // Update notes (these will be set as task text!)
111 setExtensionUpdateNotes("Bitte Script inc/monthly_newsletter.php löschen!");
114 case '0.0.7': // SQL queries for v0.0.7
115 // Update notes (these will be set as task text!)
116 setExtensionUpdateNotes("Script <strong>inc/monthly/monthly_newsletter.php</strong> wird nicht mehr ausgeführt, wenn die Erweiterung nicht aktiviert ist.");
119 case '0.0.8': // SQL queries for v0.0.8
120 // Update notes (these will be set as task text!)
121 setExtensionUpdateNotes("Sicherheitsupdate für die Include-Befehle.");
124 case '0.0.9': // SQL queries for v0.0.9
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.0': // SQL queries for v0.2.1
130 // Update notes (these will be set as task text!)
131 setExtensionUpdateNotes("Nur bei installierter Erweiterung <strong>html_mail</strong> können Sie auch HTML-Mails versenden.");
134 case '0.1.1': // SQL queries for v0.1.1
135 // Update notes (these will be set as task text!)
136 setExtensionUpdateNotes("Währung auf die Erweiterung <a href=\"#\"><strong>ext-other.zip</strong></a> verlagert. Bitte auch diese aktualisieren.");
139 case '0.1.2': // SQL queries for v0.1.2
140 // Update notes (these will be set as task text!)
141 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
144 case '0.2.0': // SQL queries for v0.2.0
147 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_data`");
148 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_newsletter_data` (
149 `nl_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
150 `nl_subject` VARCHAR(255) NOT NULL DEFAULT '{OPEN_CONFIG}nl_default_subject{CLOSE_CONFIG}',
151 `nl_header_text` MEDIUMTEXT,
152 `nl_footer_text` MEDIUMTEXT,
153 `nl_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
154 `nl_send` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
155 `nl_ready` ENUM('Y','N') NOT NULL DEFAULT 'N',
156 `nl_sent` ENUM('Y','N') NOT NULL DEFAULT 'N',
157 `nl_expired` ENUM('Y','N') NOT NULL DEFAULT 'N',
158 `nl_do_archive` ENUM('Y','N') NOT NULL DEFAULT 'Y',
159 `nl_recipients` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
160 `nl_received` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
161 `nl_total_clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
162 PRIMARY KEY (`nl_id`)
163 ) TYPE={?_TABLE_TYPE?} COMMENT='General newsletter data'");
165 // - Topics data table
166 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_topics`");
167 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_newsletter_topics` (
168 `nl_topic_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
169 `nl_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
170 `nl_topic_title` VARCHAR(255) NOT NULL DEFAULT '',
171 `nl_topic_text` MEDIUMTEXT,
172 INDEX `newsletter_id` (`nl_id`),
173 PRIMARY KEY (`nl_topic_id`)
174 ) TYPE={?_TABLE_TYPE?} COMMENT='Newsletter topics'");
176 // - Sponsor orders data table
177 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_orders`");
178 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_newsletter_orders` (
179 `nl_order_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
180 `nl_sponsor_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
181 `nl_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
182 `nl_topic_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
183 `nl_order_placed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
184 `nl_order_accepted` ENUM('Y','N') NOT NULL DEFAULT 'N',
185 UNIQUE KEY `sponsor_nl_topic` (`nl_sponsor_id`,`nl_id`,`nl_topic_id`),
186 INDEX `topic` (`nl_topic_id`),
187 PRIMARY KEY (`nl_order_id`)
188 ) TYPE={?_TABLE_TYPE?} COMMENT='Newsletter orders'");
191 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_expire` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('ONE_DAY') * 7)."");
192 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_archive_expire` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('ONE_DAY') * 14)."");
193 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_default_subject` VARCHAR(255) NOT NULL DEFAULT 'Newsletter vom {OPEN_CONFIG}CURRENT_DATE{CLOSE_CONFIG}'");
194 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_default_header` MEDIUMTEXT");
195 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_default_footer` MEDIUMTEXT");
196 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_archive` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
199 addAdminMenuSql('newsletter', 'add_newsletter','Neuen erstellen','Legen Sie hier einen neuen Newsletter mit Betreff und Verfallsdatum an.', 1);
201 // Update notes (these will be set as task text!)
202 setExtensionUpdateNotes("Komplettüberarbeitung der Erweiterung, siehe neuer Beschreibungstext.");
207 case 'modify': // When the extension got modified
210 case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
213 case 'init': // Do stuff when extension is initialized
214 // URL ends which are used to indentify the end of an URL or email link
215 // Don't use these chars in links... ;-)
216 // @TODO Move these into configuration
217 $GLOBALS['url_ends'] = array(
224 // Valid email chars (without @, or do you want to have another @ inside your email addresses?)
225 $GLOBALS['valid_email_chars'] = array(
226 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
227 't','u','v','w','x','y','z','a','B','C','D','E','F','G','H','I','J','K','L',
228 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','-','.','_',0,1,
233 default: // Unknown extension mode
234 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));