|
From: Benjamin C. <bc...@us...> - 2004-10-25 12:07:43
|
Update of /cvsroot/phpbt/phpbt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28250 Modified Files: CHANGELOG UPGRADING attachment.php bug.php config-dist.php config.php include.php index.php install.php logout.php newaccount.php query.php report.php upgrade.php user.php Added Files: messages.po Log Message: Merging in htmltemplates branch to HEAD Index: CHANGELOG =================================================================== RCS file: /cvsroot/phpbt/phpbt/CHANGELOG,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- CHANGELOG 23 Jul 2003 01:22:12 -0000 1.67 +++ CHANGELOG 25 Oct 2004 12:06:54 -0000 1.68 @@ -3,7 +3,6 @@ : Added display of the bug ids a bug blocks. : Allow users to suppress the update email when changing a bug. : Use localized strings in bug history. -: Added Japanese, Danish, Norwegian, and Spanish translations. : Allow users to override saved queries by saving a new query with the same name as an old one. : Added client-side validation to admin pages. @@ -12,6 +11,9 @@ : Fixed a bug with not being able to change the name of the 'Developer' group. : Added tracking of changes in priority to the bug history. : You can now search on "additional comments" and "description". +: Added the ability to download to Excel +: Fixed publicly-reported bugs +: Changed the localization from string arrays to gettext -- 0.9.1 -- 4 Jan 2003 : Fixed bugs with PostgreSQL Index: UPGRADING =================================================================== RCS file: /cvsroot/phpbt/phpbt/UPGRADING,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- UPGRADING 19 Oct 2002 18:44:53 -0000 1.12 +++ UPGRADING 25 Oct 2004 12:06:54 -0000 1.13 @@ -1,11 +1,14 @@ -Upgrading from 0.8.x to 0.9.x ------------------------------ +Upgrading from 0.9.1 to 1.0 +--------------------------- + +First, backup your database! This upgrade should go smoothly, but +if it doesn't, it's better to be safe than sorry. Following the steps below will upgrade your installation of phpBT. Using the directory where you unpacked the new set of files... 1. Edit config-dist.php, changing the database settings to match those from - your old config.php (DB_*, SMARTY_PATH and TBL_PREFIX constants). Save + your old config.php (DB_* and TBL_PREFIX constants). Save config-dist.php as config.php. 2. Load upgrade.php with your web browser. 3. After running that script your installation has been upgraded. Index: attachment.php =================================================================== RCS file: /cvsroot/phpbt/phpbt/attachment.php,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- attachment.php 20 May 2003 03:08:01 -0000 1.21 +++ attachment.php 25 Oct 2004 12:06:54 -0000 1.22 @@ -2,7 +2,7 @@ // attachment.php - Adding, deleting, and displaying attachments // ------------------------------------------------------------------------ -// Copyright (c) 2001, 2002 The phpBugTracker Group +// Copyright (c) 2001 - 2004 The phpBugTracker Group // ------------------------------------------------------------------------ // This file is part of phpBugTracker // @@ -25,82 +25,86 @@ include 'include.php'; function del_attachment($attachid) { - global $db, $HTTP_SERVER_VARS; + global $db; if (list($filename, $mimetype) = grab_attachment($attachid)) { $db->query("delete from ".TBL_ATTACHMENT." where attachment_id = $attachid"); unlink($filename); - header("Location: {$HTTP_SERVER_VARS['HTTP_REFERER']}"); + header("Location: {$_SERVER['HTTP_REFERER']}"); } } function grab_attachment($attachid) { - global $db, $STRING; + global $db; if (!is_numeric($attachid)) { - show_text($STRING['bad_attachment'], true); + show_text(translate("That attachment does not exist"), true); return false; } - $ainfo = $db->getRow("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"); + $ainfo = $db->getRow("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 (empty($ainfo)) { - show_text($STRING['bad_attachment'], true); + show_text(translate("That attachment does not exist"), true); return false; } $filename = join('/',array(ATTACHMENT_PATH, $ainfo['project_id'], "{$ainfo['bug_id']}-{$ainfo['file_name']}")); if (!is_readable($filename)) { - show_text($STRING['bad_attachment'], true); + show_text(translate("That attachment does not exist"), true); return false; } return array($filename, $ainfo['mime_type']); } function add_attachment($bugid, $description) { - global $db, $HTTP_POST_FILES, $now, $u, $STRING, $t, $_pv; + global $db, $now, $u, $t; - if (!isset($HTTP_POST_FILES['attachment']) || - $HTTP_POST_FILES['attachment']['tmp_name'] == 'none') { - show_attachment_form($bugid, $STRING['give_attachment']); + if (!isset($_FILES['attachment'])) { + show_attachment_form($bugid, translate("Please specify a file to upload")); + return; + } + + if ($_FILES['attachment']['tmp_name'] == 'none') { + if (empty($_FILES['attachment']['name'])) { + show_attachment_form($bugid, translate("Please specify a file to upload")); + } else { + show_attachment_form($bugid, sprintf(translate("The file you specified is larger than %s bytes"), number_format(ATTACHMENT_MAX_SIZE))); + } return; } // Check the upload size. If the size was greater than the max in // php.ini, the file won't even be set and will fail at the check above - if ($HTTP_POST_FILES['attachment']['size'] > ATTACHMENT_MAX_SIZE) { - show_attachment_form($bugid, $STRING['attachment_too_large']); + if ($_FILES['attachment']['size'] > ATTACHMENT_MAX_SIZE) { + show_attachment_form($bugid, printf(translate("The file you specified is larger than %d bytes"), number_format(ATTACHMENT_MAX_SIZE))); return; } $projectid = $db->getOne("select project_id from ".TBL_BUG." where bug_id = $bugid"); if (!$projectid) { - show_text($STRING['nobug'], true); + show_text(translate("That bug does not exist"), true); return; } // Check for a previously-uploaded attachment with the same name, bug, and project - $rs = $db->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"); + $rs = $db->query("select a.bug_id, project_id from ".TBL_ATTACHMENT." a, ".TBL_BUG." b where file_name = '{$_FILES['attachment']['name']}' and a.bug_id = b.bug_id"); while ($rs->fetchInto($ainfo)) { if ($bugid == $ainfo['bug_id'] && $projectid == $ainfo['project_id']) { - show_attachment_form($bugid, $STRING['dupe_attachment']); + show_attachment_form($bugid, translate("That attachment already exists for this bug")); return; } } $filepath = ATTACHMENT_PATH; - $tmpfilename = $HTTP_POST_FILES['attachment']['tmp_name']; - $filename = "$bugid-{$HTTP_POST_FILES['attachment']['name']}"; + $tmpfilename = $_FILES['attachment']['tmp_name']; + $filename = "$bugid-{$_FILES['attachment']['name']}"; if (!is_dir($filepath)) { - show_attachment_form($bugid, $STRING['no_attachment_save_path']); + show_attachment_form($bugid, translate("Couldn't find where to save the file!")); return; } if (!is_writeable($filepath)) { - show_attachment_form($bugid, $STRING['attachment_path_not_writeable']); + show_attachment_form($bugid, translate("Couldn't create a file in the save path")); return; } @@ -108,39 +112,33 @@ @mkdir("$filepath/$projectid", 0775); } - if (!@move_uploaded_file($HTTP_POST_FILES['attachment']['tmp_name'], + if (!@move_uploaded_file($_FILES['attachment']['tmp_name'], "$filepath/$projectid/$filename")) { - show_attachment_form($bugid, $STRING['attachment_move_error']); + show_attachment_form($bugid, translate("There was an error moving the uploaded file")); return; } @chmod("$filepath/$projectid/$filename", 0766); - $db->query("insert into ".TBL_ATTACHMENT." (attachment_id, bug_id, file_name, ". - "description, file_size, mime_type, created_by, created_date) values (". - join(', ', array($db->nextId(TBL_ATTACHMENT), $bugid, - $db->quote($HTTP_POST_FILES['attachment']['name']), - $db->quote(stripslashes($description)), - $HTTP_POST_FILES['attachment']['size'], - $db->quote($HTTP_POST_FILES['attachment']['type']), $u, $now)).")"); + $db->query("insert into ".TBL_ATTACHMENT." (attachment_id, bug_id, file_name, description, file_size, mime_type, created_by, created_date) values (".join(', ', array($db->nextId(TBL_ATTACHMENT), $bugid, $db->quote($_FILES['attachment']['name']), $db->quote(stripslashes($description)), $_FILES['attachment']['size'], $db->quote($_FILES['attachment']['type']), $u, $now)).")"); - if ($_pv['use_js']) { - $t->display('admin/edit-submit.html'); + if ($_POST['use_js']) { + $t->render('admin/edit-submit.html'); } else { header("Location: bug.php?op=show&bugid=$bugid"); } } function show_attachment_form($bugid, $error = '') { - global $db, $t, $STRING; + global $db, $t; if (!is_numeric($bugid)) { - show_text($STRING['nobug'], true); + show_text(translate("That bug does not exist"), true); return; } $bugexists = $db->getOne("select count(*) from ".TBL_BUG." where bug_id = $bugid"); if (!$bugexists) { - show_text($STRING['nobug'], true); + show_text(translate("That bug does not exist"), true); return; } @@ -153,20 +151,21 @@ ? number_format(ini_get('upload_max_filesize')) : number_format(ATTACHMENT_MAX_SIZE) )); - $t->wrap('bugattachmentform.html', 'addattachment'); + $t->render('bugattachmentform.html', translate("Add Attachment"), + !empty($_REQUEST['use_js']) ? 'wrap-popup.html' : 'wrap.html'); } -if (isset($_gv['del'])) { +if (isset($_GET['del'])) { if (!$perm->have_perm('Administrator')) { - show_text($STRING['bad_permission']); + show_text(translate("You do not have the permissions required for that function")); } else { - del_attachment($_gv['del']); + del_attachment($_GET['del']); } -} elseif (isset($_pv['submit'])) { +} elseif (isset($_POST['submit'])) { $perm->check('Editbug'); - add_attachment($_pv['bugid'], $_pv['description']); -} elseif (isset($_gv['attachid'])) { - if (list($filename, $mimetype) = grab_attachment($_gv['attachid'])) { + add_attachment($_POST['bugid'], $_POST['description']); +} elseif (isset($_GET['attachid'])) { + if (list($filename, $mimetype) = grab_attachment($_GET['attachid'])) { $base = basename($filename); header("Content-Disposition: attachment; filename=\"$base\""); header("Content-Type: $mimetype"); @@ -178,7 +177,7 @@ } } else { $perm->check('Editbug'); - show_attachment_form($_gv['bugid']); + show_attachment_form($_GET['bugid']); } ?> Index: bug.php =================================================================== RCS file: /cvsroot/phpbt/phpbt/bug.php,v retrieving revision 1.134 retrieving revision 1.135 diff -u -r1.134 -r1.135 --- bug.php 24 Jul 2003 04:47:13 -0000 1.134 +++ bug.php 25 Oct 2004 12:06:54 -0000 1.135 @@ -2,7 +2,7 @@ // bug.php - All the interactions with a bug // ------------------------------------------------------------------------ -// Copyright (c) 2001, 2002 The phpBugTracker Group +// Copyright (c) 2001 - 2004 The phpBugTracker Group // ------------------------------------------------------------------------ // This file is part of phpBugTracker // @@ -27,60 +27,51 @@ /// /// View the votes for a bug function vote_view($bug_id) { - global $u, $db, $t, $STRING; + global $u, $db, $t; - $t->assign('votes', $db->getAll('select login, v.created_date '. - 'from '.TBL_AUTH_USER.' u, '.TBL_BUG_VOTE." v ". - "where u.user_id = v.user_id and bug_id = $bug_id ". - 'order by v.created_date')); - $t->wrap('bugvotes.html', 'bugvotes'); + $t->assign('votes', $db->getAll('select login, v.created_date '.'from '.TBL_AUTH_USER.' u, '.TBL_BUG_VOTE." v where u.user_id = v.user_id and bug_id = $bug_id order by v.created_date")); + $t->render('bugvotes.html', translate("Bug Votes")); } /// /// Add a vote to a bug to (possibly) promote it function vote_bug($bug_id) { - global $u, $db, $now, $_pv, $STRING; + global $u, $db, $now; // Check to see if the user already voted on this bug - if ($db->getOne("select count(*) from ".TBL_BUG_VOTE. - " where bug_id = $bug_id and user_id = $u")) { - show_bug($bug_id, array('vote' => $STRING['already_voted'])); + if ($db->getOne("select count(*) from ".TBL_BUG_VOTE." where bug_id = $bug_id and user_id = $u")) { + show_bug($bug_id, array('vote' => translate("You have already voted for this bug"))); return; } // Check whether the user has used his allotment of votes (if there is a max) - if (MAX_USER_VOTES and $db->getOne("select count(*) from ".TBL_BUG_VOTE. - " where user_id = $u") >= MAX_USER_VOTES) { - show_bug($bug_id, array('vote' => $STRING['too_many_votes'])); + if (MAX_USER_VOTES and + $db->getOne("select count(*) from ".TBL_BUG_VOTE." where user_id = $u") >= MAX_USER_VOTES) { + show_bug($bug_id, array('vote' => translate("You have reached the maximum number of votes per user"))); return; } // Record the vote - $db->query("insert into ".TBL_BUG_VOTE." (user_id, bug_id, created_date) - values ($u, $bug_id, $now)"); + $db->query("insert into ".TBL_BUG_VOTE." (user_id, bug_id, created_date) values ($u, $bug_id, $now)"); // Proceed only if promoting by votes is turned on if (PROMOTE_VOTES) { // Has this bug already been promoted? - $bug_is_new = $db->getOne("select count(*) from ".TBL_BUG." b, ". - TBL_STATUS." s where bug_id = $bug_id and b.status_id = s.status_id and - status_name = 'New'"); + $bug_is_new = $db->getOne("select count(*) from ".TBL_BUG." b, ".TBL_STATUS." s where bug_id = $bug_id and b.status_id = s.status_id and status_name = 'New'"); // If a number of votes are required to promote a bug, check for promotion - if (!$bug_is_new and $db->getOne("select count(*) from ". - TBL_BUG_VOTE." where bug_id = $bug_id") == PROMOTE_VOTES) { + if (!$bug_is_new and $db->getOne("select count(*) from ".TBL_BUG_VOTE." where bug_id = $bug_id") == PROMOTE_VOTES) { $status_id = BUG_PROMOTED; $buginfo = $db->getOne("select * from ".TBL_BUG." where bug_id = $bug_id"); - $changedfields = array('status_id' => $status_id); + $changedfields = array('status_id' => $status_id); do_changedfields($u, $buginfo, $changedfields); } } - if (isset($_pv['pos'])) { - $posinfo = "&pos={$_pv['pos']}"; + if (isset($_POST['pos'])) { + $posinfo = "&pos={$_POST['pos']}"; } else { $posinfo = ''; } - header("Location: bug.php?op=show&bugid=$bug_id$posinfo"); - + header("Location: bug.php?op=show&bugid=$bug_id$posinfo"); } /// @@ -98,28 +89,27 @@ '<a href="'.CVS_WEB.'\\1#rev\\4" target="_new">\\1</a>\\5' // external link to cvs web interface ); - return preg_replace($patterns, $replacements, - stripslashes($comments)); + return preg_replace($patterns, $replacements, stripslashes($comments)); } /// /// Show the activity for a bug function show_history($bugid) { - global $db, $t, $STRING, $QUERY; + global $db, $t, $QUERY; if (!is_numeric($bugid)) { - show_text($STRING['nobughistory']); + show_text(translate("There is no history for this bug")); return; } $t->assign('history', $db->getAll(sprintf($QUERY['bug-history'], $bugid))); - $t->wrap('bughistory.html', 'bughistory'); + $t->render('bughistory.html', translate("Bug History")); } /// /// Send the email about changes to the bug and log the changes in the DB function do_changedfields($userid, &$buginfo, $cf = array(), $comments = '') { - global $db, $t, $u, $select, $now, $STRING, $QUERY, $_pv; + global $db, $t, $u, $select, $now, $QUERY; // It's a new bug if the changedfields array is empty and there are no comments $newbug = (!count($cf) and !$comments); @@ -128,20 +118,16 @@ $template = $newbug ? "bugemail-newbug.$template_ext" : "bugemail.$template_ext"; foreach(array('title','url','priority') as $field) { if (isset($cf[$field])) { - $db->query('insert into '.TBL_BUG_HISTORY. - ' (bug_id, changed_field, old_value, new_value, created_by, created_date)'. - " values (". join(', ', array($buginfo['bug_id'], $db->quote($field), - $db->quote(stripslashes($buginfo[$field])), - $db->quote(stripslashes($cf[$field])), $u, $now)).")"); - $t->assign(array( + $db->query('insert into '.TBL_BUG_HISTORY.' (bug_id, changed_field, old_value, new_value, created_by, created_date) values ('. join(', ', array($buginfo['bug_id'], $db->quote($field), $db->quote(stripslashes($buginfo[$field])), $db->quote(stripslashes($cf[$field])), $u, $now)).")"); + $t->assign(array( $field => stripslashes($cf[$field]), $field.'_stat' => '!' - )); + )); } else { - $t->assign(array( + $t->assign(array( $field => stripslashes($buginfo[$field]), $field.'_stat' => ' ' - )); + )); } } @@ -161,21 +147,15 @@ foreach($cfgDatabase as $field => $table) { if (isset($buginfo[$field.'_id'])) { - $oldvalue = $db->getOne("select ${field}_name from $table". - " where ${field}_id = {$buginfo[$field.'_id']}"); + $oldvalue = $db->getOne("select ${field}_name from $table"." where ${field}_id = {$buginfo[$field.'_id']}"); } if (empty($oldvalue)) $oldvalue = 'None'; if (isset($cf[$field.'_id'])) { - $newvalue = $db->getOne("select ${field}_name from $table". - " where ${field}_id = {$cf[$field.'_id']}"); - if (empty($newvalue)) $newvalue = 'None'; + $newvalue = $db->getOne("select ${field}_name from $table where ${field}_id = {$cf[$field.'_id']}"); + if (empty($newvalue)) $newvalue = 'None'; - $db->query('insert into '.TBL_BUG_HISTORY. - ' (bug_id, changed_field, old_value, new_value, created_by, created_date)'. - " values (". join(', ', array($buginfo['bug_id'], $db->quote($STRING['BUGDISPLAY'][$field]), - $db->quote(stripslashes($oldvalue)), - $db->quote(stripslashes($newvalue)), $u, $now)).")"); + $db->query('insert into '.TBL_BUG_HISTORY.' (bug_id, changed_field, old_value, new_value, created_by, created_date) values ('. join(', ', array($buginfo['bug_id'], $db->quote(translate($field)), $db->quote(stripslashes($oldvalue)), $db->quote(stripslashes($newvalue)), $u, $now)).")"); $t->assign(array( $field.'_id' => stripslashes($newvalue), $field.'_id_stat' => '!' @@ -194,19 +174,15 @@ foreach($versions as $field => $field_name) { if (isset($buginfo[$field.'_id'])) { - $oldvalue = $db->getOne('select version_name from '.$cfgDatabase['version']. - ' where version_id = '.$buginfo[$field.'_id']); + $oldvalue = $db->getOne('select version_name from '.$cfgDatabase['version'].' where version_id = '.$buginfo[$field.'_id']); } if (empty($oldvalue)) $oldvalue = 'None'; if (isset($cf[$field.'_id'])) { - $newvalue = $db->getOne('select version_name from '.$cfgDatabase['version']. - ' where version_id = '.$cf[$field.'_id']); + $newvalue = $db->getOne('select version_name from '.$cfgDatabase['version'].' where version_id = '.$cf[$field.'_id']); if (empty($newvalue)) $newvalue = 'None'; - $db->query('insert into '.TBL_BUG_HISTORY. - ' (bug_id, changed_field, old_value, new_value, created_by, created_date)'. - " values (". join(', ', array($buginfo['bug_id'], $db->quote($STRING['BUGDISPLAY'][$field_name]), + $db->query('insert into '.TBL_BUG_HISTORY.' (bug_id, changed_field, old_value, new_value, created_by, created_date) values ('. join(', ', array($buginfo['bug_id'], $db->quote(translate($field_name)), $db->quote(stripslashes($oldvalue)), $db->quote(stripslashes($newvalue)), $u, $now)).")"); $t->assign(array( @@ -222,41 +198,28 @@ } // See if the assignment has changed -- grab the email for notifications either way - list($assignedto, $emailassignedto) = $db->getRow('select email, email_notices from '. - TBL_AUTH_USER." u, ".TBL_USER_PREF.' p where u.user_id = '. - (!empty($cf['assigned_to']) ? $cf['assigned_to'] : $buginfo['assigned_to']). - " and u.user_id = p.user_id", DB_FETCHMODE_ORDERED); + list($assignedto, $emailassignedto) = $db->getRow('select email, email_notices from '.TBL_AUTH_USER." u, ".TBL_USER_PREF.' p where u.user_id = '.(!empty($cf['assigned_to']) ? $cf['assigned_to'] : $buginfo['assigned_to'])." and u.user_id = p.user_id", DB_FETCHMODE_ORDERED); if (!empty($cf['assigned_to'])) { $assignedtostat = '!'; - $oldassignedto = $db->getOne('select email from '. - TBL_AUTH_USER.' u where u.user_id = '.$buginfo['assigned_to']); + $oldassignedto = $db->getOne('select email from '.TBL_AUTH_USER.' u where u.user_id = '.$buginfo['assigned_to']); if (is_null($oldassignedto)) { $oldassignedto = ''; } - $db->query('insert into '.TBL_BUG_HISTORY. - ' (bug_id, changed_field, old_value, new_value, created_by, created_date)'. - " values (". join(', ', array($buginfo['bug_id'], - $db->quote($STRING['BUGDISPLAY']['assignedto']), - $db->quote($oldassignedto), $db->quote($assignedto), $u, $now)).")"); + $db->query('insert into '.TBL_BUG_HISTORY.' (bug_id, changed_field, old_value, new_value, created_by, created_date) values ('. join(', ', array($buginfo['bug_id'], $db->quote(translate("Assigned To")), $db->quote($oldassignedto), $db->quote($assignedto), $u, $now)).")"); } else { $assignedtostat = ' '; } - if (!empty($_pv['suppress_email'])) return; // Don't send email if silent update requested. + if (!empty($_POST['suppress_email'])) return; // Don't send email if silent update requested. // Reporter never changes - $reporter = $db->getOne('select email from '.TBL_AUTH_USER. - " u, ".TBL_USER_PREF." p where u.user_id = {$buginfo['created_by']} ". - "and u.user_id = p.user_id and email_notices = 1"); + $reporter = $db->getOne('select email from '.TBL_AUTH_USER." u, ".TBL_USER_PREF." p where u.user_id = {$buginfo['created_by']} and u.user_id = p.user_id and email_notices = 1"); $reporterstat = ' '; // If there are new comments grab the comments immediately before the latest if ($comments or $newbug) { - $rs = $db->limitQuery('select u.login, 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', 0, 2); + $rs = $db->limitQuery('select u.login, 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", 0, 2); $rs->fetchInto($row); $t->assign(array( 'newpostedby' => $row['login'], @@ -268,10 +231,7 @@ // 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 ($rs->numRows() < 2) { - list($by, $on, $comments) = $db->getRow('select u.login, 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']}", - null, DB_FETCHMODE_ORDERED); + list($by, $on, $comments) = $db->getRow('select u.login, 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']}", null, DB_FETCHMODE_ORDERED); $t->assign(array( 'oldpostedby' => $by, 'oldpostedon' => date(TIME_FORMAT,$on).' on '.date(DATE_FORMAT,$on), @@ -310,36 +270,39 @@ // Later add a watcher (such as QA person) check here if (count($maillist)) { - if ($toemail = delimit_list(', ',$maillist)) { - $t->assign(array( - 'bugid' => $buginfo['bug_id'], - 'siteroot' => INSTALL_URL, - 'bugurl' => INSTALL_URL."/bug.php?op=show&bugid={$buginfo['bug_id']}", - 'priority' => $select['priority'][(!empty($cf['priority']) ? $cf['priority'] : $buginfo['priority'])], - 'priority_stat' => !empty($cf['priority']) ? '!' : ' ', - 'reporter' => $reporter, - 'reporter_stat' => $reporterstat, - 'assignedto' => $assignedto, - 'assignedto_stat' => $assignedtostat - )); + $t->assign(array( + 'bugid' => $buginfo['bug_id'], + 'siteroot' => INSTALL_URL, + 'bugurl' => INSTALL_URL."/bug.php?op=show&bugid={$buginfo['bug_id']}", + 'priority' => $select['priority'][(!empty($cf['priority']) + ? $cf['priority'] : $buginfo['priority'])], + 'priority_stat' => !empty($cf['priority']) ? '!' : ' ', + 'reporter' => $reporter, + 'reporter_stat' => $reporterstat, + 'assignedto' => $assignedto, + 'assignedto_stat' => $assignedtostat + )); - qp_mail($toemail,"[Bug {$buginfo['bug_id']}] ".($newbug ? 'New' : 'Changed').' - '. - stripslashes((!empty($cf['title']) ? $cf['title'] : $buginfo['title'])), - $t->fetch($template), - sprintf("From: %s\nReply-To: %s\nErrors-To: %s", ADMIN_EMAIL, ADMIN_EMAIL, ADMIN_EMAIL)); - } + require_once('./inc/htmlMimeMail/htmlMimeMail.php'); + $mail = new htmlMimeMail(); + $mail->setText($t->fetch($template)); + $mail->setFrom(ADMIN_EMAIL); + $mail->setSubject("[Bug {$buginfo['bug_id']}] ". + ($newbug ? 'New' : 'Changed').' - '. + stripslashes((!empty($cf['title']) ? $cf['title'] : $buginfo['title']))); + $mail->send($maillist); } } function update_bug($bugid = 0) { - global $db, $t, $u, $STRING, $perm, $now, $_pv; + global $db, $t, $u, $perm, $now; // Pull bug from database to determine changed fields and for user validation $buginfo = $db->getRow("select * from ".TBL_BUG." where bug_id = $bugid"); $changedfields = array(); - if (isset($_pv)) { - foreach ($_pv as $k => $v) { + if (isset($_POST)) { + foreach ($_POST as $k => $v) { $$k = $v; if ($k == 'url') { if (($v == 'http://') || ($v == 'https://')) { @@ -359,35 +322,31 @@ // Should we allow changes to be made to this bug by this user? if (STRICT_UPDATING and !($u == $buginfo['assigned_to'] or $u == $buginfo['created_by'] or $perm->have_perm('Manager'))) { - show_bug($bugid,array('status' => $STRING['bugbadperm'])); + show_bug($bugid,array('status' => translate("You can not change this bug"))); return; } // Check for more than one person modifying the bug at the same time if ($last_modified_date != $buginfo['last_modified_date']) { - show_bug($bugid, array('status' => $STRING['datecollision'])); + show_bug($bugid, array('status' => translate("Someone has updated this bug since you viewed it. The bug info has been reloaded with the latest changes."))); return; } // Add CC if specified if ($add_cc) { - if (!$cc_uid = $db->getOne("select user_id from ".TBL_AUTH_USER. - " where login = ".$db->quote(stripslashes($add_cc)))) { - show_bug($bugid,array('status' => $STRING['nouser'])); + if (!$cc_uid = $db->getOne("select user_id from ".TBL_AUTH_USER." where login = ".$db->quote(stripslashes($add_cc)))) { + show_bug($bugid,array('status' => translate("That user does not exist"))); return; } - $cc_already = $db->getOne('select user_id from '.TBL_BUG_CC. - " where bug_id = $bugid and user_id = $cc_uid"); + $cc_already = $db->getOne('select user_id from '.TBL_BUG_CC." where bug_id = $bugid and user_id = $cc_uid"); if (!$cc_already && $cc_uid != $buginfo['created_by']) { - $db->query("insert into ".TBL_BUG_CC." (bug_id, user_id, created_by, - created_date) values ($bugid, $cc_uid, $u, $now)"); + $db->query("insert into ".TBL_BUG_CC." (bug_id, user_id, created_by, created_date) values ($bugid, $cc_uid, $u, $now)"); } } // Remove CCs if requested if (isset($remove_cc) and $remove_cc[0]) { - $db->query('delete from '.TBL_BUG_CC." where bug_id = $bugid and user_id in (". - delimit_list(',', $remove_cc).')'); + $db->query('delete from '.TBL_BUG_CC." where bug_id = $bugid and user_id in (".@join(',', $remove_cc).')'); } // Add dependency if requested @@ -396,62 +355,43 @@ // Validate the bug number if (!is_numeric($add_dependency)) { - show_bug($bugid, array('add_dep' => $STRING['nobug'])); + show_bug($bugid, array('add_dep' => translate("That bug does not exist"))); return; } if (!$db->getOne('select count(*) from '.TBL_BUG." where bug_id = $add_dependency")) { - show_bug($bugid, array('add_dep' => $STRING['nobug'])); + show_bug($bugid, array('add_dep' => translate("That bug does not exist"))); return; } // Check if the dependency has already been added - if ($db->getOne('select count(*) from '.TBL_BUG_DEPENDENCY. - " where bug_id = $bugid and depends_on = $add_dependency")) { - show_bug($bugid, array('add_dep' => $STRING['dupe_dependency'])); + if ($db->getOne('select count(*) from '.TBL_BUG_DEPENDENCY." where bug_id = $bugid and depends_on = $add_dependency")) { + show_bug($bugid, array('add_dep' => translate("That bug dependency has already been added"))); return; } // Add it - $db->query("insert into ".TBL_BUG_DEPENDENCY. - " (bug_id, depends_on) values($bugid, $add_dependency)"); + $db->query("insert into ".TBL_BUG_DEPENDENCY." (bug_id, depends_on) values($bugid, $add_dependency)"); } // Remove dependency if requested if (!empty($del_dependency)) { $del_dependency = preg_replace('/\D/', '', $del_dependency); if (is_numeric($del_dependency)) { - $db->query("delete from ".TBL_BUG_DEPENDENCY. - " where bug_id = $bugid and depends_on = $del_dependency"); + $db->query("delete from ".TBL_BUG_DEPENDENCY." where bug_id = $bugid and depends_on = $del_dependency"); } } if ($comments) { // $comments = strip_tags($comments); -- Uncomment this if you want no <> content in the comments - $db->query("insert into ".TBL_COMMENT." (comment_id, bug_id, comment_text, created_by, created_date)". - " values (".$db->nextId(TBL_COMMENT).", $bugid, ". - $db->quote(stripslashes($comments)).", $u, $now)"); + $db->query("insert into ".TBL_COMMENT." (comment_id, bug_id, comment_text, created_by, created_date) values (".$db->nextId(TBL_COMMENT).", $bugid, ".$db->quote(stripslashes($comments)).", $u, $now)"); } - // Allow for removing of some items from the bug page - $priority = $priority ? $priority : 0; - $os_id = $os_id ? $os_id : 0; - $severity_id = $severity_id ? $severity_id : 0; - if (is_closed($status_id)) { $closed_query = ", close_date = $now"; } else { $closed_query = ''; } - $db->query("update ".TBL_BUG." set title = ".$db->quote(stripslashes($title)). - ', url = '.$db->quote(stripslashes($url)).", severity_id = $severity_id, ". - "priority = $priority, status_id = $status_id, ". - "database_id = $database_id, to_be_closed_in_version_id = $to_be_closed_in_version_id, ". - 'closed_in_version_id = '.$closed_in_version_id.', '. - 'site_id ='.$site_id.', '. - "resolution_id = $resolution_id, assigned_to = $assigned_to, ". - "project_id = $project_id, version_id = $version_id, ". - "component_id = $component_id, os_id = $os_id, last_modified_by = $u, ". - "last_modified_date = $now $closed_query where bug_id = $bugid"); + $db->query("update ".TBL_BUG." set title = ".$db->quote(stripslashes($title)).', url = '.$db->quote(stripslashes($url)).", severity_id = ".(int)$severity_id.", priority = ".(int)$priority.", status_id = ".(int)$status_id.", database_id = ".(int)$database_id.", to_be_closed_in_version_id = ".(int)$to_be_closed_in_version_id.", closed_in_version_id = ".(int)$closed_in_version_id.', site_id ='.(int)$site_id.", resolution_id = ".(int)$resolution_id.", assigned_to = ".(int)$assigned_to.", project_id = $project_id, version_id = $version_id, component_id = ".(int)$component_id.", os_id = ".(int)$os_id.", last_modified_by = $u, last_modified_date = $now $closed_query where bug_id = $bugid"); // If the project has changed, move any attachments if (!empty($changedfields['project_id'])) { @@ -466,29 +406,26 @@ } function add_attachment($bugid, $description) { - global $db, $HTTP_POST_FILES, $now, $u, $STRING, $t, $_pv; + global $db, $now, $u, $t; - if (!isset($HTTP_POST_FILES['attachment']) || - $HTTP_POST_FILES['attachment']['tmp_name'] == 'none') { + if (!isset($_FILES['attachment']) || + $_FILES['attachment']['tmp_name'] == 'none') { return; } // Check the upload size. If the size was greater than the max in // php.ini, the file won't even be set and will fail at the check above - if ($HTTP_POST_FILES['attachment']['size'] > ATTACHMENT_MAX_SIZE) { + if ($_FILES['attachment']['size'] > ATTACHMENT_MAX_SIZE) { return; } $projectid = $db->getOne("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 - $rs = $db->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"); + $rs = $db->query("select a.bug_id, project_id from ".TBL_ATTACHMENT." a, ".TBL_BUG." b where file_name = '{$_FILES['attachment']['name']}' and a.bug_id = b.bug_id"); while ($rs->fetchInto($ainfo)) { if ($bugid == $ainfo['bug_id'] && $projectid == $ainfo['project_id']) { return; @@ -496,8 +433,8 @@ } $filepath = ATTACHMENT_PATH; - $tmpfilename = $HTTP_POST_FILES['attachment']['tmp_name']; - $filename = "$bugid-{$HTTP_POST_FILES['attachment']['name']}"; + $tmpfilename = $_FILES['attachment']['tmp_name']; + $filename = "$bugid-{$_FILES['attachment']['name']}"; if (!is_dir($filepath)) { return; @@ -511,28 +448,15 @@ @mkdir("$filepath/$projectid", 0775); } - if (!@move_uploaded_file($HTTP_POST_FILES['attachment']['tmp_name'], + if (!@move_uploaded_file($_FILES['attachment']['tmp_name'], "$filepath/$projectid/$filename")) { return; } @chmod("$filepath/$projectid/$filename", 0766); - $db->query("insert into ".TBL_ATTACHMENT." (attachment_id, bug_id, file_name, ". - "description, file_size, mime_type, created_by, created_date) values (". - join(', ', array($db->nextId(TBL_ATTACHMENT), $bugid, - $db->quote($HTTP_POST_FILES['attachment']['name']), - $db->quote(stripslashes($description)), - $HTTP_POST_FILES['attachment']['size'], - $db->quote($HTTP_POST_FILES['attachment']['type']), $u, $now)).")"); - - if ($_pv['use_js']) { - $t->display('admin/edit-submit.html'); - } else { - header("Location: bug.php?op=show&bugid=$bugid"); - } + $db->query("insert into ".TBL_ATTACHMENT." (attachment_id, bug_id, file_name, description, file_size, mime_type, created_by, created_date) values (".join(', ', array($db->nextId(TBL_ATTACHMENT), $bugid, $db->quote($_FILES['attachment']['name']), $db->quote(stripslashes($description)), $_FILES['attachment']['size'], $db->quote($_FILES['attachment']['type']), $u, $now)).")"); } - /// /// Move attachments from one project directory to another function move_attachments($bug_id, $old_project, $new_project) { @@ -543,86 +467,54 @@ @mkdir("$filepath/$new_project", 0775); } - $rs = $db->query("select attachment_id, file_name from ".TBL_ATTACHMENT. - " where bug_id = $bug_id"); + $rs = $db->query("select attachment_id, file_name from ".TBL_ATTACHMENT." where bug_id = $bug_id"); while ($row = $rs->fetchRow()) { @rename("$filepath/$old_project/$bug_id-{$row['file_name']}", "$filepath/$new_project/$bug_id-{$row['file_name']}"); } } - - - function do_form($bugid = 0) { - global $db, $me, $u, $_pv, $_gv, $STRING, $now, $HTTP_SERVER_VARS; + global $db, $me, $u, $now; $error = ''; // Validation - if (!$_pv['title'] = htmlspecialchars(trim($_pv['title']))) { - $error = $STRING['givesummary']; - } elseif (!$_pv['description'] = htmlspecialchars(trim($_pv['description']))) { - $error = $STRING['givedesc']; + if (!$_POST['title'] = htmlspecialchars(trim($_POST['title']))) { + $error = translate("Please enter a summary"); + } elseif (!$_POST['description'] = htmlspecialchars(trim($_POST['description']))) { + $error = translate("Please enter a description"); } if ($error) { - $_gv['project'] = $_pv['project']; + $_GET['project'] = $_POST['project']; show_form($bugid, $error); return; } - while (list($k,$v) = each($_pv)) { - $$k = $v; - } - + extract($_POST); if ($url == 'http://') { $url = ''; } + + // Use the selected reporter, if specified + $reporter = ($reporter and is_numeric($reporter)) ? $reporter : $u; - // Allow for removing of some items from the bug page - $priority = $priority ? $priority : 0; - $os = $os ? $os : 0; - $severity = $severity ? $severity : 0; - - if (!$bugid) { - $bugid = $db->nextId(TBL_BUG); - - // Check to see if this bug's component has an owner and should be assigned - if ($owner = $db->getOne("select owner from ".TBL_COMPONENT." c where component_id = $component")) { - $status = BUG_ASSIGNED; - } else { - $owner = 0; - // If we aren't using voting to promote, then auto-promote to New - $status = PROMOTE_VOTES ? BUG_UNCONFIRMED : BUG_PROMOTED; - } - - $db->query('insert into '.TBL_BUG.' (bug_id, title, description, url, '. - 'severity_id, priority, status_id, assigned_to, created_by, created_date, '. - 'last_modified_by, last_modified_date, project_id, site_id, database_id, version_id, '. - 'component_id, os_id, browser_string) values ('.$bugid.', '. - join(', ', array($db->quote(stripslashes($title)), - $db->quote(stripslashes($description)), - $db->quote(stripslashes($url)))).', '. - $severity.', '.$priority.', '.$status.', '.$owner.', '.$u.', '.$now.', '.$u.', '.$now.', '.$project.', '. - $site.', '.$database.', '.$version.', '.$component.', '.$os.', '. - $db->quote(stripslashes($HTTP_SERVER_VARS['HTTP_USER_AGENT'])).')'); - $buginfo = $db->getRow('select * from '.TBL_BUG." where bug_id = $bugid"); - do_changedfields($u, $buginfo); + // Check to see if this bug's component has an owner and should be assigned + if ($owner = $db->getOne("select owner from ".TBL_COMPONENT." c where component_id = $component")) { + $status = BUG_ASSIGNED; } else { - $db->query('update '.TBL_BUG.' set title = '.$db->quote(stripslashes($title)). - ", description = ".$db->quote(stripslashes($description)). - ", url = ".$db->quote(stripslashes($url)). - ", severity_id = '$severity', priority = '$priority', ". - "status_id = $status, assigned_to = '$assignedto', ". - 'database_id = '.$database.', site_id = '.$site.', '. - "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'"); + $owner = 0; + // If we aren't using voting to promote, then auto-promote to New + $status = PROMOTE_VOTES ? BUG_UNCONFIRMED : BUG_PROMOTED; } - if (isset($_pv['at_description'])) - add_attachment($bugid, $_pv['at_description']); //attachment (initial) + $bugid = $db->nextId(TBL_BUG); + + $db->query('insert into '.TBL_BUG.' (bug_id, title, description, url, severity_id, priority, status_id, assigned_to, created_by, created_date, last_modified_by, last_modified_date, project_id, site_id, database_id, version_id, component_id, os_id, browser_string) values ('.$bugid.', '.join(', ', array($db->quote(stripslashes($title)), $db->quote(stripslashes($description)), $db->quote(stripslashes($url)))).', '.(int)$severity.', '.(int)$priority.', '.(int)$status.', '.$owner.', '.$reporter.', '.$now.', '.$u.', '.$now.', '.$project.', '.(int)$site.', '.(int)$database.', '.(int)$version.', '.(int)$component.', '.(int)$os.', '.$db->quote(stripslashes($_SERVER['HTTP_USER_AGENT'])).')'); + $buginfo = $db->getRow('select * from '.TBL_BUG." where bug_id = $bugid"); + do_changedfields($u, $buginfo); + + if (isset($_POST['at_description'])) + add_attachment($bugid, $_POST['at_description']); //attachment (initial) if (isset($another)) { header("Location: $me?op=add&project=$project"); @@ -632,56 +524,47 @@ } function show_form($bugid = 0, $error = '') { - global $db, $me, $t, $_gv, $_pv, $TITLE; + global $db, $t; - $projectname = $db->getOne("select project_name from ".TBL_PROJECT." where project_id = {$_gv['project']}"); + $projectname = $db->getOne("select project_name from ".TBL_PROJECT." where project_id = '{$_GET['project']}'"); if ($bugid && !$error) { $t->assign($db->getRow("select * from ".TBL_BUG." where bug_id = '$bugid'")); } else { - $t->assign($_pv); + $t->assign($_POST); $t->assign(array( 'error' => $error, - 'project' => $_gv['project'], + 'project' => $_GET['project'], 'projectname' => $projectname )); } - $t->wrap('bugform.html', 'enterbug'); + $t->render('bugform.html', translate("Create Bug")); } function show_bug_printable($bugid) { - global $db, $me, $t, $select, $TITLE, $QUERY, $restricted_projects; + global $db, $me, $t, $select, $QUERY, $restricted_projects; if (!is_numeric($bugid) or !$row = $db->getRow(sprintf($QUERY['bug-printable'], $bugid, $restricted_projects))) { - show_text($STRING['bugbadnum'],true); + show_text(translate("That bug does not exist"), true); exit; } $t->assign($row); $t->assign(array( - 'bug_dependencies' => delimit_list(', ', $db->getCol('select '. - db_concat("'<a href=\"$me?op=show&bugid='", 'depends_on', '\'">#\'', - 'depends_on', '\'</a>\'').' from '.TBL_BUG_DEPENDENCY. - " where bug_id = $bugid")), - 'rev_bug_dependencies' => delimit_list(', ', $db->getCol('select '. - db_concat("'<a href=\"$me?op=show&bugid='", 'bug_id', '\'">#\'', - 'bug_id', '\'</a>\'').' from '.TBL_BUG_DEPENDENCY. - " where depends_on = $bugid")) + 'bug_dependencies' => @join(', ', $db->getCol('select '.db_concat("'<a href=\"$me?op=show&bugid='", 'depends_on', '\'">#\'','depends_on', '\'</a>\'').' from '.TBL_BUG_DEPENDENCY." where bug_id = $bugid")), + 'rev_bug_dependencies' => @join(', ', $db->getCol('select '.db_concat("'<a href=\"$me?op=show&bugid='", 'bug_id', '\'">#\'','bug_id', '\'</a>\'').' from '.TBL_BUG_DEPENDENCY." where depends_on = $bugid")) )); // Show the comments - $t->assign('comments', $db->getAll('select comment_text, c.created_date, login'. - ' from '.TBL_COMMENT.' c, '.TBL_AUTH_USER. - " where bug_id = $bugid and c.created_by = user_id order by c.created_date" - )); - $t->wrap('bugdisplay-printable.html', 'viewbug'); + $t->assign('comments', $db->getAll('select comment_text, c.created_date, login from '.TBL_COMMENT.' c, '.TBL_AUTH_USER." where bug_id = $bugid and c.created_by = user_id order by c.created_date")); + $t->render('bugdisplay-printable.html', translate("View Bug")); } /// /// Grab the links for the previous and next bugs in the list function prev_next_links($bugid, $pos) { - global $dsn, $_sv, $QUERY, $t; + global $dsn, $QUERY, $t; // Create a new db connection because of the limit query affecting later queries $db = DB::Connect($dsn); @@ -691,7 +574,7 @@ $db->setOption('optimize', 'portability'); $db->setErrorHandling(PEAR_ERROR_CALLBACK, "handle_db_error"); - if (!isset($_sv['queryinfo']['query']) || !$_sv['queryinfo']['query']) { + if (!isset($_SESSION['queryinfo']['query']) || !$_SESSION['queryinfo']['query']) { return array('', ''); } @@ -703,8 +586,8 @@ $limit = 1; } $rs = $db->limitQuery(sprintf($QUERY['bug-prev-next'], - $_sv['queryinfo']['query'], $bugid, $_sv['queryinfo']['order'], - $_sv['queryinfo']['sort']), $offset, $limit); + $_SESSION['queryinfo']['query'], $bugid, $_SESSION['queryinfo']['order'], + $_SESSION['queryinfo']['sort']), $offset, $limit); list($firstid, $chunks) = $rs->fetchRow(); list($secondid, $chunks) = $rs->fetchRow(); @@ -724,61 +607,31 @@ } function show_bug($bugid = 0, $error = array()) { - global $db, $me, $t, $STRING, $TITLE, $u, $_gv, $_pv, $QUERY, $restricted_projects; + global $db, $me, $t, $u, $QUERY, $restricted_projects; if (!ereg('^[0-9]+$',$bugid) or !$row = $db->getRow(sprintf($QUERY['bug-show-bug'], $bugid, $restricted_projects))) { - show_text($STRING['bugbadnum'],true); + show_text(translate("That bug does not exist"), true); return; } - prev_next_links($bugid, isset($_gv['pos']) ? $_gv['pos'] : 0); + prev_next_links($bugid, isset($_GET['pos']) ? $_GET['pos'] : 0); $t->assign($row); // Override the database values with posted values if there were errors - if (count($error)) $t->assign($_pv); + if (count($error)) $t->assign($_POST); - $bug_dependencies = $db->query('SELECT '.TBL_BUG.'.status_id, '. - TBL_BUG.'.bug_id FROM '. - TBL_BUG.', '.TBL_BUG_DEPENDENCY.' WHERE '.TBL_BUG.'.bug_id = '. - TBL_BUG_DEPENDENCY.'.depends_on AND '.TBL_BUG_DEPENDENCY. - '.bug_id = '.$bugid); - - $bug_dependencies_display = array(); - if ($bug_dependencies->numRows()) { - while ($bug_dependencies->fetchInto($dependency)) { - $bug_dependencies_display[] = - '<a href="'.$me.'?op=show&bugid='.$dependency['bug_id']. - '">'.($dependency['status_id'] == 5 ? '<strike>':'').'#'. - $dependency['bug_id'].($dependency['status_id'] == 5 ? '</strike>':'').'</a>'; - } - } + $bug_dependencies = $db->getAll("select b.bug_id, s.bug_open from ".TBL_BUG_DEPENDENCY." d, ".TBL_BUG." b, ".TBL_STATUS." s where d.bug_id = $bugid and d.depends_on = b.bug_id and b.status_id = s.status_id"); - $bug_blocks = $db->query('SELECT '.TBL_BUG.'.status_id, '. - TBL_BUG.'.bug_id FROM '. - TBL_BUG.', '.TBL_BUG_DEPENDENCY.' WHERE '.TBL_BUG.'.bug_id = '. - TBL_BUG_DEPENDENCY.'.bug_id AND '.TBL_BUG_DEPENDENCY. - '.depends_on = '.$bugid); - - $bug_blocks_display = array(); - if ($bug_blocks->numRows()) { - while ($bug_blocks->fetchInto($block)) { - $bug_blocks_display[] = - '<a href="'.$me.'?op=show&bugid='.$block['bug_id']. - '">'.($block['status_id'] == 5 ? '<strike>':'').'#'. - $block['bug_id'].($block['status_id'] == 5 ? '</strike>':'').'</a>'; - } - } + $bug_blocks = $db->getAll("select b.bug_id, s.bug_open from ".TBL_BUG_DEPENDENCY." d, ".TBL_BUG." b, ".TBL_STATUS." s where d.depends_on = $bugid and d.bug_id = b.bug_id and b.status_id = s.status_id"); $t->assign(array( 'error' => $error, - 'already_voted' => $db->getOne("select count(*) from ".TBL_BUG_VOTE. - " where bug_id = $bugid and user_id = $u"), - 'num_votes' => $db->getOne("select count(*) from ".TBL_BUG_VOTE. - " where bug_id = $bugid"), - 'bug_dependencies' => implode(', ', $bug_dependencies_display), - 'rev_bug_dependencies' => implode(', ', $bug_blocks_display) + 'already_voted' => $db->getOne("select count(*) from ".TBL_BUG_VOTE." where bug_id = $bugid and user_id = $u"), + 'num_votes' => $db->getOne("select count(*) from ".TBL_BUG_VOTE." where bug_id = $bugid"), + 'bug_dependencies' => $bug_dependencies, + 'bug_blocks' => $bug_blocks )); // Show the attachments @@ -795,16 +648,14 @@ // Show the comments $t->assign(array( 'attachments' => $attachments, - 'comments' => $db->getAll('select comment_text, c.created_date, login'. - ' from '.TBL_COMMENT.' c, '.TBL_AUTH_USER. - " where bug_id = $bugid and c.created_by = user_id order by c.created_date") + 'comments' => $db->getAll('select comment_text, c.created_date, login'.' from '.TBL_COMMENT.' c, '.TBL_AUTH_USER." where bug_id = $bugid and c.created_by = user_id order by c.created_date") )); - $t->wrap('bugdisplay.html', 'viewbug'); + $t->render('bugdisplay.html', translate("View Bug")); } function show_projects() { - global $db, $t, $STRING, $perm, $restricted_projects, $_gv; + global $db, $t, $perm, $restricted_projects; // Show only active projects with at least one component if ($perm->have_perm('Admin')) { // Show admins all projects @@ -813,56 +664,52 @@ $p_query = " and p.project_id not in ($restricted_projects)"; } $projects = array(); - $projects = $db->getAll('select p.project_id, p.project_name, p.project_desc, p.created_date - from '.TBL_PROJECT.' p, '.TBL_COMPONENT. - ' c where p.active = 1 and p.project_id = c.project_id'.$p_query. - ' group by p.project_id, p.project_name, p.project_desc, p.created_date'. - ' order by project_name'); + $projects = $db->getAll('select p.project_id, p.project_name, p.project_desc, p.created_date from '.TBL_PROJECT.' p, '.TBL_COMPONENT.' c where p.active = 1 and p.project_id = c.project_id'.$p_query.' group by p.project_id, p.project_name, p.project_desc, p.created_date order by project_name'); switch (count($projects)) { case 0 : - show_text($STRING['noprojects'], true); + show_text(translate("No projects found"), true); return; case 1 : - $_gv['project'] = $projects[0]['project_id']; + $_GET['project'] = $projects[0]['project_id']; show_form(); break; default : $t->assign('projects', $projects); - $t->wrap('projectlist.html', 'enterbug'); + $t->render('projectlist.html', translate("Select Project")); } } -if ($op) { - switch($op) { +if (!empty($_REQUEST['op'])) { + switch($_REQUEST['op']) { case 'history': - show_history($_gv['bugid']); + show_history(check_id($_GET['bugid'])); break; case 'add': $perm->check('Editbug'); - if (isset($_gv['project'])) { + if (isset($_GET['project'])) { show_form(); } else { show_projects(); } break; case 'show': - show_bug($_gv['bugid']); + show_bug(check_id($_GET['bugid'])); break; case 'update': - update_bug($_pv['bugid']); + update_bug(check_id($_POST['bugid'])); break; case 'do': - do_form($_pv['bugid']); + do_form(check_id($_POST['bugid'])); break; case 'print': - show_bug_printable($_gv['bugid']); + show_bug_printable(check_id($_GET['bugid'])); break; case 'vote': - vote_bug($_gv['bugid']); + vote_bug(check_id($_GET['bugid'])); break; case 'viewvotes': - vote_view($_gv['bugid']); + vote_view(check_id($_GET['bugid'])); break; } } else { Index: config-dist.php =================================================================== RCS file: /cvsroot/phpbt/phpbt/config-dist.php,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- config-dist.php 25 Jul 2003 19:22:26 -0000 1.27 +++ config-dist.php 25 Oct 2004 12:06:57 -0000 1.28 @@ -1,7 +1,7 @@ <?php // config.php - Set up configuration options // ------------------------------------------------------------------------ -// Copyright (c) 2001, 2002 The phpBugTracker Group +// Copyright (c) 2001 - 2004 The phpBugTracker Group // ------------------------------------------------------------------------ // This file is part of phpBugTracker // @@ -28,10 +28,6 @@ define ('DB_USER', '{db_user}'); // username for database connection define ('DB_PASSWORD', '{db_pass}'); // password for database connection -// Smarty templates location (leave blank if Smarty is in include path) -// If not blank, make sure the trailing slash is present. -define ('SMARTY_PATH', '{smarty_path}'); - // Database Table Config // you can change either the prefix of the table names or each table name individually define ('CUR_DB_VERSION', 4); // the version of the database @@ -69,7 +65,7 @@ define ('TBL_SITE', TBL_PREFIX.'site'); define ('ONEDAY', 86400); -define ('PHPBT_VERSION', '0.9.0'); +define ('PHPBT_VERSION', '1.0'); require_once ('./inc/auth.php'); Index: config.php =================================================================== RCS file: /cvsroot/phpbt/phpbt/config.php,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- config.php 25 Jul 2003 19:22:26 -0000 1.39 +++ config.php 25 Oct 2004 12:06:57 -0000 1.40 @@ -2,7 +2,7 @@ // config.php - Set up configuration options // ------------------------------------------------------------------------ -// Copyright (c) 2001 The phpBugTracker Group +// Copyright (c) 2001 - 2003 The phpBugTracker Group // ------------------------------------------------------------------------ // This file is part of phpBugTracker // Index: include.php =================================================================== RCS file: /cvsroot/phpbt/phpbt/include.php,v retrieving revision 1.126 retrieving revision 1.127 diff -u -r1.126 -r1.127 --- include.php 5 Jul 2003 22:57:33 -0000 1.126 +++ include.php 25 Oct 2004 12:06:57 -0000 1.127 @@ -2,7 +2,7 @@ // include.php - Set up global variables // ------------------------------------------------------------------------ -// Copyright (c) 2001, 2002 The phpBugTracker Group +// Copyright (c) 2001 - 2004 The phpBugTracker Group // ------------------------------------------------------------------------ // This file is part of phpBugTracker // @@ -27,12 +27,12 @@ @ini_set("session.save_handler", "files"); if (!@include('config.php')) { - header("Location: install.php"); - exit(); + header("Location: install.php"); + exit(); } if (!defined('DB_HOST')) { // Installation hasn't been completed - header("Location: install.php"); - exit(); + header("Location: install.php"); + exit(); } // Grab the global functions @@ -47,7 +47,7 @@ 'database' => DB_DATABASE, 'username' => DB_USER, 'password' => DB_PASSWORD - ); + ); $db = DB::Connect($dsn); if (DB::isError($db)) { die($db->message.'<br>'.$db->userinfo); @@ -56,104 +56,89 @@ $db->setFetchMode(DB_FETCHMODE_ASSOC); $db->setErrorHandling(PEAR_ERROR_CALLBACK, "handle_db_error"); -// Set up the configuration variables -$rs = $db->query('select varname, varvalue from '.TBL_CONFIGURATION); -while (list($k, $v) = $rs->fetchRow(DB_FETCHMODE_ORDERED)) { - define($k, $v); +if (empty($upgrading)) { + // Set up the configuration variables + $rs = $db->query('select varname, varvalue from '.TBL_CONFIGURATION); + while (list($k, $v) = $rs->fetchRow(DB_FETCHMODE_ORDERED)) { + if (!defined($k)) define($k, $v); + } + define('OPEN_BUG_STATUSES', join(', ', + $db->getCol("select status_id from " . TBL_STATUS ." where bug_open = 1"))); } -define('OPEN_BUG_STATUSES', join(', ', array(BUG_UNCONFIRMED, BUG_PROMOTED, - BUG_ASSIGNED, BUG_REOPENED))); - require_once ('inc/db/'.DB_TYPE.'.php'); -// Localization - include the file with the desired language -include 'languages/'.LANGUAGE.'.php'; - $me = $HTTP_SERVER_VARS['PHP_SELF']; $selrange = 30; $now = time(); -$_gv =& $HTTP_GET_VARS; -$_pv =& $HTTP_POST_VARS; $all_db_fields = array( - 'bug_id' => 'ID', - 'title' => 'Title', - 'description' => 'Description', - 'url' => 'URL', - 'severity_name' => 'Severity', - 'priority' => 'Priority', - 'status_name' => 'Status', - 'resolution_name' => 'Resolution', - 'closed_in_version_name' => 'Closed in Version', - 'to_be_closed_in_version_name' => 'To be Closed in Version', - 'database_name' => 'Database', - 'site_name' => 'Site', - 'reporter' => 'Reporter', - 'owner' => 'Owner', - 'created_date' => 'Created Date', - 'lastmodifier' => 'Last Modified By', - 'last_modified_date' => 'Last Modified Date', - 'project_name' => 'Project', - 'version_name' => 'Version', - 'component_name' => 'Component', - 'os_name' => 'OS', - 'browser_string' => 'Browser', - 'close_date' => 'Closed Date' - ); + 'bug_id' => 'ID', + 'title' => 'Title', + 'description' => 'Description', + 'url' => 'URL', + 'severity_name' => 'Severity', + 'priority' => 'Priority', + 'status_name' => 'Status', + 'resolution_name' => 'Resolution', + 'closed_in_version_name' => 'Closed in Version', + 'to_be_closed_in_version_name' => 'To be Closed in Version', + 'database_name' => 'Database', + 'site_name' => 'Site', + 'reporter' => 'Reporter', + 'owner' => 'Owner', + 'created_date' => 'Created Date', + 'lastmodifier' => 'Last Modified By', + 'last_modified_date' => 'Last Modified Date', + 'project_name' => 'Project', + 'version_name' => 'Version', + 'component_name' => 'Component', + 'os_name' => 'OS', + 'browser_string' => 'Browser', + 'close_date' => 'Closed Date' + ); $default_db_fields = array('bug_id', 'title', 'reporter', 'owner', - 'severity_name', 'priority', 'status_name', 'resolution_name'); + 'severity_name', 'priority', 'status_name', 'resolution_name'); // Template class -if (!@include(SMARTY_PATH . 'Smarty.class.php')) { - include('templates/default/base/smartymissing.html'); - exit; -} +class template { + var $vars; -class extSmarty extends Smarty { - - function fetch($_smarty_tpl_file, $_smarty_cache_id = null, $_smarty_compile_id = null, $_smarty_display = false) { - error_reporting(E_ALL ^ E_NOTICE); // Clobber Smarty warnings - return Smarty::fetch($_smarty_tpl_file, $_smarty_cache_id, $_smarty_compile_id, $_smarty_display); + function template() { + $this->vars = array(); } - function wrap($template, $title = '') { - global $TITLE, $_gv, $_pv; - - $this->assign(array( - 'content_template' => $template, - 'page_title' => isset($TITLE[$title]) ? $TITLE[$title] : $title - )); + function render($content_template, $page_title, $wrap_file = '', $nowrap = false) { + extract($this->vars); + $path = defined('TEMPLATE_PATH') + ? './templates/'.THEME.'/'.TEMPLATE_PATH.'/' + : './templates/'.THEME.'/'; + include($nowrap ? $path.$content_template : ($wrap_file ? $path.$wrap_file : $path.'wrap.html')); + } + + function fetch($content_template) { + ob_start(); + $this->render($content_template, '', '', true); + $rettext = ob_get_contents(); + ob_end_clean(); + return $rettext; + } + - // Use a popup wrap? - if ((isset($_gv['use_js']) and $_gv['use_js']) or - (isset($_pv['use_js']) and $_pv['use_js'])) { - $wrap = 'wrap-popup.html'; - } else { - $wrap = 'wrap.html'; - } - if (($dir = dirname($template)) != '.') { - $this->display("$dir/$wrap"); + function assign($var, $value = '') { + if (is_array($var)) { + foreach ($var as $k => $v) { + $this->vars[$k] = $v; + } } else { - $this->display($wrap); + $this->vars[$var] = $value; } } } -$t = new extSmarty; -$t->template_dir = 'templates/'.THEME.'/'; -$t->compile_dir = 'c_templates'; -$t->config_dir = '.'; -$t->use_sub_dirs = false; -$t->register_function('build_select', 'build_select'); -$t->register_function('project_js', 'build_project_js'); -$t->register_modifier('date', 'bt_date'); -$t->assign(array( - 'STRING' => $STRING, - 'TITLE' => $TITLE, - 'STYLE' => STYLE - )); +$t = new template(); +$t->assign('STYLE', STYLE); if (defined('TEMPLATE_PATH')) { $t->assign('template_path', '../templates/'.THEME.'/'.TEMPLATE_PATH); @@ -164,44 +149,45 @@ // End classes -- Begin page if (!defined('NO_AUTH')) { - session_start(); - $_sv =& $HTTP_SESSION_VARS; - $auth = new uauth; - $perm = new uperm; - $u = isset($_sv['uid']) ? $_sv['uid'] : 0; + session_start(); + $auth = new uauth; + $perm = new uperm; + $u = isset($_SESSION['uid']) ? $_SESSION['uid'] : 0; } // Check to see if the user is trying to login -if (isset($_pv['dologin'])) { - if (!empty($_pv['sendpass'])) { - $username = $_pv['username']; - list($email, $password) = $db->getRow("select email, password from ".TBL_AUTH_USER." where login = '{$_pv['username']}' and active > 0", null, DB_FETCHMODE_ORDERED); - if (!$email) { - $t->assign('loginerror', '<div class="error">Invalid login</div>'); - } else { - if (ENCRYPT_PASS) { - $password = genpassword(10); - $mpassword = md5($password); - $db->query("update ".TBL_AUTH_USER." set password = '$mpassword' where login = '$username'"); - } - qp_mail($email, $STRING['newacctsubject'], sprintf($STRING['newacctmessage'], $password), - sprintf("From: %s",ADMIN_EMAIL)); - $t->assign('loginerror', - '<div class="result">Your password has been emailed to you</div>'); +if (isset($_POST['dologin'])) { + if (!empty($_POST['sendpass'])) { + $username = $_POST['username']; + list($email, $password) = $db->getRow("select email, password from ".TBL_AUTH_USER." where login = '{$_POST['username']}' and active > 0", null, DB_FETCHMODE_ORDERED); + if (!$email) { + $t->assign('loginerror', '<div class="error">'.translate("Invalid login").'</div>'); + } else { + if (ENCRYPT_PASS) { + $password = genpassword(10); + $mpassword = md5($password); + $db->query("update ".TBL_AUTH_USER." set password = '$mpassword' where login = '$username'"); + } + qp_mail($email, + translate("phpBugTracker Login"), + sprint... [truncated message content] |