Rewrites/fixes for handling config entries in SQLs
[mailer.git] / inc / extensions / ext-nickname.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 06/17/2004 *
4  * ===================                          Last change: 06/17/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-nickname.php                                 *
8  * -------------------------------------------------------------------- *
9  * Short description : Nickname login and display in register form      *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Nickname-Login und Anzeige im Anmeldeformular    *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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                  *
23  *                                                                      *
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.                                  *
28  *                                                                      *
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.                         *
33  *                                                                      *
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,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42         die();
43 } // END - if
44
45 // Version number
46 setThisExtensionVersion('0.1.9');
47
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.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9'));
50
51 switch (getExtensionMode()) {
52         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
53                 // SQL commands to run
54                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD nickname VARCHAR(255) NOT NULL DEFAULT ''");
55                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD nick_userid ENUM ('nick','userid') NOT NULL DEFAULT 'userid'");
56                 addMemberMenuSql('main','nickname','Nicknamen','Y','Y',5);
57                 break;
58
59         case 'remove': // Do stuff when removing extension
60                 // SQL commands to run
61                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='nickname'");
62                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN ('config_nickname','list_nickname')");
63                 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_nickname_history`');
64                 break;
65
66         case 'activate': // Do stuff when admin activates this extension
67                 // SQL commands to run
68                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='nickname' LIMIT 1");
69                 break;
70
71         case 'deactivate': // Do stuff when admin deactivates this extension
72                 // SQL commands to run
73                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='nickname' LIMIT 1");
74                 break;
75
76         case 'update': // Update an extension
77                 switch (getCurrentExtensionVersion()) {
78                         case '0.0.1': // SQL queries for v0.0.1
79                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET ext_has_css='Y' WHERE `ext_name`='nickname' AND ext_has_css='N' LIMIT 1");
80
81                                 // This update depends on sql_patches update!
82                                 addExtensionUpdateDependency('sql_patches');
83
84                                 // Update notes (these will be set as task text!)
85                                 setExtensionUpdateNotes("CSS-Datei kann per Adminbereich ein- und ausgeschaltet werden.");
86                                 break;
87
88                         case '0.0.3': // SQL queries for v0.0.3
89                                 // Update notes (these will be set as task text!)
90                                 setExtensionUpdateNotes("Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.");
91                                 break;
92
93                         case '0.0.4': // SQL queries for v0.0.4
94                                 // Update notes (these will be set as task text!)
95                                 setExtensionUpdateNotes("Wegen des Theme-Supportes hat sich die URL zur CSS-Datei ge&auml;ndert.");
96                                 break;
97
98                         case '0.0.5': // SQL queries for v0.0.5
99                                 // Update notes (these will be set as task text!)
100                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
101                                 break;
102
103                         case '0.0.6': // SQL queries for v0.0.6
104                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nickname_len` TINYINT(3) UNSIGNED NOT NULL DEFAULT 5");
105                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nickname_pattern` VARCHAR(255) NOT NULL DEFAULT 'a-zA-Z0-9_'");
106                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `nickname_chars` VARCHAR(255) NOT NULL DEFAULT 'a-z, A-Z, 0-9, _'");
107                                 addAdminMenuSql('setup','config_nickname','Nicknamen','Stellen Sie minimale Nicknamenl&auml;nge, sowie erlaubte Zeichen hier ein.', 12);
108
109                                 // Update notes (these will be set as task text!)
110                                 setExtensionUpdateNotes("Minimale L&auml;nge, sowie erlaubte Zeichen sind per Adminbereich &auml;nderbar. Setzen Sie als erlaubte Zeichen nur URL-konforme Zeichen ein!");
111                                 break;
112
113                         case '0.0.7': // SQL queries for v0.0.7
114                                 // Update notes (these will be set as task text!)
115                                 setExtensionUpdateNotes("Problem mit Speicherung der Einstellungen beseitigt.");
116                                 break;
117
118                         case '0.0.8': // SQL queries for v0.0.8
119                                 // Update notes (these will be set as task text!)
120                                 setExtensionUpdateNotes("Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.");
121                                 break;
122
123                         case '0.0.9': // SQL queries for v0.0.9
124                                 // Update notes (these will be set as task text!)
125                                 setExtensionUpdateNotes("Design &quot;Solid-Business&quot; eingebaut.");
126                                 break;
127
128                         case '0.1.0': // SQL queries for v0.2.1
129                                 // Update notes (these will be set as task text!)
130                                 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
131                                 break;
132
133                         case '0.1.1': // SQL queries for v0.1.1
134                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` DROP nick_userid");
135
136                                 // Update notes (these will be set as task text!)
137                                 setExtensionUpdateNotes("Auswahlf&uuml;r Mitglied ob mit Nickname oder Mitglieder-Id einloggen entfernt.");
138                                 break;
139
140                         case '0.1.2': // SQL queries for v0.1.2
141                                 // Update notes (these will be set as task text!)
142                                 setExtensionUpdateNotes("Zum Zusenden eines neuen Passwortes kann jetzt entweder der Nickname / Mitglieder-Id <u>ODER</u> die angemeldete EMail-Adresse eingegeben werden.");
143                                 break;
144
145                         case '0.1.3': // SQL queries for v0.1.3
146                                 // Update notes (these will be set as task text!)
147                                 setExtensionUpdateNotes("CSS-Datei in general.css verschmolzen (Patch 435!)");
148                                 break;
149
150                         case '0.1.4': // SQL queries for v0.1.4
151                                 // Update notes (these will be set as task text!)
152                                 setExtensionUpdateNotes("HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.");
153                                 break;
154
155                         case '0.1.5': // SQL queries for v0.1.5
156                                 // Update notes (these will be set as task text!)
157                                 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
158                                 break;
159
160                         case '0.1.6': // SQL queries for v0.1.6
161                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='extras', `sort`=2 WHERE `what`='nickname' LIMIT 1");
162
163                                 // Update notes (these will be set as task text!)
164                                 setExtensionUpdateNotes("Mitgliedsmen&uuml; komplett umgebaut.");
165                                 break;
166
167                         case '0.1.7': // SQL queries for v0.1.7
168                                 // Update notes (these will be set as task text!)
169                                 setExtensionUpdateNotes("Mitglieder ohne Nickname sollten kein <strong>*failed*</strong> mehr sehen.");
170                                 break;
171
172                         case '0.1.8': // SQL queries for v0.1.8
173                                 // Update notes (these will be set as task text!)
174                                 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
175                                 break;
176
177                         case '0.1.9': // SQL queries for v0.1.9
178                                 addAdminMenuSql('user','list_nickname','Nickname-Historie','Listet alle verwendeten Nicknames der Mitglieder auf.', 12);
179                                 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_nickname_history`');
180                                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_nickname_history` (
181 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
182 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
183 `nickname` VARCHAR(255) NOT NULL DEFAULT '',
184 `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
185 `last_used` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
186 INDEX `userid` (`userid`),
187 INDEX (`last_used` DESC),
188 PRIMARY KEY (`id`)
189 ) TYPE={?_TABLE_TYPE?} COMMENT='History of used nicknames'");
190
191                                 // Update notes (these will be set as task text!)
192                                 setExtensionUpdateNotes("Historie eingegebener Nicknames hinzugef&uuml;gt. Mitglied kann auf bereits verwendeter zur&uuml;ckgreifen und Liste selbst l&ouml;schen.");
193                                 break;
194                 }
195                 break;
196
197         case 'modify': // When the extension got modified
198                 break;
199
200         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
201                 break;
202
203         case 'init': // Do stuff when extension is initialized
204                 break;
205
206         default: // Unknown extension mode
207                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
208                 break;
209 } // END - switch
210
211 // [EOF]
212 ?>