/** * get config from ini file */ public static function parseConfigFile() { // TODO workaround $file = self::$config_file; if (!file_exists($file)) { if (!self::$quiet) { self::$logger->error("ERROR: parseConfigFile() file " . $file . " NOT found !"); echo "ERROR: parseConfigFile() file " . $file . " NOT found !"; } return FALSE; } $ini_array = parse_ini_file($file, true); #print_r($ini_array); $general = $ini_array['general']; self::$codevInstall_timestamp = $general['codevInstall_timestamp']; self::$codevtt_logfile = $general['codevtt_logfile']; self::$codevOutputDir = $general['codevtt_output_dir']; self::$homepage_title = $general['homepage_title']; if (array_key_exists('logo_image', $general)) { self::$logoImage = $general['logo_image']; } self::$codevURL = $general['codevtt_url']; self::$codevRootDir = $general['codevtt_dir']; self::$mantisPath = $general['mantis_dir']; self::$mantisURL = $general['mantis_url']; $database = $ini_array['database']; self::$db_mantis_host = $database['db_mantis_host']; self::$db_mantis_database = $database['db_mantis_database']; self::$db_mantis_user = $database['db_mantis_user']; self::$db_mantis_pass = $database['db_mantis_pass']; $mantis = $ini_array['mantis']; self::$statusNames = Tools::doubleExplode(':', ',', $mantis['status_enum_string']); self::$priority_names = Tools::doubleExplode(':', ',', $mantis['priority_enum_string']); self::$resolution_names = Tools::doubleExplode(':', ',', $mantis['resolution_enum_string']); self::$severity_names = Tools::doubleExplode(':', ',', $mantis['severity_enum_string']); self::$bug_resolved_status_threshold = $mantis['bug_resolved_status_threshold']; self::$status_enum_workflow = json_decode($mantis['status_enum_workflow'], true); // jsonStr to array $status = $ini_array['status']; self::$status_new = $status['status_new']; self::$status_feedback = $status['status_feedback']; #self::$status_acknowledged = $status['status_acknowledged']; self::$status_open = $status['status_open']; self::$status_closed = $status['status_closed']; $resolution = $ini_array['resolution']; self::$resolution_fixed = $resolution['resolution_fixed']; self::$resolution_reopened = $resolution['resolution_reopened']; $relationships = $ini_array['relationships']; self::$relationship_constrained_by = $relationships['relationship_constrained_by']; self::$relationship_constrains = $relationships['relationship_constrains']; define('BUG_CUSTOM_RELATIONSHIP_CONSTRAINED_BY', $relationships['relationship_constrained_by']); define('BUG_CUSTOM_RELATIONSHIP_CONSTRAINS', $relationships['relationship_constrains']); $perf = $ini_array['perf']; if ($perf != null && array_key_exists('max_tooltips_per_page', $perf)) { self::$maxTooltipsPerPage = $perf['max_tooltips_per_page']; } $doodles = $ini_array['doodles']; if (is_array($doodles)) { $today = date("md"); self::$doodles = array(); // remove default doodles foreach ($doodles as $key => $value) { self::$doodles[$key] = $value; if (substr($key, 0, 11) === 'logo_image_' && (substr($key, 11, 4) <= $today && substr($key, 16, 4) >= $today) && file_exists(self::$codevRootDir . DIRECTORY_SEPARATOR . $value)) { self::$logoImage = $value; } } } $timesheets = $ini_array['timesheets']; if (null != $timesheets && array_key_exists('task_duration_list', $timesheets)) { self::$taskDurationList = Tools::doubleExplode(':', ',', $timesheets['task_duration_list']); } $internet = $ini_array['internet']; if (is_array($internet)) { if (array_key_exists('proxy', $internet)) { self::$proxy = $internet['proxy']; } if (array_key_exists('check_latest_version', $internet)) { self::$isCheckLatestVersion = $internet['check_latest_version']; } } $dashboards = $ini_array['dashboardDefaultPlugins']; if (is_array($dashboards)) { foreach ($dashboards as $domain => $plugins) { self::$dashboardDefaultPlugins[$domain] = explode(',', $plugins); } } $emailSettings = $ini_array['email']; if (is_array($emailSettings)) { foreach ($emailSettings as $key => $val) { self::$emailSettings[$key] = $val; } } // ----- /* FIXME WORKAROUND: SQL procedures still use codev_config_table.bug_resolved_status_threshold ! */ $desc = "bug resolved threshold as defined in Mantis (g_bug_resolved_status_threshold)"; self::$logger->warn("WORKAROUND update codev_config_table.bug_resolved_status_threshold = " . self::$bug_resolved_status_threshold); Config::getInstance()->setValue(Config::id_bugResolvedStatusThreshold, self::$bug_resolved_status_threshold, Config::configType_int, $desc); }
/** * update 1.0.x to 1.1.0 (DB v14 to DB v15) * * - clasmap.ser * - config.ini * - remove from mantis menu * - mantis-plugins if mantis v1.3 * - DB */ function update_v14_to_v15() { echo "- Update classmap.ser<br>"; try { Tools::createClassMap(); } catch (Exception $e) { echo "<span class='error_font'>Could not create classmap: " . $e->getMessage() . "</span><br/>"; exit; } echo "- Add [mantis] 'status_enum_workflow' to config.ini<br>"; // reload mantis config files $path_config_defaults_inc = Constants::$mantisPath . DIRECTORY_SEPARATOR . "config_defaults_inc.php"; $path_core_constant_inc = Constants::$mantisPath . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "constant_inc.php"; $path_mantis_config = Constants::$mantisPath; if (is_dir(Constants::$mantisPath . DIRECTORY_SEPARATOR . 'config')) { $path_mantis_config .= DIRECTORY_SEPARATOR . 'config'; // mantis v1.3 or higher } $path_mantis_config_inc = $path_mantis_config . DIRECTORY_SEPARATOR . 'config_inc.php'; $path_custom_constants = $path_mantis_config . DIRECTORY_SEPARATOR . 'custom_constants_inc.php'; global $g_status_enum_workflow; include_once $path_core_constant_inc; include_once $path_custom_constants; include_once $path_config_defaults_inc; include_once $path_mantis_config_inc; // set status_enum_workflow Constants::$status_enum_workflow = $g_status_enum_workflow; if (!is_array(Constants::$status_enum_workflow)) { echo "<span class='error_font'>Could not retrieve status_enum_workflow from Mantis config files</span><br/>"; exit; } // write new config file if (!update_config_file()) { // ask for manual update echo "<span class='error_font'>Could not update config.ini</span><br/>"; exit; } // if Mantis 1.3, plugins must be updated if (Tools::isMantisV1_3()) { echo "- Remove 'CodevTT' from Mantis main menu (CodevTT v1.0.x is incompatible with Mantis v1.3.x)<br>"; $query = "DELETE FROM `mantis_config_table` WHERE config_id = 'main_menu_custom_options'"; $result = execQuery($query); echo "- Install Mantis plugin: CodevTT (for mantis v1.3.x)<br>"; if (checkMantisPluginDir()) { $errStr = installMantisPlugin('CodevTT', true); if (NULL !== $errStr) { echo "<span class='error_font'>Please update 'CodevTT' mantis-plugin manualy</span><br/>"; echo "<script type=\"text/javascript\">console.error(\"{$errStr}\");</script>"; } echo "- Install Mantis plugin: FilterBugList (for mantis v1.3.x)<br>"; $errStr = installMantisPlugin('FilterBugList', true); if (NULL !== $errStr) { echo "<span class='error_font'>Please update 'FilterBugList' mantis-plugin manualy</span><br/>"; echo "<script type=\"text/javascript\">console.error(\"{$errStr}\");</script>"; } } } // execute the SQL script $sqlScriptFilename = Constants::$codevRootDir . '/install/codevtt_update_v14_v15.sql'; if (!file_exists($sqlScriptFilename)) { echo "<span class='error_font'>SQL script not found:{$sqlScriptFilename}</span><br/>"; exit; } echo "- Execute SQL script: {$sqlScriptFilename}<br>"; $retCode = Tools::execSQLscript2($sqlScriptFilename); if (0 != $retCode) { echo "<span class='error_font'>Could not execSQLscript: {$sqlScriptFilename}</span><br/>"; exit; } }
$resolution_enum_string = isset($g_resolution_enum_string) ? $g_resolution_enum_string : $s_resolution_enum_string; $status_enum_workflow = isset($g_status_enum_workflow) ? $g_status_enum_workflow : $s_status_enum_workflow; // and set codev Config variables echo "<script type=\"text/javascript\">console.log(\"DEBUG add statusNames\");</script>"; Constants::$statusNames = Tools::doubleExplode(':', ',', $status_enum_string); echo "<script type=\"text/javascript\">console.log(\"DEBUG add priorityNames\");</script>"; Constants::$priority_names = Tools::doubleExplode(':', ',', $priority_enum_string); echo "<script type=\"text/javascript\">console.log(\"DEBUG add severityNames\");</script>"; Constants::$severity_names = Tools::doubleExplode(':', ',', $severity_enum_string); echo "<script type=\"text/javascript\">console.log(\"DEBUG add resolutionNames\");</script>"; Constants::$resolution_names = Tools::doubleExplode(':', ',', $resolution_enum_string); $bug_resolved_status_threshold = isset($g_bug_resolved_status_threshold) ? $g_bug_resolved_status_threshold : constant("RESOLVED"); echo "<script type=\"text/javascript\">console.log(\"DEBUG add bug_resolved_status_threshold = {$g_bug_resolved_status_threshold}\");</script>"; Constants::$bug_resolved_status_threshold = $bug_resolved_status_threshold; echo "<script type=\"text/javascript\">console.log(\"DEBUG add status_enum_workflow\");</script>"; Constants::$status_enum_workflow = $status_enum_workflow; if (!is_array(Constants::$status_enum_workflow)) { $errStr .= "Could not retrieve status_enum_workflow form Mantis config files<br>"; } echo "<script type=\"text/javascript\">console.log(\"DEBUG create " . str_replace('\\', '/', Constants::$config_file) . "\");</script>"; $errStr .= createConstantsFile($path_mantis, $url_mantis, $url_codevtt); if (NULL != $errStr) { echo '<script type="text/javascript">'; echo ' document.getElementById("divErrMsg").style.display = "block";'; echo " document.getElementById(\"errorMsg\").innerHTML=\"" . $errStr . "\";"; echo '</script>'; exit; } // Note: config.ini is needed on step3 // everything went fine, goto step3 echo "<script type='text/javascript'> parent.location.replace('install_step3.php'); </script>";