From 795ec7cab89f2b2a4f3f3e8522db88ab5b4e4e37 Mon Sep 17 00:00:00 2001 From: Louis BAYLE Date: Fri, 31 Mar 2017 23:55:24 +0200 Subject: [PATCH] [m1553] Don't use hardcoded default prefix/suffix for mantis table names mantis_db_table_suffix mantis_bug_table mantis_project_table mantis_user_table mantis_config_table various `mantis_xxx_table` remaining mantis_xxx_table Note: mantis_plugins needs to be updated ! INSTALL: db_table_prefix (not yet finished) TODO: check mantis configuration to get real prefix/suffix ! update mantis plugins table_prefix/suffix INSTALL: check db_table_prefix & suffix --- admin/edit_team.php | 6 +- classes/Email.class.php | 2 +- classes/command.class.php | 6 +- classes/consistency_check.class.php | 10 +-- classes/consistency_check2.class.php | 4 +- classes/consistency_check_fdj.class.php | 2 +- classes/constants.class.php | 13 +++ classes/crypto.class.php | 2 +- classes/issue.class.php | 76 ++++++++-------- classes/issue_fdj.class.php | 6 +- classes/issue_note.class.php | 32 +++---- classes/issue_selection.class.php | 4 +- classes/period_stats.class.php | 4 +- classes/project.class.php | 88 +++++++++---------- classes/project_version.class.php | 2 +- classes/servicecontract.class.php | 2 +- classes/sqlwrapper.class.php | 9 +- classes/team.class.php | 20 ++--- classes/time_track.class.php | 4 +- classes/time_tracking.class.php | 44 +++++----- classes/user.class.php | 34 +++---- classes/wbsElement.class.php | 4 +- config.ini.sample | 2 + .../EffortEstimReliabilityIndicator.class.php | 24 ++--- install/codevtt_procedures.php | 4 +- install/install_step1.php | 72 ++++++++++++--- install/install_step2.php | 18 ++-- install/install_step3.php | 10 +-- install/install_step4.php | 4 +- install/uninstall.php | 8 +- login.php | 4 +- management/command_edit.php | 2 +- mantis_plugin/mantis_1_2/CodevTT/CodevTT.php | 4 +- mantis_plugin/mantis_1_3/CodevTT/CodevTT.php | 18 ++-- .../classes/IssueMantisPluginHelper.php | 13 +-- mantis_plugin/mantis_2_0/CodevTT/CodevTT.php | 19 ++-- .../classes/IssueMantisPluginHelper.php | 13 +-- ...EffortEstimReliabilityIndicator2.class.php | 24 ++--- .../LoadPerProjectIndicator.class.php | 2 +- .../MoveIssueTimetracks.class.php | 2 +- .../ReopenedRateIndicator2.class.php | 10 +-- plugins/UserTeamList/UserTeamList.class.php | 2 +- reports/export_csv_tools.php | 4 +- reports/export_csv_weekly.php | 8 +- reports/export_odt.php | 2 +- tests/bvi.php | 2 +- tools.php | 8 +- tools/checkWBS.php | 6 +- tools/create_fake_db.php | 64 +++++++------- tools/remove_from_mantis_menu.php | 8 +- tools/update_codevtt.php | 20 ++--- 51 files changed, 412 insertions(+), 339 deletions(-) diff --git a/admin/edit_team.php b/admin/edit_team.php index aa684f201..47ec8c631 100644 --- a/admin/edit_team.php +++ b/admin/edit_team.php @@ -320,7 +320,7 @@ protected function display() { private function getTeamMembers($teamid) { $query = "SELECT user.id as user_id, user.username, user.realname, ". "team_user.id, team_user.arrival_date, team_user.departure_date, team_user.team_id, team_user.access_level ". - "FROM `mantis_user_table` as user ". + "FROM `{user}` as user ". "JOIN `codev_team_user_table` as team_user ON user.id = team_user.user_id ". "WHERE team_user.team_id=$teamid ". "ORDER BY user.username;"; @@ -353,7 +353,7 @@ private function getTeamMembers($teamid) { private function getTeamProjects($teamid) { $query = "SELECT project.id AS project_id, project.name, project.enabled, project.description, ". "team_project.id, team_project.type ". - "FROM `mantis_project_table` as project ". + "FROM `{project}` as project ". "JOIN `codev_team_project_table` as team_project ON project.id = team_project.project_id ". "WHERE team_project.team_id=$teamid ". "ORDER BY project.name;"; @@ -415,7 +415,7 @@ private function getOnDutyCandidates(Team $team, array $projList) { $formatedInactivityCatList = implode( ', ', array_keys($inactivityCatList)); - $query = "SELECT * FROM `mantis_bug_table` ". + $query = "SELECT * FROM `{bug}` ". "WHERE project_id IN ($formatedInactivityCatList) "; $astreintesList = $team->getOnDutyTasks(); diff --git a/classes/Email.class.php b/classes/Email.class.php index 9ff9bba2e..7a649ce18 100644 --- a/classes/Email.class.php +++ b/classes/Email.class.php @@ -143,7 +143,7 @@ private function email_queue_add( EmailData $emailData ) { $c_body = SqlWrapper::sql_real_escape_string($emailData->body); $c_metadata = serialize( $emailData->metadata ); - $query = "INSERT INTO `mantis_email_table` (`email`, `subject`, `body`, `submitted`, `metadata`) ". + $query = "INSERT INTO `{email}` (`email`, `subject`, `body`, `submitted`, `metadata`) ". "VALUES ('$c_email', '$c_subject', '$c_body', ".$emailData->submitted.", '$c_metadata');"; #echo "queue email: $query
"; $result = SqlWrapper::getInstance()->sql_query($query); diff --git a/classes/command.class.php b/classes/command.class.php index a6a012749..0f0aa7b72 100644 --- a/classes/command.class.php +++ b/classes/command.class.php @@ -274,7 +274,7 @@ public static function getCommandId($name) { * parse all Commands for issues not found in mantis_bug_table. if any, remove them from the Commands. */ public static function checkCommands() { - $query0 = "SELECT command_id, bug_id FROM codev_command_bug_table WHERE bug_id NOT IN (SELECT id FROM mantis_bug_table)"; + $query0 = "SELECT command_id, bug_id FROM codev_command_bug_table WHERE bug_id NOT IN (SELECT id FROM {bug})"; $result0 = SqlWrapper::getInstance()->sql_query($query0); while ($row = SqlWrapper::getInstance()->sql_fetch_object($result0)) { self::$logger->warn("issue $row->bug_id does not exist in Mantis: now removed from Command $row->command_id"); @@ -633,13 +633,13 @@ public function deleteProvision($provid) { public function getIssueSelection() { if(NULL == $this->issueSelection) { $this->issueSelection = new IssueSelection($this->name); - $query = "SELECT bug.* FROM `mantis_bug_table` AS bug ". + $query = "SELECT bug.* FROM `{bug}` AS bug ". "JOIN `codev_command_bug_table` AS command_bug ON bug.id = command_bug.bug_id " . "WHERE command_bug.command_id = ".$this->id.";"; #", `mantis_bug_table`". #"WHERE codev_command_bug_table.command_id=$this->id ". #"AND codev_command_bug_table.bug_id = mantis_bug_table.id ". - #"ORDER BY mantis_bug_table.project_id ASC, mantis_bug_table.target_version DESC, mantis_bug_table.status ASC"; + #"ORDER BY {bug}.project_id ASC, {bug}.target_version DESC, {bug}.status ASC"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { diff --git a/classes/consistency_check.class.php b/classes/consistency_check.class.php index cf37c0e5e..459adbb18 100644 --- a/classes/consistency_check.class.php +++ b/classes/consistency_check.class.php @@ -137,7 +137,7 @@ public function checkDeliveryDate() { // select all issues which current status is 'analyzed' $query = "SELECT * ". - "FROM `mantis_bug_table` ". + "FROM `{bug}` ". "WHERE status >= get_project_resolved_status_threshold(project_id) "; if (0 != count($this->projectList)) { @@ -180,7 +180,7 @@ public function checkResolved() { // select all issues which current status is 'analyzed' $query = "SELECT * ". - "FROM `mantis_bug_table` ". + "FROM `{bug}` ". "WHERE status >= get_project_resolved_status_threshold(project_id) "; if (0 != count($this->projectList)) { @@ -225,7 +225,7 @@ public function checkBadBacklog() { $cerrList = array(); // select all issues which current status is 'analyzed' - $query = "SELECT * FROM `mantis_bug_table` ". + $query = "SELECT * FROM `{bug}` ". #"WHERE status NOT IN (".Constants::$status_new.", ".Constants::$status_acknowledged.") ". "WHERE status NOT IN (".Constants::$status_new.") ". "AND status < get_project_resolved_status_threshold(project_id) "; @@ -272,7 +272,7 @@ public function checkMgrEffortEstim() { // select all issues $query = "SELECT * ". - "FROM `mantis_bug_table` ". + "FROM `{bug}` ". "WHERE status < get_project_resolved_status_threshold(project_id) "; if (0 != count($this->projectList)) { @@ -335,7 +335,7 @@ function checkTimeTracksOnNewIssues() { // select all issues which current status is 'new' $query = "SELECT * ". - "FROM `mantis_bug_table` ". + "FROM `{bug}` ". "WHERE status = ".Constants::$status_new." "; if (0 != count($this->projectList)) { diff --git a/classes/consistency_check2.class.php b/classes/consistency_check2.class.php index cd3bd4a75..d902edb59 100644 --- a/classes/consistency_check2.class.php +++ b/classes/consistency_check2.class.php @@ -698,7 +698,7 @@ public function checkTimetracksOnRemovedIssues() { "FROM `codev_timetracking_table` ". "WHERE date >= ".$team->getDate()." ". "AND userid IN ($formatedUsers) "; - #"AND 0 = (SELECT COUNT(id) FROM `mantis_bug_table` WHERE id='codev_timetracking_table.bugid' ) "; + #"AND 0 = (SELECT COUNT(id) FROM `{bug}` WHERE id='codev_timetracking_table.bugid' ) "; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -771,7 +771,7 @@ public static function checkIncompleteDays(TimeTracking $timeTracking, $userid = public static function checkMantisDefaultProjectWorkflow() { $cerrList = array(); - $query = "SELECT * FROM `mantis_config_table` ". + $query = "SELECT * FROM `{config}` ". "WHERE project_id = 0 ". "AND config_id = 'status_enum_workflow' "; diff --git a/classes/consistency_check_fdj.class.php b/classes/consistency_check_fdj.class.php index d7c9ae6a2..2f138cdf6 100644 --- a/classes/consistency_check_fdj.class.php +++ b/classes/consistency_check_fdj.class.php @@ -49,7 +49,7 @@ public function checkAnalyzed() { // select all issues which current status is 'analyzed' $query = "SELECT * ". - "FROM `mantis_bug_table` ". + "FROM `{bug}` ". "WHERE status in ($status_analyzed, $status_accepted, ".Constants::$status_open.", $status_deferred) "; if (0 != count($this->projectList)) { diff --git a/classes/constants.class.php b/classes/constants.class.php index a5b5cbd6a..a8672a427 100644 --- a/classes/constants.class.php +++ b/classes/constants.class.php @@ -49,6 +49,8 @@ class Constants { public static $severity_names; public static $bug_resolved_status_threshold; public static $status_enum_workflow; + public static $mantis_db_table_prefix = 'mantis_'; + public static $mantis_db_table_suffix = '_table'; // --- RESOLUTION --- public static $resolution_fixed; @@ -197,6 +199,15 @@ public static function parseConfigFile() { 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 + + self::$mantis_db_table_prefix = $mantis['db_table_prefix']; + self::$mantis_db_table_suffix = $mantis['db_table_suffix']; + if ( !empty( self::$mantis_db_table_prefix ) && ('_' != substr( self::$mantis_db_table_prefix, -1 )) ) { + self::$mantis_db_table_prefix .= '_'; + } + if ( !empty( self::$mantis_db_table_suffix ) && ('_' != substr( self::$mantis_db_table_suffix, 0, 1 )) ) { + self::$mantis_db_table_suffix = '_' . self::$mantis_db_table_suffix; + } $status = $ini_array['status']; self::$status_new = $status['status_new']; @@ -308,6 +319,8 @@ public static function writeConfigFile() { $mantis['severity_enum_string'] = self::$severity_names ? Tools::doubleImplode(':', ',', self::$severity_names) : ' '; $mantis['bug_resolved_status_threshold'] = self::$bug_resolved_status_threshold; $mantis['status_enum_workflow'] = json_encode(self::$status_enum_workflow); // array to jsonStr + $mantis['db_table_prefix'] = self::$mantis_db_table_prefix; + $mantis['db_table_suffix'] = self::$mantis_db_table_suffix; $status = array(); $status[] = '; Note: CodevTT needs some status to be defined (new, feedback, open, closed)'; diff --git a/classes/crypto.class.php b/classes/crypto.class.php index cbdb6bffd..bcb021b9f 100644 --- a/classes/crypto.class.php +++ b/classes/crypto.class.php @@ -63,7 +63,7 @@ public function auth_generate_unique_cookie_string() { * @access public */ private function auth_is_cookie_string_unique($p_cookie_string) { - $query = "SELECT COUNT(*) FROM mantis_user_table WHERE cookie_string='$p_cookie_string'"; + $query = "SELECT COUNT(*) FROM `{user}` WHERE cookie_string='$p_cookie_string'"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { diff --git a/classes/issue.class.php b/classes/issue.class.php index 5a3786420..9a78adf11 100644 --- a/classes/issue.class.php +++ b/classes/issue.class.php @@ -177,7 +177,7 @@ public function __construct($id, $details = NULL) { public function initialize($row = NULL) { if($row == NULL) { // Get issue info - $query = "SELECT * FROM `mantis_bug_table` " . + $query = "SELECT * FROM `{bug}` " . "WHERE id = $this->bugId"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -235,7 +235,7 @@ public function initializeCustomField() { $customFields = array( $extIdField, $mgrEffortEstimField, $effortEstimField, $backlogField, $addEffortField, $deadLineField, $deliveryDateField, $customField_type #, $deliveryIdField ); - $query = "SELECT field_id, value FROM `mantis_custom_field_string_table` ". + $query = "SELECT field_id, value FROM `{custom_field_string}` ". "WHERE bug_id = ".$this->bugId." ". "AND field_id IN (".implode(',',$customFields).");"; $result = SqlWrapper::getInstance()->sql_query($query); @@ -278,9 +278,9 @@ public function initializeCustomField() { public function initializeTags() { - $query = "SELECT mantis_tag_table.* FROM `mantis_tag_table` ". - "JOIN `mantis_bug_tag_table` ON mantis_tag_table.id = mantis_bug_tag_table.tag_id ". - "WHERE mantis_bug_tag_table.bug_id = ".$this->bugId.";"; + $query = "SELECT {tag}.* FROM `{tag}` ". + "JOIN `{bug_tag}` ON {tag}.id = `{bug_tag}`.tag_id ". + "WHERE `{bug_tag}`.bug_id = ".$this->bugId.";"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -306,7 +306,7 @@ public static function exists($bugid) { if (NULL == self::$existsCache) { self::$existsCache = array(); } if (!array_key_exists($bugid,self::$existsCache)) { - $query = "SELECT COUNT(id) FROM `mantis_bug_table` WHERE id=$bugid "; + $query = "SELECT COUNT(id) FROM `{bug}` WHERE id=$bugid "; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -338,7 +338,7 @@ public function isPublic() { */ public function getDescription() { if (NULL == $this->description) { - $query = "SELECT bt.description FROM mantis_bug_text_table bt, mantis_bug_table b WHERE b.id=".$this->bugId." AND b.bug_text_id = bt.id"; + $query = "SELECT bt.description FROM {bug_text} bt, {bug} b WHERE b.id=".$this->bugId." AND b.bug_text_id = bt.id"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -389,7 +389,7 @@ public function setType($value) { */ public function getIssueNoteList() { if (NULL == $this->issueNoteList) { - $query = "SELECT id FROM `mantis_bugnote_table` WHERE bug_id = ".$this->bugId.";"; + $query = "SELECT id FROM `{bugnote}` WHERE bug_id = ".$this->bugId.";"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -650,7 +650,7 @@ public function getProjectName() { return $project->getName(); /* - $query = "SELECT name FROM `mantis_project_table` WHERE id= $this->projectId"; + $query = "SELECT name FROM `{project}` WHERE id= $this->projectId"; $result = SqlWrapper::getInstance()->sql_query($query) or die("Query failed: $query"); $projectName = SqlWrapper::getInstance()->sql_result($result, 0); @@ -763,8 +763,8 @@ public function getBacklog($timestamp = NULL) { // TODO should be done only once... in Constants singleton ? // find in bug history when was the latest update of the Backlog before $timestamp - $query = "SELECT * FROM `mantis_bug_history_table` ". - "WHERE field_name = (SELECT name FROM `mantis_custom_field_table` WHERE id = $backlogCustomFieldId) ". + $query = "SELECT * FROM `{bug_history}` ". + "WHERE field_name = (SELECT name FROM `{custom_field}` WHERE id = $backlogCustomFieldId) ". "AND bug_id = '$this->bugId' ". "AND date_modified <= '$timestamp' ". "ORDER BY date_modified DESC LIMIT 1 "; @@ -966,7 +966,7 @@ public function getRelationships() { $this->relationships = array(); - $query = 'SELECT * FROM `mantis_bug_relationship_table` '. + $query = 'SELECT * FROM `{bug_relationship}` '. 'WHERE source_bug_id='.$this->bugId.' OR destination_bug_id='.$this->bugId; $result = SqlWrapper::getInstance()->sql_query($query); @@ -1140,7 +1140,7 @@ public function getInvolvedUsers($team_id = NULL) { $userList = array(); $query = "SELECT user.id, user.username ". - "FROM `mantis_user_table` as user, `codev_timetracking_table` as tt, `codev_team_user_table` ". + "FROM `{user}` as user, `codev_timetracking_table` as tt, `codev_team_user_table` ". "WHERE tt.userid = user.id ". "AND tt.bugid = ".$this->bugId." "; @@ -1193,7 +1193,7 @@ public function getStatus($timestamp = NULL) { } else { // if a timestamp is specified, find the latest status change (strictly) before this date $query = "SELECT new_value, old_value, date_modified ". - "FROM `mantis_bug_history_table` ". + "FROM `{bug_history}` ". "WHERE bug_id = $this->bugId ". "AND field_name='status' ". "AND date_modified < $timestamp ". @@ -1241,7 +1241,7 @@ public function setBacklog($backlog) { self::$logger->debug("setBacklog old_value=$old_backlog new_value=$backlog"); } - $query = "SELECT * FROM `mantis_custom_field_string_table` WHERE bug_id=$this->bugId AND field_id = $backlogCustomField"; + $query = "SELECT * FROM `{custom_field_string}` WHERE bug_id=$this->bugId AND field_id = $backlogCustomField"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -1249,9 +1249,9 @@ public function setBacklog($backlog) { } if (0 != SqlWrapper::getInstance()->sql_num_rows($result)) { - $query2 = "UPDATE `mantis_custom_field_string_table` SET value = '$backlog' WHERE bug_id=$this->bugId AND field_id = $backlogCustomField"; + $query2 = "UPDATE `{custom_field_string}` SET value = '$backlog' WHERE bug_id=$this->bugId AND field_id = $backlogCustomField"; } else { - $query2 = "INSERT INTO `mantis_custom_field_string_table` (`field_id`, `bug_id`, `value`) VALUES ('$backlogCustomField', '$this->bugId', '$backlog');"; + $query2 = "INSERT INTO `{custom_field_string}` (`field_id`, `bug_id`, `value`) VALUES ('$backlogCustomField', '$this->bugId', '$backlog');"; } $result2 = SqlWrapper::getInstance()->sql_query($query2); if (!$result2) { @@ -1261,7 +1261,7 @@ public function setBacklog($backlog) { $this->backlog = $backlog; // Add to history - $query3 = "SELECT name FROM `mantis_custom_field_table` WHERE id = $backlogCustomField"; + $query3 = "SELECT name FROM `{custom_field}` WHERE id = $backlogCustomField"; $result3 = SqlWrapper::getInstance()->sql_query($query3); if (!$result3) { echo "ERROR: Query FAILED"; @@ -1309,7 +1309,7 @@ protected function getDurationForStatusNew() { $time = $current_date - $this->dateSubmission; } else { // Bug has changed, search history for status changed - $query = "SELECT date_modified FROM `mantis_bug_history_table` WHERE bug_id=$this->bugId AND field_name = 'status' AND old_value='".Constants::$status_new."'"; + $query = "SELECT date_modified FROM `{bug_history}` WHERE bug_id=$this->bugId AND field_name = 'status' AND old_value='".Constants::$status_new."'"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -1344,7 +1344,7 @@ protected function getDurationForStatus($status) { // Find start_date $query = "SELECT id, date_modified, old_value, new_value ". - "FROM `mantis_bug_history_table` ". + "FROM `{bug_history}` ". "WHERE bug_id=$this->bugId ". "AND field_name = 'status' ". "AND (new_value=$status OR old_value=$status) ORDER BY id"; @@ -1620,7 +1620,7 @@ public function getFirstStatusOccurrence($status) { } $query = "SELECT date_modified ". - "FROM `mantis_bug_history_table` ". + "FROM `{bug_history}` ". "WHERE bug_id=$this->bugId ". "AND field_name = 'status' ". "AND new_value=$status ORDER BY id LIMIT 1"; @@ -1657,7 +1657,7 @@ public function getLatestStatusOccurrence($status) { } $query = "SELECT date_modified ". - "FROM `mantis_bug_history_table` ". + "FROM `{bug_history}` ". "WHERE bug_id=$this->bugId ". "AND field_name = 'status' ". "AND new_value=$status ORDER BY id DESC LIMIT 1"; @@ -1753,7 +1753,7 @@ public function getCommandList() { private function setMantisBugHistory($field_name, $old_value, $new_value, $type=0) { // Add to history $now = time(); - $query = "INSERT INTO `mantis_bug_history_table` (`user_id`, `bug_id`, `field_name`, `old_value`, `new_value`, `type`, `date_modified`) ". + $query = "INSERT INTO `{bug_history}` (`user_id`, `bug_id`, `field_name`, `old_value`, `new_value`, `type`, `date_modified`) ". "VALUES ('".$_SESSION['userid']."','$this->bugId','$field_name', '$old_value', '$new_value', '".$type."', '".$now."');"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -1763,7 +1763,7 @@ private function setMantisBugHistory($field_name, $old_value, $new_value, $type= // update lastUpdated field - $query2 = "UPDATE `mantis_bug_table` SET last_updated = '".$now."' WHERE id = $this->bugId"; + $query2 = "UPDATE `{bug}` SET last_updated = '".$now."' WHERE id = $this->bugId"; $result2 = SqlWrapper::getInstance()->sql_query($query2); if (!$result2) { echo "ERROR: Query FAILED"; @@ -1775,7 +1775,7 @@ private function setMantisBugHistory($field_name, $old_value, $new_value, $type= * @param type $value */ public function setHandler($value) { - $query = "UPDATE `mantis_bug_table` SET handler_id = '$value' WHERE id=$this->bugId "; + $query = "UPDATE `{bug}` SET handler_id = '$value' WHERE id=$this->bugId "; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -1797,7 +1797,7 @@ public function setTargetVersion($versionId) { if (0 == $versionId) { $version = ''; // remove version } else { - $query = "SELECT version from `mantis_project_version_table` WHERE id=$versionId "; + $query = "SELECT version from `{project_version}` WHERE id=$versionId "; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -1806,7 +1806,7 @@ public function setTargetVersion($versionId) { $row = SqlWrapper::getInstance()->sql_fetch_object($result); $version = $row->version; } - $query = "UPDATE `mantis_bug_table` SET target_version = '$version' WHERE id=$this->bugId "; + $query = "UPDATE `{bug}` SET target_version = '$version' WHERE id=$this->bugId "; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -1818,7 +1818,7 @@ public function setTargetVersion($versionId) { } private function setCustomField($field_id, $value, $field_name=NULL) { - $query = "SELECT * FROM `mantis_custom_field_string_table` WHERE bug_id=$this->bugId AND field_id = $field_id"; + $query = "SELECT * FROM `{custom_field_string}` WHERE bug_id=$this->bugId AND field_id = $field_id"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -1827,9 +1827,9 @@ private function setCustomField($field_id, $value, $field_name=NULL) { if (0 != SqlWrapper::getInstance()->sql_num_rows($result)) { $row = SqlWrapper::getInstance()->sql_fetch_object($result); $old_value=$row->value; - $query2 = "UPDATE `mantis_custom_field_string_table` SET value = '$value' WHERE bug_id=$this->bugId AND field_id = $field_id"; + $query2 = "UPDATE `{custom_field_string}` SET value = '$value' WHERE bug_id=$this->bugId AND field_id = $field_id"; } else { - $query2 = "INSERT INTO `mantis_custom_field_string_table` (`field_id`, `bug_id`, `value`) VALUES ('$field_id', '$this->bugId', '$value');"; + $query2 = "INSERT INTO `{custom_field_string}` (`field_id`, `bug_id`, `value`) VALUES ('$field_id', '$this->bugId', '$value');"; } $result2 = SqlWrapper::getInstance()->sql_query($query2); if (!$result2) { @@ -1839,7 +1839,7 @@ private function setCustomField($field_id, $value, $field_name=NULL) { // update bug history if (NULL == $field_name) { - $query3 = "SELECT name FROM `mantis_custom_field_table` WHERE id = $field_id"; + $query3 = "SELECT name FROM `{custom_field}` WHERE id = $field_id"; $result3 = SqlWrapper::getInstance()->sql_query($query3); if (!$result3) { echo "ERROR: Query FAILED"; @@ -1922,7 +1922,7 @@ public static function getIssues(array $issueIds) { } if(count($newIssueIds) > 0) { - $query = "SELECT * FROM `mantis_bug_table` " . + $query = "SELECT * FROM `{bug}` " . "WHERE id IN (".implode(', ', $newIssueIds).")"; $result = SqlWrapper::getInstance()->sql_query($query); @@ -2213,9 +2213,9 @@ public function getTooltipItems($teamid = 0, $userid = 0, $isManager = NULL) { default: // unknown customField, get from DB $query = "SELECT value ". - "FROM `mantis_custom_field_string_table` ". - "WHERE mantis_custom_field_string_table.bug_id = $this->bugId ". - "AND mantis_custom_field_string_table.field_id = $cfield_id "; + "FROM `{custom_field_string}` ". + "WHERE {custom_field_string}.bug_id = $this->bugId ". + "AND {custom_field_string}.field_id = $cfield_id "; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -2279,7 +2279,7 @@ public function getTooltipItems($teamid = 0, $userid = 0, $isManager = NULL) { self::$logger->warn('TOOLTIP field = '.$field.' has no accessor => LOW PERF'); } - $query = "SELECT $field FROM `mantis_bug_table` WHERE id = $this->bugId "; + $query = "SELECT $field FROM `{bug}` WHERE id = $this->bugId "; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -2402,7 +2402,7 @@ public function setStatus($newStatusId) { $allowedStatusList = $this->getAvailableStatusList(); if (array_key_exists($newStatusId, $allowedStatusList)) { - $query = "UPDATE `mantis_bug_table` SET status = '$newStatusId' WHERE id=$this->bugId "; + $query = "UPDATE `{bug}` SET status = '$newStatusId' WHERE id=$this->bugId "; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { self::$logger->error("setStatus($newStatusId) : Query failed. Status has not been changed !"); @@ -2434,7 +2434,7 @@ public function setStatus($newStatusId) { */ public function setDateSubmission($newSubmissionTimestampDate) { - $query = "UPDATE `mantis_bug_table` SET date_submitted=$newSubmissionTimestampDate WHERE id=".$this->bugId; + $query = "UPDATE `{bug}` SET date_submitted=$newSubmissionTimestampDate WHERE id=".$this->bugId; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { diff --git a/classes/issue_fdj.class.php b/classes/issue_fdj.class.php index a2f92dd6c..7942477fd 100644 --- a/classes/issue_fdj.class.php +++ b/classes/issue_fdj.class.php @@ -63,7 +63,7 @@ private function getDuration_feedback() { // Find start_date $query = "SELECT id, date_modified, old_value, new_value ". - "FROM `mantis_bug_history_table` ". + "FROM `{bug_history}` ". "WHERE bug_id=$this->bugId ". "AND field_name = 'status' ". "AND (new_value=".Constants::$status_feedback." OR old_value=".Constants::$status_feedback.") ". @@ -96,7 +96,7 @@ private function getDuration_feedback() { // Determinate to whom it was assigned // find the last handler_id change before $end_id $query2 = "SELECT id, date_modified, old_value, new_value ". - "FROM `mantis_bug_history_table` ". + "FROM `{bug_history}` ". "WHERE bug_id=$this->bugId ". "AND field_name='handler_id' ". $sql_condition. @@ -127,7 +127,7 @@ private function getDuration_feedback() { // action, THEN we must take the previous 'assigned to' action in the list. // Get the next action to check if it is a 'change status' - $query3 = "SELECT id, date_modified, field_name FROM `mantis_bug_history_table` WHERE bug_id=$this->bugId AND id > '$latest_assignTo_id' ORDER BY id ASC"; + $query3 = "SELECT id, date_modified, field_name FROM `{bug_history}` WHERE bug_id=$this->bugId AND id > '$latest_assignTo_id' ORDER BY id ASC"; $result3 = SqlWrapper::getInstance()->sql_query($query3); if (!$result3) { echo "ERROR: Query FAILED"; diff --git a/classes/issue_note.class.php b/classes/issue_note.class.php index 9fc23f3e2..bd53acca2 100644 --- a/classes/issue_note.class.php +++ b/classes/issue_note.class.php @@ -84,7 +84,7 @@ public static function create($bug_id, $reporter_id, $text='', $type=self::type_ $view_state = ($private) ? self::viewState_private : self::viewState_public; $sqlWrapper = SqlWrapper::getInstance(); - $query2 = "INSERT INTO `mantis_bugnote_text_table` (`note`) VALUES ('".SqlWrapper::sql_real_escape_string($text)."');"; + $query2 = "INSERT INTO `{bugnote_text}` (`note`) VALUES ('".SqlWrapper::sql_real_escape_string($text)."');"; $result2 = $sqlWrapper->sql_query($query2); if (!$result2) { @@ -99,7 +99,7 @@ public static function create($bug_id, $reporter_id, $text='', $type=self::type_ $date_submitted = $timestamp; } - $query = 'INSERT INTO `mantis_bugnote_table` '. + $query = 'INSERT INTO `{bugnote}` '. '(`bug_id`, `reporter_id`, `view_state`, `note_type`, `bugnote_text_id`, `date_submitted`, `last_modified`) '. "VALUES ('$bug_id', '$reporter_id', '$view_state', '$type', '$bugnote_text_id', '$date_submitted', '$timestamp');"; $result = $sqlWrapper->sql_query($query); @@ -110,7 +110,7 @@ public static function create($bug_id, $reporter_id, $text='', $type=self::type_ $bugnote_id = $sqlWrapper->sql_insert_id(); // log BUGNOTE_ADD in Issue history - $query3 = 'INSERT INTO `mantis_bug_history_table` '. + $query3 = 'INSERT INTO `{bug_history}` '. '( user_id, bug_id, date_modified, type, old_value ) '. "VALUES ( $reporter_id, $bug_id, ".$timestamp.', '.self::history_BugnoteAdded.", $bugnote_id)"; $result3 = $sqlWrapper->sql_query($query3); @@ -129,8 +129,8 @@ public static function delete($id, $bugid, $userid) { //self::$logger->error("Delete note $id"); # Remove the bugnote text - $query = 'DELETE FROM `mantis_bugnote_text_table` WHERE id=' . - " (SELECT bugnote_text_id FROM `mantis_bugnote_table` WHERE id=$id)"; + $query = 'DELETE FROM `{bugnote_text}` WHERE id=' . + " (SELECT bugnote_text_id FROM `{bugnote}` WHERE id=$id)"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -138,7 +138,7 @@ public static function delete($id, $bugid, $userid) { } # Remove the bugnote - $query2 = 'DELETE FROM `mantis_bugnote_table` WHERE id=' . $id; + $query2 = 'DELETE FROM `{bugnote}` WHERE id=' . $id; $result2 = SqlWrapper::getInstance()->sql_query($query2); if (!$result2) { echo "ERROR: Query FAILED"; @@ -146,7 +146,7 @@ public static function delete($id, $bugid, $userid) { } // log BUGNOTE_DELETED in Issue history - $query3 = 'INSERT INTO `mantis_bug_history_table` '. + $query3 = 'INSERT INTO `{bug_history}` '. '( user_id, bug_id, date_modified, type, old_value ) '. "VALUES ( $userid, $bugid, ".time().', '.self::history_BugnoteDeleted.", $id)"; $result3 = SqlWrapper::getInstance()->sql_query($query3); @@ -166,9 +166,9 @@ public static function delete($id, $bugid, $userid) { public static function getTimesheetNote($bug_id) { $query2 = "SELECT note.id, note.bugnote_text_id ". - "FROM `mantis_bugnote_table` as note ". + "FROM `{bugnote}` as note ". "WHERE note.bug_id = $bug_id ". - "AND 0 <> (SELECT COUNT(id) FROM mantis_bugnote_text_table WHERE id = note.bugnote_text_id AND note LIKE '%".self::tagid_timesheetNote."%') ". + "AND 0 <> (SELECT COUNT(id) FROM {bugnote_text} WHERE id = note.bugnote_text_id AND note LIKE '%".self::tagid_timesheetNote."%') ". "ORDER BY note.date_submitted DESC LIMIT 1;"; $result = SqlWrapper::getInstance()->sql_query($query2); @@ -254,8 +254,8 @@ private function initialize() { // Get bugnote info $query = "SELECT note.*, ". "bugnote_text.note ". - "FROM `mantis_bugnote_table` as note ". - "JOIN `mantis_bugnote_text_table` as bugnote_text ON note.bugnote_text_id = bugnote_text.id ". + "FROM `{bugnote}` as note ". + "JOIN `{bugnote_text}` as bugnote_text ON note.bugnote_text_id = bugnote_text.id ". "WHERE note.id = $this->id ". "ORDER BY note.date_submitted;"; @@ -349,7 +349,7 @@ public function setText($text, $user_id) { $this->revisionAdd($oldText, $this->reporter_id, $this->last_modified); } $sqlWrapper = SqlWrapper::getInstance(); - $query = "UPDATE `mantis_bugnote_text_table` SET note='".SqlWrapper::sql_real_escape_string($text)."' ". + $query = "UPDATE `{bugnote_text}` SET note='".SqlWrapper::sql_real_escape_string($text)."' ". "WHERE id=" . $this->bugnote_text_id; $result = $sqlWrapper->sql_query($query); if (!$result) { @@ -359,7 +359,7 @@ public function setText($text, $user_id) { # updated the last_updated date $now = time(); - $query2 = "UPDATE `mantis_bugnote_table` SET last_modified=$now WHERE id= $this->id"; + $query2 = "UPDATE `{bugnote}` SET last_modified=$now WHERE id= $this->id"; $result2 = $sqlWrapper->sql_query($query2); if (!$result2) { echo "ERROR: Query FAILED"; @@ -370,7 +370,7 @@ public function setText($text, $user_id) { $revision_id = $this->revisionAdd($text, $user_id, $now); // log BUGNOTE_UPDATED in Issue history - $query3 = 'INSERT INTO `mantis_bug_history_table` '. + $query3 = 'INSERT INTO `{bug_history}` '. '( user_id, bug_id, date_modified, type, old_value, new_value ) '. "VALUES ( $user_id, ".$this->bug_id.", ".time().', '.self::history_BugnoteUpdated.', '.$this->id.", $revision_id)"; $result3 = $sqlWrapper->sql_query($query3); @@ -384,7 +384,7 @@ public function setText($text, $user_id) { } private function revisionCount() { - $query = "SELECT COUNT(id) FROM `mantis_bug_revision_table` ". + $query = "SELECT COUNT(id) FROM `{bug_revision}` ". "WHERE bug_id= $this->bug_id ". "AND bugnote_id= $this->id ". "AND type= ".self::rev_type_bugnote.';'; @@ -407,7 +407,7 @@ private function revisionCount() { */ private function revisionAdd($text, $user_id, $timestamp) { - $query = "INSERT INTO `mantis_bug_revision_table` (bug_id, bugnote_id, user_id, timestamp, type, value) ". + $query = "INSERT INTO `{bug_revision}` (bug_id, bugnote_id, user_id, timestamp, type, value) ". "VALUES ($this->bug_id, $this->id, $user_id, $timestamp, ". self::rev_type_bugnote.", '".SqlWrapper::sql_real_escape_string($text)."')"; $result = SqlWrapper::getInstance()->sql_query($query); diff --git a/classes/issue_selection.class.php b/classes/issue_selection.class.php index 6f31bc47a..ffa4847cc 100644 --- a/classes/issue_selection.class.php +++ b/classes/issue_selection.class.php @@ -585,7 +585,7 @@ public function getLastUpdated() { $lastUpdated = 0; if(count($this->issueList) > 0) { - $query = "SELECT last_updated from `mantis_bug_table` ". + $query = "SELECT last_updated from `{bug}` ". "WHERE id IN (".implode(', ',array_keys($this->issueList)).") ". "ORDER BY last_updated DESC LIMIT 1"; $result = SqlWrapper::getInstance()->sql_query($query); @@ -612,7 +612,7 @@ public function getLastUpdated() { public function getLastUpdatedList($max = 1) { $lastUpdatedList = array(); if(count($this->issueList) > 0) { - $query = "SELECT id, last_updated from `mantis_bug_table` ". + $query = "SELECT id, last_updated from `{bug}` ". "WHERE id IN (".implode(', ',array_keys($this->issueList)).") ". "ORDER BY last_updated DESC LIMIT $max"; $result = SqlWrapper::getInstance()->sql_query($query); diff --git a/classes/period_stats.class.php b/classes/period_stats.class.php index 398dd1019..c497e545b 100644 --- a/classes/period_stats.class.php +++ b/classes/period_stats.class.php @@ -111,7 +111,7 @@ private function countIssues_other() { // select all but SideTasks & rem 'doublons' $query = "SELECT DISTINCT bug.id ". - "FROM `mantis_bug_table` as bug ". + "FROM `{bug}` as bug ". "JOIN `codev_team_project_table` as team_project ON bug.project_id = team_project.project_id ". "WHERE team_project.type IN ($formatedProjectTypes) "; @@ -133,7 +133,7 @@ private function countIssues_other() { $bugId1 = $row->id; // Find most recent transitions where date < $endTimestamp $query2 = "SELECT bug_id, new_value, old_value, date_modified ". - "FROM `mantis_bug_history_table` ". + "FROM `{bug_history}` ". "WHERE field_name='status' ". "AND bug_id =$bugId1 ". "AND date_modified < $this->endTimestamp ". diff --git a/classes/project.class.php b/classes/project.class.php index 047d7d6ad..84af8fd80 100644 --- a/classes/project.class.php +++ b/classes/project.class.php @@ -126,7 +126,7 @@ public function __construct($id, $details = NULL) { */ public function initialize($row = NULL) { if($row == NULL) { - $query = "SELECT * FROM `mantis_project_table` ". + $query = "SELECT * FROM `{project}` ". "WHERE id = ".$this->id.";"; $result = SqlWrapper::getInstance()->sql_query($query); @@ -184,7 +184,7 @@ public static function exists($id) { if (NULL == self::$existsCache) { self::$existsCache = array(); } if (NULL == self::$existsCache[$id]) { - $query = "SELECT COUNT(id) FROM `mantis_project_table` WHERE id=".$id.";"; + $query = "SELECT COUNT(id) FROM `{project}` WHERE id=".$id.";"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -213,7 +213,7 @@ public static function getIdFormName($projectName) { return false; } // check if name exists - $query = "SELECT id FROM `mantis_project_table` WHERE name='$projectName'"; + $query = "SELECT id FROM `{project}` WHERE name='$projectName'"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -233,7 +233,7 @@ public static function getIdFormName($projectName) { */ public static function createExternalTasksProject($projectName, $projectDesc) { // check if name exists - $query = "SELECT id FROM `mantis_project_table` WHERE name='$projectName'"; + $query = "SELECT id FROM `{project}` WHERE name='$projectName'"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -247,7 +247,7 @@ public static function createExternalTasksProject($projectName, $projectDesc) { } // create new Project - $query = "INSERT INTO `mantis_project_table` (`name`, `status`, `enabled`, `view_state`, `access_min`, `description`, `category_id`, `inherit_global`) ". + $query = "INSERT INTO `{project}` (`name`, `status`, `enabled`, `view_state`, `access_min`, `description`, `category_id`, `inherit_global`) ". "VALUES ('$projectName',50,1,50,10,'$projectDesc',1,1);"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -261,7 +261,7 @@ public static function createExternalTasksProject($projectName, $projectDesc) { #REM first call to this function is in install step1, and $statusNames is set in step2. '90' is mantis default value for 'closed' $statusNames = NULL; # Constants::$statusNames; $status_closed = (NULL != $statusNames) ? array_search('closed', $statusNames) : 90; - $query = "INSERT INTO `mantis_config_table` (`config_id`,`project_id`,`user_id`,`access_reqd`,`type`,`value`) ". + $query = "INSERT INTO `{config}` (`config_id`,`project_id`,`user_id`,`access_reqd`,`type`,`value`) ". "VALUES ('bug_submit_status', $projectid, 0, 90, 1, '$status_closed');"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -270,7 +270,7 @@ public static function createExternalTasksProject($projectName, $projectDesc) { } // Status to set auto-assigned issues to 'closed' - $query = "INSERT INTO `mantis_config_table` (`config_id`,`project_id`,`user_id`,`access_reqd`,`type`,`value`) ". + $query = "INSERT INTO `{config}` (`config_id`,`project_id`,`user_id`,`access_reqd`,`type`,`value`) ". "VALUES ('bug_assigned_status', $projectid, 0, 90, 1, '$status_closed');"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -279,7 +279,7 @@ public static function createExternalTasksProject($projectName, $projectDesc) { } // create leave category - $query = "INSERT INTO `mantis_category_table` (`project_id`, `user_id`, `name`, `status`) ". + $query = "INSERT INTO `{category}` (`project_id`, `user_id`, `name`, `status`) ". "VALUES ('$projectid','0','Leave', '0');"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -289,7 +289,7 @@ public static function createExternalTasksProject($projectName, $projectDesc) { $catLeaveId = SqlWrapper::getInstance()->sql_insert_id(); // create otherInternal category - $query = "INSERT INTO `mantis_category_table` (`project_id`, `user_id`, `name`, `status`) ". + $query = "INSERT INTO `{category}` (`project_id`, `user_id`, `name`, `status`) ". "VALUES ('$projectid','0','Other activity', '0');"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -324,7 +324,7 @@ public static function createSideTaskProject($projectName) { $deliveryDateCustomField = Config::getInstance()->getValue(Config::id_customField_deliveryDate); // check if name exists - $query = "SELECT id FROM `mantis_project_table` WHERE name='$projectName'"; + $query = "SELECT id FROM `{project}` WHERE name='$projectName'"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -338,7 +338,7 @@ public static function createSideTaskProject($projectName) { } // create new Project - $query = "INSERT INTO `mantis_project_table` (`name`, `status`, `enabled`, `view_state`, `access_min`, `description`, `category_id`, `inherit_global`) ". + $query = "INSERT INTO `{project}` (`name`, `status`, `enabled`, `view_state`, `access_min`, `description`, `category_id`, `inherit_global`) ". "VALUES ('$projectName','50','1','50','10','$projectDesc','1','0');"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -348,7 +348,7 @@ public static function createSideTaskProject($projectName) { $projectid = SqlWrapper::getInstance()->sql_insert_id(); // add custom fields BI,BS,RAE,DeadLine,DeliveryDate - $query = "INSERT INTO `mantis_custom_field_project_table` (`field_id`, `project_id`, `sequence`) ". + $query = "INSERT INTO `{custom_field_project}` (`field_id`, `project_id`, `sequence`) ". "VALUES ('$mgrEffortEstimCustomField', '$projectid','2'), ". "('$estimEffortCustomField', '$projectid','3'), ". "('$addEffortCustomField', '$projectid','4'), ". @@ -367,7 +367,7 @@ public static function createSideTaskProject($projectName) { $statusNames = Constants::$statusNames; Config::setQuiet(FALSE); $status_closed = (NULL != $statusNames) ? array_search('closed', $statusNames) : 90; - $query = "INSERT INTO `mantis_config_table` (`config_id`,`project_id`,`user_id`,`access_reqd`,`type`,`value`) ". + $query = "INSERT INTO `{config}` (`config_id`,`project_id`,`user_id`,`access_reqd`,`type`,`value`) ". "VALUES ('bug_submit_status', '$projectid','0', '90', '1', '$status_closed');"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -376,7 +376,7 @@ public static function createSideTaskProject($projectName) { } // Status to set auto-assigned issues to 'closed' - $query = "INSERT INTO `mantis_config_table` (`config_id`,`project_id`,`user_id`,`access_reqd`,`type`,`value`) ". + $query = "INSERT INTO `{config}` (`config_id`,`project_id`,`user_id`,`access_reqd`,`type`,`value`) ". "VALUES ('bug_assigned_status', '$projectid','0', '90', '1', '$status_closed');"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -394,7 +394,7 @@ public static function createSideTaskProject($projectName) { */ public static function getCategoryName($id) { if(!array_key_exists($id, self::$categories)) { - $query = "SELECT name FROM `mantis_category_table` WHERE id = ".$id.";"; + $query = "SELECT name FROM `{category}` WHERE id = ".$id.";"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -414,7 +414,7 @@ public static function getCategoryName($id) { * @return string The category name */ public static function getCategoryId($name) { - $query = "SELECT id FROM `mantis_category_table` WHERE name='$name'"; + $query = "SELECT id FROM `{category}` WHERE name='$name'"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -430,7 +430,7 @@ public static function getCategoryId($name) { * @return string The version name */ public static function getProjectVersionName($id) { - $query = "SELECT version FROM `mantis_project_version_table` WHERE id = ".$id.";"; + $query = "SELECT version FROM `{project_version}` WHERE id = ".$id.";"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -447,7 +447,7 @@ public static function getProjectVersionName($id) { * @return string The version timestamp */ public static function getProjectVersionTimestamp($project_id, $version) { - $query = "SELECT date_order FROM `mantis_project_version_table` " + $query = "SELECT date_order FROM `{project_version}` " . 'WHERE `project_id` = '.$project_id.' AND `version` = "'.$version.'";'; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -479,7 +479,7 @@ public function getCategories($withGlobal = true, $withInherited = true) { } if ($withInherited) { - $queryParents = "SELECT parent_id FROM `mantis_project_hierarchy_table` ". + $queryParents = "SELECT parent_id FROM `{project_hierarchy}` ". "WHERE child_id = $this->id ". "AND inherit_parent = 1 "; $resultParents = SqlWrapper::getInstance()->sql_query($queryParents); @@ -492,7 +492,7 @@ public function getCategories($withGlobal = true, $withInherited = true) { } } - $query = "SELECT id, name FROM `mantis_category_table` WHERE project_id IN (".$formattedProjects.");"; + $query = "SELECT id, name FROM `{category}` WHERE project_id IN (".$formattedProjects.");"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -512,7 +512,7 @@ public function getProjectVersions($withObsolete=TRUE) { if (NULL == $this->versionCache) { $this->versionCache = array(); - $query = "SELECT id, version FROM `mantis_project_version_table` WHERE project_id = ".$this->id; + $query = "SELECT id, version FROM `{project_version}` WHERE project_id = ".$this->id; if (FALSE == $withObsolete) { $query .= " AND obsolete=0"; } @@ -545,7 +545,7 @@ public static function prepareProjectToCodev($projectid) { */ // find out which customFields are already associated - $query = "SELECT field_id FROM `mantis_custom_field_project_table` WHERE project_id = ".$projectid.";"; + $query = "SELECT field_id FROM `{custom_field_project}` WHERE project_id = ".$projectid.";"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -567,7 +567,7 @@ public static function prepareProjectToCodev($projectid) { $existingFields[] = $row->field_id; } - $query = "INSERT INTO `mantis_custom_field_project_table` (`field_id`, `project_id`, `sequence`) ". + $query = "INSERT INTO `{custom_field_project}` (`field_id`, `project_id`, `sequence`) ". "VALUES "; $found = FALSE; @@ -623,7 +623,7 @@ public function addCategoryWorkshop($catName) { private function addCategory($catType, $catName) { // create category for SideTask Project $formattedCatName = SqlWrapper::sql_real_escape_string($catName); - $query = "INSERT INTO `mantis_category_table` (`project_id`, `user_id`, `name`, `status`) VALUES ('$this->id','0','$formattedCatName', '0');"; + $query = "INSERT INTO `{category}` (`project_id`, `user_id`, `name`, `status`) VALUES ('$this->id','0','$formattedCatName', '0');"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -693,7 +693,7 @@ public function addIssue($cat_id, $issueSummary, $issueDesc, $issueStatus) { $reproducibility = 100; $formattedIssueDesc = SqlWrapper::sql_real_escape_string($issueDesc); - $query = "INSERT INTO `mantis_bug_text_table` (`description`, `steps_to_reproduce`, `additional_information`) VALUES ('".$formattedIssueDesc."', '', '');"; + $query = "INSERT INTO `{bug_text}` (`description`, `steps_to_reproduce`, `additional_information`) VALUES ('".$formattedIssueDesc."', '', '');"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -702,7 +702,7 @@ public function addIssue($cat_id, $issueSummary, $issueDesc, $issueStatus) { $bug_text_id = SqlWrapper::getInstance()->sql_insert_id(); $formattedIssueSummary = SqlWrapper::sql_real_escape_string($issueSummary); - $query = "INSERT INTO `mantis_bug_table` (`project_id`, `category_id`, `summary`, `priority`, `reproducibility`, `status`, `bug_text_id`, `date_submitted`, `last_updated`) ". + $query = "INSERT INTO `{bug}` (`project_id`, `category_id`, `summary`, `priority`, `reproducibility`, `status`, `bug_text_id`, `date_submitted`, `last_updated`) ". "VALUES ($this->id,$cat_id,'$formattedIssueSummary',$priority,$reproducibility,$issueStatus,$bug_text_id,$today,$today);"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -740,7 +740,7 @@ public function getBugResolvedStatusThreshold() { public function getBugSubmitStatus() { if(is_null($this->bug_submit_status)) { - $query = "SELECT value FROM `mantis_config_table` ". + $query = "SELECT value FROM `{config}` ". "WHERE config_id = 'bug_submit_status'". "AND project_id = $this->id". " LIMIT 1;"; @@ -870,7 +870,7 @@ public function getBugidList($handler_id = 0, $isHideResolved = FALSE) { if (NULL == $this->bugidListsCache[$key]) { $issueList = array(); - $query = "SELECT id FROM `mantis_bug_table` ". + $query = "SELECT id FROM `{bug}` ". "WHERE project_id=$this->id "; if (0 != $handler_id) { $query .= "AND handler_id = $handler_id "; @@ -910,7 +910,7 @@ public function getIssues($handler_id = 0, $isHideResolved = FALSE, $hideStatusA if (!array_key_exists($key, $this->bugidListsCache)) { $issueList = array(); - $query = "SELECT * FROM `mantis_bug_table` ". + $query = "SELECT * FROM `{bug}` ". "WHERE project_id=$this->id "; if (0 != $handler_id) { $query .= "AND handler_id = $handler_id "; @@ -1105,7 +1105,7 @@ public function isExternalTasksProject() { function getWorkflowTransitions() { // ORDER BY is important, it will ensure to return the project specific value before the generic (0) value - $query = "SELECT * FROM `mantis_config_table` ". + $query = "SELECT * FROM `{config}` ". "WHERE project_id IN (0, $this->id) ". "AND config_id = 'status_enum_workflow' ". "ORDER BY project_id DESC"; @@ -1178,7 +1178,7 @@ function getWorkflowTransitionsFormatted() { */ function getProjectConfig() { // find all srcProj specific config - $query = "SELECT * FROM `mantis_config_table` ". + $query = "SELECT * FROM `{config}` ". "WHERE project_id = ".$this->id.";"; if(self::$logger->isDebugEnabled()) { self::$logger->debug("getProjectConfig: Src query=$query"); @@ -1209,7 +1209,7 @@ function getProjectConfig() { */ static function cloneAllProjectConfig($srcProjectId, $destProjectId, $strict=TRUE) { // find all srcProj specific config - $query = "SELECT DISTINCT config_id FROM `mantis_config_table` ". + $query = "SELECT DISTINCT config_id FROM `{config}` ". "WHERE project_id = ".$srcProjectId.";"; if(self::$logger->isDebugEnabled()) { self::$logger->debug("cloneAllProjectConfig: Src query=$query"); @@ -1231,7 +1231,7 @@ static function cloneAllProjectConfig($srcProjectId, $destProjectId, $strict=TRU self::$logger->debug("cloneAllProjectConfig: SrcConfigList=$formatedSrcConfigList"); } - $query = "DELETE FROM `mantis_config_table` ". + $query = "DELETE FROM `{config}` ". "WHERE project_id=".$destProjectId." "; if (!$strict) { // delete only config defined for srcProject @@ -1248,10 +1248,10 @@ static function cloneAllProjectConfig($srcProjectId, $destProjectId, $strict=TRU //--- clone all srcProj config to destProj foreach ($srcConfigList as $cid) { - $query = "INSERT INTO `mantis_config_table` ". + $query = "INSERT INTO `{config}` ". "(config_id, project_id, user_id, access_reqd, type, value) ". " (SELECT config_id, $destProjectId, user_id, access_reqd, type, value ". - " FROM `mantis_config_table` ". + " FROM `{config}` ". " WHERE project_id=$srcProjectId ". " AND config_id='$cid') "; if(self::$logger->isDebugEnabled()) { @@ -1305,7 +1305,7 @@ public function getVersionDate($target_version) { } $sqlWrapper = SqlWrapper::getInstance(); if(!array_key_exists($target_version,$this->versionDateCache)) { - $query = "SELECT date_order FROM `mantis_project_version_table` ". + $query = "SELECT date_order FROM `{project_version}` ". "WHERE project_id=$this->id ". "AND version='".SqlWrapper::sql_real_escape_string($target_version)."';"; $result = SqlWrapper::getInstance()->sql_query($query); @@ -1377,7 +1377,7 @@ public function getDriftMgr() { * @return string[] The projects : name[id] */ public static function getProjects() { - $query = 'SELECT id, name FROM `mantis_project_table` ORDER BY name;'; + $query = 'SELECT id, name FROM `{project}` ORDER BY name;'; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { return NULL; @@ -1399,7 +1399,7 @@ public static function getProjects() { public static function getProjectIssues($projectIds) { $formatedProjList = implode( ', ', $projectIds); - $query = "SELECT * FROM `mantis_bug_table` " . + $query = "SELECT * FROM `{bug}` " . "WHERE project_id IN ($formatedProjList) " . "ORDER BY id DESC;"; $result = SqlWrapper::getInstance()->sql_query($query); @@ -1460,11 +1460,11 @@ public function getDescription() { */ public function getCustomFieldsList() { - $query = "SELECT mantis_custom_field_project_table.field_id, mantis_custom_field_table.name ". - "FROM `mantis_custom_field_project_table`, `mantis_custom_field_table` ". - "WHERE mantis_custom_field_project_table.project_id = $this->id ". - "AND mantis_custom_field_table.id = mantis_custom_field_project_table.field_id ". - "ORDER BY mantis_custom_field_table.name"; + $query = "SELECT {custom_field_project}.field_id, {custom_field}.name ". + "FROM `{custom_field_project}`, `{custom_field}` ". + "WHERE {custom_field_project}.project_id = $this->id ". + "AND {custom_field}.id = {custom_field_project}.field_id ". + "ORDER BY {custom_field}.name"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -1568,7 +1568,7 @@ public function setIssueTooltipFields ($fieldList = NULL, $teamid = 0, $userid = */ public function hasMember($memberId) { - $query = "SELECT count(*) as count FROM `mantis_project_user_list_table` WHERE user_id = $memberId AND project_id = $this->id"; + $query = "SELECT count(*) as count FROM `{project_user_list}` WHERE user_id = $memberId AND project_id = $this->id"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { diff --git a/classes/project_version.class.php b/classes/project_version.class.php index 1a78a8cd3..5e93196eb 100644 --- a/classes/project_version.class.php +++ b/classes/project_version.class.php @@ -29,7 +29,7 @@ public function __construct($projectId, $version) { public function getVersionDate() { if (NULL == $this->versionDate) { $query = "SELECT date_order ". - "FROM `mantis_project_version_table` ". + "FROM `{project_version}` ". "WHERE project_id = $this->projectId ". "AND version = '$this->name';"; diff --git a/classes/servicecontract.class.php b/classes/servicecontract.class.php index a1096995c..5322238bb 100644 --- a/classes/servicecontract.class.php +++ b/classes/servicecontract.class.php @@ -395,7 +395,7 @@ public function getProjects() { // TODO: if type==NULL return for all types if(NULL == $this->sidetasksProjectList) { // SidetaskProjects - $query = "SELECT project.* FROM `mantis_project_table` as project ". + $query = "SELECT project.* FROM `{project}` as project ". "JOIN `codev_servicecontract_stproj_table` as servicecontract_stproj ON project.id = servicecontract_stproj.project_id ". "WHERE servicecontract_stproj.servicecontract_id = $this->id ". "ORDER BY type ASC, project.id ASC;"; diff --git a/classes/sqlwrapper.class.php b/classes/sqlwrapper.class.php index 0476e4331..5eb88d29c 100644 --- a/classes/sqlwrapper.class.php +++ b/classes/sqlwrapper.class.php @@ -130,11 +130,17 @@ public static function sql_connect($server, $username, $password, $database_name * @return resource For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returns a resource on success, or false on error. * For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, returns true on success or false on error. */ - public function sql_query($query) { + public function sql_query($p_query) { if (self::$logger->isDebugEnabled()) { $start = microtime(true); } + // replace {bug} => mantis_bug_table + $query = strtr($p_query, array( + '{' => Constants::$mantis_db_table_prefix, + '}' => Constants::$mantis_db_table_suffix, + ) ); + $result = mysql_query($query, $this->link); $this->count++; @@ -404,4 +410,3 @@ public function logStats() { SqlWrapper::staticInit(); -?> diff --git a/classes/team.class.php b/classes/team.class.php index 8e77315bc..4ef54e8cb 100644 --- a/classes/team.class.php +++ b/classes/team.class.php @@ -343,7 +343,7 @@ public function getProjects($noStatsProject = true, $withDisabled = true, $sideT if(!array_key_exists($key, $this->projectIdsCache)) { $query = "SELECT project.id, project.name ". - "FROM `mantis_project_table` as project ". + "FROM `{project}` as project ". "JOIN `codev_team_project_table` as team_project ON project.id = team_project.project_id ". "WHERE team_project.team_id = $this->id "; @@ -390,7 +390,7 @@ public function getTrueProjects($noStatsProject = true, $withDisabled = true) { if(!array_key_exists($key, $this->projectIdsCache)) { $query = "SELECT project.* ". - "FROM `mantis_project_table` as project ". + "FROM `{project}` as project ". "JOIN `codev_team_project_table` as team_project ON project.id = team_project.project_id ". "WHERE team_project.team_id = $this->id "; @@ -429,7 +429,7 @@ public function getTrueProjects($noStatsProject = true, $withDisabled = true) { public function getMembers() { if(NULL == $this->members) { $query = "SELECT user.id, user.username ". - "FROM `mantis_user_table` as user ". + "FROM `{user}` as user ". "JOIN `codev_team_user_table` as team_user ON user.id = team_user.user_id ". "WHERE team_user.team_id=$this->id ". "ORDER BY user.username;"; @@ -479,7 +479,7 @@ public function getActiveMembers($startTimestamp=NULL, $endTimestamp=NULL, $user } $query = "SELECT user.id, user.username, user.realname ". - "FROM `mantis_user_table` as user ". + "FROM `{user}` as user ". "JOIN `codev_team_user_table` as team_user ON user.id = team_user.user_id ". "AND team_user.team_id=$this->id ". "AND team_user.access_level IN (".self::accessLevel_dev.', '.self::accessLevel_manager.') '. @@ -548,7 +548,7 @@ public function getTeamIssueList($addUnassignedIssues = false, $withDisabledProj } $query = "SELECT * ". - "FROM `mantis_bug_table` ". + "FROM `{bug}` ". "WHERE project_id IN ($formatedProjects) ". "AND handler_id IN ($formatedMembers) "; @@ -591,7 +591,7 @@ public function getCurrentIssueList($addUnassignedIssues = false, $addNewIssues // get Issues that are not Resolved/Closed $query = "SELECT * ". - "FROM `mantis_bug_table` ". + "FROM `{bug}` ". "WHERE status < get_project_resolved_status_threshold(project_id) ". "AND project_id IN ($formatedProjects) ". "AND handler_id IN ($formatedMembers) "; @@ -977,7 +977,7 @@ public function getUsers() { if(NULL == $this->members) { $query = "SELECT user.* ". - "FROM `mantis_user_table` as user ". + "FROM `{user}` as user ". "JOIN `codev_team_user_table` as team_user ON user.id = team_user.user_id ". "WHERE team_user.team_id = $this->id ". "ORDER BY user.username;"; @@ -1011,7 +1011,7 @@ public function getOtherProjects($withDisabledProjects = true) { $projects = $this->getProjects(true, $withDisabledProjects); $formatedCurProjList = implode( ', ', array_keys($projects)); - $query = "SELECT id, name FROM `mantis_project_table`"; + $query = "SELECT id, name FROM `{project}`"; if($projects != NULL && count($projects) != 0) { $query .= " WHERE id NOT IN ($formatedCurProjList)"; @@ -1104,13 +1104,13 @@ public function getUnassignedTasks() { $issueList = array(); $query_projects = "SELECT project.id ". - "FROM `mantis_project_table` as project ". + "FROM `{project}` as project ". "JOIN `codev_team_project_table` as team_project ON project.id = team_project.project_id ". "WHERE team_project.team_id = $this->id ". "AND team_project.type NOT IN (".Project::type_noStatsProject.', '.Project::type_sideTaskProject.') '; $query = "SELECT * ". - "FROM `mantis_bug_table` ". + "FROM `{bug}` ". "WHERE project_id IN ($query_projects) ". "AND handler_id = '0' ". "AND status < get_project_resolved_status_threshold(project_id) ". diff --git a/classes/time_track.class.php b/classes/time_track.class.php index c00ac4421..e164170b3 100644 --- a/classes/time_track.class.php +++ b/classes/time_track.class.php @@ -289,8 +289,8 @@ public function getNote() { if (NULL == $this->note) { - $query = "SELECT note FROM `mantis_bugnote_text_table` ". - "WHERE id=(SELECT bugnote_text_id FROM `mantis_bugnote_table` ". + $query = "SELECT note FROM `{bugnote_text}` ". + "WHERE id=(SELECT bugnote_text_id FROM `{bugnote}` ". "WHERE bugnote_text_id=(SELECT noteid FROM `codev_timetrack_note_table` ". "WHERE timetrackid=$this->id))"; $result = SqlWrapper::getInstance()->sql_query($query); diff --git a/classes/time_tracking.class.php b/classes/time_tracking.class.php index 581137745..b1d84af9b 100644 --- a/classes/time_tracking.class.php +++ b/classes/time_tracking.class.php @@ -242,7 +242,7 @@ public function getAvailableWorkload() { // For all the users of the team $query = "SELECT user.* ". - "FROM `mantis_user_table` as user ". + "FROM `{user}` as user ". "JOIN `codev_team_user_table` as team_user ON user.id = team_user.user_id ". "WHERE team_user.team_id = $this->team_id ". "AND team_user.access_level IN ($accessLevel_dev, $accessLevel_manager);"; @@ -290,8 +290,8 @@ public function getTimeDriftStats() { // all issues which deliveryDate is in the period. $query = "SELECT bug.* ". - "FROM `mantis_bug_table` as bug ". - "JOIN `mantis_custom_field_string_table` as field ON bug.id = field.bug_id ". + "FROM `{bug}` as bug ". + "JOIN `{custom_field_string}` as field ON bug.id = field.bug_id ". "WHERE field.field_id = $deliveryDateCustomField ". "AND field.value >= $this->startTimestamp AND field.value < $this->endTimestamp ". "ORDER BY bug.id ASC;"; @@ -347,19 +347,19 @@ public function getResolvedIssues($extRefOnly = FALSE, $withReopened=FALSE) { // all bugs which status changed to 'resolved' whthin the timestamp $query = "SELECT bug.* ". - "FROM `mantis_bug_table` as bug "; + "FROM `{bug}` as bug "; if ($extRefOnly) { - $query .= ", `mantis_custom_field_string_table` "; + $query .= ", `{custom_field_string}` "; } - $query .= ", `mantis_bug_history_table` as history ". + $query .= ", `{bug_history}` as history ". "WHERE bug.project_id IN ($formatedProjList) ". "AND bug.id = history.bug_id "; if ($extRefOnly) { - $query .= "AND mantis_custom_field_string_table.bug_id = bug.id "; - $query .= "AND mantis_custom_field_string_table.field_id = $extIdField "; - $query .= "AND mantis_custom_field_string_table.value <> '' "; + $query .= "AND {custom_field_string}.bug_id = bug.id "; + $query .= "AND {custom_field_string}.field_id = $extIdField "; + $query .= "AND {custom_field_string}.value <> '' "; } $query .= "AND history.field_name='status' ". @@ -844,8 +844,8 @@ public function getWeekDetails($userid, $isTeamProjOnly=false) { $formatedProjList = implode( ', ', array_keys($projList)); $query = "SELECT timetracking.bugid, timetracking.jobid, timetracking.date, timetracking.duration ". "FROM `codev_timetracking_table` as timetracking ". - "JOIN `mantis_bug_table` AS bug ON timetracking.bugid = bug.id ". - "JOIN `mantis_project_table` AS project ON bug.project_id = project.id ". + "JOIN `{bug}` AS bug ON timetracking.bugid = bug.id ". + "JOIN `{project}` AS project ON bug.project_id = project.id ". "WHERE timetracking.userid = $userid ". "AND timetracking.date >= $this->startTimestamp AND timetracking.date < $this->endTimestamp ". "AND bug.project_id in ($formatedProjList);"; @@ -890,7 +890,7 @@ public function getProjectTracks($isTeamProjOnly=false) { // For all bugs in timestamp $query = "SELECT bug.id as bugid, bug.project_id, timetracking.jobid, SUM(timetracking.duration) as duration ". - "FROM `codev_timetracking_table` as timetracking, `codev_team_user_table` as team_user, `mantis_bug_table` as bug, `codev_job_table` as job, `mantis_project_table` as project ". + "FROM `codev_timetracking_table` as timetracking, `codev_team_user_table` as team_user, `{bug}` as bug, `codev_job_table` as job, `{project}` as project ". "WHERE team_user.user_id = timetracking.userid ". "AND bug.id = timetracking.bugid ". "AND project.id = bug.project_id ". @@ -950,12 +950,12 @@ public function getReopened() { // all bugs which resolution changed to 'reopened' whthin the timestamp // having an ExternalReference $query = "SELECT bug.*" . - "FROM `mantis_custom_field_string_table`, `mantis_bug_table` as bug ". - "JOIN `mantis_bug_history_table` as history ON bug.id = history.bug_id " . + "FROM `{custom_field_string}`, `{bug}` as bug ". + "JOIN `{bug_history}` as history ON bug.id = history.bug_id " . "WHERE bug.project_id IN ($formatedProjList) " . - "AND mantis_custom_field_string_table.bug_id = bug.id ". - "AND mantis_custom_field_string_table.field_id = $extIdField ". - "AND mantis_custom_field_string_table.value <> '' ". + "AND {custom_field_string}.bug_id = bug.id ". + "AND {custom_field_string}.field_id = $extIdField ". + "AND {custom_field_string}.value <> '' ". "AND history.field_name='status' " . "AND history.date_modified >= $this->startTimestamp AND history.date_modified < $this->endTimestamp " . "AND history.old_value >= get_project_resolved_status_threshold(bug.project_id) " . @@ -998,9 +998,9 @@ public function getSubmitted($extRefOnly = FALSE) { $extIdField = Config::getInstance()->getValue(Config::id_customField_ExtId); $query = "SELECT COUNT(bug.id) as count ". - "FROM `mantis_bug_table` as bug "; + "FROM `{bug}` as bug "; if ($extRefOnly) { - $query .= ", `mantis_custom_field_string_table` "; + $query .= ", `{custom_field_string}` "; } $query .= "WHERE bug.date_submitted >= $this->startTimestamp AND bug.date_submitted < $this->endTimestamp "; @@ -1011,9 +1011,9 @@ public function getSubmitted($extRefOnly = FALSE) { $query .= " AND bug.project_id IN ($formatedProjects) "; } if ($extRefOnly) { - $query .= "AND mantis_custom_field_string_table.field_id = $extIdField "; - $query .= "AND mantis_custom_field_string_table.bug_id = bug.id "; - $query .= "AND mantis_custom_field_string_table.value <> '' "; + $query .= "AND {custom_field_string}.field_id = $extIdField "; + $query .= "AND {custom_field_string}.bug_id = bug.id "; + $query .= "AND {custom_field_string}.value <> '' "; } $query .= ";"; diff --git a/classes/user.class.php b/classes/user.class.php index d2f1743fe..9ce5489f8 100644 --- a/classes/user.class.php +++ b/classes/user.class.php @@ -189,7 +189,7 @@ public function __construct($user_id, $details = NULL) { private function initialize($row) { if(NULL == $row) { $query = "SELECT username, realname, enabled " . - "FROM `mantis_user_table` " . + "FROM `{user}` " . "WHERE id = $this->id;"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -217,7 +217,7 @@ private function initialize($row) { * @return int The userid (or NULL if not found) */ public static function getUserId($name) { - $query = "SELECT id FROM `mantis_user_table` WHERE username='$name';"; + $query = "SELECT id FROM `{user}` WHERE username='$name';"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -292,7 +292,7 @@ public function getRealname() { public function getEmail() { if (NULL == $this->email) { - $query = "SELECT email FROM `mantis_user_table` WHERE id='$this->id';"; + $query = "SELECT email FROM `{user}` WHERE id='$this->id';"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -410,7 +410,7 @@ public static function exists($username) { if($username != null) { - $query = "SELECT count(*) as count FROM mantis_user_table WHERE username = '$username'"; + $query = "SELECT count(*) as count FROM `{user}` WHERE username = '$username'"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -438,7 +438,7 @@ public static function existsId($id) { if($id != null) { - $query = "SELECT count(*) as count FROM mantis_user_table WHERE id = '$id'"; + $query = "SELECT count(*) as count FROM `{user}` WHERE id = '$id'"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -936,7 +936,7 @@ public function getProjectList(array $teamList = NULL, $noStatsProject = true, $ if (0 != count($teamList)) { $formatedTeamList = implode(', ', array_keys($teamList)); $query = "SELECT DISTINCT project.id, project.name " . - "FROM `mantis_project_table` as project " . + "FROM `{project}` as project " . "JOIN `codev_team_project_table` as team_project ON project.id = team_project.project_id ". "WHERE team_project.team_id IN ($formatedTeamList) "; @@ -993,7 +993,7 @@ public function getForecastWorkload(array $projList = NULL) { $formatedProjList = implode(', ', array_keys($projList)); // find all issues i'm working on - $query = "SELECT * FROM `mantis_bug_table` " . + $query = "SELECT * FROM `{bug}` " . "WHERE project_id IN ($formatedProjList) " . "AND handler_id = $this->id " . "AND status < get_project_resolved_status_threshold(project_id) " . @@ -1046,7 +1046,7 @@ public function getAssignedIssues(array $projList = NULL, $withResolved = false) $formatedProjList = implode(', ', array_keys($projList)); - $query = "SELECT * FROM `mantis_bug_table` " . + $query = "SELECT * FROM `{bug}` " . "WHERE project_id IN ($formatedProjList) " . "AND handler_id = $this->id "; @@ -1083,8 +1083,8 @@ public function getAssignedIssues(array $projList = NULL, $withResolved = false) public function getMonitoredIssues() { if(NULL == $this->monitoredIssues) { $query = "SELECT DISTINCT bug.* " . - "FROM `mantis_bug_table` as bug ". - "JOIN `mantis_bug_monitor_table` as monitor ON bug.id = monitor.bug_id " . + "FROM `{bug}` as bug ". + "JOIN `{bug_monitor}` as monitor ON bug.id = monitor.bug_id " . "WHERE monitor.user_id = $this->id " . "ORDER BY bug.id DESC;"; @@ -1546,7 +1546,7 @@ public function getDefaultLanguage() { */ public static function getUsers() { if(NULL == self::$users) { - $query = "SELECT id, username FROM `mantis_user_table` ORDER BY username"; + $query = "SELECT id, username FROM `{user}` ORDER BY username"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { return NULL; @@ -1572,7 +1572,7 @@ public static function getUsers() { public function setProjectAccessLevel($project_id, $access_level) { // check if access rights already defined - $query = "SELECT access_level FROM `mantis_project_user_list_table` ". + $query = "SELECT access_level FROM `{project_user_list}` ". "WHERE `user_id` = $this->id AND `project_id` = $project_id "; $result = SqlWrapper::getInstance()->sql_query($query); @@ -1582,10 +1582,10 @@ public function setProjectAccessLevel($project_id, $access_level) { } if (0 == SqlWrapper::getInstance()->sql_num_rows($result)) { - $query2 = "INSERT INTO `mantis_project_user_list_table` (`user_id`, `project_id`, `access_level`) ". + $query2 = "INSERT INTO `{project_user_list}` (`user_id`, `project_id`, `access_level`) ". "VALUES ('$this->id','$project_id', '$access_level');"; } else { - $query2 = "UPDATE `mantis_project_user_list_table` ". + $query2 = "UPDATE `{project_user_list}` ". "SET access_level = '$access_level' ". "WHERE `user_id` = $this->id AND `project_id` = $project_id "; } @@ -1784,7 +1784,7 @@ public function sendTimesheetEmail($team_id = NULL, $startTimestamp=NULL, $endTi #$now = time(); #$emailDate = mktime(0, 0, 0, date('m', $now), date('d',$now), date('Y', $now)); - #SELECT count(*) FROM `mantis_email_table` WHERE `subject` LIKE '%CodevTT%' AND `email` = '$emailAddress' AND submitted= '$emailDate' + #SELECT count(*) FROM `{email}` WHERE `subject` LIKE '%CodevTT%' AND `email` = '$emailAddress' AND submitted= '$emailDate' Email::getInstance()->sendEmail( $emailAddress, $emailSubject, $emailBody ); } @@ -1879,7 +1879,7 @@ public static function createUserInMantisDB($username, $realName, $email, $passw $lastVisit = time(); $cryptedPassword = $crypto->auth_process_plain_password($password); // Insert user in mantis user table - $query = "INSERT INTO mantis_user_table (`username`, `realname`, `email`, `password`, `enabled`, `access_level`, `cookie_string`, `last_visit`, `date_created`) " + $query = "INSERT INTO `{user}` (`username`, `realname`, `email`, `password`, `enabled`, `access_level`, `cookie_string`, `last_visit`, `date_created`) " . "VALUES ('$username', '$realName', '$email', '$cryptedPassword', 1, $mantisAccessLevel, '$cookieString', $lastVisit, $entryDate)"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -1902,7 +1902,7 @@ public function affectToProject($projectId, $projectAccessLevelId = 55) if(!$project->hasMember($this->id)) { - $query = "INSERT INTO mantis_project_user_list_table (`project_id`, `user_id`, `access_level`) VALUES ($projectId, $this->id, $projectAccessLevelId)"; + $query = "INSERT INTO {project_user_list} (`project_id`, `user_id`, `access_level`) VALUES ($projectId, $this->id, $projectAccessLevelId)"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; diff --git a/classes/wbsElement.class.php b/classes/wbsElement.class.php index 2c6eea98c..58bfedd90 100644 --- a/classes/wbsElement.class.php +++ b/classes/wbsElement.class.php @@ -178,7 +178,7 @@ public static function create($bug_id, $parent_id, $root_id, $order, $title, $ic self::$logger->error("EXCEPTION stack-trace:\n" . $e->getTraceAsString()); throw $e; } - $title = null; // issue summary is stored in mantis_bug_table + $title = null; // issue summary is stored in {bug} } if (is_null($order)) { $order = 1; } @@ -220,7 +220,7 @@ public static function create($bug_id, $parent_id, $root_id, $order, $title, $ic * parse all WBSs for issues not found in mantis_bug_table. if any, remove them from the WBS. */ public static function checkWBS() { - $query0 = "SELECT root_id, bug_id FROM codev_wbs_table WHERE bug_id NOT IN (SELECT id FROM mantis_bug_table)"; + $query0 = "SELECT root_id, bug_id FROM codev_wbs_table WHERE bug_id NOT IN (SELECT id FROM {bug})"; $result0 = SqlWrapper::getInstance()->sql_query($query0); while ($row = SqlWrapper::getInstance()->sql_fetch_object($result0)) { self::$logger->warn("Issue $row->bug_id does not exist in Mantis: now removed from WBS (root = $row->root_id)"); diff --git a/config.ini.sample b/config.ini.sample index 7e6da55aa..aa5ca424f 100644 --- a/config.ini.sample +++ b/config.ini.sample @@ -25,6 +25,8 @@ db_mantis_user = "mantisdbuser" db_mantis_pass = "secret_password" [mantis] +db_table_prefix = "mantis_" +db_table_suffix = "_table" status_enum_string = "10:new,20:feedback,30:acknowledged,40:analyzed,50:open,80:resolved,82:validated,85:delivered,90:closed," priority_enum_string = "10:none,20:low,30:normal,40:high,50:urgent,60:immediate," resolution_enum_string = "10:open,20:fixed,30:reopened,40:unable to duplicate,50:not fixable,60:duplicate,70:not a bug,80:suspended,90:wont fix," diff --git a/indicator_plugins/EffortEstimReliabilityIndicator/EffortEstimReliabilityIndicator.class.php b/indicator_plugins/EffortEstimReliabilityIndicator/EffortEstimReliabilityIndicator.class.php index 4f9dc437d..c01bf9c38 100644 --- a/indicator_plugins/EffortEstimReliabilityIndicator/EffortEstimReliabilityIndicator.class.php +++ b/indicator_plugins/EffortEstimReliabilityIndicator/EffortEstimReliabilityIndicator.class.php @@ -72,18 +72,18 @@ public function getEffortEstimReliabilityRate($projects, $startTimestamp, $endTi } // all bugs which status changed to 'resolved' whthin the timestamp - $query = "SELECT mantis_bug_table.id, ". - "mantis_bug_history_table.new_value, ". - "mantis_bug_history_table.old_value, ". - "mantis_bug_history_table.date_modified ". - "FROM `mantis_bug_table`, `mantis_bug_history_table` " . - "WHERE mantis_bug_table.id = mantis_bug_history_table.bug_id " . - "AND mantis_bug_table.project_id IN ($formatedProjList) " . - "AND mantis_bug_history_table.field_name='status' " . - "AND mantis_bug_history_table.date_modified >= $startTimestamp " . - "AND mantis_bug_history_table.date_modified < $endTimestamp " . - "AND mantis_bug_history_table.new_value = $bugResolvedStatusThreshold " . - " ORDER BY mantis_bug_table.id DESC"; + $query = "SELECT {bug}.id, ". + "{bug_history}.new_value, ". + "{bug_history}.old_value, ". + "{bug_history}.date_modified ". + "FROM `{bug}`, `{bug_history}` " . + "WHERE {bug}.id = {bug_history}.bug_id " . + "AND {bug}.project_id IN ($formatedProjList) " . + "AND {bug_history}.field_name='status' " . + "AND {bug_history}.date_modified >= $startTimestamp " . + "AND {bug_history}.date_modified < $endTimestamp " . + "AND {bug_history}.new_value = $bugResolvedStatusThreshold " . + " ORDER BY {bug}.id DESC"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { diff --git a/install/codevtt_procedures.php b/install/codevtt_procedures.php index 7f2bc16bc..69d708fcc 100644 --- a/install/codevtt_procedures.php +++ b/install/codevtt_procedures.php @@ -24,7 +24,7 @@ BEGIN DECLARE status INT DEFAULT NULL; - SELECT value INTO status FROM `mantis_config_table` + SELECT value INTO status FROM `{config}` WHERE config_id = 'bug_resolved_status_threshold' AND project_id = proj_id LIMIT 1; @@ -51,7 +51,7 @@ BEGIN DECLARE proj_id INT DEFAULT NULL; - SELECT project_id INTO proj_id FROM `mantis_bug_table` + SELECT project_id INTO proj_id FROM `{bug}` WHERE id = bug_id LIMIT 1; diff --git a/install/install_step1.php b/install/install_step1.php index 653e1f6c9..5908b3de4 100644 --- a/install/install_step1.php +++ b/install/install_step1.php @@ -87,7 +87,7 @@ function checkDBConnection($db_mantis_host = 'localhost', SqlWrapper::createInstance($db_mantis_host, $db_mantis_user, $db_mantis_pass, $db_mantis_database); - $query = "SELECT * FROM `mantis_config_table` WHERE config_id = 'database_version' "; + $query = "SELECT * FROM `{config}` WHERE config_id = 'database_version' "; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { @@ -165,17 +165,23 @@ function checkDBprivileges($db_mantis_database = 'bugtracker') { * * @return NULL if Success, ErrorString if Failed */ -function createConfigFile($db_mantis_host = 'localhost', - $db_mantis_user = 'mantis', - $db_mantis_pass = '', - $db_mantis_database = 'bugtracker', - $proxy_host = NULL, - $proxy_port = NULL) { +function createConfigFile($mantisPath, + $db_mantis_host = 'localhost', + $db_mantis_user = 'mantis', + $db_mantis_pass = '', + $db_mantis_database = 'bugtracker', + $db_table_prefix = 'mantis_', + $db_table_suffix = '_table', + $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; + Constants::$mantis_db_table_prefix = $db_table_prefix; + Constants::$mantis_db_table_suffix = $db_table_suffix; + Constants::$mantisPath = $mantisPath; if (!is_null($proxy_host) && !is_null($proxy_port)) { Constants::$proxy = $proxy_host.':'.$proxy_port; @@ -189,13 +195,18 @@ function createConfigFile($db_mantis_host = 'localhost', } } -function displayDatabaseForm($originPage, $db_mantis_host, $db_mantis_database, $db_mantis_user, $db_mantis_pass) { +function displayDatabaseForm($originPage, $db_mantis_host, $db_mantis_database, $db_mantis_user, $db_mantis_pass, $path_mantis) { echo "
\n"; echo "

".T_("Mantis Database Info")."

\n"; echo "\n"; echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo " \n"; @@ -266,6 +277,9 @@ function getHttpVariable($type, $variable_name, $defaultValue=NULL, $filter = FI // ================ MAIN ================= $originPage = "install_step1.php"; +$default_path_mantis = dirname(BASE_PATH).DIRECTORY_SEPARATOR."mantis"; // "/var/www/html/mantis"; +$path_mantis = (string)getHttpVariable(INPUT_POST, 'path_mantis', $default_path_mantis); + $db_mantis_host = (string)getHttpVariable(INPUT_POST, 'db_mantis_host', 'localhost'); $db_mantis_database = (string)getHttpVariable(INPUT_POST, 'db_mantis_database', 'bugtracker'); $db_mantis_user = (string)getHttpVariable(INPUT_POST, 'db_mantis_user', Tools::isWindowsServer() ? 'root' : 'mantisdbuser'); @@ -280,7 +294,7 @@ function getHttpVariable($type, $variable_name, $defaultValue=NULL, $filter = FI $proxy_port = NULL; } -displayDatabaseForm($originPage, $db_mantis_host, $db_mantis_database, $db_mantis_user, $db_mantis_pass); +displayDatabaseForm($originPage, $db_mantis_host, $db_mantis_database, $db_mantis_user, $db_mantis_pass, $path_mantis); $action = (string)getHttpVariable(INPUT_POST, 'action', 'none'); @@ -288,13 +302,49 @@ function getHttpVariable($type, $variable_name, $defaultValue=NULL, $filter = FI try { + // --- check mantis version (config files have been moved in v1.3) + if (is_dir($path_mantis.DIRECTORY_SEPARATOR.'config')) { + // mantis v1.3 or higher + $path_mantis_config = $path_mantis.DIRECTORY_SEPARATOR.'config'; + } else { + // mantis 1.2 + $path_mantis_config = $path_mantis; + } + // retrieve db_table_prefix to check DB access + $path_config_defaults_inc = $path_mantis.DIRECTORY_SEPARATOR.'config_defaults_inc.php'; + $path_config_inc = $path_mantis_config.DIRECTORY_SEPARATOR.'config_inc.php'; + + if (!file_exists($path_config_defaults_inc)) { + throw new Exception('ERROR: File not found : '. $path_config_defaults_inc); + } + if (!file_exists($path_config_inc)) { + throw new Exception('ERROR: File not found : '. $path_config_inc); + } + include_once($path_config_defaults_inc); + include_once($path_config_inc); + + // fix prefix/suffix if missing separator + if ( !empty( $g_db_table_prefix ) && ('_' != substr( $g_db_table_prefix, -1 )) ) { + $g_db_table_prefix .= '_'; + } + if ( !empty( $g_db_table_suffix ) && ('_' != substr( $g_db_table_suffix, 0, 1 )) ) { + $g_db_table_suffix = '_' . $g_db_table_suffix; + } + + // used by SqlWrapper (checkDBConnection, checkDBprivileges) + Constants::$mantis_db_table_prefix = $g_db_table_prefix; + Constants::$mantis_db_table_suffix = $g_db_table_suffix; + $database_version = checkDBConnection($db_mantis_host, $db_mantis_user, $db_mantis_pass, $db_mantis_database); echo ""; checkDBprivileges($db_mantis_database); echo ""; - createConfigFile($db_mantis_host, $db_mantis_user, $db_mantis_pass, $db_mantis_database, $proxy_host, $proxy_port); + createConfigFile($path_mantis, + $db_mantis_host, $db_mantis_user, $db_mantis_pass, $db_mantis_database, + $g_db_table_prefix, $g_db_table_suffix, + $proxy_host, $proxy_port); echo ""; //$retCode = Tools::execSQLscript2(Install::FILENAME_TABLES); @@ -317,7 +367,7 @@ function getHttpVariable($type, $variable_name, $defaultValue=NULL, $filter = FI } echo ""; - $request = "CREATE INDEX `handler_id` ON `mantis_bug_table` (`handler_id`); "; + $request = "CREATE INDEX `handler_id` ON `{bug}` (`handler_id`); "; $result = SqlWrapper::getInstance()->sql_query($request); // Note: we do not care about the result: if failed, then the INDEX already exists. diff --git a/install/install_step2.php b/install/install_step2.php index 874270edd..acfe4ba40 100644 --- a/install/install_step2.php +++ b/install/install_step2.php @@ -51,13 +51,12 @@ function proceedStep2() { * * @return NULL if OK, or an error message starting with 'ERROR' . */ -function createConstantsFile($mantisPath, $mantisURL, $codevURL) { +function createConstantsFile($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'; @@ -98,18 +97,13 @@ function createConstantsFile($mantisPath, $mantisURL, $codevURL) { return NULL; } -function displayForm($originPage, $path_mantis, $url_mantis, $url_codevtt) { +function displayForm($originPage, $url_mantis, $url_codevtt) { echo "\n"; echo "

".T_("Get Mantis customizations")."

\n"; echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; echo " \n"; echo " \n"; @@ -157,7 +151,6 @@ function addCustomMenuItem($name, $url) { // ================ MAIN ================= $originPage = "install_step2.php"; -$default_path_mantis = dirname(BASE_PATH).DIRECTORY_SEPARATOR."mantis"; // "/var/www/html/mantis"; $hostname = Tools::isWindowsServer() ? php_uname('n') : getHostName(); $default_url_mantis = 'http://'.$hostname.'/mantis'; // 'http://'.$_SERVER['HTTP_HOST'].'/mantis'; // getHostByName(getHostName()) @@ -169,8 +162,7 @@ function addCustomMenuItem($name, $url) { $filename_custom_constants = "custom_constants_inc.php"; $filename_custom_relationships = "custom_relationships_inc.php"; -$path_mantis = filter_input(INPUT_POST, 'path_mantis'); -if (NULL == $path_mantis) { $path_mantis = $default_path_mantis; } +$path_mantis = Constants::$mantisPath; $url_mantis = filter_input(INPUT_POST, 'url_mantis'); if (NULL == $url_mantis) { $url_mantis = $default_url_mantis; } @@ -183,7 +175,7 @@ function addCustomMenuItem($name, $url) { #displayStepInfo(); #echo "
\n"; -displayForm($originPage, $path_mantis, stripslashes($url_mantis), stripslashes($url_codevtt)); +displayForm($originPage, stripslashes($url_mantis), stripslashes($url_codevtt)); if ("proceedStep2" == $action) { @@ -335,7 +327,7 @@ function addCustomMenuItem($name, $url) { } echo ""; - $errStr .= createConstantsFile($path_mantis, $url_mantis, $url_codevtt); + $errStr .= createConstantsFile($url_mantis, $url_codevtt); if (NULL != $errStr) { echo '"; } - $query = "SELECT id, name FROM `mantis_custom_field_table`"; + $query = "SELECT id, name FROM `{custom_field}`"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { throw new Exception ("create custom field FAILED"); @@ -297,7 +297,7 @@ function createCustomField($fieldName, $fieldType, $configId, $attributes = NULL $fieldId = $fieldList[$fieldName]; if (!$fieldId) { - $query2 = "INSERT INTO `mantis_custom_field_table` " . + $query2 = "INSERT INTO `{custom_field}` " . "(`name`, `type` ,`access_level_r`," . " `access_level_rw` ,`require_report` ,`require_update` ,`display_report` ,`display_update` ,`require_resolved` ,`display_resolved` ,`display_closed` ,`require_closed` "; $query2 .= ", `possible_values`, `default_value`"; @@ -410,7 +410,7 @@ function getExtIdCustomFieldCandidates() { $mType_string = 0; $mType_numeric = 1; - $query = "SELECT * FROM `mantis_custom_field_table` WHERE `type` IN ($mType_string, $mType_numeric) ORDER BY name"; + $query = "SELECT * FROM `{custom_field}` WHERE `type` IN ($mType_string, $mType_numeric) ORDER BY name"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { throw new Exception("get ExtId candidates FAILED"); @@ -773,10 +773,10 @@ function installMantisPlugin($pluginName, $isReplace=true) { } // activate plugin - $query = "INSERT INTO mantis_plugin_table (basename, enabled, protected, priority)". + $query = "INSERT INTO {plugin} (basename, enabled, protected, priority)". " SELECT * FROM (SELECT '$pluginName', '1', '0', '3') AS tmp". " WHERE NOT EXISTS (". - " SELECT basename FROM mantis_plugin_table WHERE basename = '$pluginName') LIMIT 1;"; + " SELECT basename FROM {plugin} WHERE basename = '$pluginName') LIMIT 1;"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { return "WARNING: mantis $pluginName plugin must be activated manualy"; diff --git a/install/install_step4.php b/install/install_step4.php index 0b9d61759..672c3b5de 100644 --- a/install/install_step4.php +++ b/install/install_step4.php @@ -69,14 +69,14 @@ function displayPage() { echo ''; # echo '
'; - +/* echo "

".T_("Install Firefox Greasemonkey addon")."

"; echo "".T_("Note: This step is optional").""; echo ""; - +*/ echo ""; echo "
\n"; diff --git a/install/uninstall.php b/install/uninstall.php index 6c875a076..ba0f5c88a 100644 --- a/install/uninstall.php +++ b/install/uninstall.php @@ -107,7 +107,7 @@ function displayProjectsToRemove() { // find sideTasks projects $sideTaskProj_id = Project::type_sideTaskProject; $query = "SELECT project.id, project.name ". - "FROM `mantis_project_table` as project ". + "FROM `{project}` as project ". "JOIN `codev_team_project_table` as team_project ON project.id = team_project.project_id ". "WHERE team_project.type = $sideTaskProj_id ". "ORDER BY project.name DESC;"; @@ -144,15 +144,15 @@ function removeCustomFields() { ); # delete all values - $query = "DELETE FROM `mantis_custom_field_string_table` WHERE field_id IN (".implode(', ', $fieldIds).");"; + $query = "DELETE FROM `{custom_field_string}` WHERE field_id IN (".implode(', ', $fieldIds).");"; SqlWrapper::getInstance()->sql_query($query) or die("Query FAILED: $query
".SqlWrapper::getInstance()->sql_error()."
"); # delete all project associations - $query = "DELETE FROM `mantis_custom_field_project_table` WHERE field_id IN (".implode(', ', $fieldIds).");"; + $query = "DELETE FROM `{custom_field_project}` WHERE field_id IN (".implode(', ', $fieldIds).");"; SqlWrapper::getInstance()->sql_query($query) or die("Query FAILED: $query
".SqlWrapper::getInstance()->sql_error()."
"); # delete the definition - $query = "DELETE FROM `mantis_custom_field_table` WHERE id IN (".implode(', ', $fieldIds).");"; + $query = "DELETE FROM `{custom_field}` WHERE id IN (".implode(', ', $fieldIds).");"; SqlWrapper::getInstance()->sql_query($query) or die("Query FAILED: $query
".SqlWrapper::getInstance()->sql_error()."
"); #custom_field_clear_cache( $p_field_id ); diff --git a/login.php b/login.php index dd1a77661..38fe6277c 100644 --- a/login.php +++ b/login.php @@ -52,7 +52,7 @@ function login($user, $password) { $formattedUser = SqlWrapper::sql_real_escape_string($user); $formattedPass = SqlWrapper::sql_real_escape_string($password); - $query = "SELECT id, username, realname, last_visit FROM `mantis_user_table` WHERE username = '".$formattedUser."' AND password = '".$formattedPass."' AND enabled = 1;"; + $query = "SELECT id, username, realname, last_visit FROM `{user}` WHERE username = '".$formattedUser."' AND password = '".$formattedPass."' AND enabled = 1;"; $result = SqlWrapper::getInstance()->sql_query($query); if ($result && SqlWrapper::getInstance()->sql_num_rows($result) == 1 && $row_login = SqlWrapper::getInstance()->sql_fetch_object($result)) { $_SESSION['userid'] = $row_login->id; @@ -88,7 +88,7 @@ function login($user, $password) { $projid = $user->getDefaultProject(); if (0 != $projid) { $_SESSION['projectid'] = $projid; } - $query2 = "UPDATE `mantis_user_table` SET last_visit = ".$now." WHERE username = '".$formattedUser."';"; + $query2 = "UPDATE `{user}` SET last_visit = ".$now." WHERE username = '".$formattedUser."';"; SqlWrapper::getInstance()->sql_query($query2); } catch (Exception $e) { diff --git a/management/command_edit.php b/management/command_edit.php index 88478838f..1ce254c66 100644 --- a/management/command_edit.php +++ b/management/command_edit.php @@ -365,7 +365,7 @@ private function getChildIssuesCandidates($teamid) { $formattedProjectList = implode (', ', array_keys($projects)); - $query = "SELECT * FROM `mantis_bug_table` ". + $query = "SELECT * FROM `{bug}` ". "WHERE project_id IN ($formattedProjectList) ". "AND 0 = is_issue_in_team_commands(id, $teamid) ". "ORDER BY id DESC"; diff --git a/mantis_plugin/mantis_1_2/CodevTT/CodevTT.php b/mantis_plugin/mantis_1_2/CodevTT/CodevTT.php index fa0314367..c7d90ea00 100644 --- a/mantis_plugin/mantis_1_2/CodevTT/CodevTT.php +++ b/mantis_plugin/mantis_1_2/CodevTT/CodevTT.php @@ -315,7 +315,7 @@ public function bug_delete($event, $bug_id) { public function checkStatusChanged($event, BugData $bug_data) { // if status changed to 'resolved' then set Backlog = 0 - $query = 'SELECT COUNT(id) as cnt FROM `mantis_bug_table` WHERE id = ' . db_param() . ' AND ' . db_param() . ' = get_issue_resolved_status_threshold(' . db_param() . ')'; + $query = 'SELECT COUNT(id) as cnt FROM `{bug}` WHERE id = ' . db_param() . ' AND ' . db_param() . ' = get_issue_resolved_status_threshold(' . db_param() . ')'; $result = db_query_bound($query, array( $bug_data->id, $bug_data->status, $bug_data->id) ); $row = db_fetch_array( $result ); @@ -345,7 +345,7 @@ public function projectDelete($event, $project_id) { "FROM `codev_timetracking_table`, `mantis_user_table` ". "WHERE codev_timetracking_table.userid = mantis_user_table.id ". "AND codev_timetracking_table.bugid IN (". - " SELECT id FROM mantis_bug_table WHERE project_id = " . db_param() . ")"; + " SELECT id FROM {bug} WHERE project_id = " . db_param() . ")"; $errMsg = ""; $result = db_query_bound($query, array( $project_id ) ); diff --git a/mantis_plugin/mantis_1_3/CodevTT/CodevTT.php b/mantis_plugin/mantis_1_3/CodevTT/CodevTT.php index e706b00a6..f0909f3ae 100644 --- a/mantis_plugin/mantis_1_3/CodevTT/CodevTT.php +++ b/mantis_plugin/mantis_1_3/CodevTT/CodevTT.php @@ -289,12 +289,12 @@ public function view_bug_form($event, $t_bug_id) { * @param type $bug_id */ public function bug_delete($event, $bug_id) { - + $mantis_user_table = db_get_table('user'); $query = "SELECT codev_timetracking_table.date, codev_timetracking_table.userid, codev_timetracking_table.duration, ". - "mantis_user_table.username, mantis_user_table.realname ". - "FROM `codev_timetracking_table`, `mantis_user_table` ". + "$mantis_user_table.username, $mantis_user_table.realname ". + "FROM `codev_timetracking_table`, `$mantis_user_table` ". "WHERE codev_timetracking_table.bugid = " . db_param() . " ". - "AND codev_timetracking_table.userid = mantis_user_table.id "; + "AND codev_timetracking_table.userid = $mantis_user_table.id "; $errMsg = ""; $result = db_query($query, array( $bug_id ) ); @@ -334,13 +334,15 @@ public function checkStatusChanged($event, BugData $bugData_prev, BugData $bugDa * @param type $project_id */ public function projectDelete($event, $project_id) { + $mantis_user_table = db_get_table('user'); + $mantis_bug_table = db_get_table('bug'); $query = "SELECT codev_timetracking_table.bugid, codev_timetracking_table.date, codev_timetracking_table.userid, codev_timetracking_table.duration, ". - "mantis_user_table.username, mantis_user_table.realname ". - "FROM `codev_timetracking_table`, `mantis_user_table` ". - "WHERE codev_timetracking_table.userid = mantis_user_table.id ". + "$mantis_user_table.username, $mantis_user_table.realname ". + "FROM `codev_timetracking_table`, `$mantis_user_table` ". + "WHERE codev_timetracking_table.userid = $mantis_user_table.id ". "AND codev_timetracking_table.bugid IN (". - " SELECT id FROM mantis_bug_table WHERE project_id = " . db_param() . ")"; + " SELECT id FROM $mantis_bug_table WHERE project_id = " . db_param() . ")"; $errMsg = ""; $result = db_query($query, array( $project_id ) ); diff --git a/mantis_plugin/mantis_1_3/CodevTT/classes/IssueMantisPluginHelper.php b/mantis_plugin/mantis_1_3/CodevTT/classes/IssueMantisPluginHelper.php index cc6a9fbbd..377caa88e 100644 --- a/mantis_plugin/mantis_1_3/CodevTT/classes/IssueMantisPluginHelper.php +++ b/mantis_plugin/mantis_1_3/CodevTT/classes/IssueMantisPluginHelper.php @@ -56,7 +56,8 @@ public function setBacklog($backlog) { $backlogCustomField = 0; // TODO should be done only once... - $query = "SELECT name FROM mantis_custom_field_table WHERE id = " . db_param(); + $mantis_custom_field_table = db_get_table('custom_field'); + $query = "SELECT name FROM $mantis_custom_field_table WHERE id = " . db_param(); $result = db_query($query, array($backlogCustomField)); $row = db_fetch_array( $result ); @@ -66,17 +67,18 @@ public function setBacklog($backlog) { $field_name = "Backlog (BL)"; // check if backlog already defined for this issue - $query = "SELECT value FROM `mantis_custom_field_string_table` WHERE bug_id=" . db_param() . " AND field_id = " . db_param(); + $mantis_custom_field_string_table = db_get_table('custom_field_string'); + $query = "SELECT value FROM `$mantis_custom_field_string_table` WHERE bug_id=" . db_param() . " AND field_id = " . db_param(); $result = db_query($query, array( $this->id, $backlogCustomField ) ); $row = db_fetch_array( $result ); if ($row) { $old_backlog = $row['value']; - $query2 = "UPDATE mantis_custom_field_string_table SET value = " . db_param() . " WHERE bug_id=" . db_param() . " AND field_id = " . db_param(); + $query2 = "UPDATE $mantis_custom_field_string_table SET value = " . db_param() . " WHERE bug_id=" . db_param() . " AND field_id = " . db_param(); $result2 = db_query($query2, array($backlog, $this->id,$backlogCustomField)); } else { $old_backlog = ''; - $query2 = "INSERT INTO mantis_custom_field_string_table (`field_id`, `bug_id`, `value`) VALUES (" . db_param() . ", " . db_param() . ", " . db_param() . ")"; + $query2 = "INSERT INTO $mantis_custom_field_string_table (`field_id`, `bug_id`, `value`) VALUES (" . db_param() . ", " . db_param() . ", " . db_param() . ")"; $result2 = db_query($query2, array( $backlogCustomField, $this->id, $backlog )); } @@ -85,7 +87,8 @@ public function setBacklog($backlog) { if ("$old_backlog" != "$backlog") { $userid = current_user_get_field( 'id' ); $now = time(); - $query = "INSERT INTO mantis_bug_history_table (`user_id`, `bug_id`, `field_name`, `old_value`, `new_value`, `type`, `date_modified`) ". + $mantis_bug_history_table = db_get_table('bug_history'); + $query = "INSERT INTO $mantis_bug_history_table (`user_id`, `bug_id`, `field_name`, `old_value`, `new_value`, `type`, `date_modified`) ". "VALUES (" . db_param() . "," . db_param() . "," . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ")"; $result = db_query($query, array( $userid, $this->id, $field_name, $old_backlog, $backlog, 0, $now )); } diff --git a/mantis_plugin/mantis_2_0/CodevTT/CodevTT.php b/mantis_plugin/mantis_2_0/CodevTT/CodevTT.php index 774f5f5f9..49dc1360a 100644 --- a/mantis_plugin/mantis_2_0/CodevTT/CodevTT.php +++ b/mantis_plugin/mantis_2_0/CodevTT/CodevTT.php @@ -20,7 +20,7 @@ public function register() { $this->description = plugin_lang_get('description'); $this->page = ''; - $this->version = '0.7.1'; + $this->version = '0.7.2'; $this->requires = array( 'MantisCore' => '2.0' @@ -288,11 +288,12 @@ public function view_bug_form($event, $t_bug_id) { */ public function bug_delete($event, $bug_id) { + $mantis_user_table = db_get_table('user'); $query = "SELECT codev_timetracking_table.date, codev_timetracking_table.userid, codev_timetracking_table.duration, ". - "mantis_user_table.username, mantis_user_table.realname ". - "FROM `codev_timetracking_table`, `mantis_user_table` ". + "$mantis_user_table.username, $mantis_user_table.realname ". + "FROM `codev_timetracking_table`, `$mantis_user_table` ". "WHERE codev_timetracking_table.bugid = " . db_param() . " ". - "AND codev_timetracking_table.userid = mantis_user_table.id "; + "AND codev_timetracking_table.userid = $mantis_user_table.id "; $errMsg = ""; $result = db_query($query, array( $bug_id ) ); @@ -333,12 +334,14 @@ public function checkStatusChanged($event, BugData $bugData_prev, BugData $bugDa */ public function projectDelete($event, $project_id) { + $mantis_user_table = db_get_table('user'); + $mantis_bug_table = db_get_table('bug'); $query = "SELECT codev_timetracking_table.bugid, codev_timetracking_table.date, codev_timetracking_table.userid, codev_timetracking_table.duration, ". - "mantis_user_table.username, mantis_user_table.realname ". - "FROM `codev_timetracking_table`, `mantis_user_table` ". - "WHERE codev_timetracking_table.userid = mantis_user_table.id ". + "$mantis_user_table.username, $mantis_user_table.realname ". + "FROM `codev_timetracking_table`, `$mantis_user_table` ". + "WHERE codev_timetracking_table.userid = $mantis_user_table.id ". "AND codev_timetracking_table.bugid IN (". - " SELECT id FROM mantis_bug_table WHERE project_id = " . db_param() . ")"; + " SELECT id FROM $mantis_bug_table WHERE project_id = " . db_param() . ")"; $errMsg = ""; $result = db_query($query, array( $project_id ) ); diff --git a/mantis_plugin/mantis_2_0/CodevTT/classes/IssueMantisPluginHelper.php b/mantis_plugin/mantis_2_0/CodevTT/classes/IssueMantisPluginHelper.php index cc6a9fbbd..377caa88e 100644 --- a/mantis_plugin/mantis_2_0/CodevTT/classes/IssueMantisPluginHelper.php +++ b/mantis_plugin/mantis_2_0/CodevTT/classes/IssueMantisPluginHelper.php @@ -56,7 +56,8 @@ public function setBacklog($backlog) { $backlogCustomField = 0; // TODO should be done only once... - $query = "SELECT name FROM mantis_custom_field_table WHERE id = " . db_param(); + $mantis_custom_field_table = db_get_table('custom_field'); + $query = "SELECT name FROM $mantis_custom_field_table WHERE id = " . db_param(); $result = db_query($query, array($backlogCustomField)); $row = db_fetch_array( $result ); @@ -66,17 +67,18 @@ public function setBacklog($backlog) { $field_name = "Backlog (BL)"; // check if backlog already defined for this issue - $query = "SELECT value FROM `mantis_custom_field_string_table` WHERE bug_id=" . db_param() . " AND field_id = " . db_param(); + $mantis_custom_field_string_table = db_get_table('custom_field_string'); + $query = "SELECT value FROM `$mantis_custom_field_string_table` WHERE bug_id=" . db_param() . " AND field_id = " . db_param(); $result = db_query($query, array( $this->id, $backlogCustomField ) ); $row = db_fetch_array( $result ); if ($row) { $old_backlog = $row['value']; - $query2 = "UPDATE mantis_custom_field_string_table SET value = " . db_param() . " WHERE bug_id=" . db_param() . " AND field_id = " . db_param(); + $query2 = "UPDATE $mantis_custom_field_string_table SET value = " . db_param() . " WHERE bug_id=" . db_param() . " AND field_id = " . db_param(); $result2 = db_query($query2, array($backlog, $this->id,$backlogCustomField)); } else { $old_backlog = ''; - $query2 = "INSERT INTO mantis_custom_field_string_table (`field_id`, `bug_id`, `value`) VALUES (" . db_param() . ", " . db_param() . ", " . db_param() . ")"; + $query2 = "INSERT INTO $mantis_custom_field_string_table (`field_id`, `bug_id`, `value`) VALUES (" . db_param() . ", " . db_param() . ", " . db_param() . ")"; $result2 = db_query($query2, array( $backlogCustomField, $this->id, $backlog )); } @@ -85,7 +87,8 @@ public function setBacklog($backlog) { if ("$old_backlog" != "$backlog") { $userid = current_user_get_field( 'id' ); $now = time(); - $query = "INSERT INTO mantis_bug_history_table (`user_id`, `bug_id`, `field_name`, `old_value`, `new_value`, `type`, `date_modified`) ". + $mantis_bug_history_table = db_get_table('bug_history'); + $query = "INSERT INTO $mantis_bug_history_table (`user_id`, `bug_id`, `field_name`, `old_value`, `new_value`, `type`, `date_modified`) ". "VALUES (" . db_param() . "," . db_param() . "," . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ")"; $result = db_query($query, array( $userid, $this->id, $field_name, $old_backlog, $backlog, 0, $now )); } diff --git a/plugins/EffortEstimReliabilityIndicator2/EffortEstimReliabilityIndicator2.class.php b/plugins/EffortEstimReliabilityIndicator2/EffortEstimReliabilityIndicator2.class.php index e093f7ca0..797cc939b 100644 --- a/plugins/EffortEstimReliabilityIndicator2/EffortEstimReliabilityIndicator2.class.php +++ b/plugins/EffortEstimReliabilityIndicator2/EffortEstimReliabilityIndicator2.class.php @@ -200,18 +200,18 @@ private function getEffortEstimReliabilityRate($startTimestamp, $endTimestamp) { // -------- // all bugs which status changed to 'resolved' within the timestamp - $query = "SELECT mantis_bug_table.id, ". - "mantis_bug_history_table.new_value, ". - "mantis_bug_history_table.old_value, ". - "mantis_bug_history_table.date_modified ". - "FROM `mantis_bug_table`, `mantis_bug_history_table` " . - "WHERE mantis_bug_table.id = mantis_bug_history_table.bug_id " . - "AND mantis_bug_table.id IN ($this->formatedBugidList) " . - "AND mantis_bug_history_table.field_name='status' " . - "AND mantis_bug_history_table.date_modified >= $startTimestamp " . - "AND mantis_bug_history_table.date_modified < $endTimestamp " . - "AND mantis_bug_history_table.new_value = $this->bugResolvedStatusThreshold " . - "ORDER BY mantis_bug_table.id DESC"; + $query = "SELECT {bug}.id, ". + "{bug_history}.new_value, ". + "{bug_history}.old_value, ". + "{bug_history}.date_modified ". + "FROM `{bug}`, `{bug_history}` " . + "WHERE {bug}.id = {bug_history}.bug_id " . + "AND {bug}.id IN ($this->formatedBugidList) " . + "AND {bug_history}.field_name='status' " . + "AND {bug_history}.date_modified >= $startTimestamp " . + "AND {bug_history}.date_modified < $endTimestamp " . + "AND {bug_history}.new_value = $this->bugResolvedStatusThreshold " . + "ORDER BY {bug}.id DESC"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { diff --git a/plugins/LoadPerProjectIndicator/LoadPerProjectIndicator.class.php b/plugins/LoadPerProjectIndicator/LoadPerProjectIndicator.class.php index 3f7dde2e7..19aa1540d 100644 --- a/plugins/LoadPerProjectIndicator/LoadPerProjectIndicator.class.php +++ b/plugins/LoadPerProjectIndicator/LoadPerProjectIndicator.class.php @@ -196,7 +196,7 @@ public function execute() { $formatedBugidString = implode( ', ', array_keys($issueList)); $query = "SELECT ROUND(SUM(tt.duration), 2) as duration, prj.name as prjName - FROM codev_timetracking_table as tt, mantis_project_table as prj, mantis_bug_table as bug + FROM codev_timetracking_table as tt, {project} as prj, {bug} as bug WHERE tt.bugid = bug.id AND bug.project_id = prj.id AND bug.id IN ($formatedBugidString) diff --git a/plugins/MoveIssueTimetracks/MoveIssueTimetracks.class.php b/plugins/MoveIssueTimetracks/MoveIssueTimetracks.class.php index de4baf004..e09aa1e1c 100644 --- a/plugins/MoveIssueTimetracks/MoveIssueTimetracks.class.php +++ b/plugins/MoveIssueTimetracks/MoveIssueTimetracks.class.php @@ -236,7 +236,7 @@ public function moveTimetracks($timetracksIds, $destBugId) } // move timetrack notes - $query2 = "UPDATE `mantis_bugnote_table` SET bug_id='$destBugId' where id in (select noteid FROM codev_timetrack_note_table where timetrackid in ($formatedTimetracksIds))"; + $query2 = "UPDATE `{bugnote}` SET bug_id='$destBugId' where id in (select noteid FROM codev_timetrack_note_table where timetrackid in ($formatedTimetracksIds))"; $result2 = SqlWrapper::getInstance()->sql_query($query2); if (!$result2) { echo "ERROR: Query FAILED"; diff --git a/plugins/ReopenedRateIndicator2/ReopenedRateIndicator2.class.php b/plugins/ReopenedRateIndicator2/ReopenedRateIndicator2.class.php index 893ab5ba5..3851f6b1d 100644 --- a/plugins/ReopenedRateIndicator2/ReopenedRateIndicator2.class.php +++ b/plugins/ReopenedRateIndicator2/ReopenedRateIndicator2.class.php @@ -182,8 +182,8 @@ private function getReopened($formattedBugidList, $start, $end) { // 1) get all reopened bugs within the timestamp $query = "SELECT bug.* " . - "FROM `mantis_bug_table` as bug ". - "JOIN `mantis_bug_history_table` as history ON bug.id = history.bug_id " . + "FROM `{bug}` as bug ". + "JOIN `{bug_history}` as history ON bug.id = history.bug_id " . "WHERE bug.id IN ($formattedBugidList) " . "AND history.field_name='status' " . "AND history.date_modified >= $start AND history.date_modified < $end " . @@ -231,8 +231,8 @@ private function getReopened($formattedBugidList, $start, $end) { private function getValidated($formattedBugidList, $start, $end) { $query = "SELECT bug.* ". - "FROM `mantis_bug_table` as bug ". - "JOIN `mantis_bug_history_table` as history ON bug.id = history.bug_id " . + "FROM `{bug}` as bug ". + "JOIN `{bug_history}` as history ON bug.id = history.bug_id " . "WHERE bug.id IN ($formattedBugidList) " . "AND history.field_name='status' " . "AND history.date_modified >= $start AND history.date_modified < $end " . @@ -278,7 +278,7 @@ private function getResolved($formattedBugidList, $start, $end) { // all bugs which status changed to 'resolved' whthin the timestamp $query = "SELECT bug.id ". - "FROM `mantis_bug_table` as bug, `mantis_bug_history_table` as history ". + "FROM `{bug}` as bug, `{bug_history}` as history ". "WHERE bug.id IN ($formattedBugidList) " . "AND bug.id = history.bug_id ". "AND history.field_name='status' ". diff --git a/plugins/UserTeamList/UserTeamList.class.php b/plugins/UserTeamList/UserTeamList.class.php index 4a368b819..799e61e3a 100644 --- a/plugins/UserTeamList/UserTeamList.class.php +++ b/plugins/UserTeamList/UserTeamList.class.php @@ -124,7 +124,7 @@ public function setPluginSettings($pluginSettings) { */ public function execute() { - $query = "SELECT id, realname FROM `mantis_user_table` ORDER BY realname;"; + $query = "SELECT id, realname FROM `{user}` ORDER BY realname;"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { diff --git a/reports/export_csv_tools.php b/reports/export_csv_tools.php index 9622cd359..081e0ecc8 100644 --- a/reports/export_csv_tools.php +++ b/reports/export_csv_tools.php @@ -78,7 +78,7 @@ public static function exportManagedIssuesToCSV($teamid, $startTimestamp, $endTi // for all issues with status != {resolved, closed} - $query = "SELECT * FROM `mantis_bug_table` ". + $query = "SELECT * FROM `{bug}` ". "WHERE status < get_project_resolved_status_threshold(project_id) ". "AND project_id IN ($formatedProjList) ". //"AND handler_id IN ($formatedMemberList) ". @@ -137,7 +137,7 @@ public static function exportManagedIssuesToCSV($teamid, $startTimestamp, $endTi } // Add resolved issues modified into the period - $query = "SELECT * FROM `mantis_bug_table` ". + $query = "SELECT * FROM `{bug}` ". "WHERE status >= get_project_resolved_status_threshold(project_id) ". "AND project_id IN ($formatedProjList) ". //"AND handler_id IN ($formatedMemberList) ". diff --git a/reports/export_csv_weekly.php b/reports/export_csv_weekly.php index b801bcbd7..7ad482a7c 100644 --- a/reports/export_csv_weekly.php +++ b/reports/export_csv_weekly.php @@ -177,11 +177,11 @@ private function exportWeekActivityReportToCSV($teamid, $weekDates, $timeTrackin Tools::formatDate("%A %d/%m", $weekDates[5])."\n"; fwrite($fh, $stringData); - $query = "SELECT codev_team_user_table.user_id, mantis_user_table.realname ". - "FROM `codev_team_user_table`, `mantis_user_table` ". + $query = "SELECT codev_team_user_table.user_id, {user}.realname ". + "FROM `codev_team_user_table`, `{user}` ". "WHERE codev_team_user_table.team_id = $teamid ". - "AND codev_team_user_table.user_id = mantis_user_table.id ". - "ORDER BY mantis_user_table.realname"; + "AND codev_team_user_table.user_id = {user}.id ". + "ORDER BY {user}.realname"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { diff --git a/reports/export_odt.php b/reports/export_odt.php index 16dfd4803..a9e309e03 100644 --- a/reports/export_odt.php +++ b/reports/export_odt.php @@ -191,7 +191,7 @@ private function getTeamMembers(array $selectedUseridList = array(0)) { */ private function getIssueSelection($projectid, $categories = NULL, $formattedReporters = NULL, $formattedHandlers = NULL, $formattedStatuses = false) { - $query = "SELECT id from `mantis_bug_table` WHERE project_id = $projectid "; + $query = "SELECT id from `{bug}` WHERE project_id = $projectid "; if (!empty($categories)) { $query .= "AND category_id IN ($categories) "; diff --git a/tests/bvi.php b/tests/bvi.php index 51953daf6..16d53402d 100644 --- a/tests/bvi.php +++ b/tests/bvi.php @@ -52,7 +52,7 @@ private function getResolvedIssues($teamid, $userid = 0, $projects = NULL) { $formattedUsers = (0 != $userid) ? $userid : implode(',', array_keys($team->getActiveMembers())); - $query = "SELECT id FROM `mantis_bug_table` ". + $query = "SELECT id FROM `{bug}` ". "WHERE project_id IN ($formattedProjects) ". "AND handler_id IN ($formattedUsers) ". "AND status >= get_project_resolved_status_threshold(project_id) "; diff --git a/tools.php b/tools.php index 7f3bffe45..121b72afa 100644 --- a/tools.php +++ b/tools.php @@ -57,7 +57,7 @@ public static function checkPhpVersion($checkVersion = "5.3") { public static function isMantisV1_2() { if (is_null(self::$MantisDbVersion)) { - $query = "SELECT value FROM `mantis_config_table` WHERE `config_id` = 'database_version';"; + $query = "SELECT value FROM `{config}` WHERE `config_id` = 'database_version';"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; @@ -1266,7 +1266,7 @@ public static function createCustomField($fieldName, $fieldType, $configId, $att echo "WARN: using default attributes for CustomField $fieldName
"; } - $query = "SELECT id, name FROM `mantis_custom_field_table`"; + $query = "SELECT id, name FROM `{custom_field}`"; $result = mysql_query($query) or die("Query FAILED: $query
" . mysql_error() . "
"); while ($row = mysql_fetch_object($result)) { $fieldList["$row->name"] = $row->id; @@ -1274,7 +1274,7 @@ public static function createCustomField($fieldName, $fieldType, $configId, $att $fieldId = $fieldList[$fieldName]; if (!$fieldId) { - $query2 = "INSERT INTO `mantis_custom_field_table` " . + $query2 = "INSERT INTO `{custom_field}` " . "(`name`, `type` ,`access_level_r`," . " `access_level_rw` ,`require_report` ,`require_update` ,`display_report` ,`display_update` ,`require_resolved` ,`display_resolved` ,`display_closed` ,`require_closed` "; $query2 .= ", `possible_values`, `default_value`"; @@ -1444,7 +1444,7 @@ public static function getCustomFieldName($customFieldId) { $customField_type = Config::getInstance()->getValue(Config::id_customField_type); self::$customFieldNames = array(); - $query = "SELECT id, name FROM `mantis_custom_field_table` "; + $query = "SELECT id, name FROM `{custom_field}` "; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "ERROR: Query FAILED"; diff --git a/tools/checkWBS.php b/tools/checkWBS.php index dcf0be9ad..3ed12084d 100644 --- a/tools/checkWBS.php +++ b/tools/checkWBS.php @@ -51,7 +51,7 @@ function logMessage($bugid, $errMsg) { // check removed issues echo "
=================
Check issues to remove from Command (removed from mantis)
"; - $query0 = "SELECT command_id, bug_id FROM codev_command_bug_table WHERE bug_id NOT IN (SELECT id FROM mantis_bug_table)"; + $query0 = "SELECT command_id, bug_id FROM codev_command_bug_table WHERE bug_id NOT IN (SELECT id FROM {bug})"; $result0 = execQuery($query0); while ($row = SqlWrapper::getInstance()->sql_fetch_object($result0)) { $errMsg = "ERROR issue $row->bug_id does not exist in Mantis but is still defined in Command $row->command_id"; @@ -64,7 +64,7 @@ function logMessage($bugid, $errMsg) { // check removed issues echo "Check issues to remove from WBS (removed from mantis)
"; - $query0 = "SELECT root_id, bug_id FROM codev_wbs_table WHERE bug_id NOT IN (SELECT id FROM mantis_bug_table)"; + $query0 = "SELECT root_id, bug_id FROM codev_wbs_table WHERE bug_id NOT IN (SELECT id FROM {bug})"; $result0 = execQuery($query0); while ($row = SqlWrapper::getInstance()->sql_fetch_object($result0)) { $errMsg = "ERROR issue $row->bug_id does not exist in Mantis but is still defined in WBS (root = $row->root_id)"; @@ -163,7 +163,7 @@ function logMessage($bugid, $errMsg) { } - // "SELECT * FROM codev_command_bug_table WHERE bug_id NOT IN (SELECT id FROM mantis_bug_table)"; + // "SELECT * FROM codev_command_bug_table WHERE bug_id NOT IN (SELECT id FROM {bug})"; } else { echo "Sorry, you're not identified as a CodevTT administrator."; } diff --git a/tools/create_fake_db.php b/tools/create_fake_db.php index cafad92ca..eb8a1c677 100644 --- a/tools/create_fake_db.php +++ b/tools/create_fake_db.php @@ -89,7 +89,7 @@ function create_fake_db($formattedFieldList) { $j = 0; // all prj except SideTasksProjects (and externalTasksPrj) - $resProjects = execQuery("SELECT * from `mantis_project_table` WHERE id NOT IN (SELECT DISTINCT project_id FROM `codev_team_project_table` WHERE type = 1)"); + $resProjects = execQuery("SELECT * from `{project}` WHERE id NOT IN (SELECT DISTINCT project_id FROM `codev_team_project_table` WHERE type = 1)"); while($rowPrj = SqlWrapper::getInstance()->sql_fetch_object($resProjects)) { $projid = $rowPrj->id; @@ -98,35 +98,35 @@ function create_fake_db($formattedFieldList) { // change project name - execQuery("UPDATE `mantis_project_table` SET `name`='Project_".$projid."' where `id`='$projid'"); + execQuery("UPDATE `{project}` SET `name`='Project_".$projid."' where `id`='$projid'"); $j++; - execQuery("DELETE FROM `mantis_email_table` "); + execQuery("DELETE FROM `{email}` "); // clean project issues - $result1 = execQuery("SELECT * from `mantis_bug_table` WHERE `project_id`='$projid'"); + $result1 = execQuery("SELECT * from `{bug}` WHERE `project_id`='$projid'"); $i = 0; while($row = SqlWrapper::getInstance()->sql_fetch_object($result1)) { $i++; #echo "process project $projid issue $row->id"; - $query = "UPDATE `mantis_bug_table` SET `summary`='task p".$projid."_".$row->id." ' WHERE `id`='$row->id' "; + $query = "UPDATE `{bug}` SET `summary`='task p".$projid."_".$row->id." ' WHERE `id`='$row->id' "; execQuery($query); - $query = "UPDATE `mantis_bug_text_table` SET `description`='this is a fake issue...' WHERE `id`='$row->bug_text_id' "; + $query = "UPDATE `{bug_text}` SET `description`='this is a fake issue...' WHERE `id`='$row->bug_text_id' "; execQuery($query); - $query = "DELETE FROM `mantis_bugnote_table` WHERE `bug_id`='$row->id' "; + $query = "DELETE FROM `{bugnote}` WHERE `bug_id`='$row->id' "; execQuery($query); - $query = "UPDATE `mantis_bug_revision_table` SET `value` = 'revision on fake issue' WHERE `bug_id`='$row->id' "; + $query = "UPDATE `{bug_revision}` SET `value` = 'revision on fake issue' WHERE `bug_id`='$row->id' "; execQuery($query); - $query = "DELETE FROM `mantis_bug_history_table` WHERE `bug_id`='$row->id' AND `field_name` IN ($formattedFieldList)"; + $query = "DELETE FROM `{bug_history}` WHERE `bug_id`='$row->id' AND `field_name` IN ($formattedFieldList)"; execQuery($query); - $query = "UPDATE `mantis_custom_field_string_table` SET `value`='R".($projid*2).($i*231)."' WHERE `field_id`='".$extIdField."' AND `bug_id`='$row->id' AND `value` <> '' "; + $query = "UPDATE `{custom_field_string}` SET `value`='R".($projid*2).($i*231)."' WHERE `field_id`='".$extIdField."' AND `bug_id`='$row->id' AND `value` <> '' "; execQuery($query); @@ -186,43 +186,43 @@ function updateUsers() { global $mgrId; global $lbayleId; - $query = "SELECT id from `mantis_user_table` WHERE id NOT IN (1, $lbayleId, $mgrId, $usrId)"; // administrator, manager, lbayle, user1 + $query = "SELECT id from `{user}` WHERE id NOT IN (1, $lbayleId, $mgrId, $usrId)"; // administrator, manager, lbayle, user1 $result1 = execQuery($query); $i = 0; while($row = SqlWrapper::getInstance()->sql_fetch_object($result1)) { $i++; - $query = "UPDATE `mantis_user_table` SET `realname` = 'User NAME".$row->id."' WHERE `id` ='$row->id' "; + $query = "UPDATE `{user}` SET `realname` = 'User NAME".$row->id."' WHERE `id` ='$row->id' "; execQuery($query); - $query = "UPDATE `mantis_user_table` SET `username` = 'user".$row->id."' WHERE `id` ='$row->id' "; + $query = "UPDATE `{user}` SET `username` = 'user".$row->id."' WHERE `id` ='$row->id' "; execQuery($query); - $query = "UPDATE `mantis_user_table` SET `email` = 'user".$row->id."@yahoo.com' WHERE `id` ='$row->id' "; + $query = "UPDATE `{user}` SET `email` = 'user".$row->id."@yahoo.com' WHERE `id` ='$row->id' "; execQuery($query); - $query = "UPDATE `mantis_user_table` SET `password` = '5ebe2294ecd0e0f08eab7690d2a6ee69' WHERE `id` ='$row->id' "; + $query = "UPDATE `{user}` SET `password` = '5ebe2294ecd0e0f08eab7690d2a6ee69' WHERE `id` ='$row->id' "; execQuery($query); } // john the manager - $query = "UPDATE `mantis_user_table` SET `realname` = 'John the MANAGER' WHERE `id` ='$mgrId' "; + $query = "UPDATE `{user}` SET `realname` = 'John the MANAGER' WHERE `id` ='$mgrId' "; execQuery($query); - $query = "UPDATE `mantis_user_table` SET `username` = 'manager' WHERE `id` ='$mgrId' "; + $query = "UPDATE `{user}` SET `username` = 'manager' WHERE `id` ='$mgrId' "; execQuery($query); - $query = "UPDATE `mantis_user_table` SET `email` = 'manager@yahoo.com' WHERE `id` ='$mgrId' "; + $query = "UPDATE `{user}` SET `email` = 'manager@yahoo.com' WHERE `id` ='$mgrId' "; execQuery($query); - $query = "UPDATE `mantis_user_table` SET `password` = 'e26f604637ae454f792f4fcbff878bd1' WHERE `id` ='$mgrId' "; + $query = "UPDATE `{user}` SET `password` = 'e26f604637ae454f792f4fcbff878bd1' WHERE `id` ='$mgrId' "; execQuery($query); // passwd: manager2012 // user1 - $query = "UPDATE `mantis_user_table` SET `realname` = 'User ONE' WHERE `id` ='$usrId' "; + $query = "UPDATE `{user}` SET `realname` = 'User ONE' WHERE `id` ='$usrId' "; execQuery($query); - $query = "UPDATE `mantis_user_table` SET `username` = 'user1' WHERE `id` ='$usrId' "; + $query = "UPDATE `{user}` SET `username` = 'user1' WHERE `id` ='$usrId' "; execQuery($query); - $query = "UPDATE `mantis_user_table` SET `email` = 'user1@yahoo.com' WHERE `id` ='$usrId' "; + $query = "UPDATE `{user}` SET `email` = 'user1@yahoo.com' WHERE `id` ='$usrId' "; execQuery($query); - $query = "UPDATE `mantis_user_table` SET `password` = 'ea36a50f4c8944dacadb16e6ca0dd582' WHERE `id` ='$usrId' "; + $query = "UPDATE `{user}` SET `password` = 'ea36a50f4c8944dacadb16e6ca0dd582' WHERE `id` ='$usrId' "; execQuery($query); // passwd: user2012 // admin (password must be changed manualy in OVH !!) - $query = "UPDATE `mantis_user_table` SET `password` = 'e26f604637ae454f792f4fcbff878bd1' WHERE `id` ='1' "; + $query = "UPDATE `{user}` SET `password` = 'e26f604637ae454f792f4fcbff878bd1' WHERE `id` ='1' "; execQuery($query); } @@ -266,26 +266,26 @@ function updateProjects() { $extprojId= Config::getInstance()->getValue(Config::id_externalTasksProject); // 3 // remove ALL files from ALL PROJECTS (OVH upload fails) - execQuery("DELETE FROM `mantis_bug_file_table` "); - execQuery("UPDATE `mantis_project_table` SET `description` = '' "); + execQuery("DELETE FROM `{bug_file}` "); + execQuery("UPDATE `{project}` SET `description` = '' "); - //SELECT DISTINCT pt.project_id, p.name FROM `codev_team_project_table` as pt, `mantis_project_table` as p WHERE type = 1 AND p.id = pt.project_id; + //SELECT DISTINCT pt.project_id, p.name FROM `codev_team_project_table` as pt, `{project}` as p WHERE type = 1 AND p.id = pt.project_id; - execQuery("UPDATE `mantis_project_table` SET `name` = CONCAT('SideTasks Project_',id) WHERE id in (SELECT DISTINCT project_id FROM `codev_team_project_table` WHERE type = 1)"); + execQuery("UPDATE `{project}` SET `name` = CONCAT('SideTasks Project_',id) WHERE id in (SELECT DISTINCT project_id FROM `codev_team_project_table` WHERE type = 1)"); // rename project categories /* - $result1 = execQuery("SELECT * from `mantis_category_table`"); + $result1 = execQuery("SELECT * from `{category}`"); while($row = SqlWrapper::getInstance()->sql_fetch_object($result1)) { - $query = "UPDATE `mantis_category_table` SET `name`='Category_".$row->project_id.$row->id."' WHERE `id`='$row->id' "; + $query = "UPDATE `{category}` SET `name`='Category_".$row->project_id.$row->id."' WHERE `id`='$row->id' "; $result2 = execQuery($query); } */ // external tasks project - execQuery("UPDATE `mantis_project_table` SET `name` = 'ExternalTasks' WHERE `id` ='$extprojId' "); + execQuery("UPDATE `{project}` SET `name` = 'ExternalTasks' WHERE `id` ='$extprojId' "); // demo projects - execQuery("UPDATE `mantis_project_table` SET `name` = 'SideTasks DEMO_Team' WHERE `id` ='$stprojId' "); + execQuery("UPDATE `{project}` SET `name` = 'SideTasks DEMO_Team' WHERE `id` ='$stprojId' "); } diff --git a/tools/remove_from_mantis_menu.php b/tools/remove_from_mantis_menu.php index f4317c8c2..8bb799614 100644 --- a/tools/remove_from_mantis_menu.php +++ b/tools/remove_from_mantis_menu.php @@ -38,7 +38,7 @@ function execQuery($query) { function removeCustomMenuItem($name) { // get current mantis custom menu entries - $query = "SELECT value FROM `mantis_config_table` WHERE config_id = 'main_menu_custom_options'"; + $query = "SELECT value FROM `{config}` WHERE config_id = 'main_menu_custom_options'"; $result = execQuery($query); $serialized = (0 != SqlWrapper::getInstance()->mysql_num_rows($result)) ? mysql_result($result, 0) : NULL; @@ -59,10 +59,10 @@ function removeCustomMenuItem($name) { // update mantis menu if (NULL != $serialized) { - $query = "UPDATE `mantis_config_table` SET value = '$newSerialized' " . + $query = "UPDATE `{config}` SET value = '$newSerialized' " . "WHERE config_id = 'main_menu_custom_options'"; } else { - $query = "INSERT INTO `mantis_config_table` (`config_id`, `value`, `type`, `access_reqd`) " . + $query = "INSERT INTO `{config}` (`config_id`, `value`, `type`, `access_reqd`) " . "VALUES ('main_menu_custom_options', '$newSerialized', '3', '90');"; } $result = execQuery($query); @@ -81,6 +81,6 @@ function removeCustomMenuItem($name) { removeCustomMenuItem('CodevTT'); } else { echo "Remove 'main_menu_custom_options' from Mantis DB
"; - $query = "DELETE FROM `mantis_config_table` WHERE config_id = 'main_menu_custom_options'"; + $query = "DELETE FROM `{config}` WHERE config_id = 'main_menu_custom_options'"; $result = execQuery($query); } \ No newline at end of file diff --git a/tools/update_codevtt.php b/tools/update_codevtt.php index 425d6ea32..21d0d6be3 100644 --- a/tools/update_codevtt.php +++ b/tools/update_codevtt.php @@ -84,7 +84,7 @@ function createCustomField($fieldName, $fieldType, $configId, $attributes = NULL echo "WARN: using default attributes for CustomField $fieldName
"; } - $query = "SELECT id, name FROM `mantis_custom_field_table`"; + $query = "SELECT id, name FROM `{custom_field}`"; $result = execQuery($query); while ($row = mysql_fetch_object($result)) { $fieldList["$row->name"] = $row->id; @@ -92,7 +92,7 @@ function createCustomField($fieldName, $fieldType, $configId, $attributes = NULL $fieldId = $fieldList[$fieldName]; if (!$fieldId) { - $query2 = "INSERT INTO `mantis_custom_field_table` " . + $query2 = "INSERT INTO `{custom_field}` " . "(`name`, `type` ,`access_level_r`," . " `access_level_rw` ,`require_report` ,`require_update` ,`display_report` ,`display_update` ,`require_resolved` ,`display_resolved` ,`display_closed` ,`require_closed` "; $query2 .= ", `possible_values`, `default_value`"; @@ -219,13 +219,13 @@ function update_v11_to_v12() { // --- create new categories for ExternalTasksProject $extTasksProjId = Config::getInstance()->getValue(Config::id_externalTasksProject); // create leave category - $query = "INSERT INTO `mantis_category_table` (`project_id`, `user_id`, `name`, `status`) ". + $query = "INSERT INTO `{category}` (`project_id`, `user_id`, `name`, `status`) ". "VALUES ('$extTasksProjId','0','Leave', '0');"; $result = execQuery($query); $catLeaveId = SqlWrapper::getInstance()->sql_insert_id(); // create otherInternal category - $query = "INSERT INTO `mantis_category_table` (`project_id`, `user_id`, `name`, `status`) ". + $query = "INSERT INTO `{category}` (`project_id`, `user_id`, `name`, `status`) ". "VALUES ('$extTasksProjId','0','Other activity', '0');"; $result = execQuery($query); $catOtherInternalId = SqlWrapper::getInstance()->sql_insert_id(); @@ -236,9 +236,9 @@ function update_v11_to_v12() { // update existing issues $leaveTaskId = Config::getInstance()->getValue(Config::id_externalTask_leave); - $query = "UPDATE `mantis_bug_table` SET `category_id`='$catLeaveId' WHERE `id`='$leaveTaskId';"; + $query = "UPDATE `{bug}` SET `category_id`='$catLeaveId' WHERE `id`='$leaveTaskId';"; $result = execQuery($query); - $query = "UPDATE `mantis_bug_table` SET `category_id`='$catOtherInternalId' ". + $query = "UPDATE `{bug}` SET `category_id`='$catOtherInternalId' ". "WHERE `project_id`='$extTasksProjId' ". "AND `id` <> '$leaveTaskId';"; $result = execQuery($query); @@ -382,7 +382,7 @@ function update_v14_to_v15() { // if Mantis 1.3, plugins must be updated if (!Tools::isMantisV1_2()) { echo "- Remove 'CodevTT' from Mantis main menu (CodevTT v1.0.x is incompatible with Mantis v1.3.x)
"; - $query = "DELETE FROM `mantis_config_table` WHERE config_id = 'main_menu_custom_options'"; + $query = "DELETE FROM `{config}` WHERE config_id = 'main_menu_custom_options'"; $result = execQuery($query); echo "- Install Mantis plugin: CodevTT (for mantis v1.3.x)
"; @@ -498,7 +498,7 @@ function update_v16_to_v17() { // find deprecated workingProjects $query0 = "SELECT mpt.id, mpt.name FROM `codev_team_project_table` ctpt ". - "JOIN `mantis_project_table` mpt ON mpt.id = ctpt.project_id ". + "JOIN `{project}` mpt ON mpt.id = ctpt.project_id ". "WHERE ctpt.type = ".Project::type_workingProject.';'; $result0 = execQuery($query0); while($row = SqlWrapper::getInstance()->sql_fetch_object($result0)) { @@ -630,10 +630,10 @@ function installMantisPlugin($pluginName, $isReplace=true) { } // activate plugin - $query = "INSERT INTO mantis_plugin_table (basename, enabled, protected, priority)". + $query = "INSERT INTO {plugin} (basename, enabled, protected, priority)". " SELECT * FROM (SELECT '$pluginName', '1', '0', '3') AS tmp". " WHERE NOT EXISTS (". - " SELECT basename FROM mantis_plugin_table WHERE basename = '$pluginName') LIMIT 1;"; + " SELECT basename FROM {plugin} WHERE basename = '$pluginName') LIMIT 1;"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { return "WARNING: mantis $pluginName plugin must be activated manualy";