2 /************************************************************************
3 * MXChange v0.2.1 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 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
45 setThisExtensionVersion('0.2.0');
47 // Version history array (add more with , '0.1.0' and so on)
48 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'));
50 switch (getExtensionMode()) {
51 case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
52 // SQL commands to run
56 case 'remove': // Do stuff when removing extension
57 // SQL commands to run
58 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='newsletter'");
59 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='newsletter'");
60 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_data`");
61 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_topics`");
62 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_orders`");
65 case 'activate': // Do stuff when admin activates this extension
66 // SQL commands to run
67 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `locked`='N', `visible`='Y' WHERE `what`='newsletter' LIMIT 1");
70 case 'deactivate': // Do stuff when admin deactivates this extension
71 // SQL commands to run
72 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `locked`='Y', `visible`='N' WHERE `what`='newsletter' LIMIT 1");
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 addAdminMenuSql('newsletter','config_newsletter','Einstellungen','Einstellungen am Newsletter vornehmen.', 3);
80 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='newsletter' LIMIT 1");
81 addMemberMenuSql('main','newsletter','Newsletter-Empfang','N','Y', 10);
82 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `nl_receive` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
84 // Update notes (these will be set as task text!)
85 setExtensionUpdateNotes("Menüpunkte hinzufügen und Mitgliedereinstellung.");
88 case '0.0.2': // SQL queries for v0.0.2
89 // Update notes (these will be set as task text!)
90 setExtensionUpdateNotes("URL im Versendeformular und Option <em>Immer aktiv</em> für diese Erweiterung deaktiviert.");
93 case '0.0.3': // SQL queries for v0.0.3
94 // Update notes (these will be set as task text!)
95 setExtensionUpdateNotes("Wörter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.");
98 case '0.0.4': // SQL queries for v0.0.4
99 // Update notes (these will be set as task text!)
100 setExtensionUpdateNotes("HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.");
103 case '0.0.5': // SQL queries for v0.0.5
104 // Update notes (these will be set as task text!)
105 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
108 case '0.0.6': // SQL queries for v0.0.6
109 // Update notes (these will be set as task text!)
110 setExtensionUpdateNotes("Bitte Script inc/monthly_newsletter.php löschen!");
113 case '0.0.7': // SQL queries for v0.0.7
114 // Update notes (these will be set as task text!)
115 setExtensionUpdateNotes("Script <strong>inc/monthly/monthly_newsletter.php</strong> wird nicht mehr ausgeführt, wenn die Erweiterung nicht aktiviert ist.");
118 case '0.0.8': // SQL queries for v0.0.8
119 // Update notes (these will be set as task text!)
120 setExtensionUpdateNotes("Sicherheitsupdate für die Include-Befehle.");
123 case '0.0.9': // SQL queries for v0.0.9
124 // Update notes (these will be set as task text!)
125 setExtensionUpdateNotes("Nur bei installierter Erweiterung <strong>html_mail</strong> können Sie auch HTML-Mails versenden.");
128 case '0.1.0': // SQL queries for v0.2.1
129 // Update notes (these will be set as task text!)
130 setExtensionUpdateNotes("Nur bei installierter Erweiterung <strong>html_mail</strong> können Sie auch HTML-Mails versenden.");
133 case '0.1.1': // SQL queries for v0.1.1
134 // Update notes (these will be set as task text!)
135 setExtensionUpdateNotes("Währung auf die Erweiterung <a href=\"#\"><strong>ext-other.zip</strong></a> verlagert. Bitte auch diese aktualisieren.");
138 case '0.1.2': // SQL queries for v0.1.2
139 // Update notes (these will be set as task text!)
140 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
143 case '0.2.0': // SQL queries for v0.2.0
146 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_data`");
147 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_newsletter_data` (
148 `nl_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
149 `nl_subject` VARCHAR(255) NOT NULL DEFAULT '{OPEN_CONFIG}nl_default_subject{CLOSE_CONFIG}',
150 `nl_header_text` MEDIUMTEXT,
151 `nl_footer_text` MEDIUMTEXT,
152 `nl_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
153 `nl_send` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
154 `nl_ready` ENUM('Y','N') NOT NULL DEFAULT 'N',
155 `nl_sent` ENUM('Y','N') NOT NULL DEFAULT 'N',
156 `nl_expired` ENUM('Y','N') NOT NULL DEFAULT 'N',
157 `nl_do_archive` ENUM('Y','N') NOT NULL DEFAULT 'Y',
158 `nl_recipients` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
159 `nl_received` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
160 `nl_total_clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
161 PRIMARY KEY (`nl_id`)
162 ) TYPE={?_TABLE_TYPE?} COMMENT='General newsletter data'");
164 // - Topics data table
165 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_topics`");
166 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_newsletter_topics` (
167 `nl_topic_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
168 `nl_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
169 `nl_topic_title` VARCHAR(255) NOT NULL DEFAULT '',
170 `nl_topic_text` MEDIUMTEXT,
171 INDEX `newsletter_id` (`nl_id`),
172 PRIMARY KEY (`nl_topic_id`)
173 ) TYPE={?_TABLE_TYPE?} COMMENT='Newsletter topics'");
175 // - Sponsor orders data table
176 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_newsletter_orders`");
177 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_newsletter_orders` (
178 `nl_order_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
179 `nl_sponsor_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
180 `nl_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
181 `nl_topic_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
182 `nl_order_placed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
183 `nl_order_accepted` ENUM('Y','N') NOT NULL DEFAULT 'N',
184 UNIQUE KEY `sponsor_nl_topic` (`nl_sponsor_id`,`nl_id`,`nl_topic_id`),
185 INDEX `topic` (`nl_topic_id`),
186 PRIMARY KEY (`nl_order_id`)
187 ) TYPE={?_TABLE_TYPE?} COMMENT='Newsletter orders'");
190 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_expire` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('ONE_DAY') * 7)."");
191 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_archive_expire` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('ONE_DAY') * 14)."");
192 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_default_subject` VARCHAR(255) NOT NULL DEFAULT 'Newsletter vom {OPEN_CONFIG}CURRENT_DATE{CLOSE_CONFIG}'");
193 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_default_header` MEDIUMTEXT");
194 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_default_footer` MEDIUMTEXT");
195 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nl_archive` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
198 addAdminMenuSql('newsletter', 'add_newsletter','Neuen erstellen','Legen Sie hier einen neuen Newsletter mit Betreff und Verfallsdatum an.', 1);
200 // Update notes (these will be set as task text!)
201 setExtensionUpdateNotes("Komplettüberarbeitung der Erweiterung, siehe neuer Beschreibungstext.");
206 case 'modify': // When the extension got modified
209 case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
212 case 'init': // Do stuff when extension is initialized
213 // URL ends which are used to indentify the end of an URL or email link
214 // Don't use these chars in links... ;-)
215 // @TODO Move these into configuration
216 $GLOBALS['url_ends'] = array(
223 // Valid email chars (without @, or do you want to have another @ inside your email addresses?)
224 $GLOBALS['valid_email_chars'] = array(
225 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
226 't','u','v','w','x','y','z','a','B','C','D','E','F','G','H','I','J','K','L',
227 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','-','.','_',0,1,
232 default: // Unknown extension mode
233 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));