Some major rewrites + ext-network continued:
[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 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://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.9');
45
46 // Version history array (add more with , '0.0.1' and so on)
47 setExtensionVersionHistory(array('0.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', '0.7.7', '0.7.8', '0.7.9'));
48
49 // Keep this extension always active!
50 setExtensionAlwaysActive('Y');
51
52 switch (getExtensionMode()) {
53         case 'setup': // Do stuff when installation is running
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                 addExtensionDropTableColumnSql('admins', 'default_acl');
66
67                 // Remove filters
68                 unregisterFilter(__FILE__, __LINE__, 'sql_admin_extra_data', 'ADD_EXTRA_SQL_DATA', TRUE, isExtensionDryRun());
69                 unregisterFilter(__FILE__, __LINE__, 'do_admin_login_done', 'RESET_ADMINS_LOGIN_FAILURES', TRUE, isExtensionDryRun());
70                 unregisterFilter(__FILE__, __LINE__, 'do_admin_login_pass', 'COUNT_ADMINS_LOGIN_FAILURE', TRUE, isExtensionDryRun());
71                 unregisterFilter(__FILE__, __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                                 addExtensionAddTableColumnSql('admins', '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                                 addCreateTableSql('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 PRIMARY KEY (`id`),
113 INDEX (`admin_id`)",
114                                         '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                                 addExtensionChangeTableColumnSql('admins_acls', 'id', '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                                 addCreateTableSql('admins_mails', "
127 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
128 `admin_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
129 `mail_template` VARCHAR(255) NOT NULL,
130 PRIMARY KEY (`id`),
131 INDEX (`admin_id`)",
132                                         '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                                 addExtensionAddTableColumnSql('admins', '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                                 addExtensionAddTableColumnSql('admins', 'login_failtures', "BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
287                                 addExtensionAddTableColumnSql('admins', '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                                 // Add filters
295                                 registerFilter(__FILE__, __LINE__, 'sql_admin_extra_data', 'ADD_EXTRA_SQL_DATA', FALSE, TRUE, isExtensionDryRun());
296
297                                 // Update notes (these will be set as task text!)
298                                 setExtensionUpdateNotes("Filter hinzugef&uuml;gt und ist von <strong>sql_patches</strong> abh&auml;ngig.");
299                                 break;
300
301                         case '0.7.2': // SQL queries for v0.7.2
302                                 addExtensionDropTableColumnSql('admins', 'login_failtures');
303                                 addExtensionDropTableColumnSql('admins', 'last_failture');
304                                 addExtensionAddTableColumnSql('admins', 'login_failures', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
305                                 addExtensionAddTableColumnSql('admins', 'last_failure', "TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'");
306
307                                 // Update notes (these will be set as task text!)
308                                 setExtensionUpdateNotes("Schreibweise korregiert.");
309                                 break;
310
311                         case '0.7.3': // SQL queries for v0.7.3
312                                 addExtensionAddTableColumnSql('admins', 'expert_settings', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
313                                 addExtensionAddTableColumnSql('admins', 'expert_warning', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
314
315                                 // Update notes (these will be set as task text!)
316                                 setExtensionUpdateNotes("Entwicklereinstellungen sind nun hinzugekommen.");
317                                 break;
318
319                         case '0.7.4': // SQL queries for v0.7.4
320                                 // Add filter
321                                 registerFilter(__FILE__, __LINE__, 'do_admin_login_done', 'RESET_ADMINS_LOGIN_FAILURES', FALSE, TRUE, isExtensionDryRun());
322                                 registerFilter(__FILE__, __LINE__, 'do_admin_login_pass', 'COUNT_ADMINS_LOGIN_FAILURE', FALSE, TRUE, isExtensionDryRun());
323
324                                 // Update notes (these will be set as task text!)
325                                 setExtensionUpdateNotes("Filter hinzugefuegt.");
326                                 break;
327
328                         case '0.7.5': // SQL queries for v0.7.5
329                                 // Add filter
330                                 registerFilter(__FILE__, __LINE__, 'do_admin_login_done', 'REHASH_ADMINS_PASSWORD', FALSE, TRUE, isExtensionDryRun());
331
332                                 // Update notes (these will be set as task text!)
333                                 setExtensionUpdateNotes("Filter zum Rehashen des Adminpassworts nach erfolgtem Login hinzugef&uuml;gt.");
334                                 break;
335
336                         case '0.7.6': // SQL queries for v0.7.6
337                                 addExtensionChangeTableColumnSql('admins', 'last_failure', 'last_failure', 'TIMESTAMP NULL DEFAULT NULL');
338
339                                 // Update notes (these will be set as task text!)
340                                 setExtensionUpdateNotes("Ausgangswert ist nicht mehr 0000-00-00 00:00:00, sondern NULL.");
341                                 break;
342
343                         case '0.7.7': // SQL queries for v0.7.7
344                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `what`='list_admins_acls' WHERE `what`='config_admins' LIMIT 1");
345
346                                 // Update notes (these will be set as task text!)
347                                 setExtensionUpdateNotes("Ausgangswert ist nicht mehr 0000-00-00 00:00:00, sondern NULL.");
348                                 break;
349
350                         case '0.7.8': // SQL queries for v0.7.8
351                                 // Update notes (these will be set as task text!)
352                                 setExtensionUpdateNotes("Abgek&uuml;rzte Bezeichnungen k&ouml;nnen f&uuml;r Missverst&auml;ndnisse am Code sorgen. Daher wurde der Spaltenalias <strong>def_acl</strong> entfernt.");
353                                 break;
354
355                         case '0.7.9': // SQL queries for v0.7.9
356                                 addExtensionChangeTableColumnSql('admins_mails', 'admin_id', 'admin_id', 'BIGINT(20) UNSIGNED NULL DEFAULT NULL');
357                                 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_admins_mails` SET `admin_id` = NULL WHERE `admin_id`=0');
358                                 addExtensionSql("DELETE FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE `mail_template` IN ('admin-del_links', 'back-admin', 'done-admin', 'order-admin', 'register-admin')");
359
360                                 // Update notes (these will be set as task text!)
361                                 setExtensionUpdateNotes("Spalte <strong>admin_id</strong> ist jetzt Ausgangswert NULL, alte Mail-Templates bereinigt.");
362                                 break;
363                 } // END - switch
364                 break;
365
366         case 'modify': // When the extension got modified
367                 break;
368
369         case 'test': // For testing purposes
370                 break;
371
372         case 'init': // Do stuff when extension is initialized
373                 break;
374
375         default: // Unknown extension mode
376                 reportBug(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
377                 break;
378 } // END - switch
379
380 // [EOF]
381 ?>