Index: branches/unlabeled/unlabeled-1.6.2/core/install.php =================================================================== diff -u -N -r7528 -r7755 --- branches/unlabeled/unlabeled-1.6.2/core/install.php (.../install.php) (revision 7528) +++ branches/unlabeled/unlabeled-1.6.2/core/install.php (.../install.php) (revision 7755) @@ -12,13 +12,13 @@ * */ define('UPGRADES_FILE', FULL_PATH.'/%sinstall/upgrades.sql'); - + /** * Format of version identificator in upgrade files * */ define('VERSION_MARK', '# ===== v ([\d]+\.[\d]+\.[\d]+) ====='); - + // print_pre($_POST); $install_engine = new kInstallator(); @@ -97,7 +97,7 @@ * @var Array */ var $skipLoginSteps = Array ('root_password', 'choose_modules', 'finish', -1); - + /** * Steps, on which kApplication should not be initialized, because of missing correct db table structure * @@ -151,7 +151,7 @@ // can't check login on steps where no application present anyways :) $this->skipLoginSteps = array_unique(array_merge($this->skipLoginSteps, $this->skipApplicationSteps)); - + $this->SelectPreset(); if (!$this->currentStep) { @@ -166,7 +166,7 @@ reset($this->steps[$this->stepsPreset]); $this->currentStep = current($this->steps[$this->stepsPreset]); } - + /** * Selects preset to proceed based on various criteria * @@ -192,7 +192,7 @@ $this->stepsPreset = $preset; } - + function GetVar($name) { return isset($_REQUEST[$name]) ? $_REQUEST[$name] : false; @@ -214,7 +214,7 @@ $this->SetFirstStep(); } } - + switch ($this->currentStep) { case 'check_paths': foreach ($this->writeableFolders as $folder_path) { @@ -261,18 +261,18 @@ if (!$modules) { $this->currentStep = $this->GetNextStep(); } - break; - + break; + case 'install_setup': $next_preset = $this->Application->GetVar('next_preset'); if ($next_preset !== false && $this->Application->GetVar('login') == 'root') { // option was choosen, then verify password & login user $login_event = new kEvent('u.current:OnLogin'); $this->Application->HandleEvent($login_event); - + if ($login_event->status == erSUCCESS) { // login succeeded - + if (!isset($this->steps[$next_preset])) { $this->errorMessage = 'Preset "'.$next_preset.'" not yet implemented'; } @@ -284,7 +284,7 @@ // login failed $user =& $this->Application->recallObject('u.current'); /* @var $user UsersItem */ - + $this->errorMessage = $user->GetErrorMsg('ValidateLogin').'. If you don\'t know your username or password, contact Intechnic Support'; } } @@ -368,7 +368,7 @@ // import base data into database $this->RunSQL('/core/install/install_schema.sql'); $this->RunSQL('/core/install/install_data.sql'); - + // set module "Core" version after install (based on upgrade scripts) $this->SetModuleVersion('Core'); break; @@ -400,18 +400,15 @@ $install_file = MODULES_PATH.'/'.$module.'/install.php'; if (file_exists($install_file)) { include_once($install_file); - + // set module version after install (based on upgrade scripts) $this->SetModuleVersion($module); } } } // scan themes - $themes_helper =& $this->Application->recallObject('ThemesHelper'); - /* @var $themes_helper kThemesHelper */ + $this->Application->HandleEvent($themes_event, 'adm:OnRebuildThemes'); - $themes_helper->refreshThemes(); - $this->Conn->Query('UPDATE '.TABLE_PREFIX.'Theme SET Enabled=1, PrimaryTheme =1 LIMIT 1'); // update categories cache @@ -420,40 +417,40 @@ $updater->OneStepRun(); break; - + case 'upgrade_modules': // get installed modules from db and compare their versions to upgrade script $modules = $this->Application->GetVar('modules'); if ($modules) { $upgrade_data = $this->GetUpgradableModules(); - + foreach ($modules as $module_name) { $module_info = $upgrade_data[$module_name]; $upgrades_file = sprintf(UPGRADES_FILE, $module_info['Path']); - + $sqls = file_get_contents($upgrades_file); $version_mark = preg_replace('/(\(.*?\))/', $module_info['FromVersion'], VERSION_MARK); - + $start_pos = strpos($sqls, $version_mark); $sqls = substr($sqls, $start_pos); $this->RunSQLText($sqls); - + // after upgrade sqls are executed update version $this->SetModuleVersion($module_name, $module_info['ToVersion']); } } else { $this->errorMessage = 'Please select module(-s) to upgrade'; } - break; - + break; + case 'finish': // delete cache $sql = 'DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName IN ("config_files","configs_parsed","sections_parsed")'; $this->Conn->Query($sql); - - // set installation finished mark + + // set installation finished mark if ($this->Application->ConfigValue('InstallFinished') === false) { $fields_hash = Array ( 'VariableName' => 'InstallFinished', @@ -491,16 +488,16 @@ if ($version === false) { $version = $this->GetMaxModuleVersion($module_name); } - + $table_prefix = $this->systemConfig['Database']['TablePrefix']; - + $sql = 'UPDATE '.$table_prefix.'Modules SET Version = "'.$version.'" WHERE Name = "'.$module_name.'"'; $this->Conn->Query($sql); } - - + + /** * Sets new configuration variable value * @@ -561,14 +558,14 @@ // no upgrade file return '4.0.1'; } - + $sqls = file_get_contents($upgrades_file); $versions_found = preg_match_all('/'.VERSION_MARK.'/s', $sqls, $regs); if (!$versions_found) { // upgrades file doesn't contain version definitions return '4.0.1'; } - + return end($regs[1]); } @@ -722,7 +719,7 @@ // replace something additionally, e.g. module root category $sqls = str_replace($replace_from, $replace_to, $sqls); } - + $sqls = str_replace("\r\n", "\n", $sqls); // convert to linux line endings $sqls = preg_replace("/#(.*?)\n/", '', $sqls); // remove all comments $sqls = explode(";\n", $sqls); @@ -740,7 +737,7 @@ } } } - + function ImportLanguage($lang_file) { $lang_file = FULL_PATH.$lang_file.'.lang'; @@ -791,12 +788,12 @@ function ConvertModuleVersion($version) { $parts = explode('.', $version); - + $bin = ''; foreach ($parts as $part) { $bin .= str_pad(decbin($part), 8, '0', STR_PAD_LEFT); } - + return bindec($bin); } @@ -807,21 +804,21 @@ function GetUpgradableModules() { $ret = Array (); - + foreach ($this->Application->ModuleInfo as $module_name => $module_info) { $upgrades_file = sprintf(UPGRADES_FILE, $module_info['Path']); if (!file_exists($upgrades_file)) { // no upgrade file continue; } - + $sqls = file_get_contents($upgrades_file); $versions_found = preg_match_all('/'.VERSION_MARK.'/s', $sqls, $regs); if (!$versions_found) { // upgrades file doesn't contain version definitions continue; } - + $to_version = end($regs[1]); $this_version = $this->ConvertModuleVersion($module_info['Version']); if ($this->ConvertModuleVersion($to_version) > $this_version) { @@ -832,19 +829,19 @@ break; } } - + $version_info = Array ( 'FromVersion' => $from_version, 'ToVersion' => $to_version, ); - + $ret[$module_name] = array_merge_recursive2($module_info, $version_info); } } - + return $ret; } - + /** * Returns content to show for current step *