die();
} // END - if
+//-----------------------------------------------------------------------------
+// Generic call-back functions, they all rely on session data
+//-----------------------------------------------------------------------------
+
+// Establish a database link
+function establishAjaxInstallerDatabaseLink () {
+ // This requires some session data
+ if (!isSessionDataSet(array('mysql_host', 'mysql_dbase', 'mysql_prefix', 'mysql_login', 'mysql_password1', 'mysql_password2', 'mysql_engine'))) {
+ // Some required session data is not set
+ reportBug(__FUNCTION__, __LINE__, 'Required session data for this step not found.');
+ } // END - if
+
+ // Establish link
+ $linkResource = SQL_CONNECT(getSession('mysql_host'), getSession('mysql_login'), getSession('mysql_password1'), __FUNCTION__, __LINE__);
+
+ // Is this a link resource?
+ if (!is_resource($linkResource)) {
+ // Is not a resource
+ reportBug(__FUNCTION__, __LINE__, 'linkResource[]=' . gettype($linkResource) . ', expected: link resource');
+ } // END - if
+
+ // Does selecting the database work?
+ if (!SQL_SELECT_DB(getSession('mysql_dbase'), __FUNCTION__, __LINE__)) {
+ // Could not be selected
+ reportBug(__FUNCTION__, __LINE__, 'Could not select database ' . getSession('mysql_dbase'));
+ } elseif ((!isFileReadable(getPath() . 'install/tables.sql')) || (!isFileReadable(getPath() . 'install/menu-'.getLanguage().'.sql'))) {
+ // Installation area not found
+ reportBug(__FUNCTION__, __LINE__, 'SQL dumps not found. Please extract ALL files from the archive or checkout all files out from SVN.');
+ } elseif (ifFatalErrorsDetected()) {
+ // Some other fatal error occured
+ reportBug(__FUNCTION__, __LINE__, 'Some fatal error detected, please check debug.log for details.');
+ } // END - if
+
+ // Set type, prefix from POST data and database name for later queries
+ setConfigEntry('_TABLE_TYPE' , getSession('mysql_engine'));
+ setConfigEntry('_MYSQL_PREFIX', getSession('mysql_prefix'));
+ setConfigEntry('__DB_NAME' , getSession('mysql_dbase'));
+}
+
//-----------------------------------------------------------------------------
// Call-back functions for processing AJAX requests
//-----------------------------------------------------------------------------
// Processes installer request for testing
function doAjaxInstallerTest () {
// Load the "test passed" template
- setAjaxReplyContent(loadTemplate('ajax_test_passed', TRUE));
+ setAjaxReplyContent(encodeJson(postRequestElement('step').'=OK'));
// All okay if we reach this point
setHttpStatus('200 OK');
} // END - switch
// Output the array for JSON reply
- setAjaxReplyContent(json_encode($enabledNavigations, JSON_FORCE_OBJECT));
+ setAjaxReplyContent(encodeJson($enabledNavigations));
+
+ // All okay if we reach this point
+ setHttpStatus('200 OK');
+}
+
+// Processes installer AJAX calls for content-requests
+function doAjaxInstallerDoStep () {
+ // 'step' must be there
+ if (!isPostRequestElementSet('step')) {
+ // This shall not happen
+ reportBug(__FUNCTION__, __LINE__, 'The JavaScript did not send "step" which is fatal.');
+ } // END - if
+
+ // Construct call-back name
+ $callbackName = 'doAjaxInstallerStep' . capitalizeUnderscoreString(postRequestElement('step'));
+
+ // Is the function there?
+ if (function_exists($callbackName)) {
+ // Call it for setting values in session
+ call_user_func($callbackName);
+ } else {
+ // Log missing functions
+ reportBug(__FUNCTION__, __LINE__, 'Call-back function ' . $callbackName . ' does not exist.');
+ }
+
+ // Set dummy content
+ setAjaxReplyContent(loadTemplate('install_step_passed', TRUE, postRequestElement('step')));
// All okay if we reach this point
setHttpStatus('200 OK');
call_user_func($callbackName);
} else {
// Log missing functions
- logDebugMessage(__FUNCTION__, __LINE__, 'Call-back function ' . $callbackName . ' does not exist.');
+ reportBug(__FUNCTION__, __LINE__, 'Call-back function ' . $callbackName . ' does not exist.');
}
// Is the HTTP status still the same? (204 No Content)
} // END - if
// Output the status array for JSON reply
- setAjaxReplyContent(json_encode($saveStatus, JSON_FORCE_OBJECT));
+ setAjaxReplyContent(encodeJson($saveStatus));
// All okay if we reach this point
setHttpStatus('200 OK');
}
+// ----------------------------------------------------------------------------
+// Call-back functions for preparing installer page requests
+// ----------------------------------------------------------------------------
+
// Prepare AJAX request 'welcome'
function doAjaxPrepareInstallerWelcome () {
// Kept empty to prevent logfile entry
} // END - if
// Is 'mysql_dbase' not set?
- if (!isSessionVariableSet('mysql_pass1')) {
+ if (!isSessionVariableSet('mysql_password1')) {
// Then set it directly
- setSession('mysql_pass1', '');
+ setSession('mysql_password1', '');
} // END - if
- // Is 'mysql_pass2' not set?
- if (!isSessionVariableSet('mysql_pass2')) {
+ // Is 'mysql_password2' not set?
+ if (!isSessionVariableSet('mysql_password2')) {
// Then set it directly
- setSession('mysql_pass2', '');
+ setSession('mysql_password2', '');
} // END - if
// Is 'mysql_engine' not set?
} // END - if
}
+// ----------------------------------------------------------------------------
+// Call-back functions for doing installation steps
+// ----------------------------------------------------------------------------
+
+// Call-back function to import first tables.sql file
+function doAjaxInstallerStepImportTablesSql () {
+ // Establish database link
+ establishAjaxInstallerDatabaseLink();
+
+ // Init SQL array
+ initSqls();
+
+ // Import tables.sql
+ importInstallSqlDump('tables');
+
+ // Are some SQLs found?
+ if (countSqls() == 0) {
+ // Abort here
+ reportBug(__FUNCTION__, __LINE__, '{--INSTALLER_SQL_IMPORT_FAILED--}');
+ } // END - if
+
+ // Now run all queries through
+ runFilterChain('run_sqls');
+}
+
// [EOF]
?>