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 * -------------------------------------------------------------------- *
17 * $Tag:: 0.2.1-FINAL $ *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009 - 2013 by Mailer Developer Team *
22 * For more information visit: http://mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
43 } elseif (isInstaller()) {
44 // Do not run in installation phase
45 //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Run from installation phase.');
49 // Next cached table is the extension
50 if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) {
51 // Load extension from cache
52 $EXT_DUMMY = $GLOBALS['cache_instance']->getArrayFromCache();
54 // Init extension inc-pool
58 if (count($EXT_DUMMY) > 0) {
63 foreach ($EXT_DUMMY['ext_name'] as $k => $ext_name) {
65 if ($EXT_DUMMY['ext_css'][$k] == 'Y') {
66 addExtensionCssFile($ext_name . '.css');
69 // Load extension file itself
70 if (($EXT_DUMMY['ext_active'][$k] == 'Y') || ($EXT_DUMMY['ext_keep'][$k] == 'Y')) {
71 array_push($EXT_POOL, $ext_name);
75 $EXT_DUMMY['ext_version'][$ext_name] = $EXT_DUMMY['ext_version'][$k];
76 unset($EXT_DUMMY['ext_version'][$k]);
78 // Extension is active
79 $EXT_DUMMY['ext_active'][$ext_name] = $EXT_DUMMY['ext_active'][$k];
80 unset($EXT_DUMMY['ext_active'][$k]);
83 $EXT_DUMMY['ext_menu'][$ext_name] = $EXT_DUMMY['ext_menu'][$k];
84 unset($EXT_DUMMY['ext_menu'][$k]);
87 $EXT_DUMMY['ext_lang'][$ext_name] = $EXT_DUMMY['ext_lang'][$k];
88 unset($EXT_DUMMY['ext_lang'][$k]);
91 $EXT_DUMMY['ext_func'][$ext_name] = $EXT_DUMMY['ext_func'][$k];
92 unset($EXT_DUMMY['ext_func'][$k]);
95 $EXT_DUMMY['ext_id'][$ext_name] = $EXT_DUMMY['ext_id'][$k];
96 $id = $EXT_DUMMY['ext_id'][$ext_name];
97 unset($EXT_DUMMY['ext_id'][$k]);
100 $EXT_NAMES[$id] = $ext_name;
102 // Add deprecated flag (defaults to 'not deprecated')
103 $EXT_DUMMY['ext_deprecated'][$ext_name] = 'N';
105 // Mark it as active extension
106 $GLOBALS['cache_array']['always_active'][$ext_name] = $EXT_DUMMY['ext_keep'][$k];
107 unset($EXT_DUMMY['ext_keep'][$k]);
109 // Remove unneccessary data from memory
110 unset($EXT_DUMMY['ext_css'][$k]);
113 // Write dummy array back
114 $EXT_DUMMY['ext_name'] = $EXT_NAMES;
117 // Loading cache is done so let's free some memory!
118 unset($EXT_DUMMY['ext_keep']);
119 unset($EXT_DUMMY['ext_css']);
122 // Transfer dummy array
123 $GLOBALS['cache_array']['extension'] = $EXT_DUMMY;
126 // No database load needed
127 $res_ext_crt = FALSE;
129 // Load all extension files in test-mode (we initialize them later)
130 foreach ($EXT_POOL as $ext) {
131 loadExtension($ext, 'test');
134 // Remove array and mark cache as loaded
136 } elseif ((isHtmlOutputMode()) || (isAjaxOutputMode()) || (isRawOutputMode())) {
137 // Create cache file here
138 $GLOBALS['cache_instance']->init();
140 // Add more if ext-sql_patches is recent enougth
142 if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
144 $add = ', `ext_has_css` AS `ext_css`';
147 // Query for all extensions
148 $result = sqlQuery('SELECT
155 `{?_MYSQL_PREFIX?}_extensions`
157 `ext_name` ASC', __FILE__, __LINE__);
160 while ($content = sqlFetchArray($result)) {
162 if (!loadExtension($content['ext_name'], 'test')) {
163 // Is the name valid?
164 if (!isExtensionNameValid($content['ext_name'])) {
165 // Is not valid name (empty ext-foo.php script)
166 sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
167 array($content['ext_name']), __FILE__, __LINE__);
169 // Didn't load so deactivate it
170 doDeactivateExtension($content['ext_name'], TRUE);
178 $content['ext_menu'] = convertBooleanToYesNo(ifModuleHasMenu($content['ext_name'], TRUE));
180 // Get language entry
181 $content['ext_lang'] = convertBooleanToYesNo(isLanguageIncludeReadable($content['ext_name']));
183 // Get function entry
184 $content['ext_func'] = convertBooleanToYesNo(isExtensionFunctionFileReadable($content['ext_name']));
186 // Transfer EXT_ALWAYS_ACTIVE flag
187 $content['ext_keep'] = getThisExtensionAlwaysActive();
189 // Fix missing ext_css
190 if (!isset($content['ext_css'])) {
191 $content['ext_css'] = 'N';
194 // Add row to cache file
195 $GLOBALS['cache_instance']->addRow($content);
199 sqlFreeResult($result);
202 $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
203 $GLOBALS['cache_instance']->finalize();