|
From: Benjamin C. <bc...@us...> - 2001-08-17 04:06:09
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv19303
Modified Files:
include.php query.php
Log Message:
DB conversion
Index: include.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/include.php,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- include.php 2001/08/16 23:12:52 1.29
+++ include.php 2001/08/17 04:06:06 1.30
@@ -125,15 +125,15 @@
if (ENCRYPTPASS) {
$password = md5($password);
}
- $u = $q->grab("select * from User where Email = '$username' and Password = '$password' and UserLevel > 0");
+ $u = $q->grab("select * from user where email = '$username' and password = '$password' and user_level > 0");
if (!$q->num_rows()) {
return 'nobody';
} else {
- $this->auth['fname'] = $u['FirstName'];
- $this->auth['lname'] = $u['LastName'];
- $this->auth['email'] = $u['Email'];
- $this->auth['perm'] = $select['authlevels'][$u['UserLevel']];
- return $u['UserID'];
+ $this->auth['fname'] = $u['first_name'];
+ $this->auth['lname'] = $u['last_name'];
+ $this->auth['email'] = $u['email'];
+ $this->auth['perm'] = $select['authlevels'][$u['user_level']];
+ return $u['user_id'];
}
}
}
@@ -165,9 +165,9 @@
$this->set_block('wrap', 'adminnavblock', 'anblock');
if ($u && $u != 'nobody') {
list($owner_open, $owner_closed) =
- $q->grab("select sum(if(s.Name in ('Unconfirmed','New','Assigned','Reopened'),1,0)) as Open, sum(if(s.Name not in ('Unconfirmed','New','Assigned','Reopened'),1,0)) as Closed from Bug b left join Status s on Status = StatusID where AssignedTo = $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 bug b left join status s using(status_id) where assigned_to = $u");
list($reporter_open, $reporter_closed) =
- $q->grab("select sum(if(s.Name in ('Unconfirmed','New','Assigned','Reopened'),1,0)) as Open, sum(if(s.Name not in ('Unconfirmed','New','Assigned','Reopened'),1,0)) as Closed from Bug b left join Status s on Status = StatusID where CreatedBy = $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 bug b left join status s using(status_id) where created_by = $u");
$this->set_var(array(
'loggedinas' => $auth->auth['email'],
'liblock' => '',
@@ -225,62 +225,51 @@
///
/// Build a select box with the item matching $value selected
-function build_select($box, $value='',$project=0) {
- #static $select;
+function build_select($box, $value = '', $project = 0) {
global $q, $select;
-
- //include_once "select.php";
+
+ $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"
+ );
+
switch($box) {
- case 'Severity' :
- case 'Status' :
- case 'Resolution' :
- $q->query("Select {$box}ID, Name from $box where SortOrder order by SortOrder");
- while ($row = $q->grab()) {
- if ($value == $row[$box.'ID'] and $value != '') $sel = ' selected';
- else $sel = '';
- $text .= '<option value="'.$row[$box.'ID']."\"$sel>{$row['Name']}</option>";
- }
- break;
- case 'Project' :
- $q->query("Select {$box}ID, Name from $box where Active order by Name");
+ case 'severity' :
+ case 'status' :
+ case 'resolution' :
+ case 'project' :
+ case 'component' :
+ case 'version' :
+ $q->query($queries[$box]);
while ($row = $q->grab()) {
- if ($value == $row[$box.'ID'] and $value != '') $sel = ' selected';
+ if ($value == $row[$box.'_id'] and $value != '') $sel = ' selected';
else $sel = '';
- $text .= '<option value="'.$row[$box.'ID']."\"$sel>{$row['Name']}</option>";
+ $text .= '<option value="'.
+ $row[$box.'_id']."\"$sel>".$row[$box.'_name']."</option>";
}
break;
- case 'Component' :
- $q->query("Select {$box}ID, Name from $box where ProjectID = $project order by Name");
+ case 'os' :
+ $q->query("select {$box}_id, {$box}_name, regex from $box order by sort_order");
while ($row = $q->grab()) {
- if ($value == $row[$box.'ID'] and $value != '') $sel = ' selected';
- else $sel = '';
- $text .= '<option value="'.$row[$box.'ID']."\"$sel>{$row['Name']}</option>";
- }
- break;
- case 'OS' :
- $q->query("Select {$box}ID, Name, Regex from $box order by SortOrder");
- while ($row = $q->grab()) {
if ($value == '' and $row['Regex'] and
preg_match($row['Regex'],$GLOBALS['HTTP_USER_AGENT'])) $sel = ' selected';
elseif ($value == $row[$box.'ID']) $sel = ' selected';
- else $sel = '';
- $text .= '<option value="'.$row[$box.'ID']."\"$sel>{$row['Name']}</option>";
- }
- break;
- case 'Version' :
- $q->query("Select {$box}ID, Name from $box where ProjectID = $project order by Name");
- while ($row = $q->grab()) {
- if ($value == $row[$box.'ID']) $sel = ' selected';
else $sel = '';
- $text .= '<option value="'.$row[$box.'ID']."\"$sel>{$row['Name']}</option>";
+ $text .= '<option value="'.
+ $row[$box.'_id']."\"$sel>".$row[$box.'_name']."</option>";
}
break;
case 'owner' :
- $q->query("Select UserID, Email from User where UserLevel > 1 order by Email");
+ $q->query("Select user_id, email from user where user_level > 1 order by email");
while ($row = $q->grab()) {
- if ($value == $row['UserID']) $sel = ' selected';
+ if ($value == $row['user_id']) $sel = ' selected';
else $sel = '';
- $text .= '<option value="'.$row['UserID']."\"$sel>{$row['Email']}</option>";
+ $text .= "<option value=\"{$row['user_id']}\"$sel>{$row['email']}</option>";
}
break;
default :
@@ -422,7 +411,7 @@
// Check to see if the user is trying to login
if (isset($HTTP_POST_VARS['login'])) {
if (isset($HTTP_POST_VARS['sendpass'])) {
- list($email, $password) = $q->grab("select Email, Password from User where Email = '$username' and UserLevel > 0");
+ list($email, $password) = $q->grab("select email, password from user where email = '$username' and user_level > 0");
if (!$q->num_rows()) {
$t->set_var(array(
'loginerrorcolor' => '#ff0000',
@@ -432,7 +421,7 @@
if (ENCRYPTPASS) {
$password = genpassword(10);
$mpassword = md5($password);
- $q->query("update User set Password = '$mpassword' where Email = '$username'");
+ $q->query("update user set password = '$mpassword' where email = '$username'");
}
mail($email, $STRING['newacctsubject'], sprintf($STRING['newacctmessage'],
$password), 'From: '.ADMINEMAIL);
Index: query.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/query.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- query.php 2001/08/17 03:26:37 1.15
+++ query.php 2001/08/17 04:06:06 1.16
@@ -83,12 +83,12 @@
$t->set_var(array(
'js' => $js,
- 'status' => build_select('Status',$q->grab_field("select status_id from status where status_name = 'New'")),
- 'resolution' => build_select('Resolution',$resolution),
- 'os' => build_select('OS',-1), // Prevent the OS regex selection
+ 'status' => build_select('status',$q->grab_field("select status_id from status where status_name = 'New'")),
+ 'resolution' => build_select('resolution',$resolution),
+ 'os' => build_select('os',-1), // Prevent the OS regex selection
'priority' => build_select('priority',$priority),
- 'severity' => build_select('Severity',$severity),
- 'projects' => build_select('Project'),
+ 'severity' => build_select('severity',$severity),
+ 'projects' => build_select('project'),
'TITLE' => $TITLE['bugquery']
));
@@ -180,7 +180,7 @@
'first' => $llimit+1,
'last' => $llimit+$selrange > $nr ? $nr : $llimit+$selrange,
'total' => $nr,
- 'project' => build_select('Project'),
+ 'project' => build_select('project'),
'TITLE' => $TITLE['buglist']));
$q->query("select bug_id, title, reporter.email as reporter, owner.email as owner, severity_name as severity, bug.created_date, status_name as status, priority_id, version_name as version, component_name as component, resolution_name as resolution from bug, resolution, severity, status, version, component left join user owner on bug.assigned_to = owner.user_id left join user reporter on bug.created_by = reporter.user_id where bug.resolution_id = resolution.resolution_id and bug.severity_id = severity.severity_id and bug.status_id = status.status_id and bug.version_id = version.version_id and bug.component_id = component.component_id ". ($querystring != '' ? "and $querystring " : ''). "order by $order $sort limit $llimit, $selrange");
|