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 "