More fixes for installation and extension registration
authorRoland Häder <roland@mxchange.org>
Wed, 25 Nov 2009 18:14:57 +0000 (18:14 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 25 Nov 2009 18:14:57 +0000 (18:14 +0000)
inc/classes/cachesystem.class.php
inc/extensions-functions.php
inc/filters.php
inc/functions.php
inc/modules/admin/what-overview.php
templates/de/html/admin/admin_login_form.tpl

index a8223aa640d60dabaf3d4e8ac73859c910011cbc..571721e63df27a0ce329c36a866abd22d4fc49b7 100644 (file)
@@ -417,11 +417,11 @@ class CacheSystem {
                                // Get extension version
                                $ext_ver = getExtensionVersion($ext_name);
 
-                               // Write cache line to file
-                               fwrite($this->pointer, $this->rewriteEntry($ext_name, $ext_ver, 'version', true));
-
                                // Add the extension version to object (DO NOT REMOVE IT! Endless loop...)
                                $this->version[$this->name][$ext_name] = $ext_ver;
+
+                               // Write cache line to file
+                               fwrite($this->pointer, $this->rewriteEntry($ext_name, $ext_ver, 'version', true));
                        } // END - if
                        //* DEBUG: */ outputHtml(__METHOD__."(<font color=\"#0000aa\">".__LINE__."</font>): {$this->name} - {$ext_name}={$ext_ver}<br />");
                } else {
index e26f462871cd34ea878f7241832808b70cd0635c..c73a57fe4c3bc0d2adbbc45b50623c868a5f61d3 100644 (file)
@@ -226,7 +226,7 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru
                        incrementExtensionUpdateIterator();
 
                        // Check for required file
-                       if (loadExtension($ext_update, 'register', '', getExtensionDryRun())) {
+                       if ((!isExtensionInstalled($ext_update)) && (loadExtension($ext_update, 'register', '', getExtensionDryRun()))) {
                                // Set current extension name again
                                setCurrentExtensionName($ext_name);
 
@@ -254,12 +254,15 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru
                                        } // END - if
                                } elseif ($ext_ver != getCurrentExtensionVersion()) {
                                        // Ok, update this extension now
-                                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName().",ext_update=".$ext_update.",ext_ver=".$ext_ver."/".getCurrentExtensionVersion()."");
-                                       $GLOBALS['ext_backup'][$ext_update][$ext_ver] = getCurrentExtensionName();
+                                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName='.getCurrentExtensionName().',currVer='.getCurrentExtensionVersion().'');
+                                       $GLOBALS['ext_backup_name'][$ext_update][$ext_ver] = getCurrentExtensionName();
+                                       $GLOBALS['ext_backup_ver'][$ext_update][$ext_ver] = getCurrentExtensionVersion();
                                        updateExtension($ext_update, $ext_ver, getExtensionDryRun());
-                                       setCurrentExtensionName($GLOBALS['ext_backup'][$ext_update][$ext_ver]);
-                                       unset($GLOBALS['ext_backup'][$ext_update][$ext_ver]);
-                                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName()."");
+                                       setCurrentExtensionName($GLOBALS['ext_backup_name'][$ext_update][$ext_ver]);
+                                       setCurrentExtensionVersion($GLOBALS['ext_backup_ver'][$ext_update][$ext_ver]);
+                                       unset($GLOBALS['ext_backup_name'][$ext_update][$ext_ver]);
+                                       unset($GLOBALS['ext_backup_ver'][$ext_update][$ext_ver]);
+                                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName='.getCurrentExtensionName().',currVer='.getCurrentExtensionVersion().'');
 
                                        // All okay!
                                        $test = true;
@@ -537,7 +540,7 @@ function getExtensionVersion ($ext_name, $force = false) {
        // Is the cache written?
        if (isset($GLOBALS['cache_array']['extension']['ext_version'][$ext_name])) {
                // Load data from cache
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ": CACHE!");
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $ext_name . ': CACHE!');
                $data['ext_version'] = $GLOBALS['cache_array']['extension']['ext_version'][$ext_name];
 
                // Count cache hits
@@ -546,15 +549,15 @@ function getExtensionVersion ($ext_name, $force = false) {
                // 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__);
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ": DB - ".SQL_NUMROWS($result)."");
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $ext_name . ': DB - '.SQL_NUMROWS($result).'');
 
                // Is the extension there?
                if (SQL_NUMROWS($result) == 1) {
                        // Load entry
                        $data = SQL_FETCHARRAY($result);
                } elseif (isDebugModeEnabled()) {
-                       // Not found!
-                       logDebugMessage(__FUNCTION__, __LINE__, sprintf(": Cannot find extension %s in database!", $ext_name));
+                       // Not found, please report all
+                       debug_report_bug(sprintf(": Cannot find extension %s in database!", $ext_name));
                }
 
                // Free result
@@ -946,7 +949,7 @@ function ifModuleHasMenu ($mod, $forceDb = false) {
        // All is false by default
        $ret = false;
 
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "mod={$mod},cache=".getExtensionVersion('cache'));
+       // Extension installed and newer than or has version 0.1.2?
        if (isExtensionInstalledAndNewer('cache', '0.1.2')) {
                // Cache version is okay, so let's check the cache!
                if (isset($GLOBALS['cache_array']['modules']['has_menu'][$mod])) {
@@ -986,7 +989,6 @@ function ifModuleHasMenu ($mod, $forceDb = false) {
        }
 
        // Return status
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName().intval($ret));
        return $ret;
 }
 
@@ -1553,7 +1555,7 @@ function isExtensionIncludeReadable ($ext_name = '') {
        } // END - if
 
        // Return result
-       //* DEBUG: */ print __FUNCTION__.': '.$ext_name.'='.intval($GLOBALS['ext_inc_readable'][$ext_name]).'<br />';
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',realable='.intval($GLOBALS['ext_inc_readable'][$ext_name]));
        return $GLOBALS['ext_inc_readable'][$ext_name];
 }
 
index b3c41423c408b1c595889abd2b462b3315d9c85e..1019759bdee08d74e290dda0760ec7cbc0122c71 100644 (file)
@@ -408,7 +408,7 @@ function FILTER_COMPILE_CONFIG ($code, $compiled = false) {
                                        // Is the config valid?
                                        if (isConfigEntrySet($matches[1][$key])) {
                                                // Set it for caching
-                                               $GLOBALS['compile_config'][$matches[1][$key]] = "\".getConfig('" . $matches[1][$key] . "').\"";
+                                               $GLOBALS['compile_config'][$matches[1][$key]] = "\" . getConfig('" . $matches[1][$key] . "') . \"";
                                        } elseif (isConfigEntrySet('default_' . strtoupper($matches[1][$key]))) {
                                                // Use default value
                                                $GLOBALS['compile_config'][$matches[1][$key]] = "\" . getConfig('" . 'DEFAULT_' . strtoupper($matches[1][$key]) . "') . \"";
@@ -525,14 +525,20 @@ function FILTER_COMPILE_EXTENSION ($code) {
                                        break;
 
                                case 'ext':
-                                       // Construct call-back function name
-                                       $functionName = 'getExtension' . ucfirst(strtolower($callback));
+                                       // Not installed is default
+                                       $replacer = 'false';
 
-                                       // Construct call of the function
-                                       $replacer = "\" . call_user_func_array('" . $functionName . "', array('" . $matches[4][$key] . "', true)) . \"";
+                                       // Is the extension installed?
+                                       if (isExtensionInstalled($matches[4][$key])) {
+                                               // Construct call-back function name
+                                               $functionName = 'getExtension' . ucfirst(strtolower($callback));
+
+                                               // Construct call of the function
+                                               $replacer = "\" . call_user_func_array('" . $functionName . "', array('" . $matches[4][$key] . "', true)) . \"";
+                                       } // END - if
 
                                        // Replace it and insert parameter for GET request
-                                       $code = str_replace($matches[0][$key], sprintf("&amp;ext=%s&amp;rev=\" . getConfig('CURR_SVN_REVISION') . \"", $replacer), $code);
+                                       $code = str_replace($matches[0][$key], sprintf("&amp;ext=%s&amp;ver=%s&amp;rev=\" . getConfig('CURR_SVN_REVISION') . \"", $matches[4][$key], $replacer), $code);
                                        break;
 
                                case 'config': // @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again
@@ -584,7 +590,7 @@ function FILTER_RUN_RESET_INCLUDES () {
        // Is the reset set or old sql_patches?
        if (((!isResetModeEnabled()) || (!isExtensionInstalled('sql_patches'))) && (getOutputMode() == '0')) {
                // Then abort here
-               logDebugMessage(__FUNCTION__, __LINE__, 'Cannot run reset! Please report this bug. Thanks');
+               debug_report_bug('Cannot run reset! enabled='.intval(isResetModeEnabled()).',ext='.intval(isExtensionInstalled('sql_patches')).' Please report this bug. Thanks');
        } // END - if
 
        // Get more daily reset scripts
@@ -753,10 +759,9 @@ function FILTER_CHECK_SVN_REVISION () {
 // Filter for running daily reset
 function FILTER_RUN_DAILY_RESET () {
        // Only execute this filter if installed
-       if ((!isInstalled()) || (!isAdminRegistered())) return;
+       if ((isInstallationPhase()) || (!isInstalled()) || (!isAdminRegistered()) || (!isExtensionInstalled('sql_patches'))) return;
 
        // Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D
-       // 012    3              4             43        3         4432    2         3             3       21    1                    221    1                 221    1                  2          21    1             22     10
        if (((date('d', getConfig('last_update')) != date('d', time())) || ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'))) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestElementSet('register')) && (getOutputMode() != 1)) {
                // Tell every module we are in reset-mode!
                doReset();
index 51e21667aac2164e7a38215c9a04b448d9569413..eb36b77d60840cef80982cc30d907c83fb9cbdd9 100644 (file)
@@ -588,10 +588,10 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = '
        if (isDebugModeEnabled()) {
                // In debug mode we want to display the mail instead of sending it away so we can debug this part
                outputHtml('<pre>
-Headers : ' . htmlentities(trim($mailHeader)) . '
-To      : ' . htmlentities($toEmail) . '
-Subject : ' . htmlentities($subject) . '
-Message : ' . htmlentities($message) . '
+Headers : ' . htmlentities(utf8_decode(trim($mailHeader))) . '
+To      : ' . htmlentities(utf8_decode($toEmail)) . '
+Subject : ' . htmlentities(utf8_decode($subject)) . '
+Message : ' . htmlentities(utf8_decode($message)) . '
 </pre>');
        } elseif (($isHtml == 'Y') && (isExtensionActive('html_mail'))) {
                // Send mail as HTML away
@@ -1384,6 +1384,16 @@ function generateImageOrCode ($img_code, $headerSent = true) {
 }
 // Create selection box or array of splitted timestamp
 function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = 'center', $return_array=false) {
+       // Do not continue if ONE_DAY is absend
+       if (!isConfigEntrySet('ONE_DAY')) {
+               // And return the timestamp itself or empty array
+               if ($return_array === true) {
+                       return array();
+               } else {
+                       return $timestamp;
+               }
+       } // END - if
+
        // Calculate 2-seconds timestamp
        $stamp = round($timestamp);
        //* DEBUG: */ print("*" . $stamp.'/' . $timestamp."*<br />");
@@ -2081,6 +2091,9 @@ function scrambleString($str) {
                $scrambleNums = explode(':', genScrambleString(strlen($str)));
        }
 
+       // Compare both lengths and abort if different
+       if (strlen($str) != count($scrambleNums)) return $str;
+
        // Scramble string here
        //* DEBUG: */ outputHtml('***Original=' . $str.'***<br />');
        for ($idx = '0'; $idx < strlen($str); $idx++) {
index 4a464836a0c6431fa4d50aa00841b4f9e2e4445b..3805b7734dce44e817784d0c4548e69d34ce0d31 100644 (file)
@@ -58,7 +58,7 @@ $taskExt = false; // Default is that 'task' is not installed
 
 // When the admin is logging in check several things first (new jobs to complete and so on)
 if (getAction() == 'login') {
-       if (isExtensionActive('task')) {
+       if ((isExtensionActive('task')) && (function_exists('outputAdvancedOverview'))) {
                // When task extension is registered output advanced overview page
                $jobsDone = outputAdvancedOverview($result_tasks); // This function is provided by the extension 'task'
                $taskExt = true;
index 1484dbb5cc032ba34729bde65208e2bad8406a85..bf071ab2e3d979a68c9b70e0999ff8d0840dc1a8 100644 (file)
@@ -35,7 +35,7 @@
        @TODO Doesn't work with sessions
        <tr>
                <td class="bottom" width="50%" align="right">{--SELECT_TIMEOUT--}:</td>
-               <!-- @TODO Try to move the select box to our generic functions //-->
+               @TODO Try to move the select box to our generic functions
                <td class="bottom" width="50%">
                        <select name="timeout" size="1" class="admin_select">
                                <option value="86400">{--TIMEOUT_ONE_DAY--}</option>