AJAX installation is 'basicly finished' :) Plus I threw in a small christmas present...
[mailer.git] / inc / extensions-functions.php
index 08346b041b6902e74af124f24eaa3e73ba26ec6c..526552cd5bcec4aa2f16e65abec342f8737fba1c 100644 (file)
@@ -201,7 +201,7 @@ function registerExtension ($ext_name, $taskId, $isDryRun = FALSE, $ignoreUpdate
        // When this extension is already in registration/update phase, all is fine
        if ((isExtensionRegistrationRunning($ext_name)) || ((isExtensionUpdateRunning($ext_name)) && ($ignoreUpdates === FALSE))) {
                // Then abort here with 'true' because it is fine
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - already in registration/update phase, all fine,isDryRun=' . intval($isDryRun) . ',ignoreUpdates=' . intval($ignoreUpdates));
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - already in registration/update phase, all fine,isDryRun=' . intval($isDryRun) . ',ignoreUpdates=' . intval($ignoreUpdates));
                //* BUG: */ reportBug(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',isDryRun=' . intval($isDryRun) . ',ignoreUpdates=' . intval($ignoreUpdates) . ' - Please investigate!');
                return TRUE;
        } // END - if
@@ -1378,6 +1378,12 @@ function isExtensionUpdateDependenciesInitialized () {
 
 // Checks whether an update is already running for given extension
 function isExtensionUpdateRunning ($ext_name, $ignoreDependencies = FALSE) {
+       // 'ext_running_updates' must be there
+       if ((!isset($GLOBALS['ext_running_updates'])) || (!is_array($GLOBALS['ext_running_updates']))) {
+               // Is not there
+               reportBug(__FUNCTION__, __LINE__, 'Required array ext_running_updates not found. ext_name=' . $ext_name . ',ignoreDependencies=' . intval($ignoreDependencies));
+       } // END - if
+
        // Current and given extensions means whole array
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentExtension=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ',ignoreDependencies=' . intval($ignoreDependencies) . ' - ENTERED!');
        if ($ext_name == getCurrentExtensionName()) {
@@ -2158,18 +2164,31 @@ function registerExtensionPointsData ($subject, $columnName, $lockedMode, $payme
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ifSqlTableExists(points_data)=' . ifSqlTableExists('points_data') . ',getExtensionMode()=' . getExtensionMode() . ',add=' . $add);
        if (((!ifSqlTableExists('points_data')) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (countSumTotalData($subject, 'points_data', 'id', 'subject', TRUE, $add) == 0)) {
                // Not found so:
-               if ((isset($GLOBALS['previous_extension'][getCurrentExtensionName()])) && (!ifSqlTableExists('points_data'))) {
+               if ((!isInstallationPhase()) && (isset($GLOBALS['previous_extension'][getCurrentExtensionName()])) && (!ifSqlTableExists('points_data'))) {
+                       // This may happen (but when?)
+                       // @TODO Is this really neccessary?
                        $dummy = $GLOBALS['previous_extension'][getCurrentExtensionName()];
                        reportBug(__FUNCTION__, __LINE__, 'previous_extension[' . gettype($dummy) . ']=' . $dummy . ',getCurrentExtensionName()=' . getCurrentExtensionName() . ' - Under development, please report this!');
                } // END - if
 
-               // ... add an SQL query
-               addExtensionSql(sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`, `column_name`, `locked_mode`, `payment_method`) VALUES ('%s','%s','%s','%s')",
-                       $subject,
-                       $columnName,
-                       $lockedMode,
-                       $paymentMethod
-               ));
+               // With or without account_provider?
+               if (((isInstallationPhase()) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (isExtensionInstalledAndNewer('sql_patches', '0.8.9'))) {
+                       // Add account_provider
+                       addExtensionSql(sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`, `column_name`, `locked_mode`, `payment_method`, `account_provider`) VALUES ('%s','%s','%s','%s','EXTENSION')",
+                               $subject,
+                               $columnName,
+                               $lockedMode,
+                               $paymentMethod
+                       ));
+               } else {
+                       // ... add an SQL query
+                       addExtensionSql(sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`, `column_name`, `locked_mode`, `payment_method`) VALUES ('%s','%s','%s','%s')",
+                               $subject,
+                               $columnName,
+                               $lockedMode,
+                               $paymentMethod
+                       ));
+               }
        } // END - if
 }
 
@@ -2280,7 +2299,7 @@ function copyExtensionDataToCacheArray ($ext_name, $ext_id) {
        $GLOBALS['cache_array']['extension']['ext_active'][$ext_name]     = getThisExtensionAlwaysActive();
        $GLOBALS['cache_array']['extension']['ext_lang'][$ext_name]       = convertBooleanToYesNo(isExtensionLanguageFileReadable($ext_name));
        $GLOBALS['cache_array']['extension']['ext_func'][$ext_name]       = convertBooleanToYesNo(isExtensionFunctionFileReadable($ext_name));
-       $GLOBALS['cache_array']['extension']['ext_menu'][$ext_name]       = convertBooleanToYesNo(ifModuleHasMenu($ext_name));
+       $GLOBALS['cache_array']['extension']['ext_menu'][$ext_name]       = convertBooleanToYesNo(ifModuleHasMenu($ext_name, isInstallationPhase()));
        $GLOBALS['cache_array']['extension']['ext_css'][$ext_name]        = convertBooleanToYesNo(getExtensionHasCss());
        $GLOBALS['cache_array']['extension']['ext_deprecated'][$ext_name] = 'N';
 }
@@ -2298,5 +2317,23 @@ function isTaskIdValid ($taskId) {
        return $GLOBALS[__FUNCTION__][$taskId];
 }
 
+// "Getter" for "checked="checked" from given session data
+function getExtensionSelectedFromSession ($ext_name, $sessionName, $separator = ':') {
+       // Get the data and explode it
+       $selections = explode($separator, getSession($sessionName));
+
+       // Default is not checked
+       $checked = '';
+
+       // Is it there?
+       if (in_array($ext_name, $selections)) {
+               // It is, so mark it
+               $checked = ' checked="checked"';
+       } // END - if
+
+       // Return result
+       return $checked;
+}
+
 // [EOF]
 ?>