/** * Creates constants.php that contains variable * definitions that the codev admin may want to tune. * * WARN: depending on your HTTP server installation, the file may be created * by user 'apache', so be sure that this user has write access * to the CoDev install directory * * @return NULL if OK, or an error message starting with 'ERROR' . */ function createConstantsFile($mantisPath, $mantisURL, $codevURL) { // --- general --- Constants::$homepage_title = 'Welcome'; Constants::$codevURL = $codevURL; Constants::$mantisURL = $mantisURL; Constants::$mantisPath = $mantisPath; Constants::$codevRootDir = dirname(dirname(__FILE__)); Constants::$codevtt_logfile = Constants::$codevRootDir . '/codevtt.log'; // --- database --- // already set... // --- mantis --- // already set... // --- status --- $status_new = array_search('new', Constants::$statusNames); $status_feedback = array_search('feedback', Constants::$statusNames); #$status_acknowledged = array_search('acknowledged', Constants::$statusNames); $status_open = array_search('open', Constants::$statusNames); $status_closed = array_search('closed', Constants::$statusNames); Constants::$status_new = $status_new; Constants::$status_feedback = $status_feedback; Constants::$status_open = NULL != $status_open ? $status_open : 50; // (50 = 'assigned' in default mantis workflow) Constants::$status_closed = $status_closed; // --- resolution --- Constants::$resolution_fixed = array_search('fixed', Constants::$resolution_names); Constants::$resolution_reopened = array_search('reopened', Constants::$resolution_names); // --- relationships --- define('BUG_CUSTOM_RELATIONSHIP_CONSTRAINED_BY', 2500); define('BUG_CUSTOM_RELATIONSHIP_CONSTRAINS', 2501); Constants::$relationship_constrained_by = 2500; Constants::$relationship_constrains = 2501; $retCode = Constants::writeConfigFile(); if (!$retCode) { // TODO throw exception... return "ERROR: Could not create file " . Constants::$config_file; } return NULL; }
/** * writes an INCOMPLETE config.ini file (containing only DB access variables) * * WARN: depending on your HTTP server installation, the file may be created * by user 'apache', so be sure that this user has write access * to the CoDev install directory * * @return NULL if Success, ErrorString if Failed */ function createConfigFile($db_mantis_host = 'localhost', $db_mantis_user = '******', $db_mantis_pass = '', $db_mantis_database = 'bugtracker', $proxy_host = NULL, $proxy_port = NULL) { Constants::$db_mantis_host = $db_mantis_host; Constants::$db_mantis_user = $db_mantis_user; Constants::$db_mantis_pass = $db_mantis_pass; Constants::$db_mantis_database = $db_mantis_database; if (!is_null($proxy_host) && !is_null($proxy_port)) { Constants::$proxy = $proxy_host . ':' . $proxy_port; } // this writes an INCOMPLETE config.ini file (containing only DB access variables) $retCode = Constants::writeConfigFile(); if (!$retCode) { throw new Exception("ERROR: Could not create file " . Constants::$config_file); } }
createCustomFields($isCreateExtIdField); echo "DEBUG 6/16 create ExternalTasks Project<br/>"; $extproj_id = createExternalTasksProject(T_("CodevTT_ExternalTasks"), T_("CodevTT ExternalTasks Project")); $adminLeader = UserCache::getInstance()->getUser($adminTeamLeaderId); echo "DEBUG 7/16 createAdminTeam with leader: " . $adminLeader->getName() . "<br/>"; createAdminTeam($adminTeamName, $adminTeamLeaderId); echo "DEBUG 8/16 update status list<br/>"; Constants::$status_new = $status_new; Constants::$status_feedback = $status_feedback; Constants::$status_open = $status_open; Constants::$status_closed = $status_closed; // Set path for .CSV reports (Excel) echo "DEBUG 9/16 add CodevTT output directory<br/>"; Constants::$codevOutputDir = $codevOutputDir; Constants::$codevtt_logfile = $codevOutputDir . '/logs/codevtt.log'; $retCode = Constants::writeConfigFile(); if (FALSE == $retCode) { echo "<span class='error_font'>ERROR: could not update config file: " . Constants::$config_file . "</span><br/>"; $installStepFailed = TRUE; exit; } echo "DEBUG 10/16 create Logger configuration file<br/>"; $errStr = createLog4phpFile(); if (NULL != $errStr) { echo "<span class='error_font'>" . $errStr . "</span><br/>"; $installStepFailed = TRUE; exit; } echo "DEBUG 11/16 create output directories (logs, reports, cache)<br/>"; $errStr = Tools::checkOutputDirectories(); if (NULL !== $errStr) {
/** * Some new variables may have been added, this rewrites the config.ini * file with new default values. * */ function update_config_file() { // check if config.ini is writable if (!is_writable(Constants::$config_file)) { echo "<span class='warn_font'>File not writable : " . Constants::$config_file . '</span><br/>'; return false; } // backup config.ini to config.ini.old_YYYYMMDDHHmmss if (is_writable(Constants::$codevRootDir)) { if (FALSE == copy(Constants::$config_file, Constants::$config_file . '.old_' . date('YmdHis'))) { echo "<span class='warn_font'>Could not backup config.ini file</span><br/>"; } } else { echo "<span class='warn_font'>Could not backup config.ini file (directory not writable)</span><br/>"; } // write new config.ini file return Constants::writeConfigFile(); }