2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 06/26/2004 *
4 * =================== Last change: 07/01/2005 *
6 * -------------------------------------------------------------------- *
7 * File : load-extension.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Load all extensions *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Alle Erweiterungen laden *
12 * -------------------------------------------------------------------- *
13 * @TODO Rewrite this whole file *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2009 by Roland Haeder *
16 * Copyright (c) 2009 - 2013 by Mailer Developer Team *
17 * For more information visit: http://mxchange.org *
19 * This program is free software; you can redistribute it and/or modify *
20 * it under the terms of the GNU General Public License as published by *
21 * the Free Software Foundation; either version 2 of the License, or *
22 * (at your option) any later version. *
24 * This program is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU General Public License for more details. *
29 * You should have received a copy of the GNU General Public License *
30 * along with this program; if not, write to the Free Software *
31 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
33 ************************************************************************/
35 // Some security stuff...
36 if (!defined('__SECURITY')) {
38 } elseif (isInstaller()) {
39 // Do not run in installation phase
40 //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Run from installation phase.');
44 // Next cached table is the extension
45 if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) {
46 // Load extension from cache
47 $EXT_DUMMY = $GLOBALS['cache_instance']->getArrayFromCache();
49 // Init extension inc-pool
53 if (count($EXT_DUMMY) > 0) {
58 foreach ($EXT_DUMMY['ext_name'] as $k => $ext_name) {
60 if ($EXT_DUMMY['ext_css'][$k] == 'Y') {
61 addExtensionCssFile($ext_name . '.css');
64 // Load extension file itself
65 if (($EXT_DUMMY['ext_active'][$k] == 'Y') || ($EXT_DUMMY['ext_keep'][$k] == 'Y')) {
66 array_push($EXT_POOL, $ext_name);
70 $EXT_DUMMY['ext_version'][$ext_name] = $EXT_DUMMY['ext_version'][$k];
71 unset($EXT_DUMMY['ext_version'][$k]);
73 // Extension is active
74 $EXT_DUMMY['ext_active'][$ext_name] = $EXT_DUMMY['ext_active'][$k];
75 unset($EXT_DUMMY['ext_active'][$k]);
78 $EXT_DUMMY['ext_menu'][$ext_name] = $EXT_DUMMY['ext_menu'][$k];
79 unset($EXT_DUMMY['ext_menu'][$k]);
82 $EXT_DUMMY['ext_lang'][$ext_name] = $EXT_DUMMY['ext_lang'][$k];
83 unset($EXT_DUMMY['ext_lang'][$k]);
86 $EXT_DUMMY['ext_func'][$ext_name] = $EXT_DUMMY['ext_func'][$k];
87 unset($EXT_DUMMY['ext_func'][$k]);
90 $EXT_DUMMY['ext_id'][$ext_name] = $EXT_DUMMY['ext_id'][$k];
91 $id = $EXT_DUMMY['ext_id'][$ext_name];
92 unset($EXT_DUMMY['ext_id'][$k]);
95 $EXT_NAMES[$id] = $ext_name;
97 // Add deprecated flag (defaults to 'not deprecated')
98 $EXT_DUMMY['ext_deprecated'][$ext_name] = 'N';
100 // Mark it as active extension
101 $GLOBALS['cache_array']['always_active'][$ext_name] = $EXT_DUMMY['ext_keep'][$k];
102 unset($EXT_DUMMY['ext_keep'][$k]);
104 // Remove unneccessary data from memory
105 unset($EXT_DUMMY['ext_css'][$k]);
108 // Write dummy array back
109 $EXT_DUMMY['ext_name'] = $EXT_NAMES;
112 // Loading cache is done so let's free some memory!
113 unset($EXT_DUMMY['ext_keep']);
114 unset($EXT_DUMMY['ext_css']);
117 // Transfer dummy array
118 $GLOBALS['cache_array']['extension'] = $EXT_DUMMY;
121 // No database load needed
122 $res_ext_crt = FALSE;
124 // Load all extension files in test-mode (we initialize them later)
125 foreach ($EXT_POOL as $ext) {
126 loadExtension($ext, 'test');
129 // Remove array and mark cache as loaded
131 } elseif ((isHtmlOutputMode()) || (isAjaxOutputMode()) || (isRawOutputMode())) {
132 // Create cache file here
133 $GLOBALS['cache_instance']->init();
135 // Add more if ext-sql_patches is recent enougth
137 if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
139 $add = ', `ext_has_css` AS `ext_css`';
142 // Query for all extensions
143 $result = sqlQuery('SELECT
150 `{?_MYSQL_PREFIX?}_extensions`
152 `ext_name` ASC', __FILE__, __LINE__);
155 while ($content = sqlFetchArray($result)) {
157 if (!loadExtension($content['ext_name'], 'test')) {
158 // Is the name valid?
159 if (!isExtensionNameValid($content['ext_name'])) {
160 // Is not valid name (empty ext-foo.php script)
161 sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
162 array($content['ext_name']), __FILE__, __LINE__);
164 // Didn't load so deactivate it
165 doDeactivateExtension($content['ext_name'], TRUE);
173 $content['ext_menu'] = convertBooleanToYesNo(ifModuleHasMenu($content['ext_name'], TRUE));
175 // Get language entry
176 $content['ext_lang'] = convertBooleanToYesNo(isLanguageIncludeReadable($content['ext_name']));
178 // Get function entry
179 $content['ext_func'] = convertBooleanToYesNo(isExtensionFunctionFileReadable($content['ext_name']));
181 // Transfer EXT_ALWAYS_ACTIVE flag
182 $content['ext_keep'] = getThisExtensionAlwaysActive();
184 // Fix missing ext_css
185 if (!isset($content['ext_css'])) {
186 $content['ext_css'] = 'N';
189 // Add row to cache file
190 $GLOBALS['cache_instance']->addRow($content);
194 sqlFreeResult($result);
197 $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
198 $GLOBALS['cache_instance']->finalize();