LAS (logical area system) table renamed, table comments added:
[mailer.git] / inc / extensions / ext-admins.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 04/11/2004 *
4  * ===================                          Last change: 10/29/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-admins.php                                   *
8  * -------------------------------------------------------------------- *
9  * Short description : Administrator management                         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Admin-Accountsverwaltung                         *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Version of this extension
44 setThisExtensionVersion('0.7.6');
45
46 // Version history array (add more with , '0.1.0' and so on)
47 setExtensionVersionHistory(array('0.0', '0.1.0', '0.2.0', '0.3.0', '0.3.1', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5', '0.7.6'));
48
49 // Keep this extension always active!
50 setExtensionAlwaysActive('Y');
51
52 switch (getExtensionMode()) {
53         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
54                 // SQL commands to run
55                 addAdminMenuSql('admins', NULL, 'Admin-Management','Administratoren anlegen, l&ouml;schen oder Passwort/E-Mail Adresse &auml;ndern.',1);
56                 addAdminMenuSql('admins','admins_add','Admin hinzuf&uuml;gen','Neuen Admin-Account anlegen',0);
57                 addAdminMenuSql('admins','admins_edit','Admin-Account &auml;ndern','Bestehende Admin-Accounts bearbeiten: E-Mail-Adresse, Passwort und/oder Login-Name &auml;ndern.',1);
58                 break;
59
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`='admins'");
63                 addDropTableSql('admins_acls');
64                 addDropTableSql('admins_mails');
65                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` DROP `default_acl`");
66
67                 // Remove filters
68                 unregisterFilter(__FUNCTION__, __LINE__, 'sql_admin_extra_data', 'ADD_EXTRA_SQL_DATA', true, isExtensionDryRun());
69                 unregisterFilter(__FUNCTION__, __LINE__, 'do_admin_login_done', 'RESET_ADMINS_LOGIN_FAILURES', true, isExtensionDryRun());
70                 unregisterFilter(__FUNCTION__, __LINE__, 'do_admin_login_pass', 'COUNT_ADMINS_LOGIN_FAILURE', true, isExtensionDryRun());
71                 unregisterFilter(__FUNCTION__, __LINE__, 'do_admin_login_done', 'REHASH_ADMINS_PASSWORD', true, isExtensionDryRun());
72                 break;
73
74         case 'activate': // Do stuff when admin activates this extension
75                 // SQL commands to run
76                 addExtensionSql('');
77                 break;
78
79         case 'deactivate': // Do stuff when admin deactivates this extension
80                 // SQL commands to run
81                 addExtensionSql('');
82                 break;
83
84         case 'update': // Update an extension
85                 switch (getCurrentExtensionVersion()) {
86                         case '0.2.0': // SQL queries for v0.2
87                                 addAdminMenuSql('admins','admins_contact','Admin kontaktieren','Kontaktiert einen Admin per Mail oder Nachricht (nur wenn messaging-Erweiterung installiert ist).',2);
88
89                                 // Update notes (these will be set as task text!)
90                                 setExtensionUpdateNotes("F&uuml;gt den Men&uuml;punkt &quot;Admin kontaktieren&quot; hinzu.");
91                                 break;
92
93                         case '0.3.0': // SQL queries for v0.3
94                                 // Add admin menu
95                                 addAdminMenuSql('admins','config_admins','ACL einstellen','Richten Sie Zugriffskontrollzeilen f&uuml;r jeden Admin individuell ein, um ihm nur bestimmte Bereiche des Admin-Bereiches zug&auml;nglich zu machen oder zu sperren.',4);
96
97                                 // Which is the default setting when you create a new admin login?
98                                 addConfigAddSql('admins_default_acl', "ENUM('deny','allow') NOT NULL DEFAULT 'deny'");
99
100                                 // Default is deny everything
101                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD default_acl ENUM('deny','allow') NOT NULL DEFAULT 'deny'");
102
103                                 // But allow current admin everything (THIS SHALL BE YOU!)
104                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `default_acl`='allow' WHERE `id`=".bigintval(getCurrentAdminId())." LIMIT 1");
105                                 addDropTableSql('admins_acls');
106                                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_admins_acls` (
107 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
108 `admin_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
109 `action_menu` VARCHAR(255) NOT NULL DEFAULT '',
110 `what_menu` VARCHAR(255) NOT NULL DEFAULT '',
111 `access_mode` ENUM('deny','allow') NOT NULL DEFAULT 'deny',
112 KEY (`admin_id`),
113 PRIMARY KEY (`id`)
114 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Access control lines (ACLs)'");
115
116                                 // Update notes (these will be set as task text!)
117                                 setExtensionUpdateNotes("Sogn. ACLs werden hinzugef&uuml;gt: <strong>A</strong>ccess <strong>C</strong>ontrol <strong>L</strong>ines sind zu deutsch Zugriffkontrollzeilen, mit denen Sie einstellen k&ouml;nnen, was welcher Admin machen darf oder nicht. <strong>Nur Sie haben momentan Vollzugriff auf den Adminbereich.</strong>");
118                                 break;
119
120                         case '0.3.1': // SQL queries for v0.3.1
121                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins_acls` MODIFY id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT");
122                                 break;
123
124                         case '0.4.0': // SQL queries for v0.4.0
125                                 addDropTableSql('admins_mails');
126                                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_admins_mails` (
127 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
128 `admin_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
129 `mail_template` VARCHAR(255) NOT NULL,
130 KEY (`admin_id`),
131 PRIMARY KEY (`id`)
132 ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Mail template -> admin connection table'");
133                                 addExtensionSql("INSERT INTO  `{?_MYSQL_PREFIX?}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('admins','admins_mails','Admin-Mails','Stellen Sie hier ein, welcher Admin welche Mail erhalten soll. Sie k&ouml;nnen dies (derzeit) jedoch erst, wenn einmal die Mail versendet wurde!',5)");
134
135                                 // Update notes (these will be set as task text!)
136                                 setExtensionUpdateNotes("Kontrollieren Sie, welche Mails welcher Admin oder alle (admin_id=0) bekommen soll oder im UserLog (admin_id=-1) verzeichnet werden soll. Standardm&auml;ssig wird weiter an alle versendet.");
137                                 break;
138
139                         case '0.4.1': // SQL queries for v0.4.1
140                                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE mail_template LIKE '% %'");
141
142                                 // Update notes (these will be set as task text!)
143                                 setExtensionUpdateNotes("Admins-Mails-Tabelle geleert.");
144
145                         case '0.4.4': // SQL queries for v0.4.4
146                                 // Update notes (these will be set as task text!)
147                                 setExtensionUpdateNotes("&amp;admin= in &amp;amp;admin= umgewandelt.");
148                                 break;
149
150                         case '0.4.5': // SQL queries for v0.4.5
151                                 // Update notes (these will be set as task text!)
152                                 setExtensionUpdateNotes("Vorbereitet auf Cache-System");
153                                 break;
154
155                         case '0.4.6': // SQL queries for v0.4.6
156                                 // Update notes (these will be set as task text!)
157                                 setExtensionUpdateNotes("Problem mit cache-Erweiterung gefixt. Der Admin-Bereich war permanent gesperrt.");
158                                 break;
159
160                         case '0.4.7': // SQL queries for v0.4.7
161                                 // Update notes (these will be set as task text!)
162                                 setExtensionUpdateNotes("Es wurde die Zeitmarke der Cache-Datei admins.cache mit ber&uuml;cksichtigt.");
163                                 break;
164
165                         case '0.4.8': // SQL queries for v0.4.8
166                                 // Update notes (these will be set as task text!)
167                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
168                                 break;
169
170                         case '0.4.9': // SQL queries for v0.4.9
171                                 // Update notes (these will be set as task text!)
172                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
173                                 break;
174
175                         case '0.5.0': // SQL queries for v0.5.0
176                                 // Update notes (these will be set as task text!)
177                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
178                                 break;
179
180                         case '0.5.1': // SQL queries for v0.5.1
181                                 // Update notes (these will be set as task text!)
182                                 setExtensionUpdateNotes("Cache wird endlich gel&oumlscht, wenn Admin entfernt wird.");
183                                 break;
184
185                         case '0.5.2': // SQL queries for v0.5.2
186                                 // Update notes (these will be set as task text!)
187                                 setExtensionUpdateNotes("L&ouml;schen von Admin-Accounts repariert und HTML-Code ausgelagert in Templates.");
188                                 break;
189
190                         case '0.5.3': // SQL queries for v0.5.3
191                                 // Update notes (these will be set as task text!)
192                                 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
193                                 break;
194
195                         case '0.5.4': // SQL queries for v0.5.4
196                                 // Update notes (these will be set as task text!)
197                                 setExtensionUpdateNotes("IP-Nummer und Browserbezeichnung wird in Admin-Mails eingesetzt.");
198                                 break;
199
200                         case '0.5.5': // SQL queries for v0.5.5
201                                 // Update notes (these will be set as task text!)
202                                 setExtensionUpdateNotes("Men&uuml;punkt Admin-Mails korregiert: SQL-Anweisung war fehlerhaft; und HTML-Code in Templates ausgelagert.");
203                                 break;
204
205                         case '0.5.6': // SQL queries for v0.5.6
206                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `what`='admins_contct' WHERE `what`='admins_contact' LIMIT 1");
207
208                                 // Update notes (these will be set as task text!)
209                                 setExtensionUpdateNotes("Namenskonflikt zwischen den Erweiterungen <strong>admins</strong> und (kommender) <strong>contact</strong>.");
210                                 break;
211
212                         case '0.5.7': // SQL queries for v0.5.7
213                                 // Update notes (these will be set as task text!)
214                                 setExtensionUpdateNotes("Links wegen <strong>what=admins_contct</strong> ge&auml;ndert.");
215                                 break;
216
217                         case '0.5.8': // SQL queries for v0.5.8
218                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `what`='admins_contct' WHERE `what`='admins_contact' LIMIT 1");
219
220                                 // Update notes (these will be set as task text!)
221                                 setExtensionUpdateNotes("Ein Punkt in der Versionsnummernliste verhinderte das 0.5.6-Update.");
222                                 break;
223
224                         case '0.5.9': // SQL queries for v0.5.9
225                                 // Update notes (these will be set as task text!)
226                                 setExtensionUpdateNotes("Sicherheitsupdate: SQL-Anweisungen gesch&uuml;tzt.");
227                                 break;
228
229                         case '0.6.0': // SQL queries for v0.6.0
230                                 // Update notes (these will be set as task text!)
231                                 setExtensionUpdateNotes("Link in &quot;ACL Einstellen&quot; zum Admin-Kontaktformular korregiert.");
232                                 break;
233
234                         case '0.6.1': // SQL queries for v0.6.1
235                                 // Update notes (these will be set as task text!)
236                                 setExtensionUpdateNotes("Speichern von Admin-Accounts klappt wieder.");
237                                 break;
238
239                         case '0.6.2': // SQL queries for v0.6.2
240                                 // Update notes (these will be set as task text!)
241                                 setExtensionUpdateNotes("Bitte verschieben Sie die admins-Templates (Ordner: {?PATH?}/templates/de/emails/) in den neuen Order admins!");
242                                 break;
243
244                         case '0.6.3': // SQL queries for v0.6.3
245                                 // Update notes (these will be set as task text!)
246                                 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
247                                 break;
248
249                         case '0.6.4': // SQL queries for v0.6.4
250                                 // Update notes (these will be set as task text!)
251                                 setExtensionUpdateNotes("Problem mit der Rechtevererbung beseitigt: Geben Sie nun ein Hauptmen&uuml; frei (Allow), dann kann der Admin auch die Untermen&uuml;s erreichen. Zudem k&ouml;nnen Sie gezielte Untermen&uuml;s im freigegeben Hauptmen&uuml; dennoch sperren.");
252                                 break;
253
254                         case '0.6.5': // SQL queries for v0.6.5
255                                 // Update notes (these will be set as task text!)
256                                 setExtensionUpdateNotes("Sicherheitsupdate f&uuml;r die Include-Befehle.");
257                                 break;
258
259                         case '0.6.6': // SQL queries for v0.5.6
260                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `what`='admins_contct' WHERE `what`='admins_contact' LIMIT 1");
261
262                                 // Update notes (these will be set as task text!)
263                                 setExtensionUpdateNotes("Namenskonflikt zwischen den Erweiterungen <strong>admins</strong> und (kommender) <strong>contact</strong>.");
264                                 break;
265
266                         case '0.6.7': // SQL queries for v0.6.7
267                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD la_mode ENUM('global','OLD','NEW') NOT NULL DEFAULT 'global'");
268
269                                 // Update notes (these will be set as task text!)
270                                 setExtensionUpdateNotes("Namenskonflikt zwischen den Erweiterungen <strong>admins</strong> und (kommender) <strong>contact</strong>. Beseitigung eines Fehlers <strong>HTTP_POSR_VARS</strong> beim &Auml;ndern von Administratoren.");
271                                 break;
272
273                         case '0.6.8': // SQL queries for v0.6.8
274                                 // Update notes (these will be set as task text!)
275                                 setExtensionUpdateNotes("<strong>setSession()</strong> mit @-Zeichen gegen ungewollte Ausgaben abgesichert.");
276                                 break;
277
278                         case '0.6.9': // SQL queries for v0.6.9
279                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='Admin-Management' WHERE `action`='admins' AND (`what`='' OR `what` IS NULL) LIMIT 1");
280
281                                 // Update notes (these will be set as task text!)
282                                 setExtensionUpdateNotes("Verwaltung nach Management umbenannt.");
283                                 break;
284
285                         case '0.7.0': // SQL queries for v0.7.0
286                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD `login_failtures` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
287                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD `last_failture` TIMESTAMP NULL DEFAULT NULL");
288
289                                 // Update notes (these will be set as task text!)
290                                 setExtensionUpdateNotes("Veraltetes Update.");
291                                 break;
292
293                         case '0.7.1': // SQL queries for v0.7.1
294                                 // Update depends on sql_patches
295                                 addExtensionDependency('sql_patches');
296
297                                 // Add filters
298                                 registerFilter('sql_admin_extra_data', 'ADD_EXTRA_SQL_DATA', false, true, isExtensionDryRun());
299
300                                 // Update notes (these will be set as task text!)
301                                 setExtensionUpdateNotes("Filter hinzugef&uuml;gt und ist von <strong>sql_patches</strong> abh&auml;ngig.");
302                                 break;
303
304                         case '0.7.2': // SQL queries for v0.7.2
305                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` DROP `login_failtures`");
306                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` DROP `last_failture`");
307                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD `login_failures` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
308                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD `last_failure` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'");
309
310                                 // Update notes (these will be set as task text!)
311                                 setExtensionUpdateNotes("Schreibweise korregiert.");
312                                 break;
313
314                         case '0.7.3': // SQL queries for v0.7.3
315                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD `expert_settings` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
316                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD `expert_warning` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
317
318                                 // Update notes (these will be set as task text!)
319                                 setExtensionUpdateNotes("Experten-Einstellungen sind nun hinzugekommen.");
320                                 break;
321
322                         case '0.7.4': // SQL queries for v0.7.4
323                                 // Add filter
324                                 registerFilter('do_admin_login_done', 'RESET_ADMINS_LOGIN_FAILURES', false, true, isExtensionDryRun());
325                                 registerFilter('do_admin_login_pass', 'COUNT_ADMINS_LOGIN_FAILURE', false, true, isExtensionDryRun());
326
327                                 // Update notes (these will be set as task text!)
328                                 setExtensionUpdateNotes("Filter hinzugefuegt.");
329                                 break;
330
331                         case '0.7.5': // SQL queries for v0.7.5
332                                 // Add filter
333                                 registerFilter('do_admin_login_done', 'REHASH_ADMINS_PASSWORD', false, true, isExtensionDryRun());
334
335                                 // Update notes (these will be set as task text!)
336                                 setExtensionUpdateNotes("Filter hinzugefuegt.");
337                                 break;
338
339                         case '0.7.6': // SQL queries for v0.7.6
340                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` CHANGE `last_failure` `last_failure` TIMESTAMP NULL DEFAULT NULL");
341
342                                 // Update notes (these will be set as task text!)
343                                 setExtensionUpdateNotes("Standardwert ist nicht mehr 0000-00-00 00:00:00, sondern NULL.");
344                                 break;
345                 } // END - switch
346                 break;
347
348         case 'modify': // When the extension got modified
349                 break;
350
351         case 'test': // For testing purposes
352                 break;
353
354         case 'init': // Do stuff when extension is initialized
355                 break;
356
357         default: // Unknown extension mode
358                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
359                 break;
360 } // END - switch
361
362 // [EOF]
363 ?>