$serialized = 0 != mysql_num_rows($result) ? mysql_result($result, 0) : NULL; // add entry if (!is_null($serialized) && "" != $serialized) { $menuItems = unserialize($serialized); foreach ($menuItems as $key => $item) { if (in_array($name, $item)) { echo "remove key={$key}<br>"; unset($menuItems[$key]); } } $newSerialized = serialize($menuItems); // update mantis menu if (NULL != $serialized) { $query = "UPDATE `mantis_config_table` SET value = '{$newSerialized}' " . "WHERE config_id = 'main_menu_custom_options'"; } else { $query = "INSERT INTO `mantis_config_table` (`config_id`, `value`, `type`, `access_reqd`) " . "VALUES ('main_menu_custom_options', '{$newSerialized}', '3', '90');"; } $result = execQuery($query); } else { // echo "no custom menu entries found<br>"; } } // ========== MAIN =========== if (!Tools::isMantisV1_3()) { echo "Remove 'CodevTT' from Mantis main menu<br>"; removeCustomMenuItem('CodevTT'); } else { echo "Remove 'main_menu_custom_options' from Mantis DB<br>"; $query = "DELETE FROM `mantis_config_table` WHERE config_id = 'main_menu_custom_options'"; $result = execQuery($query); }
/** * 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; } }
/** * Returns the fields to display in the Issue tooltip * * fields can be * - mantis_bug_table columns (ex: project_id, status) * - customField id prefixed with 'custom_' (ex: custom_23) * - CodevTT calculated field prefixed with 'codevtt_' (ex: codevtt_drift) * * @param int $teamid * @param int $userid * @return array */ public function getIssueTooltipFields($teamid = 0, $userid = 0) { $key = 'team' . $teamid . '_user' . $userid; if (is_null($this->issueTooltipFieldsCache)) { $this->issueTooltipFieldsCache = array(); } if (!array_key_exists($key, $this->issueTooltipFieldsCache)) { $query = "SELECT value FROM `codev_config_table` WHERE `config_id` = '" . Config::id_issueTooltipFields . "' "; $query .= "AND `project_id` IN (0, {$this->id}) "; if (0 != $teamid) { // TODO FIXME if team not specified (timetracking.php must be fixed) then this request will skip // all 'team' specific settings and systematicaly return the team=0 response. // the if (0 != $teamid) will at least return the team specific settings, and the biggest teamid // will be chosen. // Note: once teamid selector added to timetracking.php, remove the if condition $query .= "AND `team_id` IN (0, {$teamid}) "; } $query .= "AND `user_id` IN (0, {$userid}) "; $query .= "ORDER by project_id DESC, team_id DESC, user_id DESC"; if (self::$logger->isDebugEnabled()) { self::$logger->debug("getIssueTooltipFields({$teamid}, {$userid}) query = {$query}"); } $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } if (0 != SqlWrapper::getInstance()->sql_num_rows($result)) { $serialized = SqlWrapper::getInstance()->sql_result($result, 0); if (Tools::isMantisV1_3()) { $unserialized = json_decode($serialized, true); } else { $unserialized = unserialize($serialized); } $this->issueTooltipFieldsCache[$key] = $unserialized; } else { // TODO get default value (project_id = 0) self::$logger->error('no issueTooltipFields found for project ' . $this->id); } } return $this->issueTooltipFieldsCache[$key]; }