]> git.mxchange.org Git - mailer.git/blobdiff - inc/extensions-functions.php
Naming convention, more usage of EL, new wrapper function introduced:
[mailer.git] / inc / extensions-functions.php
index a680cc148770565a9499f898a22aed5253c204f3..e755418accd30e5ac705a8406b972a48675ba7a2 100644 (file)
@@ -43,7 +43,7 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Load the extension and maybe found language and function files.
-function loadExtension ($ext_name, $ext_mode = 'init', $ext_ver = '', $dry_run = false) {
+function loadExtension ($ext_name, $ext_mode, $ext_ver = '', $dry_run = false) {
        // If this happens twice, we need the bug report from you, except for updates/tests
        if ((isset($GLOBALS['loaded_extension'][$ext_name][$ext_mode])) && (!in_array($ext_mode, array('update', 'test')))) {
                debug_report_bug(__FUNCTION__, __LINE__, '() is called twice: ext_name=' . $ext_name . ', ext_mode='. $ext_mode . ',ext_sqls=' . print_r(getExtensionSqls(), true) . ', ext_register_running=' . print_r($GLOBALS['ext_register_running'], true) . ', ext_running_updates=' . print_r($GLOBALS['ext_running_updates'], true));
@@ -125,7 +125,7 @@ function loadExtension ($ext_name, $ext_mode = 'init', $ext_ver = '', $dry_run =
                        // Download functions file
                        loadIncludeOnce($funcsInclude);
                } // END - if
-       } 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')) {
+       } elseif ((!isset($GLOBALS['cache_array']['extension']['ext_func'][$ext_name])) && (isDebugModeEnabled()) && (getScriptOutputMode() == '0') && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme') && (getExtensionMode() == 'test')) {
                // No functions file is not so good...
                logDebugMessage(__FUNCTION__, __LINE__, sprintf("NOTICE: Extension %s has no own functions file or we cannot read from it. mode=%s",
                        $ext_name,
@@ -338,7 +338,7 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $logout = true
                                setSqlsArray(getExtensionSqls());
 
                                // Run installation pre-installation filters
-                               runFilterChain('pre_extension_installed', array('dry_run' => isExtensionDryRun()));
+                               runFilterChain('pre_extension_installed', array('dry_run' => isExtensionDryRun(), 'enable_codes' => false));
 
                                // Register extension
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'insert=' . getCurrentExtensionName() . '/' . getCurrentExtensionVersion() . ' - INSERT!');
@@ -481,7 +481,7 @@ function isExtensionInstalled ($ext_name) {
        // We don't like empty extension names here
        if (empty($ext_name)) {
                // Please fix them all
-               debug_report_bug(__FUNCTION__.': ext_name is empty.');
+               debug_report_bug(__FUNCTION__, __LINE__, 'ext_name is empty.');
        } // END - if
 
        // By default non is installed
@@ -522,8 +522,16 @@ function isExtensionInstalled ($ext_name) {
 
 // Check if given extension is active
 function isExtensionActive ($ext_name) {
-       // Extensions are all inactive during installation
-       if ((isInstallationPhase()) || (empty($ext_name))) return false;
+       if (isInstallationPhase()) {
+               // Extensions are all inactive during installation
+               return false;
+       } elseif (empty($ext_name)) {
+               // Empty extension names must befixed
+               debug_report_bug(__FUNCTION__, __LINE__, 'Empty extension name provided.');
+       } elseif (!isExtensionInstalled($ext_name)) {
+               // Not installed extensions are always inactive
+               return false;
+       }
 
        // Not active is the default
        $data['ext_active'] = 'N';
@@ -593,7 +601,7 @@ function getExtensionVersion ($ext_name, $force = false) {
 
                // Count cache hits
                incrementStatsEntry('cache_hits');
-       } elseif ((!isCacheInstanceValid()) || (isset($GLOBALS['cache_array']['extension'])) || (getOutputMode() != 0)) {
+       } elseif ((!isCacheInstanceValid()) || (isset($GLOBALS['cache_array']['extension'])) || (getScriptOutputMode() != 0)) {
                // Load from database
                $result = SQL_QUERY_ESC("SELECT `ext_version` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
                        array($ext_name), __FUNCTION__, __LINE__);
@@ -712,7 +720,7 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) {
                setSqlsArray(getExtensionSqls());
 
                // Run SQLs
-               runFilterChain('run_sqls', array('dry_run' => isExtensionDryRun()));
+               runFilterChain('run_sqls', array('dry_run' => isExtensionDryRun(), 'enable_codes' => false));
 
                if (isExtensionDryRun() === false) {
                        // Run filters on success extension update
@@ -733,7 +741,7 @@ function addExtensionVerboseSqlTable ($title = '', $dashed = '', $switch = false
        $OUT = '';
 
        // Do we have queries?
-       if ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y')) {
+       if (isVerboseSqlEnabled()) {
                // Do we have entries?
                if (countExtensionSqls() > 0) {
                        // Init counter
@@ -750,7 +758,7 @@ function addExtensionVerboseSqlTable ($title = '', $dashed = '', $switch = false
                                                // Prepare output for template
                                                $content = array(
                                                        'i'   => ($idx + 1),
-                                                       'sql' => $sql
+                                                       'sql' => str_replace('{', '{', str_replace('}', '}', encodeEntities($sql)))
                                                );
 
                                                // Load row template
@@ -1068,7 +1076,7 @@ function addExtensionNotes ($ext_ver) {
        $content = array();
 
        // Is do we have verbose output enabled?
-       if ((!isExtensionActive('sql_patches')) || (getConfig('verbose_sql') == 'Y')) {
+       if ((!isExtensionActive('sql_patches')) || (isVerboseSqlEnabled())) {
                // Update notes found?
                if (isExtensionUpdateNoteSet($ext_ver)) {
                        // Update notes found