rewritten to new functions, some parts rewritten to filters
[mailer.git] / inc / extensions / ext-nickname.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Version number
41 EXT_SET_VERSION("0.1.9");
42
43 // Version history array (add more with , "0.1" and so on)
44 EXT_SET_VER_HISTORY(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"));
45
46 switch ($EXT_LOAD_MODE)
47 {
48 case "register": // Do stuff when installation is running (modules.php?module=admin&action=login is called)
49         // SQL commands to run
50         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` ADD nickname VARCHAR(255) NOT NULL DEFAULT ''");
51         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` ADD nick_uid ENUM ('nick','uid') NOT NULL DEFAULT 'uid'");
52         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`sort`,`visible`,`locked`) VALUES ('main','nickname','Nicknamen','5','Y','Y')");
53         break;
54
55 case "remove": // Do stuff when removing extension
56         // SQL commands to run
57         ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_member_menu` WHERE `what`='nickname' LIMIT 1");
58         ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE what IN ('config_nickname','list_nickname') LIMIT 2");
59         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_nickname_history`");
60         break;
61
62 case "activate": // Do stuff when admin activates this extension
63         // SQL commands to run
64         ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='nickname' LIMIT 1");
65         break;
66
67 case "deactivate": // Do stuff when admin deactivates this extension
68         // SQL commands to run
69         ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='nickname' LIMIT 1");
70         break;
71
72 case "update": // Update an extension
73         switch ($EXT_VER)
74         {
75         case "0.0.1": // SQL queries for v0.0.1
76                 ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_extensions` SET ext_has_css='Y' WHERE ext_name='nickname' AND ext_has_css='N' LIMIT 1");
77
78                 // This update depends on sql_patches update!
79                 EXT_SET_UPDATE_DEPENDS("sql_patches");
80
81                 // Update notes (these will be set as task text!)
82                 EXT_SET_UPDATE_NOTES("CSS-Datei kann per Adminbereich ein- und ausgeschaltet werden.");
83                 break;
84
85         case "0.0.3": // SQL queries for v0.0.3
86                 // Update notes (these will be set as task text!)
87                 EXT_SET_UPDATE_NOTES("Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.");
88                 break;
89
90         case "0.0.4": // SQL queries for v0.0.4
91                 // Update notes (these will be set as task text!)
92                 EXT_SET_UPDATE_NOTES("Wegen des Theme-Supportes hat sich die URL zur CSS-Datei ge&auml;ndert.");
93                 break;
94
95         case "0.0.5": // SQL queries for v0.0.5
96                 // Update notes (these will be set as task text!)
97                 EXT_SET_UPDATE_NOTES("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
98                 break;
99
100         case "0.0.6": // SQL queries for v0.0.6
101                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD nickname_len TINYINT(3) UNSIGNED NOT NULL DEFAULT '5'");
102                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD nickname_pattern VARCHAR(255) NOT NULL DEFAULT 'a-zA-Z0-9_'");
103                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD nickname_chars VARCHAR(255) NOT NULL DEFAULT 'a-z, A-Z, 0-9, _'");
104                 ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('setup','config_nickname','Nicknamen','Stellen Sie minimale Nicknamenl&auml;nge, sowie erlaubte Zeichen hier ein.', 12)");
105
106                 // Update notes (these will be set as task text!)
107                 EXT_SET_UPDATE_NOTES("Minimale L&auml;nge, sowie erlaubte Zeichen sind per Adminbereich &auml;nderbar. Setzen Sie als erlaubte Zeichen nur URL-konforme Zeichen ein!");
108                 break;
109
110         case "0.0.7": // SQL queries for v0.0.7
111                 // Update notes (these will be set as task text!)
112                 EXT_SET_UPDATE_NOTES("Problem mit Speicherung der Einstellungen beseitigt.");
113                 break;
114
115         case "0.0.8": // SQL queries for v0.0.8
116                 // Update notes (these will be set as task text!)
117                 EXT_SET_UPDATE_NOTES("Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.");
118                 break;
119
120         case "0.0.9": // SQL queries for v0.0.9
121                 // Update notes (these will be set as task text!)
122                 EXT_SET_UPDATE_NOTES("Design &quot;Solid-Business&quot; eingebaut.");
123                 break;
124
125         case "0.1.0": // SQL queries for v0.2.1
126                 // Update notes (these will be set as task text!)
127                 EXT_SET_UPDATE_NOTES("Seit <a href=\"#\">Patch 340</a> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
128                 break;
129
130         case "0.1.1": // SQL queries for v0.1.1
131                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` DROP nick_uid");
132
133                 // Update notes (these will be set as task text!)
134                 EXT_SET_UPDATE_NOTES("Auswahlf&uuml;r Mitglied ob mit Nickname oder User-ID einloggen entfernt.");
135                 break;
136
137         case "0.1.2": // SQL queries for v0.1.2
138                 // Update notes (these will be set as task text!)
139                 EXT_SET_UPDATE_NOTES("Zum Zusenden eines neuen Passwortes kann jetzt entweder der Nickname / User-ID <u>ODER</u> die angemeldete EMail-Adresse eingegeben werden.");
140                 break;
141
142         case "0.1.3": // SQL queries for v0.1.3
143                 // Update notes (these will be set as task text!)
144                 EXT_SET_UPDATE_NOTES("CSS-Datei in general.css verschmolzen (Patch 435!)");
145                 break;
146
147         case "0.1.4": // SQL queries for v0.1.4
148                 // Update notes (these will be set as task text!)
149                 EXT_SET_UPDATE_NOTES("HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.");
150                 break;
151
152         case "0.1.5": // SQL queries for v0.1.5
153                 // Update notes (these will be set as task text!)
154                 EXT_SET_UPDATE_NOTES("Abspeichern von Einstellungen repariert.");
155                 break;
156
157         case "0.1.6": // SQL queries for v0.1.6
158                 ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `action`='extras', `sort`='2' WHERE `what`='nickname' LIMIT 1");
159
160                 // Update notes (these will be set as task text!)
161                 EXT_SET_UPDATE_NOTES("Mitgliedsmen&uuml; komplett umgebaut.");
162                 break;
163
164         case "0.1.7": // SQL queries for v0.1.7
165                 // Update notes (these will be set as task text!)
166                 EXT_SET_UPDATE_NOTES("Mitglieder ohne Nickname sollten kein <strong>*failed*</strong> mehr sehen.");
167                 break;
168
169         case "0.1.8": // SQL queries for v0.1.8
170                 // Update notes (these will be set as task text!)
171                 EXT_SET_UPDATE_NOTES("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
172                 break;
173
174         case "0.1.9": // SQL queries for v0.1.9
175                 ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('user','list_nickname','Nickname-Historie','Listet alle verwendeten Nicknames der Mitglieder auf.', 12)");
176                 ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_nickname_history`");
177                 ADD_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_nickname_history` (
178 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
179 userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
180 nickname VARCHAR(255) NOT NULL DEFAULT '',
181 added TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
182 last_used TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
183 INDEX userid (userid),
184 INDEX (last_used DESC),
185 PRIMARY KEY(id)
186 ) TYPE=MyISAM COMMENT='History of used nicknames'");
187
188                 // Update notes (these will be set as task text!)
189                 EXT_SET_UPDATE_NOTES("Historie eingegebener Nicknames hinzugef&uuml;gt. Mitglied kann auf bereits verwendeter zur&uuml;ckgreifen und Liste selbst l&ouml;schen.");
190                 break;
191         }
192         break;
193
194 case "test": // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
195         break;
196
197 default: // Do stuff when extension is loaded
198         break;
199 }
200
201 //
202 ?>