|
From: Patrick M. <mo...@us...> - 2001-09-01 15:44:23
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv32304
Modified Files:
attachment.php bug.php config.php images.php include.php
index.php newaccount.php query.php report.php user.php
Added Files:
table_rename.sql
Log Message:
configurable tablenames
----------------------------------------------------------------------
Committing in .
Modified Files:
attachment.php bug.php config.php images.php include.php
index.php newaccount.php query.php report.php user.php
admin/component.php admin/os.php admin/project.php
admin/resolution.php admin/severity.php admin/status.php
admin/user.php admin/version.php
Added Files:
table_rename.sql
----------------------------------------------------------------------
--- NEW FILE: table_rename.sql ---
alter table attachment rename phpbt_attachment;
alter table bug rename phpbt_bug;
alter table bug_history rename phpbt_bug_history;
alter table comment rename phpbt_comment;
alter table component rename phpbt_component;
alter table os rename phpbt_os;
alter table project rename phpbt_project;
alter table resolution rename phpbt_resolution;
alter table saved_query rename phpbt_saved_query;
alter table severity rename phpbt_severity;
alter table status rename phpbt_status;
alter table auth_user rename phpbt_auth_user;
alter table version rename phpbt_version;
alter table auth_group rename phpbt_auth_group;
alter table auth_perm rename phpbt_auth_perm;
alter table user_group rename phpbt_user_group;
alter table user_perm rename phpbt_user_perm;
alter table group_perm rename phpbt_group_perm;
alter table bug_group rename phpbt_bug_group;
alter table project_group rename phpbt_project_group;
Index: attachment.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/attachment.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- attachment.php 2001/08/23 02:03:16 1.6
+++ attachment.php 2001/09/01 15:44:20 1.7
@@ -28,7 +28,7 @@
global $q;
if (list($filename, $mimetype) = grab_attachment($attachid)) {
- $q->query("delete from attachment where attachment_id = $attachid");
+ $q->query("delete from ".TBL_ATTACHMENT." where attachment_id = $attachid");
unlink($filename);
header("Location: bug.php?op=show&bugid=$attachid");
}
@@ -41,7 +41,9 @@
show_text($STRING['bad_attachment'], true);
return false;
}
- $ainfo = $q->grab("select a.bug_id, file_name, mime_type, project_id from attachment a, bug b where attachment_id = $attachid and a.bug_id = b.bug_id");
+ $ainfo = $q->grab("select a.bug_id, file_name, mime_type, project_id"
+ ." from ".TBL_ATTACHMENT." a, ".TBL_BUG." b"
+ ." where attachment_id = $attachid and a.bug_id = b.bug_id");
if ($q->num_rows() != 1) {
show_text($STRING['bad_attachment'], true);
return false;
@@ -71,14 +73,15 @@
return;
}
- $projectid = $q->grab_field("select project_id from bug where bug_id = $bugid");
+ $projectid = $q->grab_field("select project_id from ".TBL_BUG." where bug_id = $bugid");
if (!$projectid) {
show_text($STRING['nobug'], true);
return;
}
// Check for a previously-uploaded attachment with the same name, bug, and project
- $q->query("select a.bug_id, project_id from attachment a, bug b where file_name = '{$HTTP_POST_FILES['attachment']['name']}' and a.bug_id = b.bug_id");
+ $q->query("select a.bug_id, project_id from ".TBL_ATTACHMENT." a, ".TBL_BUG." b"
+ ." where file_name = '{$HTTP_POST_FILES['attachment']['name']}' and a.bug_id = b.bug_id");
while ($ainfo = $q->grab()) {
if ($bugid == $ainfo['bug_id'] && $projectid == $ainfo['project_id']) {
show_attachment_form($bugid, $STRING['dupe_attachment']);
@@ -111,7 +114,7 @@
}
@chmod("$filepath/$projectid/$filename", 0766);
- $q->query("insert into attachment (attachment_id, bug_id, file_name, description, file_size, mime_type, created_by, created_date) values (".$q->nextid('attachment').", $bugid, '{$HTTP_POST_FILES['attachment']['name']}', '$description', {$HTTP_POST_FILES['attachment']['size']}, '{$HTTP_POST_FILES['attachment']['type']}', $u, $now)");
+ $q->query("insert into ".TBL_ATTACHMENT." (attachment_id, bug_id, file_name, description, file_size, mime_type, created_by, created_date) values (".$q->nextid('attachment').", $bugid, '{$HTTP_POST_FILES['attachment']['name']}', '$description', {$HTTP_POST_FILES['attachment']['size']}, '{$HTTP_POST_FILES['attachment']['type']}', $u, $now)");
$t->set_file('content', 'bugattachmentsuccess.html');
$t->set_var('bugid', $bugid);
}
@@ -125,7 +128,7 @@
return;
}
- $bugexists = $q->grab_field("select count(*) from bug where bug_id = $bugid");
+ $bugexists = $q->grab_field("select count(*) from ".TBL_BUG." where bug_id = $bugid");
if (!$bugexists) {
show_text($STRING['nobug'], true);
return;
Index: bug.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/bug.php,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- bug.php 2001/08/31 04:25:07 1.34
+++ bug.php 2001/09/01 15:44:20 1.35
@@ -34,7 +34,8 @@
return;
}
- $q->query("select bh.*, email from bug_history bh left join auth_user on created_by = user_id where bug_id = $bugid");
+ $q->query("select bh.*, email from ".TBL_BUG_HISTORY." bh left join ".TBL_AUTH_USER." on created_by = user_id"
+ ." where bug_id = $bugid");
if (!$q->num_rows()) {
show_text($STRING['nobughistory']);
return;
@@ -65,7 +66,9 @@
$t->set_block('emailout','commentblock', 'cblock');
foreach(array('title','url') as $field) {
if (isset($cf[$field])) {
- $q->query("insert into bug_history (bug_id, changed_field, old_value, new_value, created_by, created_date) values ({$buginfo['bug_id']}, '$field', '$buginfo[$field]', '$cf[$field]', $u, $now)");
+ $q->query("insert into ".TBL_BUG_HISTORY
+ ." (bug_id, changed_field, old_value, new_value, created_by, created_date)"
+ ." values ({$buginfo['bug_id']}, '$field', '$buginfo[$field]', '$cf[$field]', $u, $now)");
$t->set_var(array(
$field => $cf[$field],
$field.'_stat' => '!'
@@ -77,13 +80,28 @@
));
}
}
+
+ //create array with tablenames for following loop
+ $cfgDatabase=array(
+ 'project' => TBL_PROJECT,
+ 'component' => TBL_COMPONENT,
+ 'status' => TBL_STATUS,
+ 'resolution' => TBL_RESOLUTION,
+ 'severity' => TBL_SEVERITY,
+ 'os' => TBL_OS,
+ 'version' => TBL_VERSION
+ );
foreach(array('project','component','status','resolution','severity','os',
'version') as $field) {
- $oldvalue = $q->grab_field("select ${field}_name from $field where ${field}_id = {$buginfo[$field.'_id']}");
+ $oldvalue = $q->grab_field("select ${field}_name from ".$cfgDatabase[$field]
+ ." where ${field}_id = {$buginfo[$field.'_id']}");
if ($cf[$field]) {
- $newvalue = $q->grab_field("select ${field}_name from $field where ${field}_id = $cf[$field]");
- $q->query("insert into bug_history (bug_id, changed_field, old_value, new_value, created_by, created_date) values ({$buginfo['bug_id']}, '$field', '$oldvalue', '$newvalue', $u, $now)");
+ $newvalue = $q->grab_field("select ${field}_name from ".$cfgDatabase[$field]
+ ." where ${field}_id = $cf[$field]");
+ $q->query("insert into ".TBL_BUG_HISTORY
+ ." (bug_id, changed_field, old_value, new_value, created_by, created_date)"
+ ." values ({$buginfo['bug_id']}, '$field', '$oldvalue', '$newvalue', $u, $now)");
$t->set_var(array(
$field => stripslashes($newvalue),
$field.'Stat' => '!'
@@ -97,14 +115,18 @@
}
// Reporter never changes;
- $reporter = $q->grab_field("select email from auth_user where user_id = {$buginfo['created_by']}");
+ $reporter = $q->grab_field("select email from ".TBL_AUTH_USER." where user_id = {$buginfo['created_by']}");
$reporterstat = ' ';
- $assignedto = $q->grab_field("select email from auth_user where user_id = ". ($cf['assigned_to'] ? $cf['assigned_to'] : $buginfo['assigned_to']));
+ $assignedto = $q->grab_field("select email from ".TBL_AUTH_USER
+ ." where user_id = ". ($cf['assigned_to'] ? $cf['assigned_to'] : $buginfo['assigned_to']));
$assignedtostat = $cf['assigned_to'] ? '!' : ' ';
// If there are new comments grab the comments immediately before the latest
if ($comments) {
- $q->query("select u.email, c.comment_text, c.created_date from comment c, auth_user u where bug_id = {$buginfo['bug_id']} and c.created_by = u.user_id order by created_date desc limit 2");
+ $q->query("select u.email, c.comment_text, c.created_date"
+ ." from ".TBL_COMMENT." c, ".TBL_AUTH_USER." u"
+ ." where bug_id = {$buginfo['bug_id']} and c.created_by = u.user_id"
+ ." order by created_date desc limit 2");
$row = $q->grab();
$t->set_var(array(
'newpostedby' => $row['email'],
@@ -115,7 +137,9 @@
// If this comment is the first additional comment after the creation of the
// bug then we need to grab the bug's description as the previous comment
if ($q->num_rows() < 2) {
- list($by, $on, $comments) = $q->grab("select u.email, b.created_date, b.description from bug b, auth_user u where b.created_by = u.user_id and bug_id = {$buginfo['bug_id']}");
+ list($by, $on, $comments) = $q->grab("select u.email, b.created_date, b.description"
+ ." from ".TBL_BUG." b, ".TBL_AUTH_USER." u"
+ ." where b.created_by = u.user_id and bug_id = {$buginfo['bug_id']}");
$t->set_var(array(
'oldpostedby' => $by,
'oldpostedon' => date(TIMEFORMAT,$on).' on '.date(DATEFORMAT,$on),
@@ -166,7 +190,7 @@
global $q, $t, $u, $STRING, $perm, $now;
// Pull bug from database to determine changed fields and for user validation
- $buginfo = $q->grab("select * from bug where bug_id = $bugid");
+ $buginfo = $q->grab("select * from ".TBL_BUG." where bug_id = $bugid");
if (isset($GLOBALS['HTTP_POST_VARS'])) {
foreach ($GLOBALS['HTTP_POST_VARS'] as $k => $v) {
@@ -187,7 +211,7 @@
}
if ($outcome == 'reassign' and
- (!$assignedto = $q->grab_field("select user_id from auth_user where email = '$reassignto'"))) {
+ (!$assignedto = $q->grab_field("select user_id from ".TBL_AUTH_USER." where email = '$reassignto'"))) {
show_bug($bugid,array('status' => $STRING['nouser']));
return;
}
@@ -201,7 +225,7 @@
case 'unchanged' : break;
case 'assign' : $assignedto = $u; $statusfield = 'Assigned'; break;
case 'reassign' :
- if (!$assignedto = $q->grab_field("select user_id from auth_user where email = '$reassignto'")) {
+ if (!$assignedto = $q->grab_field("select user_id from ".TBL_AUTH_USER." where email = '$reassignto'")) {
show_bug($bugid,array('status' => $STRING['nouser']));
return;
} else {
@@ -210,21 +234,23 @@
break;
}
case 'reassigntocomponent' :
- $assignedto = $q->grab_field("select owner from component where component_id = $component");
+ $assignedto = $q->grab_field("select owner from ".TBL_COMPONENT." where component_id = $component");
$statusfield = 'Assigned'; break;
case 'dupe' :
$changeresolution = true;
if ($dupenum == $bugid) {
show_bug($bugid,array('status' => $STRING['dupeofself']));
return;
- } elseif (!$q->grab_field("select bug_id from bug where bug_id = $dupenum")) {
+ } elseif (!$q->grab_field("select bug_id from ".TBL_BUG." where bug_id = $dupenum")) {
show_bug($bugid,array('status' => $STRING['nobug']));
return;
}
- $q->query("insert into comment (comment_id, bug_id, comment_text, created_by, created_date) values (".$q->nextid('comment').", $dupenum, 'Bug #$bugid is a duplicate of this bug', $u, $now)");
- $q->query("insert into comment (comment_id, bug_id, comment_text, created_by, created_date) values (".$q->nextid('comment').", $bugid, 'This bug is a duplicate of bug #$dupenum', $u, $now)");
+ $q->query("insert into ".TBL_COMMENT." (comment_id, bug_id, comment_text, created_by, created_date)"
+ ." values (".$q->nextid('comment').", $dupenum, 'Bug #$bugid is a duplicate of this bug', $u, $now)");
+ $q->query("insert into ".TBL_COMMENT." (comment_id, bug_id, comment_text, created_by, created_date)"
+ ." values (".$q->nextid('comment').", $bugid, 'This bug is a duplicate of bug #$dupenum', $u, $now)");
$statusfield = 'Duplicate';
- $bugresolution = $q->grab_field("select resolution_id from resolution where resolution_name = 'Duplicate'");
+ $bugresolution = $q->grab_field("select resolution_id from ".TBL_RESOLUTION." where resolution_name = 'Duplicate'");
$statusfield = 'Resolved';
break;
case 'resolve' :
@@ -244,16 +270,17 @@
break;
}
if ($statusfield) {
- $status = $q->grab_field("select status_id from status where status_name = '$statusfield'");
+ $status = $q->grab_field("select status_id from ".TBL_STATUS." where status_name = '$statusfield'");
$changedfields['status'] = $status;
}
if ($comments) {
$comments = htmlspecialchars($comments);
- $q->query("insert into comment (comment_id, bug_id, comment_text, created_by, created_date) values (".$q->nextid('comment').", $bugid, '$comments', $u, $now)");
+ $q->query("insert into ".TBL_COMMENT." (comment_id, bug_id, comment_text, created_by, created_date)"
+ ." values (".$q->nextid('comment').", $bugid, '$comments', $u, $now)");
}
- $q->query("update bug set title = '$title', url = '$url', severity_id = $severity_id, priority = $priority, ".($status ? "status_id = $status, " : ''). ($changeresolution ? "resolution_id = $bugresolution, " : ''). ($assignedto ? "assigned_to = $assignedto, " : '')." project_id = $project_id, version_id = $version_id, component_id = $component_id, os_id = $os_id, last_modified_by = $u, last_modified_date = $now where bug_id = $bugid");
+ $q->query("update ".TBL_BUG." set title = '$title', url = '$url', severity_id = $severity_id, priority = $priority, ".($status ? "status_id = $status, " : ''). ($changeresolution ? "resolution_id = $bugresolution, " : ''). ($assignedto ? "assigned_to = $assignedto, " : '')." project_id = $project_id, version_id = $version_id, component_id = $component_id, os_id = $os_id, last_modified_by = $u, last_modified_date = $now where bug_id = $bugid");
if ($changedfields or $comments) {
do_changedfields($u, $buginfo, $changedfields, $comments);
@@ -277,10 +304,10 @@
if ($url == 'http://') $url = '';
$time = time();
if (!$bugid) {
- $status = $q->grab_field("select status_id from status where status_name = 'Unconfirmed'");
- $q->query("insert into bug (bug_id, title, description, url, severity_id, priority, status_id, created_by, created_date, last_modified_by, last_modified_date, project_id, version_id, component_id, os_id, browser_string) values (".$q->nextid('bug').", '$title', '$description', '$url', $severity, $priority, $status, $u, $time, $u, $time, $project, $version, $component, '$os', '{$GLOBALS['HTTP_USER_AGENT']}')");
+ $status = $q->grab_field("select status_id from ".TBL_STATUS." where status_name = 'Unconfirmed'");
+ $q->query("insert into ".TBL_BUG." (bug_id, title, description, url, severity_id, priority, status_id, created_by, created_date, last_modified_by, last_modified_date, project_id, version_id, component_id, os_id, browser_string) values (".$q->nextid('bug').", '$title', '$description', '$url', $severity, $priority, $status, $u, $time, $u, $time, $project, $version, $component, '$os', '{$GLOBALS['HTTP_USER_AGENT']}')");
} else {
- $q->query("update bug set title = '$title', description = '$description', url = '$url', severity_id = '$severity', priority = '$priority', status_id = $status, assigned_to = '$assignedto', project_id = $project, version_id = $version, component_id = $component, os_id = '$os', browser_string = '{$GLOBALS['HTTP_USER_AGENT']}' last_modified_by = $u, last_modified_date = $time where bug_id = '$bugid'");
+ $q->query("update ".TBL_BUG." set title = '$title', description = '$description', url = '$url', severity_id = '$severity', priority = '$priority', status_id = $status, assigned_to = '$assignedto', project_id = $project, version_id = $version, component_id = $component, os_id = '$os', browser_string = '{$GLOBALS['HTTP_USER_AGENT']}' last_modified_by = $u, last_modified_date = $time where bug_id = '$bugid'");
}
if ($another) header("Location: $me?op=add&project=$project");
else header("Location: query.php");
@@ -293,9 +320,9 @@
while (list($k,$v) = each($GLOBALS['HTTP_POST_VARS'])) $$k = $v;
$t->set_file('content','bugform.html');
- $projectname = $q->grab_field("select project_name from project where project_id = $project");
+ $projectname = $q->grab_field("select project_name from ".TBL_PROJECT." where project_id = $project");
if ($bugid && !$error) {
- $row = $q->grab("select * from bug where bug_id = '$bugid'");
+ $row = $q->grab("select * from ".TBL_BUG." where bug_id = '$bugid'");
$t->set_var(array(
'bugid' => $bugid,
'TITLE' => $TITLE['editbug'],
@@ -343,9 +370,14 @@
}
function show_bug($bugid = 0, $error = '') {
- global $q, $me, $t, $project, $STRING, $u, $perm;
+ global $q, $me, $t, $project, $STRING, $u, $perm;
- if (!ereg('^[0-9]+$',$bugid) or !$row = $q->grab("select b.*, reporter.email as reporter, owner.email as owner, status_name, resolution_name from bug b left join resolution r using(resolution_id), severity sv, status st left join auth_user owner on b.assigned_to = owner.user_id left join auth_user reporter on b.created_by = reporter.user_id where bug_id = '$bugid' and b.severity_id = sv.severity_id and b.status_id = st.status_id")) {
+ if (!ereg('^[0-9]+$',$bugid) or !$row = $q->grab("select b.*, reporter.email as reporter, owner.email as owner,"
+ ." status_name, resolution_name"
+ ." from ".TBL_BUG." b left join ".TBL_RESOLUTION." r using(resolution_id),"
+ .TBL_SEVERITY." sv, ".TBL_STATUS." st left join ".TBL_AUTH_USER." owner on b.assigned_to=owner.user_id"
+ ." left join ".TBL_AUTH_USER." reporter on b.created_by = reporter.user_id"
+ ." where bug_id = '$bugid' and b.severity_id = sv.severity_id and b.status_id = st.status_id")) {
show_text($STRING['bugbadnum'],true);
return;
}
@@ -410,7 +442,7 @@
}
// Show the attachments
- $q->query("select * from attachment where bug_id = $bugid");
+ $q->query("select * from ".TBL_ATTACHMENT." where bug_id = $bugid");
if (!$q->num_rows()) {
$t->set_var('attrows', '<tr><td colspan="5" align="center">No attachments</td></tr>');
} else {
@@ -444,7 +476,9 @@
}
}
- $q->query("select comment_text, comment.created_date, email from comment, auth_user where bug_id = $bugid and comment.created_by = user_id order by comment.created_date");
+ $q->query("select comment_text, comment.created_date, email"
+ ." from ".TBL_COMMENT." c, ".TBL_AUTH_USER
+ ." where bug_id = $bugid and c.created_by = user_id order by c.created_date");
if (!$q->num_rows()) {
$t->set_var('rows','');
} else {
@@ -465,7 +499,7 @@
function show_projects() {
global $me, $q, $t, $project, $STRING;
- $q->query("select * from project where active order by project_name");
+ $q->query("select * from ".TBL_PROJECT." where active order by project_name");
switch ($q->num_rows()) {
case 0 :
$t->set_var('rows',$STRING['noprojects']);
Index: config.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/config.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- config.php 2001/08/28 03:51:09 1.5
+++ config.php 2001/09/01 15:44:20 1.6
@@ -35,6 +35,31 @@
define ('DB_USER', 'root');
define ('DB_PASSWORD', '');
+//Database Table Config
+//you can change either the prefix of the table names or each table name individualy
+//define ('TBL_PREFIX', 'phpbt_'); //the prefix for all tables
+define ('TBL_PREFIX', ''); //the prefix for all tables, leave empty to use the old style
+define ('TBL_ATTACHMENT', TBL_PREFIX.'attachment');
+define ('TBL_BUG', TBL_PREFIX.'bug');
+define ('TBL_BUG_HISTORY', TBL_PREFIX.'bug_history');
+define ('TBL_COMMENT', TBL_PREFIX.'comment');
+define ('TBL_COMPONENT', TBL_PREFIX.'component');
+define ('TBL_PROJECT', TBL_PREFIX.'project');
+define ('TBL_RESOLUTION', TBL_PREFIX.'resolution');
+define ('TBL_SAVED_QUERY', TBL_PREFIX.'saved_query');
+define ('TBL_SEVERITY', TBL_PREFIX.'severity');
+define ('TBL_STATUS', TBL_PREFIX.'status');
+define ('TBL_AUTH_USER', TBL_PREFIX.'auth_user');
+define ('TBL_VERSION', TBL_PREFIX.'version');
+define ('TBL_OS', TBL_PREFIX.'os');
+define ('TBL_AUTH_GROUP', TBL_PREFIX.'auth_group');
+define ('TBL_AUTH_PERM', TBL_PREFIX.'auth_perm');
+define ('TBL_USER_GROUP', TBL_PREFIX.'user_group');
+define ('TBL_USER_PERM', TBL_PREFIX.'user_perm');
+define ('TBL_GROUP_PERM', TBL_PREFIX.'group_perm');
+define ('TBL_BUG_GROUP', TBL_PREFIX.'bug_group');
+define ('TBL_PROJECT_GROUP', TBL_PREFIX.'project_group');
+
define ('ADMINEMAIL', 'ph...@be...');
define ('ENCRYPTPASS', 0); // Whether to store passwords encrypted
define ('THEME', 'default/'); // Which set of templates to use
Index: images.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/images.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- images.php 2001/08/17 01:34:55 1.5
+++ images.php 2001/09/01 15:44:20 1.6
@@ -31,13 +31,13 @@
include_once JPGRAPH_PATH.'jpgraph_pie.php';
// Grab the legend
- $q->query("select status_id, status_name from status order by sort_order");
+ $q->query("select status_id, status_name from ".TBL_STATUS." order by sort_order");
while ($row = $q->grab()) {
$stats[$row['status_id']]['name'] = $row['status_name'];
}
// Grab the data
- $q->query("select status_id, count(status_id) as count from bug group by status_id");
+ $q->query("select status_id, count(status_id) as count from ".TBL_BUG." group by status_id");
while ($row = $q->grab()) {
$stats[$row['status_id']]['count'] = $row['count'];
}
Index: include.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/include.php,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- include.php 2001/08/29 08:05:39 1.44
+++ include.php 2001/09/01 15:44:20 1.45
@@ -118,14 +118,17 @@
if (ENCRYPTPASS) {
$password = md5($password);
}
- $u = $q->grab("select * from auth_user where login = '$username' and password = '$password' and active > 0");
+ $u = $q->grab("select * from ".TBL_AUTH_USER." where login = '$username' and password = '$password' and active > 0");
if (!$q->num_rows()) {
return 'nobody';
} else {
$this->auth['db_fields'] = unserialize($u['bug_list_fields']);
// Grab group assignments and permissions based on groups
- $q->query("select group_name, perm_name from auth_perm ap, group_perm gp, auth_group ag, user_group ug where ap.perm_id = gp.perm_id and gp.group_id = ag.group_id and ag.group_id = ug.group_id and ug.user_id = {$u['user_id']}");
+ $q->query("select group_name, perm_name"
+ ." from ".TBL_AUTH_PERM." ap, ".TBL_GROUP_PERM." gp, ".TBL_AUTH_GROUP." ag, ".TBL_USER_GROUP." ug"
+ ." where ap.perm_id = gp.perm_id and gp.group_id = ag.group_id"
+ ." and ag.group_id = ug.group_id and ug.user_id = {$u['user_id']}");
while (list($group, $perm) = $q->grab()) {
$this->auth['perm'][$perm] = true;
$this->auth['group'][$group] = true;
@@ -196,9 +199,14 @@
$this->set_block('wrap', 'adminnavblock', 'anblock');
if ($u && $u != 'nobody') {
list($owner_open, $owner_closed) =
- $q->grab("select sum(if(status_name in ('Unconfirmed','New','Assigned','Reopened'),1,0)), sum(if(status_name not in ('Unconfirmed','New','Assigned','Reopened'),1,0)) from bug b left join status s using(status_id) where assigned_to = $u");
+ $q->grab("select sum(if(status_name in ('Unconfirmed','New','Assigned','Reopened'),1,0)),"
+ ." sum(if(status_name not in ('Unconfirmed','New','Assigned','Reopened'),1,0))"
+ ." from ".TBL_BUG." b left join ".TBL_STATUS." s using(status_id)"
+ ." where assigned_to = $u");
list($reporter_open, $reporter_closed) =
- $q->grab("select sum(if(status_name in ('Unconfirmed','New','Assigned','Reopened'),1,0)), sum(if(status_name not in ('Unconfirmed','New','Assigned','Reopened'),1,0)) from bug b left join status s using(status_id) where created_by = $u");
+ $q->grab("select sum(if(status_name in ('Unconfirmed','New','Assigned','Reopened'),1,0)),"
+ ." sum(if(status_name not in ('Unconfirmed','New','Assigned','Reopened'),1,0))"
+ ." from ".TBL_BUG." b left join ".TBL_STATUS." s using(status_id) where created_by = $u");
$this->set_var(array(
'loggedinas' => $auth->auth['uname'],
'liblock' => '',
@@ -259,14 +267,24 @@
function build_select($box, $value = '', $project = 0) {
global $q, $select;
+ //create hash to map tablenames
+ $cfgDatabase=array(
+ 'project' => TBL_PROJECT,
+ 'component' => TBL_COMPONENT,
+ 'status' => TBL_STATUS,
+ 'resolution' => TBL_RESOLUTION,
+ 'severity' => TBL_SEVERITY,
+ 'version' => TBL_VERSION
+ );
+
$text = '';
$queries = array(
- 'severity' => "select {$box}_id, {$box}_name from $box where sort_order > 0 order by sort_order",
- 'status' => "select {$box}_id, {$box}_name from $box where sort_order > 0 order by sort_order",
- 'resolution' => "select {$box}_id, {$box}_name from $box where sort_order > 0 order by sort_order",
- 'project' => "select {$box}_id, {$box}_name from $box where active = 1 order by {$box}_name",
- 'component' => "select {$box}_id, {$box}_name from $box where project_id = $project order by {$box}_name",
- 'version' => "select {$box}_id, {$box}_name from $box where project_id = $project order by {$box}_name"
+ 'severity' => "select {$box}_id, {$box}_name from ".$cfgDatabase[$box]." where sort_order > 0 order by sort_order",
+ 'status' => "select {$box}_id, {$box}_name from ".$cfgDatabase[$box]." where sort_order > 0 order by sort_order",
+ 'resolution' => "select {$box}_id, {$box}_name from ".$cfgDatabase[$box]." where sort_order > 0 order by sort_order",
+ 'project' => "select {$box}_id, {$box}_name from ".$cfgDatabase[$box]." where active = 0 order by {$box}_name",
+ 'component' => "select {$box}_id, {$box}_name from ".$cfgDatabase[$box]." where project_id = $project order by {$box}_name",
+ 'version' => "select {$box}_id, {$box}_name from ".$cfgDatabase[$box]." where project_id = $project order by {$box}_name"
);
switch($box) {
@@ -285,7 +303,7 @@
}
break;
case 'os' :
- $q->query("select {$box}_id, {$box}_name, regex from $box order by sort_order");
+ $q->query("select {$box}_id, {$box}_name, regex from ".TBL_OS." order by sort_order");
while ($row = $q->grab()) {
if ($value == '' and $row['Regex'] and
preg_match($row['Regex'],$GLOBALS['HTTP_USER_AGENT'])) $sel = ' selected';
@@ -296,7 +314,7 @@
}
break;
case 'owner' :
- $q->query("select user_id, email from auth_user where user_level > 1 order by email");
+ $q->query("select user_id, email from ".TBL_AUTH_USER." where user_level > 1 order by email");
while ($row = $q->grab()) {
if ($value == $row['user_id']) $sel = ' selected';
else $sel = '';
@@ -442,7 +460,7 @@
// Check to see if the user is trying to login
if (isset($HTTP_POST_VARS['dologin'])) {
if (isset($HTTP_POST_VARS['sendpass'])) {
- list($email, $password) = $q->grab("select email, password from auth_user where login = '$username' and active > 0");
+ list($email, $password) = $q->grab("select email, password from ".TBL_AUTH_USER." where login = '$username' and active > 0");
if (!$q->num_rows()) {
$t->set_var(array(
'loginerrorcolor' => '#ff0000',
@@ -452,7 +470,7 @@
if (ENCRYPTPASS) {
$password = genpassword(10);
$mpassword = md5($password);
- $q->query("update auth_user set password = '$mpassword' where login = '$username'");
+ $q->query("update ".TBL_AUTH_USER." set password = '$mpassword' where login = '$username'");
}
mail($email, $STRING['newacctsubject'], sprintf($STRING['newacctmessage'],
$password), sprintf("From: %s\nContent-Type: text/plain; charset=%s\nContent-Transfer-Encoding: 8bit\n",ADMINEMAIL, $STRING['lang_charset']));
Index: index.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/index.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- index.php 2001/08/17 01:25:48 1.10
+++ index.php 2001/09/01 15:44:20 1.11
@@ -34,11 +34,11 @@
if (USE_JPGRAPH) {
$t->set_var('sblock', '<img src="images.php" align="right">');
} else {
- $q->query("select * from status order by sort_order");
+ $q->query("select * from ".TBL_STATUS." order by sort_order");
while ($row = $q->grab()) {
$stats[$row['status_id']]['name'] = $row['status_name'];
}
- $q->query("select status_id, count(status_id) as count from bug group by status_id");
+ $q->query("select status_id, count(status_id) as count from ".TBL_BUG." group by status_id");
while ($row = $q->grab()) {
$stats[$row['status_id']]['count'] = $row['count'];
}
Index: newaccount.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/newaccount.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- newaccount.php 2001/08/29 08:05:39 1.14
+++ newaccount.php 2001/09/01 15:44:20 1.15
@@ -31,7 +31,7 @@
$error = $STRING['loginused'];
elseif (!$email or !valid_email($email))
$error = $STRING['giveemail'];
- elseif ($q->grab_field("select user_id from auth_user where email = '$email' or login = '$login'"))
+ elseif ($q->grab_field("select user_id from ".TBL_AUTH_USER." where email = '$email' or login = '$login'"))
$error = $STRING['loginused'];
if ($error) {
show_form($error);
@@ -47,8 +47,10 @@
}
if (EMAIL_IS_LOGIN) $login = $email;
$user_id = $q->nextid('user');
- $q->query("insert into auth_user (user_id, login, first_name, last_name, email, password, active, created_date, last_modified_date) values ($user_id, '$login', '$firstname', '$lastname', '$email', '$mpassword', 1, $now, $now)");
- $q->query("insert into user_group (user_id, group_id) select $user_id, group_id from auth_group where group_name = 'user'");
+ $q->query("insert into ".TBL_AUTH_USER." (user_id, login, first_name, last_name, email, password, active, created_date, last_modified_date)"
+ ." values ($user_id, '$login', '$firstname', '$lastname', '$email', '$mpassword', 1, $now, $now)");
+ $q->query("insert into ".TBL_USER_GROUP." (user_id, group_id)"
+ ." select $user_id, group_id from ".TBL_AUTH_GROUP." where group_name = 'user'");
mail($email, $STRING['newacctsubject'], sprintf($STRING['newacctmessage'],
$password), sprintf("From: %s\nContent-Type: text/plain; charset=%s\nContent-Transfer-Encoding: 8bit\n",ADMINEMAIL, $STRING['lang_charset']));
$t->set_file('content','newaccountsuccess.html');
Index: query.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/query.php,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- query.php 2001/09/01 14:59:42 1.25
+++ query.php 2001/09/01 15:44:20 1.26
@@ -26,7 +26,7 @@
function delete_saved_query($queryid) {
global $q, $u, $me;
- $q->query("delete from saved_query where user_id = $u and saved_query_id = $queryid");
+ $q->query("delete from ".TBL_SAVED_QUERY." where user_id = $u and saved_query_id = $queryid");
header("Location: $me?op=query");
}
@@ -40,11 +40,11 @@
$t->set_block('savequeryblock','row','rows');
// Build the javascript-powered select boxes
- $q->query("select project_id, project_name from project where active order by project_name");
+ $q->query("select project_id, project_name from ".TBL_PROJECT." where active order by project_name");
while (list($pid, $pname) = $q->grab()) {
// Version array
$js .= "versions['$pname'] = new Array(new Array('','All'),";
- $nq->query("select version_name, version_id from version where project_id = $pid and active");
+ $nq->query("select version_name, version_id from ".TBL_VERSION." where project_id = $pid and active");
while (list($version,$vid) = $nq->grab()) {
$js .= "new Array($vid,'$version'),";
}
@@ -53,7 +53,7 @@
// Component array
$js .= "components['$pname'] = new Array(new Array('','All'),";
- $nq->query("select component_name, component_id from component where project_id = $pid and active");
+ $nq->query("select component_name, component_id from ".TBL_COMPONENT." where project_id = $pid and active");
while (list($comp,$cid) = $nq->grab()) {
$js .= "new Array($cid,'$comp'),";
}
@@ -63,7 +63,7 @@
if ($u != 'nobody') {
// Grab the saved queries if there are any
- $q->query("select * from saved_query where user_id = '$u'");
+ $q->query("select * from ".TBL_SAVED_QUERY." where user_id = '$u'");
if (!$q->num_rows()) {
$t->set_var('rows','');
} else {
@@ -101,7 +101,7 @@
// Open bugs assigned to the user -- a hit list
if ($assignedto || $reportedby) {
- $q->query("select status_id from status where status_name ".($open ? '' : 'not ')."in ('Unconfirmed', 'New', 'Assigned', 'Reopened')");
+ $q->query("select status_id from ".TBL_STATUS." where status_name ".($open ? '' : 'not ')."in ('Unconfirmed', 'New', 'Assigned', 'Reopened')");
while ($statusid = $q->grab_field()) $status[] = $statusid;
$query[] = 'bug.status_id in ('.delimit_list(',',$status).')';
if ($assignedto) {
@@ -113,7 +113,7 @@
// Select boxes
if ($status) $flags[] = 'bug.status_id in ('.delimit_list(',',$status).')';
if ($resolution) $flags[] = 'bug.resolution_id in ('.delimit_list(',',$resolution).')';
- if ($os) $flags[] = 'bug.os_id in ('.delimit_list(',',$os).')';
+ if ($os) $flags[] = 'bug.op_sys_id in ('.delimit_list(',',$os).')';
if ($priority) $flags[] = 'bug.priority in ('.delimit_list(',',$priority).')';
if ($severity) $flags[] = 'bug.severity_id in ('.delimit_list(',',$severity).')';
if ($flags) $query[] = '('.delimit_list(' or ',$flags).')';
@@ -168,11 +168,15 @@
// Save the query if requested
if ($savedqueryname) {
$savedquerystring = ereg_replace('&savedqueryname=.*(&?)', '\\1', $GLOBALS['QUERY_STRING']);
- $q->query("insert into saved_query (user_id, saved_query_name, saved_query_string) values ($u, '$savedqueryname', '$savedquerystring')");
+ $q->query("insert into ".TBL_SAVED_QUERY." (user_id, saved_query_name, saved_query_string)"
+ ." values ($u, '$savedqueryname', '$savedquerystring')");
}
if (!$order) { $order = 'bug_id'; $sort = 'asc'; }
if (!$querystring or $op) build_query($assignedto, $reportedby, $open);
- $nr = $q->grab_field("select count(*) from bug left join auth_user owner on bug.assigned_to = owner.user_id left join auth_user reporter on bug.created_by = reporter.user_id ".($querystring != '' ? "where $querystring": ''));
+ $nr = $q->grab_field("select count(*) from ".TBL_BUG." bug"
+ ." left join ".TBL_AUTH_USER." owner on bug.assigned_to = owner.user_id"
+ ." left join ".TBL_AUTH_USER." reporter on bug.created_by = reporter.user_id "
+ .($querystring != '' ? "where $querystring": ''));
list($selrange, $llimit, $npages, $pages) = multipages($nr,$page,
"order=$order&sort=$sort");
@@ -185,7 +189,20 @@
'project' => build_select('project'),
'TITLE' => $TITLE['buglist']));
- $q->query("select bug.*, reporter.login as reporter, owner.login as owner, lastmodifier.login as lastmodifier, project_name, severity_name, status_name, os_name, version_name, component_name, resolution_name, severity_color from bug left join resolution using (resolution_id), severity, status, os, version, component, project left join auth_user owner on bug.assigned_to = owner.user_id left join auth_user reporter on bug.created_by = reporter.user_id left join auth_user lastmodifier on bug.last_modified_by = lastmodifier.user_id where bug.severity_id = severity.severity_id and bug.status_id = status.status_id and bug.os_id = os.os_id and bug.version_id = version.version_id and bug.component_id = component.component_id and bug.project_id = project.project_id ". ($querystring != '' ? "and $querystring " : ''). "order by $order $sort limit $llimit, $selrange");
+ $q->query("select bug.*, reporter.login as reporter, owner.login as owner, lastmodifier.login as lastmodifier,"
+ ." project_name, severity_name, status_name, os_name, version_name, component_name, resolution_name,"
+ ." severity_color"
+ ." from ".TBL_BUG." bug left join ".TBL_RESOLUTION." resolution using (resolution_id),"
+ . TBL_SEVERITY." severity, ".TBL_STATUS." status, ".TBL_OS." os, ".TBL_VERSION." version, "
+ . TBL_COMPONENT." component, ".TBL_PROJECT." project"
+ ." left join ".TBL_AUTH_USER." owner on bug.assigned_to = owner.user_id"
+ ." left join ".TBL_AUTH_USER." reporter on bug.created_by = reporter.user_id"
+ ." left join ".TBL_AUTH_USER." lastmodifier on bug.last_modified_by = lastmodifier.user_id"
+ ." where bug.severity_id = severity.severity_id and bug.status_id = status.status_id"
+ ." and bug.os_id = os.os_id and bug.version_id = version.version_id"
+ ." and bug.component_id = component.component_id and bug.project_id = project.project_id "
+ . ($querystring != '' ? "and $querystring " : '')
+ ." order by $order $sort limit $llimit, $selrange");
$headers = array(
'bug_id' => 'bug_id',
Index: report.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/report.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- report.php 2001/08/25 18:39:11 1.14
+++ report.php 2001/09/01 15:44:20 1.15
@@ -34,7 +34,7 @@
$querystring = 'select email as "Assigned To", sum(if(resolution_id = "0",1,0)) as "Open"';
$resfields = array('Assigned To','Open');
// Grab the resolutions from the database
- $q->query("select resolution_name, concat(', sum(if(resolution_id = \"',resolution_id,'\",1,0)) as \"',resolution_name,'\"') from resolution");
+ $q->query("select resolution_name, concat(', sum(if(resolution_id = \"',resolution_id,'\",1,0)) as \"',resolution_name,'\"') from ".TBL_RESOLUTION);
while (list($fieldname, $countquery) = $q->grab()) {
$resfields[] = $fieldname;
$querystring .= $countquery;
@@ -47,7 +47,7 @@
$projectquery = '';
}
- $q->query("$querystring, count(bug_id) as 'Total' from bug b left join auth_user u on assigned_to = user_id $projectquery group by assigned_to");
+ $q->query("$querystring, count(bug_id) as 'Total' from ".TBL_BUG." b left join ".TBL_AUTH_USER." u on assigned_to = user_id $projectquery group by assigned_to");
if (!$q->num_rows()) {
$t->set_var('rows', 'No data to display');
} else {
@@ -86,7 +86,7 @@
$t->set_file('wrap','wrap.html');
$t->set_file('content','report.html');
$t->set_var(array(
- 'projects' => build_select('Project', $projectid),
+ 'projects' => build_select('project', $projectid),
'TITLE' => $TITLE['reporting']
));
Index: user.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/user.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- user.php 2001/08/25 18:39:11 1.13
+++ user.php 2001/09/01 15:44:20 1.14
@@ -28,7 +28,7 @@
$auth->auth['db_fields'] = $column_list;
$column_list = serialize($column_list);
- $q->query("update auth_user set bug_list_fields = '$column_list' where user_id = $u");
+ $q->query("update ".TBL_AUTH_USER." set bug_list_fields = '$column_list' where user_id = $u");
//$t->set_file('content', 'columnlistchanged.html');
show_text('Your bug list column preferences have been saved');
}
@@ -50,7 +50,7 @@
$mpassword = $pass1;
}
- $q->query("update auth_user set password = '$mpassword' where user_id = $u");
+ $q->query("update ".TBL_AUTH_USER." set password = '$mpassword' where user_id = $u");
$t->set_file('content', 'passwordchanged.html');
}
|