2 /************************************************************************
3 * MXChange v0.2.1 Start: 03/25/2004 *
4 * =============== Last change: 09/29/2004 *
6 * -------------------------------------------------------------------- *
7 * File : extensions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Extension management *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Erweiterungen-Management *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 - 2008 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
45 // Load the extension and maybe found language and function files.
46 function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = '', $EXT_VER = '', $dry_run = false) {
47 // Set current extension name
48 EXT_SET_CURR_NAME($ext_name);
53 // Init EXT_UPDATE_DEPENDS
54 EXT_INIT_UPDATE_DEPENDS();
56 // Init current extension name list
59 // Is the extension already loaded?
60 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Loading extension {$ext_name}, mode={$EXT_LOAD_MODE}, ver={$EXT_VER}.");
61 if ((isset($GLOBALS['ext_loaded']['ext'][$ext_name])) && (empty($EXT_LOAD_MODE))) {
63 DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Extension %s already loaded.", $ext_name));
69 // Construct include filename and FQFN for extension file
70 $INC = sprintf("inc/extensions/ext-%s.php", $ext_name);
71 $FQFN = constant('PATH') . $INC;
73 // Is the extension file NOT there?
74 if (!isIncludeReadable($INC)) {
76 DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Extension %s not found or not readable.", $ext_name));
82 // Construct FQFN for language file
83 $langInclude = sprintf("inc/language/%s_%s.php", $ext_name, getLanguage());
85 // Is this include there?
86 if ((isFileReadable($langInclude)) && (!isset($GLOBALS['ext_loaded']['lang'][$ext_name]))) {
88 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Language loaded.");
89 $GLOBALS['ext_loaded']['lang'][$ext_name] = true;
90 loadIncludeOnce($langInclude);
91 } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
92 // No language file is not so good...
93 DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no language file or we cannot read from it. lang=%s",
94 $ext_name, getLanguage()
98 // Construct FQFN for functions file
99 $funcsInclude = sprintf("inc/libs/%s_functions.php", $ext_name);
101 // Is this include there?
102 if ((isFileReadable($funcsInclude)) && (!isset($GLOBALS['ext_loaded']['funcs'][$ext_name]))) {
104 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Functions loaded.");
105 $GLOBALS['ext_loaded']['funcs'][$ext_name] = true;
106 loadIncludeOnce($funcsInclude);
107 } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
108 // No functions file is not so good...
109 DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no own functions file or we cannot read from it.",
114 // Extensions are not deprecated by default
115 EXT_SET_DEPRECATED('N');
117 // Extensions are not always active by default
118 EXT_SET_ALWAYS_ACTIVE('N');
120 // Extension update notes
121 EXT_SET_UPDATE_NOTES('');
123 // Include the extension file
124 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Extension loaded.");
127 // Is this extension deprecated?
128 if (EXT_GET_DEPRECATED() == 'Y') {
129 // Deactivate the extension
130 DEACTIVATE_EXTENSION($ext_name);
136 // Mark it as loaded in normal mode
137 if (empty($EXT_LOAD_MODE)) {
139 $GLOBALS['ext_loaded']['ext'][$ext_name] = true;
146 // Registeres an extension and possible update depencies
147 function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = true) {
148 // Set current extension name
149 EXT_SET_CURR_NAME($ext_name);
151 //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()." - ENTERED!<br />\n";
152 // This shall never do a non-admin user or if the extension is active (already installed)
153 if ((!IS_ADMIN()) || (EXT_IS_ACTIVE($ext_name))) {
157 // When this extension is already in install/update phase, all is fine
158 if (EXT_IS_REGISTER_RUNNING($ext_name)) {
159 // Then abort here which is fine
160 //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()." - ALREADY!<br />\n";
164 // This registration is running
165 EXT_ADD_RUNNING_REGISTRATION($ext_name);
167 // Init EXT_UPDATE_DEPENDS
168 EXT_INIT_UPDATE_DEPENDS();
170 // Is the task id zero? Then we need to auto-fix it here
172 // Try to find the task
173 $task_id = DETERMINE_EXTENSION_TASK_ID(EXT_GET_CURR_NAME());
175 // Still zero and not in dry-run?
176 if (($task_id == 0) && (!$dry_run)) {
177 // Then request a bug report
178 debug_report_bug(sprintf("%s: task_id is still zero after DETERMINE_EXTENSION_TASK_ID(%s)",
185 // Init queries and notes
194 // By default we have no failures
195 EXT_SET_REPORTS_FAILURE(false);
197 // Does this extension exists?
198 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "currName=".EXT_GET_CURR_NAME()."");
199 if (LOAD_EXTENSION(EXT_GET_CURR_NAME(), 'register', '', $dry_run)) {
200 // Set current extension name again
201 EXT_SET_CURR_NAME($ext_name);
203 // And run possible updates
204 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "".EXT_GET_CURR_NAME());
205 $history = EXT_GET_VER_HISTORY();
206 foreach ($history as $ver) {
207 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ext_name=".EXT_GET_CURR_NAME().", ext_ver={$ver}");
208 // Load extension in update mode
209 LOAD_EXTENSION(EXT_GET_CURR_NAME(), 'update', $ver, $dry_run);
211 // Add update notes to our output
212 ADD_EXTENSION_NOTES($ver);
215 // Does this extension depends on an outstanding update of another update?
216 for ($dmy = EXT_GET_UPDATE_ITERATOR(); EXT_GET_UPDATE_ITERATOR() < EXT_COUNT_UPDATE_DEPENDS();) {
218 $ext_update = EXT_GET_ITERATOR_UPDATE_DEPENDS();
220 // Increment here to avoid endless loop
221 EXT_INCREMENT_UPDATE_INTERATOR();
223 // Check for required file
224 if (LOAD_EXTENSION($ext_update, 'register', '', $dry_run)) {
225 // Set current extension name again
226 EXT_SET_CURR_NAME($ext_name);
228 // If versions mismatch update extension first
229 $ext_ver = GET_EXT_VERSION($ext_update);
231 // Extension version set? If empty the extension is not registered
232 if (empty($ext_ver)) {
233 // Extension not registered so far so first load task's ID...
234 $task = DETERMINE_EXTENSION_TASK_ID($ext_update);
238 // Try to register the extension
239 //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().":ext_update=".$ext_update.",taskId=".$task."<br />\n";
240 $test = REGISTER_EXTENSION($ext_update, $task, $dry_run, false);
242 // Reset extension name
243 EXT_SET_CURR_NAME($ext_name);
244 //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'; var_dump($test);
246 } elseif ($ext_ver != EXT_GET_VERSION()) {
247 // Ok, update this extension now
248 EXTENSION_UPDATE($ext_update, $ext_ver, $dry_run);
253 // Nothing to register / update before...
257 // Required file for update does not exists!
259 // But this is fine for the first time...
262 // Restore the current extension name
263 EXT_SET_CURR_NAME($ext_name);
266 // Is there no update?
267 if (EXT_COUNT_UPDATE_DEPENDS(EXT_GET_CURR_NAME()) == 0) {
268 // Then test is passed!
272 // Switch back to register mode
273 $EXT_LOAD_MODE = 'register';
275 // Remains true if extension registration reports no failures
276 //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'; var_dump($test);
277 $test = (($test === true) && (EXT_GET_REPORTS_FAILURE() === false));
278 //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'; var_dump($test);
280 // Does everthing before wents ok?
281 if ($test === true) {
282 // "Dry-run-mode" activated?
283 if ((!$dry_run) && (!EXT_IS_ON_REMOVAL_LIST())) {
284 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " ext_name=".EXT_GET_CURR_NAME());
285 // Init SQLs and transfer ext->generic
287 SET_SQLS(GET_EXT_SQLS());
289 // Run installation pre-installation filters
290 runFilterChain('pre_extension_installed', array('dry_run' => $dry_run));
292 // Register extension
293 //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:insert=".EXT_GET_CURR_NAME().'/'.EXT_GET_VERSION()." - INSERT!<br />\n";
294 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_extensions` (ext_name, ext_active, ext_version) VALUES ('%s','%s','%s')",
295 array(EXT_GET_CURR_NAME(), EXT_GET_ALWAYS_ACTIVE(), EXT_GET_VERSION()), __FUNCTION__, __LINE__);
297 // Remove cache file(s) if extension is active
298 runFilterChain('post_extension_installed', array('ext_name' => EXT_GET_CURR_NAME(), 'task_id' => $task_id));
300 // Remove all SQL commands
303 // In normal mode return a true on success
305 } elseif ($dry_run) {
306 // Init SQLs and transfer ext->generic
308 SET_SQLS(GET_EXT_SQLS());
310 // Rewrite SQL command to keep { and } inside for dry-run
311 foreach (GET_SQLS() as $key => $sql) {
312 $sql = str_replace('{', "{", str_replace('}', "}", $sql));
313 SET_SQL_KEY($key, $sql);
316 // In "dry-run" mode return array with all SQL commands
319 // Remove all SQL commands
322 // Extension has been removed for updates, so all is fine!
326 // No, an error occurs while registering extension :-(
327 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "".EXT_GET_CURR_NAME());
330 } elseif (($task_id > 0) && (EXT_GET_CURR_NAME() != '')) {
331 //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()."<br />\n";
332 // Remove task from system when id and extension's name is valid
333 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE `id`=%s AND `status`='NEW' LIMIT 1",
334 array(bigintval($task_id)), __FUNCTION__, __LINE__);
337 // Is this the sql_patches?
338 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ':'.EXT_GET_CURR_NAME()."/{$EXT_LOAD_MODE}");
339 if ((EXT_GET_CURR_NAME() == 'sql_patches') && (($EXT_LOAD_MODE == 'register') || ($EXT_LOAD_MODE == 'remove')) && (!$dry_run) && ($test)) {
340 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": LOAD!");
341 if ($logout === true) {
342 // Then redirect to logout
343 redirectToUrl('modules.php?module=admin&logout=1&' . $EXT_LOAD_MODE . '=sql_patches');
345 // Add temporary filter
346 registerFilter('shutdown', 'REDIRECT_TO_LOGOUT_SQL_PATCHES', true, true);
347 $GLOBALS['ext_load_mode'] = $EXT_LOAD_MODE;
351 // Return status code
352 //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()." - LEFT!<br />\n";
353 //* DEBUG: */ var_dump($ret);
357 // Run SQL queries for given extension id
358 // @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
359 function EXTENSION_RUN_SQLS ($ext_id, $load_mode) {
360 // This shall never do a non-admin user!
361 if (!IS_ADMIN()) return false;
363 // Get extension's name
364 $ext_name = GET_EXT_NAME($ext_id);
366 // If it is not set then maybe there is no extension for that ID number
367 if (empty($ext_name)) {
368 // We should fix these all!
369 debug_report_bug(__FUNCTION__ . ': ext_name is empty. ext_id=' . $ext_id);
372 // Set current SQL name
373 EXT_SET_CURR_NAME($ext_name);
375 // Init EXT_UPDATE_DEPENDS
376 EXT_INIT_UPDATE_DEPENDS();
381 // By default no SQL has been executed
384 // Load extension in detected mode
385 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ":ext_name[{$ext_id}]=".EXT_GET_CURR_NAME()."");
386 LOAD_EXTENSION(EXT_GET_CURR_NAME(), $load_mode, '', false);
390 SET_SQLS(GET_EXT_SQLS());
392 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ":SQLs::count=".COUNT_SQLS()."");
393 if ((IS_SQLS_VALID() && (COUNT_SQLS() > 0))) {
394 // Run any filters depending on the action here
395 runFilterChain('extension_' . $load_mode, $ext_name);
397 // Run SQL commands...
398 runFilterChain('run_sqls');
401 if ($load_mode == 'remove') {
402 // Delete this extension (remember to remove it from your server *before* you click on welcome!
403 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
404 array(EXT_GET_CURR_NAME()), __FUNCTION__, __LINE__);
408 // Remove cache file(s) if extension is active
409 if (((EXT_IS_ACTIVE('cache')) || (GET_EXT_VERSION('cache') != '')) && (((SQL_AFFECTEDROWS() == 1)) || ($sqlRan === true) || ($load_mode == 'activate') || ($load_mode == 'deactivate'))) {
411 runFilterChain('post_extension_run_sql', EXT_GET_CURR_NAME());
414 // Is this the sql_patches?
415 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": id=".$ext_id.",currName=".EXT_GET_CURR_NAME().",loadMode=".$load_mode);
416 if ((EXT_GET_CURR_NAME() == 'sql_patches') && (($load_mode == 'register') || ($load_mode == 'remove'))) {
417 // Then redirect to logout
418 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": LOAD!");
419 redirectToUrl('modules.php?module=admin&logout=1&' . $load_mode . '=sql_patches');
423 // Check if given extension is active
424 function EXT_IS_ACTIVE ($ext_name) {
425 // Extensions are all inactive during installation
426 if ((!isInstalled()) || (isInstalling()) || (empty($ext_name))) return false;
428 // Not active is the default
432 if (isset($GLOBALS['cache_array']['extensions']['ext_active'][$ext_name])) {
434 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "CACHE! ext_name={$ext_name}");
435 $active = $GLOBALS['cache_array']['extensions']['ext_active'][$ext_name];
438 incrementConfigEntry('cache_hits');
439 } elseif (isset($GLOBALS['ext_loaded'][$ext_name])) {
440 // @TODO Extension is loaded, what next?
441 app_die(__FUNCTION__, __LINE__, "LOADED:$ext_name");
442 } elseif (($ext_name == 'cache') || (GET_EXT_VERSION('cache') == '')) {
443 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "DB! ext_name={$ext_name}");
444 // Load from database
445 $result = SQL_QUERY_ESC("SELECT `ext_active` FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
446 array($ext_name), __FUNCTION__, __LINE__);
449 if (SQL_NUMROWS($result) == 1) {
451 list($active) = SQL_FETCHROW($result);
455 SQL_FREERESULT($result);
458 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ext_name=".$ext_name."[DB]: {$active}");
459 $GLOBALS['cache_array']['extensions']['ext_active'][$ext_name] = $active;
461 // Extension not active!
462 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ext_name=".$ext_name.": Not active!");
463 $GLOBALS['cache_array']['extensions']['ext_active'][$ext_name] = 'N';
467 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ext_name={$ext_name},active={$active}");
469 // Is this extension activated? (For admins we always have active extensions...)
470 return ($active == 'Y');
472 // Get version from extensions
473 function GET_EXT_VERSION ($ext_name) {
474 // By default no extension is found
477 // Empty extension name should be fixed!
478 if (empty($ext_name)) {
479 // Please report this bug!
480 debug_report_bug(__FUNCTION__ . ': ext_name is empty which is not allowed here.');
483 // Extensions are all inactive during installation
484 if ((!isInstalled()) || (isInstalling())) return "";
485 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": ext_name={$ext_name}");
487 // Is the cache written?
488 if (isset($GLOBALS['cache_array']['extensions']['ext_version'][$ext_name])) {
489 // Load data from cache
490 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": CACHE!");
491 $ext_ver = $GLOBALS['cache_array']['extensions']['ext_version'][$ext_name];
494 incrementConfigEntry('cache_hits');
495 } elseif (!isCacheInstanceValid()) {
496 // Load from database
497 $result = SQL_QUERY_ESC("SELECT `ext_version` FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
498 array($ext_name), __FUNCTION__, __LINE__);
499 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": DB - ".SQL_NUMROWS($result)."");
501 // Is the extension there?
502 if (SQL_NUMROWS($result) == 1) {
504 list($ext_ver) = SQL_FETCHROW($result);
505 } elseif (isDebugModeEnabled()) {
507 DEBUG_LOG(__FUNCTION__, __LINE__, sprintf(": Cannot find extension %s in database!", $ext_name));
511 SQL_FREERESULT($result);
514 $GLOBALS['cache_array']['extensions']['ext_version'][$ext_name] = $ext_ver;
518 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": ret={$ext_ver}");
522 // Updates a given extension with current extension version to latest version
523 function EXTENSION_UPDATE ($ext_name, $ext_ver, $dry_run = false) {
524 // Only admins are allowed to update extensions
525 if ((!IS_ADMIN()) || (empty($ext_name))) return false;
527 // Set current SQL name
528 EXT_SET_CURR_NAME($ext_name);
535 // Load extension in test mode
536 LOAD_EXTENSION($ext_name, 'test', $ext_ver, $dry_run);
538 // Save version history
539 $history = EXT_GET_VER_HISTORY();
541 // Remove old SQLs array to prevent possible bugs
544 // Check if version is updated
545 if (((EXT_GET_VERSION() != $ext_ver) || ($dry_run)) && (is_array($history))) {
546 // Search for starting point
547 $start = array_search($ext_ver, $history);
549 // And load SQL queries in order of version history
550 for ($idx = ($start + 1); $idx < count($history); $idx++) {
551 // Set current extension name
552 //* DEBUG: */ print __FUNCTION__.'['.__LINE__.':] ext_name='.$ext_name.'<br />';
553 EXT_SET_CURR_NAME($ext_name);
555 // Set extension version
556 $GLOBALS['cache_array']['update_ver'][EXT_GET_CURR_NAME()] = $history[$idx];
559 LOAD_EXTENSION(EXT_GET_CURR_NAME(), 'update', $GLOBALS['cache_array']['update_ver'][EXT_GET_CURR_NAME()], $dry_run);
562 $depencies = EXT_GET_UPDATE_DEPENDS();
565 if (count($depencies) > 0) {
566 // Apply all extension depencies
567 foreach ($depencies as $ext_depend) {
569 EXT_SET_CURR_NAME($ext_depend);
571 // Is the extension there?
572 if (GET_EXT_VERSION($ext_depend) != '') {
573 // Update another extension first!
574 $test = EXTENSION_UPDATE($ext_depend, GET_EXT_VERSION($ext_depend), $dry_run);
576 // Register new extension
577 $test = REGISTER_EXTENSION($ext_depend, 0, $dry_run, false);
582 EXT_SET_CURR_NAME($ext_name);
586 ADD_EXTENSION_NOTES($GLOBALS['cache_array']['update_ver'][EXT_GET_CURR_NAME()]);
589 // In real-mode execute any existing includes
591 $GLOBALS['cache_array']['inc_pool'][EXT_GET_CURR_NAME()] = GET_INC_POOL();
592 runFilterChain('load_includes');
593 SET_INC_POOL($GLOBALS['cache_array']['inc_pool'][EXT_GET_CURR_NAME()]);
594 unset($GLOBALS['cache_array']['inc_pool'][EXT_GET_CURR_NAME()]);
599 SET_SQLS(GET_EXT_SQLS());
602 runFilterChain('run_sqls', array('dry_run' => $dry_run));
606 CREATE_EXTENSION_UPDATE_TASK(getCurrentAdminId(), EXT_GET_CURR_NAME(), $GLOBALS['cache_array']['update_ver'][EXT_GET_CURR_NAME()], SQL_ESCAPE(EXT_GET_NOTES(EXT_GET_NOTES())));
608 // Update extension's version
609 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_extensions` SET ext_version='%s' WHERE `ext_name`='%s' LIMIT 1",
610 array($GLOBALS['cache_array']['update_ver'][EXT_GET_CURR_NAME()], EXT_GET_CURR_NAME()), __FUNCTION__, __LINE__);
614 unset($GLOBALS['cache_array']['update_ver'][EXT_GET_CURR_NAME()]);
616 // Run filters on success extension update
617 runFilterChain('extension_update', EXT_GET_CURR_NAME());
622 // Output verbose SQL table for extension
623 function EXTENSION_VERBOSE_TABLE ($queries = array(), $title = '', $dashed = '', $switch = false, $width = '100%') {
626 // Then fix it to default
627 $title = getMessage('ADMIN_SQLS_EXECUTED_ON_REMOVAL');
630 // Are there some queries in $queries?
631 if (count($queries) > 0) {
632 // Then use them instead!
640 // Do we have queries?
641 if ((IS_SQLS_VALID()) && (GET_EXT_VERSION('sql_patches') >= '0.0.7') && (getConfig('verbose_sql') == 'Y')) {
642 foreach (GET_SQLS() as $idx => $sql) {
646 // Output command if set
648 // Prepare output for template
656 $OUT .= LOAD_TEMPLATE("admin_ext_sql_row", true, $content);
658 // Switch color and count up
664 // Prepare content for template
672 // Load main template
673 $OUT = LOAD_TEMPLATE("admin_ext_sql_table", true, $content);
674 } elseif ((GET_EXT_VERSION('sql_patches') >= '0.0.7') && (getConfig('verbose_sql') == 'Y')) {
675 // No addional SQL commands to run
676 $OUT = LOAD_TEMPLATE('admin_settings_saved', true, getMessage('ADMIN_NO_ADDITIONAL_SQLS'));
683 // Get extension name from id
684 function GET_EXT_NAME ($ext_id) {
685 // Init extension name
689 if (isset($GLOBALS['cache_array']['extensions']['ext_name'][$ext_id])) {
691 $ret = $GLOBALS['cache_array']['extensions']['ext_name'][$ext_id];
694 incrementConfigEntry('cache_hits');
695 } elseif (!EXT_IS_ACTIVE('cache')) {
696 // Load from database
697 $result = SQL_QUERY_ESC("SELECT ext_name FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `id`=%s LIMIT 1",
698 array(bigintval($ext_id)), __FUNCTION__, __LINE__);
699 list($ret) = SQL_FETCHROW($result);
700 SQL_FREERESULT($result);
703 // Return the extension name
707 // Get extension id from name
708 function GET_EXT_ID ($ext_name) {
711 if (isset($GLOBALS['cache_array']['extensions']['ext_id'][$ext_name])) {
713 $ret = $GLOBALS['cache_array']['extensions']['ext_id'][$ext_name];
716 incrementConfigEntry('cache_hits');
717 } elseif (!EXT_IS_ACTIVE('cache')) {
718 // Load from database
719 $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
720 array($ext_name), __FUNCTION__, __LINE__);
721 list($ret) = SQL_FETCHROW($result);
722 SQL_FREERESULT($result);
729 // Activate given extension
730 function ACTIVATE_EXTENSION ($ext_name) {
731 // Activate the extension
732 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_extensions` SET `ext_active`='Y' WHERE `ext_name`='%s' LIMIT 1",
733 array($ext_name), __FUNCTION__, __LINE__);
735 // Extension has been activated?
736 if (SQL_AFFECTEDROWS() == 1) {
737 // Then run all queries
738 EXTENSION_RUN_SQLS(GET_EXT_ID($ext_name), 'activate');
742 // Deactivate given extension
743 function DEACTIVATE_EXTENSION($ext_name) {
744 // Activate the extension
745 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_extensions` SET `ext_active`='N' WHERE `ext_name`='%s' LIMIT 1",
746 array($ext_name), __FUNCTION__, __LINE__);
748 // Extension has been activated?
749 if (SQL_AFFECTEDROWS() == 1) {
750 // Then run all queries
751 EXTENSION_RUN_SQLS(GET_EXT_ID($ext_name), 'deactivate');
754 CREATE_EXTENSION_DEACTIVATION_TASK($ext_name);
757 sendAdminNotification(
758 getMessage('ADMIN_SUBJECT_EXTENSION_DEACTIVATED'),
759 'admin_ext_deactivated',
760 array('ext_name' => $ext_name)
765 // Checks wether the extension is older than given
766 function EXT_VERSION_IS_OLDER ($ext_name, $ext_ver) {
767 // Get current extension version
768 $currVersion = GET_EXT_VERSION($ext_name);
770 // Remove all dots from both versions
771 $currVersion = str_replace('.', '', $currVersion);
772 $ext_ver = str_replace('.', '', $ext_ver);
774 // Now compare both and return the result
775 return ($currVersion < $ext_ver);
778 // Creates a new task for updated extension
779 function CREATE_EXTENSION_UPDATE_TASK ($admin_id, $ext_name, $ext_ver, $notes) {
780 // Create subject line
781 $subject = '[UPDATE-'.$ext_name.'-'.$ext_ver.':] {--ADMIN_UPDATE_EXT_SUBJ--}';
783 // Is the extension there?
784 if (GET_EXT_VERSION($ext_name) != '') {
785 // Check if task is not there
786 if (DETERMINE_TASK_ID_BY_SUBJECT($subject) == 0) {
787 // Task not created so it's a brand-new extension which we need to register and create a task for!
788 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (assigned_admin, userid, status, task_type, subject, text, task_created) VALUES ('%s','0','NEW','EXTENSION_UPDATE','%s','%s', UNIX_TIMESTAMP())",
789 array($admin_id, $subject, $notes), __FUNCTION__, __LINE__);
794 // Creates a new task for newly installed extension
795 function CREATE_NEW_EXTENSION_TASK ($admin_id, $subject, $ext) {
796 // Not installed and do we have created a task for the admin?
797 if ((DETERMINE_TASK_ID_BY_SUBJECT($subject) == 0) && (GET_EXT_VERSION($ext) == '')) {
799 $tpl = sprintf("%stemplates/%s/html/ext/ext_%s.tpl",
805 // Set default message if ext-foo is missing
806 $msg = sprintf(getMessage('ADMIN_EXT_TEXT_FILE_MISSING'), $ext);
808 // Load text for task if found
809 if (isFileReadable($tpl)) {
810 // Load extension's own text template (HTML!)
811 $msg = LOAD_TEMPLATE('ext_' . $ext, true);
813 // Write this in debug.log as well
814 DEBUG_LOG(__FUNCTION__, __LINE__, $msg);
817 // Task not created so it's a brand-new extension which we need to register and create a task for!
818 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (assigned_admin, userid, status, task_type, subject, text, task_created)
819 VALUES (%s, 0, 'NEW', 'EXTENSION', '%s', '%s', UNIX_TIMESTAMP())",
823 smartAddSlashes($msg),
824 ), __FUNCTION__, __LINE__, true, false, false
829 // Creates a task for automatically deactivated (deprecated) extension
830 function CREATE_EXTENSION_DEACTIVATION_TASK ($ext) {
831 // Create subject line
832 $subject = sprintf("[%s:] %s", $ext, getMessage('TASK_SUBJ_EXTENSION_DEACTIVATED'));
834 // Not installed and do we have created a task for the admin?
835 if ((DETERMINE_TASK_ID_BY_SUBJECT($subject) == 0) && (GET_EXT_VERSION($ext) != '')) {
836 // Task not created so add it
837 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (assigned_admin, userid, status, task_type, subject, text, task_created)
838 VALUES (0, 0, 'NEW', 'EXTENSION_DEACTIVATION', '%s', '%s', UNIX_TIMESTAMP())",
841 SQL_ESCAPE(LOAD_TEMPLATE('task_ext_deactivated', true, $ext)),
842 ), __FUNCTION__, __LINE__, true, false
847 // Checks if the module has a menu
848 function MODULE_HAS_MENU ($mod, $forceDb = false) {
849 // All is false by default
852 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "mod={$mod},cache=".GET_EXT_VERSION('cache'));
853 if (GET_EXT_VERSION('cache') >= '0.1.2') {
854 // Cache version is okay, so let's check the cache!
855 if (isset($GLOBALS['cache_array']['modules']['has_menu'][$mod])) {
856 // Check module cache and count hit
857 $ret = ($GLOBALS['cache_array']['modules']['has_menu'][$mod] == 'Y');
858 incrementConfigEntry('cache_hits');
859 } elseif (isset($GLOBALS['cache_array']['extensions']['ext_menu'][$mod])) {
860 // Check cache and count hit
861 $ret = ($GLOBALS['cache_array']['extensions']['ext_menu'][$mod] == 'Y');
862 incrementConfigEntry('cache_hits');
863 } elseif ((IS_ADMIN()) && ($mod == 'admin')) {
864 // Admin module has always a menu!
867 } elseif ((GET_EXT_VERSION('sql_patches') >= '0.3.6') && ((!EXT_IS_ACTIVE('cache')) || ($forceDb === true))) {
868 // Check database for entry
869 $result = SQL_QUERY_ESC("SELECT has_menu FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE `module`='%s' LIMIT 1",
870 array($mod), __FUNCTION__, __LINE__);
873 if (SQL_NUMROWS($result) == 1) {
874 // Load "has_menu" column
875 list($has_menu) = SQL_FETCHROW($result);
878 $GLOBALS['cache_array']['extensions']['ext_menu'][$mod] = $has_menu;
880 // Does it have a menu?
881 $ret = ($has_menu == 'Y');
885 SQL_FREERESULT($result);
886 } elseif (GET_EXT_VERSION('sql_patches') == '') {
887 // No sql_patches installed, so maybe in admin area or no admin registered?
888 $ret = (((IS_ADMIN()) || (!isAdminRegistered())) && ($mod == 'admin')); // Then there is a menu!
892 //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'; var_dump($ret);
896 // Determines the task id for given extension
897 function DETERMINE_EXTENSION_TASK_ID ($ext_name) {
898 // Default is not found
901 // Search for extension task's id
902 $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_task_system` WHERE task_type='EXTENSION' AND subject='[%s:]' LIMIT 1",
903 array($ext_name), __FUNCTION__, __LINE__);
906 if (SQL_NUMROWS($result) == 1) {
907 // Task found so load task's ID and register extension...
908 list($task_id) = SQL_FETCHROW($result);
912 SQL_FREERESULT($result);
918 // Determines the task id for given subject
919 function DETERMINE_TASK_ID_BY_SUBJECT ($subject) {
920 // Default is not found
923 // Search for task id
924 $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_task_system` WHERE subject LIKE '%s%%' LIMIT 1",
925 array($subject), __FUNCTION__, __LINE__);
928 if (SQL_NUMROWS($result) == 1) {
929 // Task found so load task's ID and register extension...
930 list($task_id) = SQL_FETCHROW($result);
934 SQL_FREERESULT($result);
940 // Add updates notes for given version
941 function ADD_EXTENSION_NOTES ($ver) {
942 // Init notes/content
943 $out = ''; $content = array();
945 // Is do we have verbose output enabled?
946 if ((getConfig('verbose_sql') == 'Y') || (!EXT_IS_ACTIVE('sql_patches'))) {
947 // Update notes found?
948 if (EXT_GET_UPDATE_NOTES() != '') {
949 // Update notes found
952 'notes' => EXT_GET_UPDATE_NOTES()
956 EXT_SET_UPDATE_NOTES('');
957 } elseif (($ver == '0.0') || ($ver == '0.0.0')) {
961 'notes' => getMessage('INITIAL_RELEASE')
964 // No update notes found!
967 'notes' => getMessage('NO_UPDATE_NOTES')
972 $out = LOAD_TEMPLATE('admin_ext_notes', true, $content);
976 EXT_APPEND_NOTES($out);
979 // Getter for CSS files array
980 function EXT_GET_CSS_FILES () {
981 // By default no additional CSS files are found
984 // Is the array there?
985 if (isset($GLOBALS['css_files'])) {
987 $cssFiles = $GLOBALS['css_files'];
994 // Init CSS files array
995 function EXT_INIT_CSS_FILES () {
997 $GLOBALS['css_files'] = array();
1001 function EXT_ADD_CSS_FILE ($file) {
1002 // Is the array there?
1003 if (!isset($GLOBALS['css_files'])) {
1004 // Then auto-init them
1005 EXT_INIT_CSS_FILES();
1009 $GLOBALS['css_files'][] = $file;
1012 // Setter for EXT_ALWAYS_ACTIVE flag
1013 function EXT_SET_ALWAYS_ACTIVE ($active) {
1014 $GLOBALS['ext_always_active'][EXT_GET_CURR_NAME()] = (string) $active;
1017 // Getter for EXT_ALWAYS_ACTIVE flag
1018 function EXT_GET_ALWAYS_ACTIVE () {
1019 return $GLOBALS['ext_always_active'][EXT_GET_CURR_NAME()];
1022 // Setter for EXT_VERSION flag
1023 function EXT_SET_VERSION ($version) {
1024 $GLOBALS['ext_version'][EXT_GET_CURR_NAME()] = (string) $version;
1027 // Getter for EXT_VERSION flag
1028 function EXT_GET_VERSION () {
1029 return $GLOBALS['ext_version'][EXT_GET_CURR_NAME()];
1032 // Setter for EXT_DEPRECATED flag
1033 function EXT_SET_DEPRECATED ($deprecated) {
1034 $GLOBALS['ext_deprecated'][EXT_GET_CURR_NAME()] = (string) $deprecated;
1037 // Getter for EXT_DEPRECATED flag
1038 function EXT_GET_DEPRECATED () {
1039 return $GLOBALS['ext_deprecated'][EXT_GET_CURR_NAME()];
1042 // Setter for EXT_UPDATE_DEPENDS flag
1043 function EXT_ADD_UPDATE_DEPENDS ($updateDepends) {
1044 // Is the update depency empty? (NEED TO BE FIXED!)
1045 if (empty($updateDepends)) {
1046 // Please report this bug!
1047 debug_report_bug("updateDepends is left empty!");
1050 // Is it not yet added?
1051 if (!in_array($updateDepends, $GLOBALS['ext_running_updates'])) {
1052 //* DEBUG */ DEBUG_LOG(__FUNCTION__, __LINE__, "currName=".EXT_GET_CURR_NAME().'/'.$updateDepends);
1053 // Add it to the list of extension update depencies map
1054 $GLOBALS['ext_update_depends'][EXT_GET_CURR_NAME()][] = (string) $updateDepends;
1056 // Remember it in the list of running updates
1057 $GLOBALS['ext_running_updates'][] = $updateDepends;
1061 // Checks wether the given extension registration is in progress
1062 function EXT_IS_REGISTER_RUNNING ($ext_name) {
1063 return ((isset($GLOBALS['ext_register_running'])) && (in_array($ext_name, $GLOBALS['ext_register_running'])));
1066 // Init EXT_UPDATE_DEPENDS flag
1067 function EXT_INIT_UPDATE_DEPENDS () {
1068 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "currName=".EXT_GET_CURR_NAME());
1070 // Init update depency map automatically if not found
1071 if (!EXT_IS_UPDATE_DEPENDS_INIT()) {
1072 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "currName=".EXT_GET_CURR_NAME()." - INIT!");
1073 $GLOBALS['ext_update_depends'][EXT_GET_CURR_NAME()] = array();
1076 // Init running updates array
1077 EXT_INIT_RUNNING_UPDATES();
1080 // Adds an extension as "registration in progress"
1081 function EXT_ADD_RUNNING_REGISTRATION ($ext_name) {
1083 if (!EXT_IS_REGISTER_RUNNING($ext_name)) {
1085 $GLOBALS['ext_register_running'][] = $ext_name;
1089 // Checks wether EXT_UPDATE_DEPENDS is initialized
1090 function EXT_IS_UPDATE_DEPENDS_INIT () {
1091 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "currName=".EXT_GET_CURR_NAME());
1092 return (isset($GLOBALS['ext_update_depends'][EXT_GET_CURR_NAME()]));
1095 // Initializes the list of running updates
1096 function EXT_INIT_RUNNING_UPDATES () {
1097 // Auto-init ext_running_updates
1098 if (!isset($GLOBALS['ext_running_updates'])) {
1099 $GLOBALS['ext_running_updates'] = array();
1100 $GLOBALS['ext_register_running'] = array();
1104 // Getter for EXT_UPDATE_DEPENDS flag
1105 function EXT_GET_UPDATE_DEPENDS () {
1106 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "currName=".EXT_GET_CURR_NAME());
1107 return $GLOBALS['ext_update_depends'][EXT_GET_CURR_NAME()];
1110 // Getter for next iterator depency
1111 function EXT_GET_ITERATOR_UPDATE_DEPENDS () {
1112 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "currName=".EXT_GET_CURR_NAME());
1113 return ($GLOBALS['ext_update_depends'][EXT_GET_CURR_NAME()][EXT_GET_UPDATE_ITERATOR()]);
1116 // Counter for extension update depencies
1117 function EXT_COUNT_UPDATE_DEPENDS () {
1118 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "currName=".EXT_GET_CURR_NAME());
1119 return count($GLOBALS['ext_update_depends'][EXT_GET_CURR_NAME()]);
1122 // Removes given extension from update denpency list
1123 function EXT_REMOVE_UPDATE_DEPENDS ($ext_name) {
1125 $key = array_search($ext_name, EXT_GET_UPDATE_DEPENDS());
1128 if ($key !== false) {
1130 unset($GLOBALS['ext_update_depends'][EXT_GET_CURR_NAME()][$key]);
1132 // And sort the array
1133 ksort($GLOBALS['ext_update_depends'][EXT_GET_CURR_NAME()]);
1137 // Init iterator for update depencies
1138 function EXT_INIT_UPDATE_ITERATOR () {
1139 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "currName=".EXT_GET_CURR_NAME());
1140 $GLOBALS['ext_depend_iterator'][EXT_GET_CURR_NAME()] = 0;
1143 // Getter for depency iterator
1144 function EXT_GET_UPDATE_ITERATOR () {
1145 // Auto-init iterator
1146 if (!isset($GLOBALS['ext_depend_iterator'][EXT_GET_CURR_NAME()])) EXT_INIT_UPDATE_ITERATOR();
1149 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "currName=".EXT_GET_CURR_NAME().'/'.$GLOBALS['ext_depend_iterator'][EXT_GET_CURR_NAME()]);
1150 return $GLOBALS['ext_depend_iterator'][EXT_GET_CURR_NAME()];
1153 // Increments the update iterator
1154 function EXT_INCREMENT_UPDATE_INTERATOR () {
1155 //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "currName=".EXT_GET_CURR_NAME());
1156 $GLOBALS['ext_depend_iterator'][EXT_GET_CURR_NAME()]++;
1159 // Setter for EXT_REPORTS_FAILURE flag
1160 function EXT_SET_REPORTS_FAILURE ($reportsFailure) {
1161 $GLOBALS['ext_reports_failure'] = (bool) $reportsFailure;
1164 // Getter for EXT_REPORTS_FAILURE flag
1165 function EXT_GET_REPORTS_FAILURE () {
1166 return $GLOBALS['ext_reports_failure'];
1169 // Setter for EXT_VER_HISTORY flag
1170 function EXT_SET_VER_HISTORY ($verHistory) {
1171 $GLOBALS['ext_ver_history'] = (array) $verHistory;
1174 // Getter for EXT_VER_HISTORY array
1175 function EXT_GET_VER_HISTORY () {
1176 return $GLOBALS['ext_ver_history'];
1179 // Setter for EXT_UPDATE_NOTES flag
1180 function EXT_SET_UPDATE_NOTES ($updateNotes) {
1181 $GLOBALS['ext_update_notes'] = (string) $updateNotes;
1184 // Getter for EXT_UPDATE_NOTES flag
1185 function EXT_GET_UPDATE_NOTES () {
1186 return $GLOBALS['ext_update_notes'];
1189 // Init extension notice
1190 function EXT_INIT_NOTES () {
1191 $GLOBALS['ext_notes'] = '';
1194 // Append extension notice
1195 function EXT_APPEND_NOTES ($notes) {
1196 $GLOBALS['ext_notes'] .= (string) $notes;
1199 // Getter for extension notes
1200 function EXT_GET_NOTES () {
1201 return $GLOBALS['ext_notes'];
1204 // Setter for current extension name
1205 function EXT_SET_CURR_NAME ($ext_name) {
1206 $GLOBALS['curr_ext_name'] = (string) $ext_name;
1209 // Getter for current extension name
1210 function EXT_GET_CURR_NAME () {
1211 if (isset($GLOBALS['curr_ext_name'])) {
1212 return $GLOBALS['curr_ext_name'];
1216 debug_report_bug(__FUNCTION__.": curr_ext_name not initialized. Please execute INIT_EXT_SQLS() before calling this function.");
1219 // Init SQLs array for current extension
1220 function INIT_EXT_SQLS () {
1221 // Auto-init the array now...
1222 if (!isset($GLOBALS['ext_sqls'][EXT_GET_CURR_NAME()])) {
1223 $GLOBALS['ext_sqls'][EXT_GET_CURR_NAME()] = array();
1227 // Adds SQLs to the SQLs array but "assigns" it with current extension name
1228 function ADD_EXT_SQL ($sql) {
1229 $GLOBALS['ext_sqls'][EXT_GET_CURR_NAME()][] = $sql;
1232 // Getter for SQLs array for current extension
1233 function GET_EXT_SQLS () {
1234 // Output debug backtrace if not found (SHOULD NOT HAPPEN!)
1235 if (!isset($GLOBALS['ext_sqls'][EXT_GET_CURR_NAME()])) {
1236 // Not found, should not happen
1237 debug_report_bug(sprintf("ext_sqls is empty, current extension: %s",
1243 return $GLOBALS['ext_sqls'][EXT_GET_CURR_NAME()];
1246 // Removes SQLs for current extension
1247 function UNSET_EXT_SQLS () {
1248 unset($GLOBALS['ext_sqls'][EXT_GET_CURR_NAME()]);
1251 // Auto-initializes the removal list
1252 function EXT_INIT_REMOVAL_LIST () {
1253 // Is the remove list there?
1254 if (!isset($GLOBALS['ext_update_remove'])) {
1256 $GLOBALS['ext_update_remove'] = array();
1260 // Checks wether the current extension is on the removal list
1261 function EXT_IS_ON_REMOVAL_LIST () {
1262 // Init removal list
1263 EXT_INIT_REMOVAL_LIST();
1266 return (in_array(EXT_GET_CURR_NAME(), $GLOBALS['ext_update_remove']));
1269 // Adds the current extension to the removal list
1270 function EXT_ADD_CURRENT_TO_REMOVAL_LIST () {
1272 $GLOBALS['ext_update_remove'][] = EXT_GET_CURR_NAME();
1275 // Getter for removal list
1276 function EXT_GET_REMOVAL_LIST () {
1277 // Return the removal list
1278 return $GLOBALS['ext_update_remove'];
1281 // Redirects if the provided extension is not installed
1282 function redirectOnUninstalledExtension ($ext_name) {
1283 // So is the extension there?
1284 if ((!isExtensionInstalled($ext_name)) || (!EXT_IS_ACTIVE($ext_name))) {
1285 // Redirect to index
1286 redirectToUrl('modules.php?module=index&msg=' . getCode('EXTENSION_PROBLEM') . '&ext=' . $ext_name);
1290 // Determines wether the given extension is installed
1291 function isExtensionInstalled ($ext_name) {
1292 // Default is not installed
1293 $isInstalled = false;
1295 // Check cache ext_version
1296 $isInstalled = isset($GLOBALS['cache_array']['extensions']['ext_version'][$ext_name]);
1299 return $isInstalled;