New extension ext-partner introduced
[mailer.git] / inc / extensions / ext-cache.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/11/2004 *
4  * ===================                          Last change: 10/11/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-cache.php                                    *
8  * -------------------------------------------------------------------- *
9  * Short description : Caching system for SQL tables on hard disc       *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Caching-System zum Auslagern von SQL-Tabellen    *
12  *                     auf der Festplatte des Servers                   *
13  * -------------------------------------------------------------------- *
14  * $Revision::                                                        $ *
15  * $Date::                                                            $ *
16  * $Tag:: 0.2.1-FINAL                                                 $ *
17  * $Author::                                                          $ *
18  * Needs to be in all Files and every File needs "svn propset           *
19  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
20  * -------------------------------------------------------------------- *
21  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
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.2.5');
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', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5'));
50
51 // Keep this extension always active!
52 setExtensionAlwaysActive('Y');
53
54 // Which load mode?
55 switch (getExtensionMode()) {
56         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
57                 break;
58
59         case 'remove': // Do stuff when removing extension
60                 // SQL commands to run
61                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('cache_stats','config_config')");
62
63                 // Unregister all filters
64                 unregisterFilter('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', true, getExtensionDryRun());
65                 unregisterFilter('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', true, getExtensionDryRun());
66                 unregisterFilter('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', true, getExtensionDryRun());
67                 unregisterFilter('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, getExtensionDryRun());
68                 unregisterFilter('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, getExtensionDryRun());
69                 unregisterFilter('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, getExtensionDryRun());
70                 unregisterFilter('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, getExtensionDryRun());
71                 unregisterFilter('extension_remove', 'CACHE_DESTROY_ALL', true, getExtensionDryRun());
72                 unregisterFilter('shutdown', 'CACHE_DESTROY_FILTER', true, getExtensionDryRun());
73                 break;
74
75         case 'activate': // Do stuff when admin activates this extension
76                 // SQL commands to run
77                 addExtensionSql('');
78                 break;
79
80         case 'deactivate': // Do stuff when admin deactivates this extension
81                 // SQL commands to run
82                 addExtensionSql('');
83                 break;
84
85         case 'update': // Update an extension
86                 // Which version?
87                 switch (getCurrentExtensionVersion()) {
88                         case '0.0.1': // SQL queries for v0.0.1
89                                 // Update notes (these will be set as task text!)
90                                 setExtensionUpdateNotes("Es wurde die Zeitmarke der Cache-Datei extensions.cache mit ber&uuml;cksichtigt. Dies hatte die Folge, dass wenn bei einem Gast die Datei aktualisiert wurde, nur aktivierte und nicht die deaktivierten mit geladen wurden. Folglich fiehlen einfach ein paar Erweiterungen aus.");
91                                 break;
92
93                         case '0.0.2': // SQL queries for v0.0.2
94                                 // Update notes (these will be set as task text!)
95                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
96                                 break;
97
98                         case '0.0.3': // SQL queries for v0.0.3
99                                 // Update notes (these will be set as task text!)
100                                 setExtensionUpdateNotes("Cache-Update repariert.");
101                                 break;
102
103                         case '0.0.4': // SQL queries for v0.0.4
104                                 // Is the cache extension itself there?
105                                 if (isExtensionActive('cache')) {
106                                         // Check for cache when extension is already installed
107                                         if ($GLOBALS['cache_instance']->loadCacheFile('extension')) $GLOBALS['cache_instance']->removeCacheFile();
108                                 } // END - if
109
110                                 // Update notes (these will be set as task text!)
111                                 setExtensionUpdateNotes("Spalte &quot;keep_active&quot; ist hinzugef&uuml;gt. Cache wurde reinitialisiert.");
112                                 break;
113
114                         case '0.0.5': // SQL queries for v0.0.5
115                                 // Update notes (these will be set as task text!)
116                                 setExtensionUpdateNotes("Registrierung der Cache-Erweiterung repariert");
117                                 break;
118
119                         case '0.0.6': // SQL queries for v0.0.6
120                                 // Update notes (these will be set as task text!)
121                                 setExtensionUpdateNotes("Validierung der Cache-Datei admins.cache integriert.");
122                                 break;
123
124                         case '0.0.7': // SQL queries for v0.0.7
125                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD db_hits BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
126                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD cache_hits BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
127                                 addAdminMenuSql('stats','cache_stats','DB-Cache','Auf Cache und gesamte Datenbank registrierte Anfragen anzeigen.', 4);
128
129                                 // Update notes (these will be set as task text!)
130                                 setExtensionUpdateNotes("Hits auf den Cache werden gez&auml;hlt.");
131                                 break;
132
133                         case '0.0.8': // SQL queries for v0.0.8
134                                 // Update notes (these will be set as task text!)
135                                 setExtensionUpdateNotes("Das Umschreiben der Cache-Daten hat eine Fehlermeldung <strong>Falsches Passwort!</strong> im Admin-Bereich verursacht.");
136                                 break;
137
138                         case '0.0.9': // SQL queries for v0.0.9
139                                 // Update notes (these will be set as task text!)
140                                 setExtensionUpdateNotes("Interne Datenfeld-Management korregiert und Cache-Statistiken korregiert.");
141                                 break;
142
143                         case '0.1.0': // SQL queries for v0.2.1
144                                 // Update notes (these will be set as task text!)
145                                 setExtensionUpdateNotes("Problem mit fehlender admins-Erweiterung beseitigt.");
146                                 break;
147
148                         case '0.1.1': // SQL queries for v0.1.1
149                                 // Update notes (these will be set as task text!)
150                                 setExtensionUpdateNotes("Fehler <strong>Division durch 0</strong> repariert in den DB-Cache Statistiken.");
151                                 break;
152
153                         case '0.1.2': // SQL queries for v0.1.2
154                                 // Update notes (these will be set as task text!)
155                                 setExtensionUpdateNotes("Die Tabelen <strong>{?_MYSQL_PREFIX?}_config</strong>, <strong>{?_MYSQL_PREFIX?}_refsystem</strong>, <strong>{?_MYSQL_PREFIX?}_refdepths</strong> und <strong>{?_MYSQL_PREFIX?}_mod_reg</strong> werden nun auch ausgelagert.");
156                                 break;
157
158                         case '0.1.3': // SQL queries for v0.1.3
159                                 // Update notes (these will be set as task text!)
160                                 setExtensionUpdateNotes("Ung&uuml;ltiges Update.");
161                                 break;
162
163                         case '0.1.4': // SQL queries for v0.1.4
164                                 // Update notes (these will be set as task text!)
165                                 setExtensionUpdateNotes("Fehler <strong>Division durch 0</strong> repariert in <strong>inc/load_cache.php</strong>.");
166                                 break;
167
168                         case '0.1.5': // SQL queries for v0.1.5
169                                 // Update notes (these will be set as task text!)
170                                 setExtensionUpdateNotes("Weitere Fehler im System beseitigt.");
171                                 break;
172
173                         case '0.1.6': // SQL queries for v0.1.6
174                                 // Update notes (these will be set as task text!)
175                                 setExtensionUpdateNotes("Probleme w&auml;hrend des Installationsvorganges beseitigt.");
176                                 break;
177
178                         case '0.1.7': // SQL queries for v0.1.7
179                                 // Update notes (these will be set as task text!)
180                                 setExtensionUpdateNotes("CSS-Klassenname gefixt in Templates.");
181                                 break;
182
183                         case '0.1.8': // SQL queries for v0.1.8
184                                 // Update notes (these will be set as task text!)
185                                 setExtensionUpdateNotes("Daten von installierten Themes werden nun gecacht.");
186                                 break;
187
188                         case '0.1.9': // SQL queries for v0.1.9
189                                 // Update notes (these will be set as task text!)
190                                 setExtensionUpdateNotes("Update nicht mehr g&uuml;ltig.");
191                                 break;
192
193                         case '0.2.0': // SQL queries for v0.2.0
194                                 // This update depends on sql_patches
195                                 addExtensionUpdateDependency('sql_patches');
196
197                                 // Update notes (these will be set as task text!)
198                                 setExtensionUpdateNotes("Die Erweiterung h&auml;ngt nun von der <strong>sql_patches</strong> ab.");
199                                 break;
200
201                         case '0.2.1': // SQL queries for v0.2.1
202                                 // Register the new filter
203                                 registerFilter('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true, getExtensionDryRun());
204                                 registerFilter('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true, getExtensionDryRun());
205                                 registerFilter('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true, getExtensionDryRun());
206                                 registerFilter('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, getExtensionDryRun());
207                                 registerFilter('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, getExtensionDryRun());
208                                 registerFilter('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, getExtensionDryRun());
209                                 registerFilter('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, getExtensionDryRun());
210                                 registerFilter('extension_remove', 'CACHE_DESTROY_ALL', false, true, getExtensionDryRun());
211
212                                 // Update notes (these will be set as task text!)
213                                 setExtensionUpdateNotes("Filter f&uuml;r Erweiterungsmanagement hinzugef&uuml;gt.");
214                                 break;
215
216                         case '0.2.2': // SQL queries for v0.2.2
217                                 // Update notes (these will be set as task text!)
218                                 setExtensionUpdateNotes("Update nicht mehr g&uuml;ltig.");
219                                 break;
220
221                         case '0.2.3': // SQL queries for v0.2.3
222                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD cache_filter ENUM('Y','N') NOT NULL DEFAULT 'Y'");
223
224                                 // Update notes (these will be set as task text!)
225                                 setExtensionUpdateNotes("Cachen von Filtern hinzugef&uuml;gt.");
226
227                                 // Register a new filter
228                                 registerFilter('shutdown', 'CACHE_DESTROY_FILTER', false, true, getExtensionDryRun());
229                                 break;
230
231                         case '0.2.4': // SQL queries for v0.2.4
232                                 // SQL commands to run
233                                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='config_cache' LIMIT 1");
234
235                                 // Remove config entries
236                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_themes`");
237                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_admins`");
238                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_acls`");
239                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_exts`");
240                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_config`");
241                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_modreg`");
242                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_refdepth`");
243                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_refsys`");
244
245                                 // Update notes (these will be set as task text!)
246                                 setExtensionUpdateNotes("Der Cache hat keine Konfiguration mehr.");
247                                 break;
248
249                         case '0.2.5': // SQL queries for v0.2.5
250                                 // Update notes (these will be set as task text!)
251                                 setExtensionUpdateNotes("Daten von gefundenen Sprachdateien werden zu den Erweiterungen gecacht.");
252                                 break;
253                 }
254                 break;
255
256         case 'modify': // When the extension got modified
257                 break;
258
259         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
260                 break;
261
262         case 'init': // Do stuff when extension is initialized
263                 break;
264
265         default: // Unknown extension mode
266                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));
267                 break;
268 }
269
270 // [EOF]
271 ?>