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