Fixes/rewrites for content-type
[mailer.git] / inc / extensions-functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/25/2009 *
4  * ===================                          Last change: 10/25/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : extensions-functions.php                         *
8  * -------------------------------------------------------------------- *
9  * Short description : Extension management                             *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Erweiterungen-Management                         *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
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 // Load the extension and maybe found language and function files.
45 function loadExtension ($ext_name, $ext_mode = 'init', $ext_ver = '', $dry_run = false) {
46         // Set current extension name
47         setCurrentExtensionName($ext_name);
48
49         // Set current extension version
50         setCurrentExtensionVersion($ext_ver);
51
52         // Set extension mode
53         setExtensionMode($ext_mode);
54
55         // Set dry-run
56         enableExtensionDryRun($dry_run);
57
58         // Init array
59         initIncludePool('extension');
60
61         // Init EXT_UPDATE_DEPENDS
62         initExtensionUpdateDependencies();
63
64         // Init current extension name list
65         initExtensionSqls();
66
67         // Is the extension already loaded?
68         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "Loading extension {$ext_name}, mode=".getExtensionMode().", ver=".getCurrentExtensionVersion()."");
69         if ((isset($GLOBALS['ext_loaded']['ext'][$ext_name])) && (getExtensionMode() == 'init')) {
70                 // Debug message
71                 logDebugMessage(__FUNCTION__, __LINE__, sprintf("Extension %s already loaded.", $ext_name));
72
73                 // Abort here
74                 return false;
75         } // END - if
76
77         // Is the extension file NOT there?
78         if (!isExtensionNameValid($ext_name)) {
79                 // Debug message
80                 logDebugMessage(__FUNCTION__, __LINE__, sprintf("Extension %s not found or not readable.", $ext_name));
81
82                 // Abort here
83                 return false;
84         } // END - if
85
86         // Load extension's own language file if not in test mode
87         if ((getExtensionMode() != 'test') && (ifExtensionHasLanguageFile($ext_name))) {
88                 // Load it
89                 loadLanguageFile($ext_name);
90         } // END - if
91
92         // Do we have cache?
93         if (isExtensionFunctionFileReadable($ext_name)) {
94                 // Not yet loaded?
95                 if ((($GLOBALS['cache_array']['extension']['ext_func'][$ext_name] == 'Y') || (!isset($GLOBALS['cache_array']['extension']['ext_func'][$ext_name]))) && (!isset($GLOBALS['ext_loaded']['funcs'][$ext_name]))) {
96                         // Construct FQFN for functions file
97                         $funcsInclude = sprintf("inc/libs/%s_functions.php", $ext_name);
98
99                         // Mark it as loaded
100                         $GLOBALS['ext_loaded']['funcs'][$ext_name] = true;
101
102                         // Download functions file
103                         loadIncludeOnce($funcsInclude);
104                 } // END - if
105         } elseif ((!isset($GLOBALS['cache_array']['extension']['ext_func'][$ext_name])) && (isDebugModeEnabled()) && (getOutputMode() == '0') && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme') && (getExtensionMode() == 'test')) {
106                 // No functions file is not so good...
107                 logDebugMessage(__FUNCTION__, __LINE__, sprintf("NOTICE: Extension %s has no own functions file or we cannot read from it. mode=%s",
108                         $ext_name,
109                         getExtensionMode()
110                 ));
111         }
112
113         // Extensions are not deprecated by default
114         setExtensionDeprecated('N');
115
116         // Extensions are not always active by default
117         setExtensionAlwaysActive('N');
118
119         // Extension update notes
120         setExtensionUpdateNotes('');
121
122         // Include the extension file
123         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "Extension loaded.");
124         loadExtensionInclude();
125
126         // Is this extension deprecated?
127         if (isExtensionDeprecated()) {
128                 // Deactivate the extension
129                 doDeactivateExtension($ext_name);
130
131                 // Abort here
132                 return false;
133         } // END - if
134
135         // Mark it as loaded in normal mode
136         if (getExtensionMode() == '') {
137                 // Mark it now...
138                 $GLOBALS['ext_loaded']['ext'][$ext_name] = true;
139         } // END - if
140
141         // All fine!
142         return true;
143 }
144
145 // Registeres an extension and possible update depencies
146 function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = true) {
147         // Set current extension name
148         setCurrentExtensionName($ext_name);
149
150         // Enable dry-run
151         enableExtensionDryRun($dry_run);
152
153         // By default all extensions are in productive phase
154         enableExtensionProductive();
155
156         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName()." - ENTERED!");
157         // This shall never do a non-admin user or if the extension is active (already installed)
158         if ((!isAdmin()) || (isExtensionInstalled($ext_name))) {
159                 return false;
160         } // END - if
161
162         // When this extension is already in install/update phase, all is fine
163         if (isExtensionRegisterRunning($ext_name)) {
164                 // Then abort here which is fine
165                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName()." - ALREADY!");
166                 return true;
167         } // END - if
168
169         // This registration is running
170         addExtensionRunningRegistration($ext_name);
171
172         // Init EXT_UPDATE_DEPENDS
173         initExtensionUpdateDependencies();
174
175         // Is the task id zero? Then we need to auto-fix it here
176         if ($task_id == '0') {
177                 // Try to find the task
178                 $task_id = determineExtensionTaskId(getCurrentExtensionName());
179
180                 // Still zero and not in dry-run?
181                 if (($task_id == '0') && (!getExtensionDryRun())) {
182                         // Then request a bug report
183                         debug_report_bug(sprintf("%s: task_id is still zero after determineExtensionTaskId(%s)",
184                                 __FUNCTION__,
185                                 getCurrentExtensionName()
186                         ));
187                 } // END - if
188         } // END - if
189
190         // Init queries and notes
191         initExtensionSqls();
192         initExtensionNotes();
193
194         // Init variables
195         $ret = false;
196         $test = false;
197         initIncludePool('extension');
198
199         // By default we have no failures
200         setExtensionReportsFailure(false);
201
202         // Does this extension exists?
203         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName()."");
204         if (loadExtension(getCurrentExtensionName(), 'register', '', getExtensionDryRun())) {
205                 // Set current extension name again
206                 setCurrentExtensionName($ext_name);
207
208                 // And run possible updates
209                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "".getCurrentExtensionName());
210                 $history = getExtensionVersionHistory();
211                 foreach ($history as $ver) {
212                         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "ext_name=".getCurrentExtensionName().", ext_ver={$ver}");
213                         // Load extension in update mode
214                         loadExtension(getCurrentExtensionName(), 'update', $ver, getExtensionDryRun());
215
216                         // Add update notes to our output
217                         addExtensionNotes($ver);
218                 } // END - foreach
219
220                 // Does this extension depends on an outstanding update of another update?
221                 for ($dmy = getExtensionUpdateIterator(); getExtensionUpdateIterator() < countExtensionUpdateDependencies();) {
222                         // Get next update
223                         $ext_update = getExtensionUpdateDependenciesIterator();
224
225                         // Increment here to avoid endless loop
226                         incrementExtensionUpdateIterator();
227
228                         // Check for required file
229                         if ((!isExtensionInstalled($ext_update)) && (loadExtension($ext_update, 'register', '', getExtensionDryRun()))) {
230                                 // Set current extension name again
231                                 setCurrentExtensionName($ext_name);
232
233                                 // If versions mismatch update extension first
234                                 $ext_ver = '';
235                                 if (isExtensionInstalled($ext_update)) {
236                                         // Get version only if installed
237                                         $ext_ver = getExtensionVersion($ext_update);
238                                 } // END - if
239
240                                 // Extension version set? If empty the extension is not registered
241                                 if (empty($ext_ver)) {
242                                         // Extension not registered so far so first load task's id...
243                                         $task = determineExtensionTaskId($ext_update);
244
245                                         // Entry found?
246                                         if ($task > 0) {
247                                                 // Try to register the extension
248                                                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName().":ext_update=".$ext_update.",taskId=".$task."");
249                                                 $test = registerExtension($ext_update, $task, getExtensionDryRun(), false);
250
251                                                 // Reset extension name
252                                                 setCurrentExtensionName($ext_name);
253                                                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName()); print getCurrentExtensionName().':<pre>'.print_r($test);
254                                         } // END - if
255                                 } elseif ($ext_ver != getCurrentExtensionVersion()) {
256                                         // Ok, update this extension now
257                                         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName='.getCurrentExtensionName().',currVer='.getCurrentExtensionVersion().'');
258                                         $GLOBALS['ext_backup_name'][$ext_update][$ext_ver] = getCurrentExtensionName();
259                                         $GLOBALS['ext_backup_ver'][$ext_update][$ext_ver] = getCurrentExtensionVersion();
260                                         updateExtension($ext_update, $ext_ver, getExtensionDryRun());
261                                         setCurrentExtensionName($GLOBALS['ext_backup_name'][$ext_update][$ext_ver]);
262                                         setCurrentExtensionVersion($GLOBALS['ext_backup_ver'][$ext_update][$ext_ver]);
263                                         unset($GLOBALS['ext_backup_name'][$ext_update][$ext_ver]);
264                                         unset($GLOBALS['ext_backup_ver'][$ext_update][$ext_ver]);
265                                         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName='.getCurrentExtensionName().',currVer='.getCurrentExtensionVersion().'');
266
267                                         // All okay!
268                                         $test = true;
269                                 } else {
270                                         // Nothing to register / update before...
271                                         $test = true;
272                                 }
273                         } else {
274                                 // Required file for update does not exists!
275                                 $test = true;
276                                 // But this is fine for the first time...
277                         }
278
279                         // Restore the current extension name
280                         setCurrentExtensionName($ext_name);
281                 } // END - for
282
283                 // Is there no update?
284                 if (countExtensionUpdateDependencies(getCurrentExtensionName()) == '0') {
285                         // Then test is passed!
286                         $test = true;
287                 } // END - if
288
289                 // Switch back to register mode
290                 setExtensionMode('register');
291
292                 // Remains true if extension registration reports no failures
293                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName()); print getCurrentExtensionName().':<pre>'.print_r($test, true).'</pre>';
294                 $test = (($test === true) && (getExtensionReportsFailure() === false));
295                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName()); print getCurrentExtensionName().':<pre>'.print_r($test, true).'</pre>';
296
297                 // Does everthing before wents ok?
298                 if ($test === true) {
299                         // "Dry-run-mode" activated?
300                         if ((getExtensionDryRun() === false) && (!isExtensionOnRemovalList())) {
301                                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "ext_name=".getCurrentExtensionName());
302                                 // Init SQLs and transfer ext->generic
303                                 initSqls();
304                                 setSqlsArray(getExtensionSqls());
305
306                                 // Run installation pre-installation filters
307                                 runFilterChain('pre_extension_installed', array('dry_run' => getExtensionDryRun()));
308
309                                 // Register extension
310                                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "insert=".getCurrentExtensionName().'/'.getCurrentExtensionVersion()." - INSERT!");
311                                 if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
312                                         // New way, with CSS
313                                         SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_extensions` (`ext_name`, `ext_active`, `ext_version`,`ext_has_css`) VALUES ('%s','%s','%s','%s')",
314                                                 array(getCurrentExtensionName(), getExtensionAlwaysActive(), getCurrentExtensionVersion(), getExtensionHasCss()), __FUNCTION__, __LINE__);
315                                 } else {
316                                         // Old way, no CSS
317                                         SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_extensions` (`ext_name`, `ext_active`, `ext_version`) VALUES ('%s','%s','%s')",
318                                                 array(getCurrentExtensionName(), getExtensionAlwaysActive(), getCurrentExtensionVersion()), __FUNCTION__, __LINE__);
319                                 }
320
321                                 // Remove cache file(s) if extension is active
322                                 runFilterChain('post_extension_installed', array(
323                                         'pool'     => 'extension',
324                                         'ext_name' => getCurrentExtensionName(),
325                                         'task_id'  => $task_id
326                                 ));
327
328                                 // Remove all SQL commands
329                                 unsetSqls();
330
331                                 // Mark it as installed
332                                 $GLOBALS['ext_is_installed'][getCurrentExtensionName()] = true;
333
334                                 // In normal mode return a true on success
335                                 $ret = true;
336                         } elseif (getExtensionDryRun() === true) {
337                                 // In  "dry-run" mode return array with all SQL commands
338                                 $ret = getExtensionSqls();
339
340                                 // Remove all SQL commands
341                                 unsetSqls();
342                         } else {
343                                 // Extension has been removed for updates, so all is fine!
344                                 $ret = true;
345                         }
346                 } else {
347                         // No, an error occurs while registering extension :-(
348                         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "".getCurrentExtensionName());
349                         $ret = false;
350                 }
351         } elseif (($task_id > 0) && (getCurrentExtensionName() != '')) {
352                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName()."");
353                 // Remove task from system when id and extension's name is valid
354                 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s AND `status`='NEW' LIMIT 1",
355                         array(bigintval($task_id)), __FUNCTION__, __LINE__);
356         }
357
358         // Is this the sql_patches?
359         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ':'.getCurrentExtensionName()."/".getExtensionMode()."");
360         if ((getCurrentExtensionName() == 'sql_patches') && ((getExtensionMode() == 'register') || (getExtensionMode() == 'remove')) && (!getExtensionDryRun()) && ($test)) {
361                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ": LOAD!");
362                 if ($logout === true) {
363                         // Then redirect to logout
364                         redirectToUrl('modules.php?module=admin&amp;logout=1&amp;' . getExtensionMode() . '=sql_patches');
365                 } else {
366                         // Add temporary filter
367                         registerFilter('shutdown', 'REDIRECT_TO_LOGOUT_SQL_PATCHES', true, true);
368                         $GLOBALS['ext_load_mode'] = getExtensionMode();
369                 }
370         } // END - if
371
372         // Return status code
373         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName()." - LEFT!");
374         //* DEBUG: */ print getCurrentExtensionName().':<pre>'.print_r($ret, true).'</pre>';
375         return $ret;
376 }
377
378 // Run SQL queries for given extension id
379 // @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
380 function doExtensionSqls ($ext_id, $load_mode) {
381         // This shall never do a non-admin user!
382         if (!isAdmin()) return false;
383
384         // Get extension's name
385         $ext_name = getExtensionName($ext_id);
386
387         // Set current SQL name
388         setCurrentExtensionName($ext_name);
389
390         // Init EXT_UPDATE_DEPENDS
391         initExtensionUpdateDependencies();
392
393         // Init array
394         initExtensionSqls();
395
396         // By default no SQL has been executed
397         $sqlRan = false;
398
399         // Load extension in detected mode
400         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ":ext_name[{$ext_id}]=".getCurrentExtensionName()."");
401         loadExtension(getCurrentExtensionName(), $load_mode, '', false);
402
403         // Init these SQLs
404         initSqls();
405         setSqlsArray(getExtensionSqls());
406
407         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ":SQLs::count=".countSqls()."");
408         if (isSqlsValid()) {
409                 // Run SQL commands...
410                 runFilterChain('run_sqls');
411         } // END - if
412
413         // Run any filters depending on the action here
414         runFilterChain('extension_' . $load_mode);
415
416         // Remove cache file(s) if extension is active
417         if (((isExtensionActive('cache')) && ((SQL_AFFECTEDROWS() == 1)) || ($sqlRan === true) || ($load_mode == 'activate') || ($load_mode == 'deactivate'))) {
418                 // Run filters
419                 runFilterChain('post_extension_run_sql', getCurrentExtensionName());
420         } // END - if
421
422         // Is this the sql_patches?
423         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ": id=".$ext_id.",currName=".getCurrentExtensionName().",loadMode=".$load_mode);
424         if ((getCurrentExtensionName() == 'sql_patches') && (($load_mode == 'register') || ($load_mode == 'remove'))) {
425                 // Then redirect to logout
426                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ": LOAD!");
427                 redirectToUrl('modules.php?module=admin&amp;logout=1&amp;' . $load_mode . '=sql_patches');
428         } // END - if
429 }
430
431 // Check wether the given extension is installed
432 function isExtensionInstalled ($ext_name) {
433         // We don't like empty extension names here
434         if (empty($ext_name)) {
435                 // Please fix them all
436                 debug_report_bug(__FUNCTION__.': ext_name is empty.');
437         } // END - if
438
439         // By default non is installed
440         $isInstalled = false;
441
442         // Check if there is a cache entry
443         if (isset($GLOBALS['ext_is_installed'][$ext_name])) {
444                 // Use cache built from below queries
445                 $isInstalled = $GLOBALS['ext_is_installed'][$ext_name];
446         } elseif (isset($GLOBALS['cache_array']['extension']['ext_id'][$ext_name])) {
447                 // Found!
448                 $isInstalled = true;
449
450                 // Count cache hits
451                 incrementStatsEntry('cache_hits');
452         } elseif ((isInstallationPhase())) {
453                 // Extensions are all inactive/not installed during installation
454         } else {
455                 // Look in database
456                 $ext_id = getExtensionId($ext_name);
457
458                 // Do we have a record?
459                 $isInstalled = ($ext_id > 0);
460
461                 // Is it installed, then cache the entry
462                 if ($isInstalled === true) {
463                         // Dummy call (get is okay here)
464                         getExtensionId($ext_name, true);
465                 } // END - if
466
467                 // Remember the status
468                 $GLOBALS['ext_is_installed'][$ext_name] = $isInstalled;
469         }
470
471         // Return status
472         return $isInstalled;
473 }
474
475 // Check if given extension is active
476 function isExtensionActive ($ext_name) {
477         // Extensions are all inactive during installation
478         if ((isInstallationPhase()) || (empty($ext_name))) return false;
479
480         // Not active is the default
481         $data['ext_active'] = 'N';
482
483         // Check cache
484         if (isset($GLOBALS['cache_array']['extension']['ext_active'][$ext_name])) {
485                 // Load from cache
486                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "CACHE! ext_name={$ext_name}");
487                 $data['ext_active'] = $GLOBALS['cache_array']['extension']['ext_active'][$ext_name];
488
489                 // Count cache hits
490                 incrementStatsEntry('cache_hits');
491         } elseif (isset($GLOBALS['ext_loaded'][$ext_name])) {
492                 // @TODO Extension is loaded, what next?
493                 app_die(__FUNCTION__, __LINE__, 'LOADED:' . $ext_name);
494         } elseif (($ext_name == 'cache') || (!isExtensionInstalled('cache'))) {
495                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "DB! ext_name={$ext_name}");
496                 // Load from database
497                 $result = SQL_QUERY_ESC("SELECT `ext_active` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
498                         array($ext_name), __FUNCTION__, __LINE__);
499
500                 // Entry found?
501                 if (SQL_NUMROWS($result) == 1) {
502                         // Load entry
503                         $data = SQL_FETCHARRAY($result);
504                 } // END - if
505
506                 // Free result
507                 SQL_FREERESULT($result);
508
509                 // Write cache array
510                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "ext_name=".$ext_name."[DB]: ".$data['ext_active']."");
511                 $GLOBALS['cache_array']['extension']['ext_active'][$ext_name] = $data['ext_active'];
512         } else {
513                 // Extension not active!
514                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "ext_name=".$ext_name.": Not active!");
515                 $GLOBALS['cache_array']['extension']['ext_active'][$ext_name] = 'N';
516         }
517
518         // Debug message
519         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "ext_name=".$ext_name.",active=".$data['ext_active']."");
520
521         // Is this extension activated? (For admins we always have active extensions...)
522         return ($data['ext_active'] == 'Y');
523 }
524
525 // Get version from extensions
526 function getExtensionVersion ($ext_name, $force = false) {
527         // By default no extension is found
528         $data['ext_version'] = 'false';
529
530         // Empty extension name should be fixed!
531         if (empty($ext_name)) {
532                 // Please report this bug!
533                 debug_report_bug(__FUNCTION__ . ': ext_name is empty which is not allowed here.');
534         } // END - if
535
536         // Extensions are all inactive during installation
537         if (isInstallationPhase()) return '';
538         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ": ext_name=".$ext_name."");
539
540         // Is the cache written?
541         if (isset($GLOBALS['cache_array']['extension']['ext_version'][$ext_name])) {
542                 // Load data from cache
543                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $ext_name . ': CACHE!');
544                 $data['ext_version'] = $GLOBALS['cache_array']['extension']['ext_version'][$ext_name];
545
546                 // Count cache hits
547                 incrementStatsEntry('cache_hits');
548         } elseif ((!isCacheInstanceValid()) || (isset($GLOBALS['cache_array']['extension'])) || (getOutputMode() != 0)) {
549                 // Load from database
550                 $result = SQL_QUERY_ESC("SELECT `ext_version` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
551                         array($ext_name), __FUNCTION__, __LINE__);
552                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $ext_name . ': DB - '.SQL_NUMROWS($result).'');
553
554                 // Is the extension there?
555                 if (SQL_NUMROWS($result) == 1) {
556                         // Load entry
557                         $data = SQL_FETCHARRAY($result);
558                 } elseif (isDebugModeEnabled()) {
559                         // Not found, please report all
560                         debug_report_bug(sprintf(": Cannot find extension %s in database!", $ext_name));
561                 }
562
563                 // Free result
564                 SQL_FREERESULT($result);
565
566                 // Set cache
567                 $GLOBALS['cache_array']['extension']['ext_version'][$ext_name] = $data['ext_version'];
568         }
569
570         // Extension version should not be invalid
571         if (($data['ext_version'] == 'false') && ($force === false)) {
572                 // Please report this trouble
573                 debug_report_bug(sprintf("Extension <strong>%s</strong> has empty version!", $ext_name));
574         } // END - if
575
576         // Return result
577         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ": ret={$data['ext_version']}");
578         return $data['ext_version'];
579 }
580
581 // Updates a given extension with current extension version to latest version
582 function updateExtension ($ext_name, $ext_ver, $dry_run = false) {
583         // Only admins are allowed to update extensions
584         if ((!isAdmin()) || (empty($ext_name))) return false;
585
586         // Set current SQL name
587         setCurrentExtensionName($ext_name);
588
589         // Init arrays
590         initExtensionSqls();
591         initExtensionNotes();
592         initIncludePool('extension');
593
594         // Load extension in test mode
595         loadExtension($ext_name, 'test', $ext_ver, getExtensionDryRun());
596
597         // Save version history
598         $history = getExtensionVersionHistory();
599
600         // Remove old SQLs array to prevent possible bugs
601         initExtensionSqls();
602
603         // Check if version is updated
604         //* DEBUG: */ print getCurrentExtensionName().'/'.$ext_name.':'.getThisExtensionVersion().'/'.$ext_ver.'/'.intval(is_array($history)).'<br />';
605         if (((getThisExtensionVersion() != $ext_ver) || (getExtensionDryRun())) && (is_array($history))) {
606                 // Search for starting point
607                 $start = array_search($ext_ver, $history);
608
609                 // And load SQL queries in order of version history
610                 for ($idx = ($start + 1); $idx < count($history); $idx++) {
611                         // Set extension version
612                         $GLOBALS['update_ver'][getCurrentExtensionName()] = $history[$idx];
613
614                         // Load again...
615                         loadExtension(getCurrentExtensionName(), 'update', $GLOBALS['update_ver'][getCurrentExtensionName()], getExtensionDryRun());
616
617                         // Get all depencies
618                         $depencies = getExtensionUpdateDependencies();
619
620                         // Nothing to apply?
621                         if (count($depencies) > 0) {
622                                 // Apply all extension depencies
623                                 foreach ($depencies as $ext_depend) {
624                                         // Did we already update/register this?
625                                         if (!isset($GLOBALS['ext_updated'][$ext_depend])) {
626                                                 // Set it as current
627                                                 setCurrentExtensionName($ext_depend);
628
629                                                 // Mark it as already updated before we update it
630                                                 $GLOBALS['ext_updated'][$ext_depend] = true;
631
632                                                 // Is the extension there?
633                                                 if (isExtensionInstalled($ext_depend)) {
634                                                         // Update another extension first!
635                                                         $test = updateExtension($ext_depend, getExtensionVersion($ext_depend), getExtensionDryRun());
636                                                 } else {
637                                                         // Register new extension
638                                                         $test = registerExtension($ext_depend, 0, getExtensionDryRun(), false);
639                                                 }
640                                         } // END - if
641                                 } // END - foreach
642
643                                 // Set name back
644                                 setCurrentExtensionName($ext_name);
645                         } // END - if
646
647                         // Add notes
648                         addExtensionNotes($history[$idx]);
649                 } // END - for
650
651                 // In real-mode execute any existing includes
652                 if (getExtensionDryRun() === false) {
653                         $GLOBALS['ext_inc_pool'][getCurrentExtensionName()] = getIncludePool('extension');
654                         runFilterChain('load_includes', 'extension');
655                         setIncludePool('extension', $GLOBALS['ext_inc_pool'][getCurrentExtensionName()]);
656                         unset($GLOBALS['ext_inc_pool'][getCurrentExtensionName()]);
657                 } // END - if
658
659                 // Init these SQLs
660                 initSqls();
661                 setSqlsArray(getExtensionSqls());
662
663                 // Run SQLs
664                 runFilterChain('run_sqls', array('dry_run' => getExtensionDryRun()));
665
666                 if (getExtensionDryRun() === false) {
667                         // Run filters on success extension update
668                         runFilterChain('extension_update', getCurrentExtensionName());
669                 } // END - if
670         } // END - if
671 }
672
673 // Output verbose SQL table for extension
674 function addExtensionVerboseSqlTable ($title = '', $dashed = '', $switch = false, $width = '100%') {
675         // Empty title?
676         if (empty($title)) {
677                 // Then fix it to default
678                 $title = getMessage('ADMIN_SQLS_EXECUTED_ON_REMOVAL');
679         } // END - if
680
681         // Init variables
682         $OUT = '';
683
684         // Do we have queries?
685         if ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y')) {
686                 // Init switch color
687                 $SW = 2;
688
689                 // Get all SQLs
690                 foreach (getExtensionSqls() as $sqls) {
691                         // New array format is recursive
692                         foreach ($sqls as $idx => $sql) {
693                                 // Trim out spaces
694                                 $sql = trim($sql);
695
696                                 // Output command if set
697                                 if (!empty($sql)) {
698                                         // Prepare output for template
699                                         $content = array(
700                                                 'sw'  => $SW,
701                                                 'i'   => ($idx+1),
702                                                 'sql' => $sql
703                                         );
704
705                                         // Load row template
706                                         $OUT .= loadTemplate('admin_ext_sql_row', true, $content);
707
708                                         // Switch color
709                                         $SW = 3 - $SW;
710                                 } // END - if
711                         } // END - foreach
712                 } // END - foreach
713
714                 // Prepare content for template
715                 $content = array(
716                         'width'  => $width,
717                         'dashed' => $dashed,
718                         'title'  => $title,
719                         'rows'   => $OUT
720                 );
721
722                 // Load main template
723                 $OUT = loadTemplate('admin_ext_sql_table', true, $content);
724         } elseif ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y')) {
725                 // No addional SQL commands to run
726                 $OUT = loadTemplate('admin_settings_saved', true, getMessage('ADMIN_NO_ADDITIONAL_SQLS'));
727         } // END - if
728
729         // Return output
730         return $OUT;
731 }
732
733 // Get extension name from id
734 function getExtensionName ($ext_id) {
735         // Init extension name
736         $data['ext_name'] = '';
737
738         // Is cache there?
739         if (isset($GLOBALS['cache_array']['extension']['ext_name'][$ext_id])) {
740                 // Load from cache
741                 $data['ext_name'] = $GLOBALS['cache_array']['extension']['ext_name'][$ext_id];
742
743                 // Count cache hits
744                 incrementStatsEntry('cache_hits');
745         } elseif (!isExtensionActive('cache')) {
746                 // Load from database
747                 $result = SQL_QUERY_ESC("SELECT `ext_name` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1",
748                         array(bigintval($ext_id)), __FUNCTION__, __LINE__);
749
750                 // Is the entry there?
751                 if (SQL_NUMROWS($result) == 1) {
752                         // Get the extension's name from database
753                         $data = SQL_FETCHARRAY($result);
754                 } // END - if
755
756                 // Free result
757                 SQL_FREERESULT($result);
758         }
759
760         // Did we find some extension?
761         if (empty($data['ext_name'])) {
762                 // We should fix these all!
763                 debug_report_bug(__FUNCTION__ . ': ext_name is empty. ext_id=' . $ext_id);
764         } // END - if
765
766         // Return the extension name
767         return $data['ext_name'];
768 }
769
770 // Get extension id from name
771 function getExtensionId ($ext_name) {
772         // Init id number
773         $data['ext_id'] = '0';
774
775         // Do we have cache?
776         if (isset($GLOBALS['cache_array']['extension']['ext_id'][$ext_name])) {
777                 // Load from cache
778                 $data['ext_id'] = $GLOBALS['cache_array']['extension']['ext_id'][$ext_name];
779
780                 // Count cache hits
781                 incrementStatsEntry('cache_hits');
782         } else {
783                 // Load from database
784                 $result = SQL_QUERY_ESC("SELECT `id` AS ext_id FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
785                         array($ext_name), __FUNCTION__, __LINE__);
786
787                 // Is the entry there?
788                 if (SQL_NUMROWS($result) == 1) {
789                         // Get the extension's id from database
790                         $data = SQL_FETCHARRAY($result);
791                 } // END - if
792
793                 // Free result
794                 SQL_FREERESULT($result);
795
796                 // Cache it
797                 $GLOBALS['cache_array']['extension']['ext_id'][$ext_name] = $data['ext_id'];
798         }
799
800         // Return value
801         return $data['ext_id'];
802 }
803
804 // Determines wether the given extension name is valid
805 function isExtensionNameValid ($ext_name) {
806         // Do we have cache?
807         if (!isset($GLOBALS['ext_name_valid'][$ext_name])) {
808                 // Generate include file name
809                 $INC = sprintf("inc/extensions/ext-%s.php", $ext_name);
810
811                 // Is there a file in inc/extensions/ ?
812                 $GLOBALS['ext_name_valid'][$ext_name] = isIncludeReadable($INC);
813         } // END - if
814
815         // Return result
816         return $GLOBALS['ext_name_valid'][$ext_name];
817 }
818
819 // Determines wether the given extension id is valid
820 function isExtensionIdValid ($ext_id) {
821         // Default is nothing valid
822         $isValid = false;
823
824         // Check in cache then in database
825         if (isset($GLOBALS['cache_array']['extension']['ext_name'][$ext_id])) {
826                 // Valid!
827                 $isValid = true;
828
829                 // Count cache hits
830                 incrementStatsEntry('cache_hits');
831         } else {
832                 // Query database
833                 $isValid = (countSumTotalData($ext_id, 'extensions', 'id', 'id', true) == 1);
834         }
835
836         // Return result
837         return $isValid;
838 }
839
840 // Activate given extension
841 function doActivateExtension ($ext_name) {
842         // Activate the extension
843         SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='Y' WHERE `ext_name`='%s' LIMIT 1",
844                 array($ext_name), __FUNCTION__, __LINE__);
845
846         // Extension has been activated?
847         if (SQL_AFFECTEDROWS() == 1) {
848                 // Then run all queries
849                 doExtensionSqls(getExtensionId($ext_name), 'activate');
850         } // END - if
851 }
852
853 // Deactivate given extension
854 function doDeactivateExtension($ext_name) {
855         // Activate the extension
856         SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='N' WHERE `ext_name`='%s' LIMIT 1",
857                 array($ext_name), __FUNCTION__, __LINE__);
858
859         // Extension has been activated?
860         if (SQL_AFFECTEDROWS() == 1) {
861                 // Then run all queries
862                 doExtensionSqls(getExtensionId($ext_name), 'deactivate');
863
864                 // Create new task
865                 createExtensionDeactivationTask($ext_name);
866
867                 // Notify the admin
868                 sendAdminNotification(
869                         getMessage('ADMIN_SUBJECT_EXTENSION_DEACTIVATED'),
870                         'admin_ext_deactivated',
871                         array('ext_name' => $ext_name)
872                 );
873         } // END - if
874 }
875
876 // Checks wether the extension is older than given
877 function isExtensionOlder ($ext_name, $ext_ver) {
878         // Get current extension version
879         $currVersion = getExtensionVersion($ext_name);
880
881         // Remove all dots from both versions
882         $currVersion = str_replace('.', '', $currVersion);
883         $ext_ver = str_replace('.', '', $ext_ver);
884
885         // Now compare both and return the result
886         return ($currVersion < $ext_ver);
887 }
888
889 // Creates a new task for updated extension
890 function createExtensionUpdateTask ($adminId, $ext_name, $ext_ver, $notes) {
891         // Create subject line
892         $subject = '[UPDATE-' . $ext_name . '-' . $ext_ver . ':] {--ADMIN_UPDATE_EXT_SUBJ--}';
893
894         // Is the extension there?
895         if (isExtensionInstalled($ext_name)) {
896                 // Check if task is not there
897                 if (determineTaskIdBySubject($subject) == '0') {
898                         // Create extension update-task
899                         createNewTask($subject, $notes, 'EXTENSION_UPDATE', 0, $adminId);
900                 } // END - if
901         } else {
902                 // Extension not there! :-(
903                 debug_report_bug(sprintf("Extension <strong>%s</strong> not found but should be updated?", $ext_name));
904         }
905 }
906
907 // Creates a new task for newly installed extension
908 function createNewExtensionTask ($adminId, $subject, $ext) {
909         // Not installed and do we have created a task for the admin?
910         if ((determineTaskIdBySubject($subject) == '0') && (!isExtensionInstalled($ext))) {
911                 // Set default message if ext-foo is missing
912                 $message = getMaskedMessage('ADMIN_EXT_TEXT_FILE_MISSING', $ext);
913
914                 // Template file
915                 $tpl = sprintf("%stemplates/%s/html/ext/ext_%s.tpl",
916                         getConfig('PATH'),
917                         getLanguage(),
918                         $ext
919                 );
920
921                 // Load text for task if found
922                 if (isFileReadable($tpl)) {
923                         // Load extension's own text template (HTML!)
924                         $message = loadTemplate('ext_' . $ext, true);
925                 } else {
926                         // Write this in debug.log as well
927                         logDebugMessage(__FUNCTION__, __LINE__, $message);
928                 }
929
930                 // Task not created so it's a brand-new extension which we need to register and create a task for!
931                 createNewTask($subject, $message, 'EXTENSION', 0, $adminId, false);
932         } // END - if
933 }
934
935 // Creates a task for automatically deactivated (deprecated) extension
936 function createExtensionDeactivationTask ($ext) {
937         // Create subject line
938         $subject = sprintf("[%s:] %s", $ext, getMessage('TASK_SUBJ_EXTENSION_DEACTIVATED'));
939
940         // Not installed and do we have created a task for the admin?
941         if ((determineTaskIdBySubject($subject) == '0') && (getExtensionVersion($ext) != '')) {
942                 // Task not created so add it
943                 createNewTask($subject, SQL_ESCAPE(loadTemplate('task_ext_deactivated', true, $ext)), 'EXTENSION_DEACTIVATION');
944         } // END - if
945 }
946
947 // Checks if the module has a menu
948 function ifModuleHasMenu ($mod, $forceDb = false) {
949         // All is false by default
950         $ret = false;
951
952         // Extension installed and newer than or has version 0.1.2?
953         if (isExtensionInstalledAndNewer('cache', '0.1.2')) {
954                 // Cache version is okay, so let's check the cache!
955                 if (isset($GLOBALS['cache_array']['modules']['has_menu'][$mod])) {
956                         // Check module cache and count hit
957                         $ret = ($GLOBALS['cache_array']['modules']['has_menu'][$mod] == 'Y');
958                         incrementStatsEntry('cache_hits');
959                 } elseif (isset($GLOBALS['cache_array']['extension']['ext_menu'][$mod])) {
960                         // Check cache and count hit
961                         $ret = ($GLOBALS['cache_array']['extension']['ext_menu'][$mod] == 'Y');
962                         incrementStatsEntry('cache_hits');
963                 } else {
964                         // Admin/guest/member/sponsor modules have always a menu!
965                         $ret = in_array($mod, array('admin', 'index', 'login', 'sponsor'));
966                 }
967         } elseif ((isExtensionInstalled('sql_patches')) && (getExtensionVersion('sql_patches') >= '0.3.6') && ((!isExtensionActive('cache')) || ($forceDb === true))) {
968                 // Check database for entry
969                 $result = SQL_QUERY_ESC("SELECT `has_menu` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1",
970                         array($mod), __FUNCTION__, __LINE__);
971
972                 // Entry found?
973                 if (SQL_NUMROWS($result) == 1) {
974                         // Load "has_menu" column
975                         $data = SQL_FETCHARRAY($result);
976
977                         // Fake cache... ;-)
978                         $GLOBALS['cache_array']['extension']['ext_menu'][$mod] = $data['has_menu'];
979
980                         // Does it have a menu?
981                         $ret = ($data['has_menu'] == 'Y');
982                 } // END  - if
983
984                 // Free memory
985                 SQL_FREERESULT($result);
986         } elseif (!isExtensionInstalled('sql_patches')) {
987                 // No sql_patches installed, so maybe in admin/guest/member/sponsor area or no admin registered?
988                 $ret = in_array($mod, array('admin', 'index', 'login', 'sponsor')); // Then there is a menu!
989         } else {
990                 // Unsupported state!
991                 logDebugMessage(__FUNCTION__, __LINE__, 'This should never be reached.');
992         }
993
994         // Return status
995         return $ret;
996 }
997
998 // Determines the task id for given extension
999 function determineExtensionTaskId ($ext_name) {
1000         // Default is not found
1001         $data['task_id'] = '0';
1002
1003         // Search for extension task's id
1004         $result = SQL_QUERY_ESC("SELECT `id` AS task_id FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `task_type`='EXTENSION' AND `subject`='[%s:]' LIMIT 1",
1005                 array($ext_name), __FUNCTION__, __LINE__);
1006
1007         // Entry found?
1008         if (SQL_NUMROWS($result) == 1) {
1009                 // Task found so load task's id and register extension...
1010                 $data = SQL_FETCHARRAY($result);
1011         } // END - if
1012
1013         // Free result
1014         SQL_FREERESULT($result);
1015
1016         // Return it
1017         return $data['task_id'];
1018 }
1019
1020 // Determines the task id for given subject
1021 function determineTaskIdBySubject ($subject) {
1022         // Default is not found
1023         $data['task_id'] = '0';
1024
1025         // Search for task id
1026         $result = SQL_QUERY_ESC("SELECT `id` AS task_id FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `subject` LIKE '%s%%' LIMIT 1",
1027                 array($subject), __FUNCTION__, __LINE__);
1028
1029         // Entry found?
1030         if (SQL_NUMROWS($result) == 1) {
1031                 // Task found so load task's id and register extension...
1032                 $data = SQL_FETCHARRAY($result);
1033         } // END - if
1034
1035         // Free result
1036         SQL_FREERESULT($result);
1037
1038         // Return it
1039         return $data['task_id'];
1040 }
1041
1042 // Add updates notes for given version
1043 function addExtensionNotes ($ver) {
1044         // Init notes/content
1045         $out = ''; $content = array();
1046
1047         // Is do we have verbose output enabled?
1048         if ((!isExtensionActive('sql_patches')) || (getConfig('verbose_sql') == 'Y')) {
1049                 // Update notes found?
1050                 if (getExtensionUpdateNotes($ver) != '') {
1051                         // Update notes found
1052                         $content = array(
1053                                 'ver'   => $ver,
1054                                 'notes' => getExtensionUpdateNotes($ver)
1055                         );
1056
1057                         // Reset them
1058                         setExtensionUpdateNotes('', $ver);
1059                 } elseif (($ver == '0.0') || ($ver == '0.0.0')) {
1060                         // Initial release
1061                         $content = array(
1062                                 'ver'   => $ver,
1063                                 'notes' => getMessage('INITIAL_RELEASE')
1064                         );
1065                 } else {
1066                         // No update notes found!
1067                         $content = array(
1068                                 'ver'   => $ver,
1069                                 'notes' => getMessage('NO_UPDATE_NOTES')
1070                         );
1071                 }
1072
1073                 // Load template
1074                 $out = loadTemplate('admin_ext_notes', true, $content);
1075         } // END - if
1076
1077         // Add the notes
1078         appendExtensionNotes($out);
1079 }
1080
1081 // Getter for CSS files array
1082 function getExtensionCssFiles () {
1083         // By default no additional CSS files are found
1084         $cssFiles = array();
1085
1086         // Is the array there?
1087         if (isset($GLOBALS['css_files'])) {
1088                 // Then use it
1089                 $cssFiles = $GLOBALS['css_files'];
1090         } // END - if
1091
1092         // Return array
1093         return $cssFiles;
1094 }
1095
1096 // Init CSS files array
1097 function initExtensionCssFiles () {
1098         // Simply init it
1099         $GLOBALS['css_files'] = array();
1100 }
1101
1102 // Add new entry
1103 function addExtensionCssFile ($file) {
1104         // Is the array there?
1105         if (!isset($GLOBALS['css_files'])) {
1106                 // Then auto-init them
1107                 initExtensionCssFiles();
1108         } // END - if
1109
1110         // Add the entry
1111         $GLOBALS['css_files'][] = $file;
1112 }
1113
1114 // Setter for EXT_ALWAYS_ACTIVE flag
1115 function setExtensionAlwaysActive ($active) {
1116         $GLOBALS['ext_always_active'][getCurrentExtensionName()] = (string) $active;
1117 }
1118
1119 // Getter for EXT_ALWAYS_ACTIVE flag
1120 function getExtensionAlwaysActive () {
1121         return $GLOBALS['ext_always_active'][getCurrentExtensionName()];
1122 }
1123
1124 // Setter for EXT_VERSION flag
1125 function setThisExtensionVersion ($version) {
1126         $GLOBALS['ext_version'][getCurrentExtensionName()] = (string) $version;
1127 }
1128
1129 // Getter for EXT_VERSION flag
1130 function getThisExtensionVersion () {
1131         return $GLOBALS['ext_version'][getCurrentExtensionName()];
1132 }
1133
1134 // Setter for EXT_DEPRECATED flag
1135 function setExtensionDeprecated ($deprecated) {
1136         $GLOBALS['ext_deprecated'][getCurrentExtensionName()] = (string) $deprecated;
1137 }
1138
1139 // Getter for EXT_DEPRECATED flag
1140 function isExtensionDeprecated () {
1141         return ($GLOBALS['ext_deprecated'][getCurrentExtensionName()] == 'Y');
1142 }
1143
1144 // Setter for EXT_UPDATE_DEPENDS flag
1145 function addExtensionUpdateDependency ($updateDepends) {
1146         // Is the update depency empty? (NEED TO BE FIXED!)
1147         if (empty($updateDepends)) {
1148                 // Please report this bug!
1149                 debug_report_bug('updateDepends is left empty!');
1150         } // END - if
1151
1152         // Is it not yet added?
1153         if (!in_array($updateDepends, $GLOBALS['ext_running_updates'])) {
1154                 //* DEBUG */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName().'/'.$updateDepends);
1155                 // Add it to the list of extension update depencies map
1156                 $GLOBALS['ext_update_depends'][getCurrentExtensionName()][] = (string) $updateDepends;
1157
1158                 // Remember it in the list of running updates
1159                 $GLOBALS['ext_running_updates'][] = $updateDepends;
1160         } // END - if
1161 }
1162
1163 // Checks wether the given extension registration is in progress
1164 function isExtensionRegisterRunning ($ext_name) {
1165         return ((isset($GLOBALS['ext_register_running'])) && (in_array($ext_name, $GLOBALS['ext_register_running'])));
1166 }
1167
1168 // Init EXT_UPDATE_DEPENDS flag
1169 function initExtensionUpdateDependencies () {
1170         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName());
1171
1172         // Init update depency map automatically if not found
1173         if (!isExtensionUpdateDependenciesInitialized()) {
1174                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName()." - INIT!");
1175                 $GLOBALS['ext_update_depends'][getCurrentExtensionName()] = array();
1176         } // END - if
1177
1178         // Init running updates array
1179         initExtensionRuningUpdates();
1180 }
1181
1182 // Adds an extension as "registration in progress"
1183 function addExtensionRunningRegistration ($ext_name) {
1184         // Is it running?
1185         if (!isExtensionRegisterRunning($ext_name)) {
1186                 // Then add it!
1187                 $GLOBALS['ext_register_running'][] = $ext_name;
1188         } // END - if
1189 }
1190
1191 // Checks wether EXT_UPDATE_DEPENDS is initialized
1192 function isExtensionUpdateDependenciesInitialized () {
1193         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName());
1194         return (isset($GLOBALS['ext_update_depends'][getCurrentExtensionName()]));
1195 }
1196
1197 // Initializes the list of running updates
1198 function initExtensionRuningUpdates () {
1199         // Auto-init ext_running_updates
1200         if (!isset($GLOBALS['ext_running_updates'])) {
1201                 $GLOBALS['ext_running_updates'] = array();
1202                 $GLOBALS['ext_register_running'] = array();
1203         } // END - if
1204 }
1205
1206 // Getter for EXT_UPDATE_DEPENDS flag
1207 function getExtensionUpdateDependencies () {
1208         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName());
1209         return $GLOBALS['ext_update_depends'][getCurrentExtensionName()];
1210 }
1211
1212 // Getter for next iterator depency
1213 function getExtensionUpdateDependenciesIterator () {
1214         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName());
1215         return ($GLOBALS['ext_update_depends'][getCurrentExtensionName()][getExtensionUpdateIterator()]);
1216 }
1217
1218 // Counter for extension update depencies
1219 function countExtensionUpdateDependencies () {
1220         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName());
1221         return count($GLOBALS['ext_update_depends'][getCurrentExtensionName()]);
1222 }
1223
1224 // Removes given extension from update denpency list
1225 function removeExtensionUpdateDependency ($ext_name) {
1226         // Look it up
1227         $key = array_search($ext_name, getExtensionUpdateDependencies());
1228
1229         // Is it valid?
1230         if ($key !== false) {
1231                 // Then remove it
1232                 unset($GLOBALS['ext_update_depends'][getCurrentExtensionName()][$key]);
1233
1234                 // And sort the array
1235                 ksort($GLOBALS['ext_update_depends'][getCurrentExtensionName()]);
1236         } // END - if
1237 }
1238
1239 // Init iterator for update depencies
1240 function initExtensionUpdateIterator () {
1241         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName());
1242         $GLOBALS['ext_depend_iterator'][getCurrentExtensionName()] = '0';
1243 }
1244
1245 // Getter for depency iterator
1246 function getExtensionUpdateIterator () {
1247         // Auto-init iterator
1248         if (!isset($GLOBALS['ext_depend_iterator'][getCurrentExtensionName()])) initExtensionUpdateIterator();
1249
1250         // Return it
1251         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName().'/'.$GLOBALS['ext_depend_iterator'][getCurrentExtensionName()]);
1252         return $GLOBALS['ext_depend_iterator'][getCurrentExtensionName()];
1253 }
1254
1255 // Increments the update iterator
1256 function incrementExtensionUpdateIterator () {
1257         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName());
1258         $GLOBALS['ext_depend_iterator'][getCurrentExtensionName()]++;
1259 }
1260
1261 // Setter for EXT_REPORTS_FAILURE flag
1262 function setExtensionReportsFailure ($reportsFailure) {
1263         $GLOBALS['ext_reports_failure'] = (bool) $reportsFailure;
1264 }
1265
1266 // Getter for EXT_REPORTS_FAILURE flag
1267 function getExtensionReportsFailure () {
1268         return $GLOBALS['ext_reports_failure'];
1269 }
1270
1271 // Setter for EXT_VER_HISTORY flag
1272 function setExtensionVersionHistory ($verHistory) {
1273         $GLOBALS['ext_ver_history'][getCurrentExtensionName()] = (array) $verHistory;
1274 }
1275
1276 // Getter for EXT_VER_HISTORY array
1277 function getExtensionVersionHistory () {
1278         return $GLOBALS['ext_ver_history'][getCurrentExtensionName()];
1279 }
1280
1281 // Setter for EXT_UPDATE_NOTES
1282 function setExtensionUpdateNotes ($updateNotes, $ver='') {
1283         //* DEBUG: */ print __FUNCTION__.':'.getCurrentExtensionName().'/'.getCurrentExtensionVersion().'/'.$ver.'='.$updateNotes.'<br />';
1284         if (empty($ver)) {
1285                 $GLOBALS['ext_update_notes'][getCurrentExtensionName()][getCurrentExtensionVersion()] = (string) $updateNotes;
1286         } else {
1287                 $GLOBALS['ext_update_notes'][getCurrentExtensionName()][$ver] = (string) $updateNotes;
1288         }
1289 }
1290
1291 // Getter for EXT_UPDATE_NOTES
1292 function getExtensionUpdateNotes ($ver) {
1293         return $GLOBALS['ext_update_notes'][getCurrentExtensionName()][$ver];
1294 }
1295
1296 // Init extension notice
1297 function initExtensionNotes () {
1298         $GLOBALS['ext_notes'][getCurrentExtensionName()] = '';
1299 }
1300
1301 // Append extension notice
1302 function appendExtensionNotes ($notes) {
1303         $GLOBALS['ext_notes'][getCurrentExtensionName()] .= (string) trim($notes);
1304 }
1305
1306 // Getter for extension notes
1307 function getExtensionNotes () {
1308         return $GLOBALS['ext_notes'][getCurrentExtensionName()];
1309 }
1310
1311 // Setter for current extension name
1312 function setCurrentExtensionName ($ext_name) {
1313         $GLOBALS['curr_ext_name'] = (string) trim($ext_name);
1314 }
1315
1316 // Getter for current extension name
1317 function getCurrentExtensionName () {
1318         if (isset($GLOBALS['curr_ext_name'])) {
1319                 return $GLOBALS['curr_ext_name'];
1320         } // END - if
1321
1322         // Not set!
1323         debug_report_bug(__FUNCTION__.": curr_ext_name not initialized. Please execute initExtensionSqls() before calling this function.");
1324 }
1325
1326 // Init SQLs array for current extension
1327 function initExtensionSqls () {
1328         // Auto-init the array now...
1329         if (!isset($GLOBALS['ext_sqls'][getCurrentExtensionName()])) {
1330                 $GLOBALS['ext_sqls'][getCurrentExtensionName()] = array();
1331         } // END - if
1332 }
1333
1334 // Adds SQLs to the SQLs array but "assigns" it with current extension name
1335 function addExtensionSql ($sql) {
1336         // Add it
1337         $GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()][] = $sql;
1338 }
1339
1340 // Getter for SQLs array for current extension
1341 function getExtensionSqls () {
1342         // Output debug backtrace if not found (SHOULD NOT HAPPEN!)
1343         if (!isset($GLOBALS['ext_sqls'][getCurrentExtensionName()])) {
1344                 // Not found, should not happen
1345                 debug_report_bug(sprintf("ext_sqls is empty, current extension: %s",
1346                         getCurrentExtensionName()
1347                 ));
1348         } // END - if
1349
1350         // Return the array
1351         return $GLOBALS['ext_sqls'][getCurrentExtensionName()];
1352 }
1353
1354 // Removes SQLs for current extension
1355 function unsetExtensionSqls () {
1356         unset($GLOBALS['ext_sqls'][getCurrentExtensionName()]);
1357 }
1358
1359 // Auto-initializes the removal list
1360 function initExtensionRemovalList () {
1361         // Is the remove list there?
1362         if (!isset($GLOBALS['ext_update_remove'])) {
1363                 // Then create it
1364                 $GLOBALS['ext_update_remove'] = array();
1365         } // END - if
1366 }
1367
1368 // Checks wether the current extension is on the removal list
1369 function isExtensionOnRemovalList () {
1370         // Init removal list
1371         initExtensionRemovalList();
1372
1373         // Is it there?
1374         return (in_array(getCurrentExtensionName(), $GLOBALS['ext_update_remove']));
1375 }
1376
1377 // Adds the current extension to the removal list
1378 function addCurrentExtensionToRemovalList () {
1379         // Simply add it
1380         $GLOBALS['ext_update_remove'][] = getCurrentExtensionName();
1381 }
1382
1383 // Getter for removal list
1384 function getExtensionRemovalList () {
1385         // Return the removal list
1386         return $GLOBALS['ext_update_remove'];
1387 }
1388
1389 // Redirects if the provided extension is not installed
1390 function redirectOnUninstalledExtension ($ext_name) {
1391         // So is the extension there?
1392         if ((!isExtensionInstalled($ext_name)) || (!isExtensionActive($ext_name))) {
1393                 // Redirect to index
1394                 redirectToUrl('modules.php?module=index&amp;code=' . getCode('EXTENSION_PROBLEM') . '&amp;ext=' . $ext_name);
1395         } // END - if
1396 }
1397
1398 // Filter for initialization of all extensions by loading them in 'init' mode
1399 function FILTER_INIT_EXTENSIONS () {
1400         // Do we have some entries?
1401         //* DEBUG */ print __FUNCTION__.': ENTRY!<br />';
1402         if (isset($GLOBALS['cache_array']['extension']['ext_name'])) {
1403                 // Load all found extensions if found
1404                 //* DEBUG */ print __FUNCTION__.': CACHE - START!<br />';
1405                 foreach ($GLOBALS['cache_array']['extension']['ext_name'] as $key => $ext_name) {
1406                         // Load it
1407                         //* DEBUG */ print __FUNCTION__.': '.$ext_name.' - START<br />';
1408                         loadExtension($ext_name, 'init');
1409                         //* DEBUG */ print __FUNCTION__.': '.$ext_name.' - END<br />';
1410                 } // END - foreach
1411                 //* DEBUG */ print __FUNCTION__.': CACHE - END!<br />';
1412         } // END - if
1413         //* DEBUG */ print __FUNCTION__.': EXIT!<br />';
1414 }
1415
1416 // Setter for extension mode
1417 function setExtensionMode ($ext_mode) {
1418         $GLOBALS['ext_mode'] = (string) $ext_mode;
1419 }
1420
1421 // Getter for extension mode
1422 function getExtensionMode () {
1423         return $GLOBALS['ext_mode'];
1424 }
1425
1426 // Setter for dry-run
1427 function enableExtensionDryRun ($dry_run = true) {
1428         //* DEBUG: */ print __FUNCTION__.': '.getCurrentExtensionName().'='.intval($dry_run).'<br />';
1429         $GLOBALS['ext_dry_run'] = (bool) $dry_run;
1430 }
1431
1432 // Getter for dry-run
1433 function getExtensionDryRun () {
1434         return $GLOBALS['ext_dry_run'];
1435 }
1436
1437 // Setter for current extension version
1438 function setCurrentExtensionVersion ($ext_ver) {
1439         if (empty($ext_ver)) {
1440                 // 0.0 is okay here
1441                 $GLOBALS['ext_current_version'] = '0.0';
1442         } else {
1443                 // Add version
1444                 $GLOBALS['ext_current_version'] = (string) $ext_ver;
1445         }
1446 }
1447
1448 // Getter for current extension version
1449 function getCurrentExtensionVersion () {
1450         return $GLOBALS['ext_current_version'];
1451 }
1452
1453 // Remove the extension from cache array
1454 function removeExtensionFromArray () {
1455         // "Cache" this name
1456         $ext_name = getCurrentExtensionName();
1457
1458         // Now loop through the whole cache
1459         foreach ($GLOBALS['cache_array']['extension'] as $cacheName => $cacheArray) {
1460                 // Is it an element?
1461                 if (isset($cacheArray[$ext_name])) {
1462                         // Array element
1463                         unset($cacheArray[$ext_name]);
1464                         $GLOBALS['cache_array']['extension'][$cacheName] = $cacheArray;
1465                 } else {
1466                         // Maybe in array?
1467                         $key = array_search($ext_name, $cacheArray);
1468
1469                         // Is it there?
1470                         if ($key !== false) {
1471                                 // Found, so remove it
1472                                 unset($cacheArray[$key]);
1473                                 $GLOBALS['cache_array']['extension'][$cacheName] = $cacheArray;
1474                         } // END - if
1475                 }
1476         } // END - foreach
1477 }
1478
1479 // "Getter" for 'extension has a CSS file' (with same name, of course)
1480 function getExtensionHasCss () {
1481         // Default is no CSS
1482         $hasCss = 'N';
1483
1484         // Construct FQFN for check
1485         $FQFN = sprintf("%stheme/%s/css/%s.css",
1486                 getConfig('PATH'),
1487                 getCurrentTheme(),
1488                 getCurrentExtensionName()
1489         );
1490
1491         // Is it there?
1492         if (isFileReadable($FQFN)) {
1493                 // Readable, so it is there...
1494                 $hasCss = 'Y';
1495         } // END - if
1496
1497         // Return it
1498         return $hasCss;
1499 }
1500
1501 // Checks wether the given extension has a language file
1502 function ifExtensionHasLanguageFile ($ext_name) {
1503         // Default is no language file
1504         $hasLanguage = false;
1505
1506         // Do we have cache?
1507         if (isset($GLOBALS['cache_array']['extension']['ext_lang'][$ext_name])) {
1508                 // Then use it
1509                 $hasLanguage = ($GLOBALS['cache_array']['extension']['ext_lang'][$ext_name] == 'Y');
1510
1511                 // Count cache hits
1512                 incrementStatsEntry('cache_hits');
1513         } else {
1514                 // Not readable is default
1515                 $readable = 'N';
1516
1517                 // Is the language file readable for this extension?
1518                 if (isLanguageIncludeReadable($ext_name)) {
1519                         // Readable
1520                         $readable = 'Y';
1521                 } // END - if
1522
1523                 // Put it in cache
1524                 $GLOBALS['cache_array']['extension']['ext_lang'][$ext_name] = 'Y';
1525         }
1526
1527         // Return result
1528         return ($GLOBALS['cache_array']['extension']['ext_lang'][$ext_name] == 'Y');
1529 }
1530
1531 // Load an extension's include file
1532 function loadExtensionInclude () {
1533         // Is it readable?
1534         if (!isExtensionIncludeReadable()) {
1535                 // Not readable
1536                 debug_report_bug('Extension ' . getCurrentExtensionName() . ' should be loaded, but is not readable.');
1537         } // END - if
1538
1539         // Generate INC name
1540         $INC = sprintf("inc/extensions/ext-%s.php", getCurrentExtensionName());
1541
1542         // Load it
1543         loadInclude($INC);
1544 }
1545
1546 // Checks wether an extension is readable
1547 function isExtensionIncludeReadable ($ext_name = '') {
1548         // If empty, use current
1549         if (empty($ext_name)) $ext_name = getCurrentExtensionName();
1550
1551         // Array found?
1552         if (!isset($GLOBALS['ext_inc_readable'][$ext_name])) {
1553                 // Generate INC name
1554                 $INC = sprintf("inc/extensions/ext-%s.php", getCurrentExtensionName());
1555
1556                 // Is it readable?
1557                 $GLOBALS['ext_inc_readable'][$ext_name] = isIncludeReadable($INC);
1558         } // END - if
1559
1560         // Return result
1561         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',realable='.intval($GLOBALS['ext_inc_readable'][$ext_name]));
1562         return $GLOBALS['ext_inc_readable'][$ext_name];
1563 }
1564
1565 // Checks if an extension's function file is readable
1566 function isExtensionFunctionFileReadable ($ext_name) {
1567         if (isset($GLOBALS['cache_array']['extension']['ext_func'][$ext_name])) {
1568                 // Just count cache hits
1569                 incrementStatsEntry('cache_hits');
1570         } else {
1571                 // Construct FQFN for functions file
1572                 $funcsInclude = sprintf("inc/libs/%s_functions.php", $ext_name);
1573
1574                 // Is this include there?
1575                 if ((isFileReadable($funcsInclude)) && (!isset($GLOBALS['ext_loaded']['funcs'][$ext_name])) && (getExtensionMode() == 'test')) {
1576                         // Cache it!
1577                         $GLOBALS['cache_array']['extension']['ext_func'][$ext_name] = 'Y';
1578                 } else {
1579                         // Cache it!
1580                         $GLOBALS['cache_array']['extension']['ext_func'][$ext_name] = 'N';
1581                 }
1582         }
1583
1584         // Return result
1585         return ($GLOBALS['cache_array']['extension']['ext_func'][$ext_name] == 'Y');
1586 }
1587
1588 // Adds an admin menu to the SQL queue of the menu entry is not found
1589 function addAdminMenuSql ($action, $what, $title, $descr, $sort) {
1590         // Now check if this menu is there
1591         if (!isMenuActionValid('admin', $action, $what)) {
1592                 // Is what null?
1593                 if (is_null($what)) {
1594                         // Add main menu
1595                         $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES('%s',NULL,'%s','%s',%s)",
1596                                 $action,
1597                                 $title,
1598                                 $descr,
1599                                 bigintval($sort)
1600                         );
1601                 } else {
1602                         // Add sub menu
1603                         $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES('%s','%s','%s','%s',%s)",
1604                                 $action,
1605                                 $what,
1606                                 $title,
1607                                 $descr,
1608                                 bigintval($sort)
1609                         );
1610                 }
1611
1612                 // Add it to the queue
1613                 addExtensionSql($sql);
1614         } elseif (isDebugModeEnabled()) {
1615                 // Double menus should be located and fixed!
1616                 logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double admin menu action=%s, what=%s detected.", $action, $what));
1617         }
1618 }
1619
1620 // Adds a guest menu to the SQL queue if the menu entry is not found
1621 function addGuestMenuSql ($action, $what, $title, $visible, $locked, $sort) {
1622         // Now check if this menu is there
1623         if (!isMenuActionValid('guest', $action, $what)) {
1624                 // Is what null?
1625                 if (is_null($what)) {
1626                         // Add main menu
1627                         $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES('%s',NULL,'%s','%s','%s',%s)",
1628                                 $action,
1629                                 $title,
1630                                 $visible,
1631                                 $locked,
1632                                 bigintval($sort)
1633                         );
1634                 } else {
1635                         // Add sub menu
1636                         $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES('%s','%s','%s','%s','%s',%s)",
1637                                 $action,
1638                                 $what,
1639                                 $title,
1640                                 $visible,
1641                                 $locked,
1642                                 bigintval($sort)
1643                         );
1644                 }
1645
1646                 // Add it to the queue
1647                 addExtensionSql($sql);
1648         } elseif (isDebugModeEnabled()) {
1649                 // Double menus should be located and fixed!
1650                 logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double guest menu action=%s, what=%s detected.", $action, $what));
1651         }
1652 }
1653
1654 // Adds a member menu to the SQL queue if the menu entry is not found
1655 function addMemberMenuSql ($action, $what, $title, $visible, $locked, $sort) {
1656         // Now check if this menu is there
1657         if (!isMenuActionValid('member', $action, $what)) {
1658                 // Is what null?
1659                 if (is_null($what)) {
1660                         // Add main menu
1661                         $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES('%s',NULL,'%s','%s','%s',%s)",
1662                                 $action,
1663                                 $title,
1664                                 $visible,
1665                                 $locked,
1666                                 bigintval($sort)
1667                         );
1668                 } else {
1669                         // Add sub menu
1670                         $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES('%s','%s','%s','%s','%s',%s)",
1671                                 $action,
1672                                 $what,
1673                                 $title,
1674                                 $visible,
1675                                 $locked,
1676                                 bigintval($sort)
1677                         );
1678                 }
1679
1680                 // Add it to the queue
1681                 addExtensionSql($sql);
1682         } elseif (isDebugModeEnabled()) {
1683                 // Double menus should be located and fixed!
1684                 logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double member menu action=%s, what=%s detected.", $action, $what));
1685         }
1686 }
1687
1688 // Adds a sponsor menu to the SQL queue if the menu entry is not found
1689 function addSponsorMenuSql ($action, $what, $title, $active, $sort) {
1690         // Now check if this menu is there, if no ext-sponsor is installed all is not yet added
1691         if ((!isExtensionInstalled('sponsor')) || (!isMenuActionValid('sponsor', $action, $what))) {
1692                 // Is what null?
1693                 if (is_null($what)) {
1694                         // Add main menu
1695                         $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_menu` (`action`,`what`,`title`,`active`,`sort`) VALUES('%s',NULL,'%s','%s',%s)",
1696                                 $action,
1697                                 $title,
1698                                 $active,
1699                                 bigintval($sort)
1700                         );
1701                 } else {
1702                         // Add sub menu
1703                         $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_menu` (`action`,`what`,`title`,`active`,`sort`) VALUES('%s','%s','%s','%s',%s)",
1704                                 $action,
1705                                 $what,
1706                                 $title,
1707                                 $active,
1708                                 bigintval($sort)
1709                         );
1710                 }
1711
1712                 // Add it to the queue
1713                 addExtensionSql($sql);
1714         } elseif (isDebugModeEnabled()) {
1715                 // Double menus should be located and fixed!
1716                 logDebugMessage(__FUNCTION__, __LINE__, sprintf("Double sponsor menu action=%s, what=%s detected.", $action, $what));
1717         }
1718 }
1719
1720 // Enables/disables productive mode for current extension (used only while
1721 // registration).
1722 function enableExtensionProductive ($isProductive = true) {
1723         $GLOBALS['ext_productive'][getCurrentExtensionName()] = (bool) $isProductive;
1724 }
1725
1726 // Checks wether the extension is in productive phase. If not set, development
1727 // phase (=false) is assumed.
1728 function isExtensionProductive () {
1729         return ((isset($GLOBALS['ext_productive'][getCurrentExtensionName()])) && ($GLOBALS['ext_productive'][getCurrentExtensionName()] === true));
1730 }
1731
1732 // [EOF]
1733 ?>