fd920a839c66da74adc42308f6b1f4244c3560bb
[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  * -------------------------------------------------------------------- *
19  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
20  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         die();
42 } // END - if
43
44 // Version number
45 setThisExtensionVersion('0.2.5');
46
47 // Version history array (add more with , '0.1.0' and so on)
48 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'));
49
50 // Keep this extension always active!
51 setExtensionAlwaysActive('Y');
52
53 // Which load mode?
54 switch (getExtensionMode()) {
55         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
56                 break;
57
58         case 'remove': // Do stuff when removing extension
59                 // SQL commands to run
60                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('cache_stats','config_config')");
61
62                 // Unregister all filters
63                 unregisterFilter(__FUNCTION__, __LINE__, 'extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', true, isExtensionDryRun());
64                 unregisterFilter(__FUNCTION__, __LINE__, 'post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', true, isExtensionDryRun());
65                 unregisterFilter(__FUNCTION__, __LINE__, 'post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', true, isExtensionDryRun());
66                 unregisterFilter(__FUNCTION__, __LINE__, 'post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, isExtensionDryRun());
67                 unregisterFilter(__FUNCTION__, __LINE__, 'post_form_submited', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, isExtensionDryRun());
68                 unregisterFilter(__FUNCTION__, __LINE__, 'post_form_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, isExtensionDryRun());
69                 unregisterFilter(__FUNCTION__, __LINE__, 'post_form_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, isExtensionDryRun());
70                 unregisterFilter(__FUNCTION__, __LINE__, 'extension_remove', 'CACHE_DESTROY_ALL', true, isExtensionDryRun());
71                 unregisterFilter(__FUNCTION__, __LINE__, 'shutdown', 'CACHE_DESTROY_FILTER', 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                 // Which version?
86                 switch (getCurrentExtensionVersion()) {
87                         case '0.0.1': // SQL queries for v0.0.1
88                                 // Update notes (these will be set as task text!)
89                                 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.");
90                                 break;
91
92                         case '0.0.2': // SQL queries for v0.0.2
93                                 // Update notes (these will be set as task text!)
94                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
95                                 break;
96
97                         case '0.0.3': // SQL queries for v0.0.3
98                                 // Update notes (these will be set as task text!)
99                                 setExtensionUpdateNotes("Cache-Update repariert.");
100                                 break;
101
102                         case '0.0.4': // SQL queries for v0.0.4
103                                 // Is the cache extension itself there?
104                                 if (isExtensionActive('cache')) {
105                                         // Check for cache when extension is already installed
106                                         if ($GLOBALS['cache_instance']->loadCacheFile('extension')) $GLOBALS['cache_instance']->removeCacheFile();
107                                 } // END - if
108
109                                 // Update notes (these will be set as task text!)
110                                 setExtensionUpdateNotes("Spalte &quot;keep_active&quot; ist hinzugef&uuml;gt. Cache wurde reinitialisiert.");
111                                 break;
112
113                         case '0.0.5': // SQL queries for v0.0.5
114                                 // Update notes (these will be set as task text!)
115                                 setExtensionUpdateNotes("Registrierung der Cache-Erweiterung repariert");
116                                 break;
117
118                         case '0.0.6': // SQL queries for v0.0.6
119                                 // Update notes (these will be set as task text!)
120                                 setExtensionUpdateNotes("Validierung der Cache-Datei admins.cache integriert.");
121                                 break;
122
123                         case '0.0.7': // SQL queries for v0.0.7
124                                 addConfigAddSql("db_hits BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
125                                 addConfigAddSql("cache_hits BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
126                                 addAdminMenuSql('stats','cache_stats','DB-Cache','Auf Cache und gesamte Datenbank registrierte Anfragen anzeigen.', 4);
127
128                                 // Update notes (these will be set as task text!)
129                                 setExtensionUpdateNotes("Hits auf den Cache werden gez&auml;hlt.");
130                                 break;
131
132                         case '0.0.8': // SQL queries for v0.0.8
133                                 // Update notes (these will be set as task text!)
134                                 setExtensionUpdateNotes("Das Umschreiben der Cache-Daten hat eine Fehlermeldung <strong>Falsches Passwort!</strong> im Admin-Bereich verursacht.");
135                                 break;
136
137                         case '0.0.9': // SQL queries for v0.0.9
138                                 // Update notes (these will be set as task text!)
139                                 setExtensionUpdateNotes("Interne Datenfeld-Management korregiert und Cache-Statistiken korregiert.");
140                                 break;
141
142                         case '0.1.0': // SQL queries for v0.2.1
143                                 // Update notes (these will be set as task text!)
144                                 setExtensionUpdateNotes("Problem mit fehlender admins-Erweiterung beseitigt.");
145                                 break;
146
147                         case '0.1.1': // SQL queries for v0.1.1
148                                 // Update notes (these will be set as task text!)
149                                 setExtensionUpdateNotes("Fehler <strong>Division durch 0</strong> repariert in den DB-Cache Statistiken.");
150                                 break;
151
152                         case '0.1.2': // SQL queries for v0.1.2
153                                 // Update notes (these will be set as task text!)
154                                 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.");
155                                 break;
156
157                         case '0.1.3': // SQL queries for v0.1.3
158                                 // Update notes (these will be set as task text!)
159                                 setExtensionUpdateNotes("Ung&uuml;ltiges Update.");
160                                 break;
161
162                         case '0.1.4': // SQL queries for v0.1.4
163                                 // Update notes (these will be set as task text!)
164                                 setExtensionUpdateNotes("Fehler <strong>Division durch 0</strong> repariert in <strong>inc/load_cache.php</strong>.");
165                                 break;
166
167                         case '0.1.5': // SQL queries for v0.1.5
168                                 // Update notes (these will be set as task text!)
169                                 setExtensionUpdateNotes("Weitere Fehler im System beseitigt.");
170                                 break;
171
172                         case '0.1.6': // SQL queries for v0.1.6
173                                 // Update notes (these will be set as task text!)
174                                 setExtensionUpdateNotes("Probleme w&auml;hrend des Installationsvorganges beseitigt.");
175                                 break;
176
177                         case '0.1.7': // SQL queries for v0.1.7
178                                 // Update notes (these will be set as task text!)
179                                 setExtensionUpdateNotes("CSS-Klassenname gefixt in Templates.");
180                                 break;
181
182                         case '0.1.8': // SQL queries for v0.1.8
183                                 // Update notes (these will be set as task text!)
184                                 setExtensionUpdateNotes("Daten von installierten Themes werden nun gecacht.");
185                                 break;
186
187                         case '0.1.9': // SQL queries for v0.1.9
188                                 // Update notes (these will be set as task text!)
189                                 setExtensionUpdateNotes("Update nicht mehr g&uuml;ltig.");
190                                 break;
191
192                         case '0.2.0': // SQL queries for v0.2.0
193                                 // This update depends on sql_patches
194                                 addExtensionDependency('sql_patches');
195
196                                 // Update notes (these will be set as task text!)
197                                 setExtensionUpdateNotes("Die Erweiterung h&auml;ngt nun von der <strong>sql_patches</strong> ab.");
198                                 break;
199
200                         case '0.2.1': // SQL queries for v0.2.1
201                                 // Register the new filter
202                                 registerFilter('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true, isExtensionDryRun());
203                                 registerFilter('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true, isExtensionDryRun());
204                                 registerFilter('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true, isExtensionDryRun());
205                                 registerFilter('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, isExtensionDryRun());
206                                 registerFilter('post_form_submited', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, isExtensionDryRun());
207                                 registerFilter('post_form_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, isExtensionDryRun());
208                                 registerFilter('post_form_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, isExtensionDryRun());
209                                 registerFilter('extension_remove', 'CACHE_DESTROY_ALL', false, true, isExtensionDryRun());
210
211                                 // Update notes (these will be set as task text!)
212                                 setExtensionUpdateNotes("Filter f&uuml;r Erweiterungsmanagement hinzugef&uuml;gt.");
213                                 break;
214
215                         case '0.2.2': // SQL queries for v0.2.2
216                                 // Update notes (these will be set as task text!)
217                                 setExtensionUpdateNotes("Update nicht mehr g&uuml;ltig.");
218                                 break;
219
220                         case '0.2.3': // SQL queries for v0.2.3
221                                 addConfigAddSql("cache_filter ENUM('Y','N') NOT NULL DEFAULT 'Y'");
222
223                                 // Update notes (these will be set as task text!)
224                                 setExtensionUpdateNotes("Cachen von Filtern hinzugef&uuml;gt.");
225
226                                 // Register a new filter
227                                 registerFilter('shutdown', 'CACHE_DESTROY_FILTER', false, true, isExtensionDryRun());
228                                 break;
229
230                         case '0.2.4': // SQL queries for v0.2.4
231                                 // SQL commands to run
232                                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='config_cache' LIMIT 1");
233
234                                 // Remove config entries
235                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_themes`");
236                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_admins`");
237                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_acls`");
238                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_exts`");
239                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_config`");
240                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_modreg`");
241                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_refdepth`");
242                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_refsys`");
243
244                                 // Update notes (these will be set as task text!)
245                                 setExtensionUpdateNotes("Der Cache hat keine Konfiguration mehr.");
246                                 break;
247
248                         case '0.2.5': // SQL queries for v0.2.5
249                                 // Update notes (these will be set as task text!)
250                                 setExtensionUpdateNotes("Daten von gefundenen Sprachdateien werden zu den Erweiterungen gecacht.");
251                                 break;
252                 }
253                 break;
254
255         case 'modify': // When the extension got modified
256                 break;
257
258         case 'test': // For testing purposes
259                 break;
260
261         case 'init': // Do stuff when extension is initialized
262                 break;
263
264         default: // Unknown extension mode
265                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
266                 break;
267 }
268
269 // [EOF]
270 ?>