cvs: bugtracker /htdocs cache.php /includes bug.php cache_generate.php /template/generic/admin state.php
| From: | Barry Carlyon | Date: | Thu, 14 Aug 2008 00:43:32 +0000 |
| Subject: | cvs: bugtracker /htdocs cache.php /includes bug.php cache_generate.php /template/generic/admin state.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-2410@lists.php.net to get a copy of this message | ||
bcarlyon Thu Aug 14 00:43:32 2008 UTC
Added files:
/bugtracker/template/generic/admin state.php
Modified files:
/bugtracker/htdocs cache.php
/bugtracker/includes bug.php cache_generate.php
Log:
Taught the bugtraker how to change the state of a bug, and tell users about it
Minor file path fixed to the caches system
http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/cache.php?r1=1.11&r2=1.12&diff_format=u Index: bugtracker/htdocs/cache.php diff -u bugtracker/htdocs/cache.php:1.11 bugtracker/htdocs/cache.php:1.12 --- bugtracker/htdocs/cache.php:1.11 Wed Aug 13 22:33:33 2008 +++ bugtracker/htdocs/cache.php Thu Aug 14 00:43:32 2008 @@ -37,11 +37,11 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: cache.php,v 1.11 2008/08/13 22:33:33 bcarlyon Exp $ +* @version CVS: $Id: cache.php,v 1.12 2008/08/14 00:43:32 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ -set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)) . '/../includes/'); +set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)) . '/includes/'); include('config.php'); include('functions.php'); http://cvs.php.net/viewvc.cgi/bugtracker/includes/bug.php?r1=1.17&r2=1.18&diff_format=u Index: bugtracker/includes/bug.php diff -u bugtracker/includes/bug.php:1.17 bugtracker/includes/bug.php:1.18 --- bugtracker/includes/bug.php:1.17 Thu Aug 14 00:00:41 2008 +++ bugtracker/includes/bug.php Thu Aug 14 00:43:32 2008 @@ -38,7 +38,7 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: bug.php,v 1.17 2008/08/14 00:00:41 bcarlyon Exp $ +* @version CVS: $Id: bug.php,v 1.18 2008/08/14 00:43:32 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ @@ -118,7 +118,7 @@ function is_bug() { global $db; - $query = 'SELECT bug_id,status,reported_by FROM ' . BUG_TABLE . ' WHERE bug_id = ' . $this->bug_id; + $query = 'SELECT bug_id,status,reported_by,assigned_to FROM ' . BUG_TABLE . ' WHERE bug_id = ' . $this->bug_id; $db->get_data($query); if ($db->total_rows) { $this->bug_data = $db->fetch_row(); @@ -142,7 +142,7 @@ } //email time $email_message = 'Greetings,' . "\n\r\n\r" . 'The bug ' . $cookie['host'] . 'bug/' . $this->bug_id . '/ has been updated'; - $email_message .= "\n\r\n\r" . 'The update was '; + $email_message .= "\n\r\n\r" . 'The update was: '; $email_message .= 'Bug Assigned to: ' . $target . ', by ' . $user->handle . ', the bug\'s status is currently: ' . $cache->obtain('status',$this->bug_data['status']); //email the reportee $email->send_to_user($this->bug_data['reported_by'], 'Bug Update; #' . $this->bug_id, $email_message); @@ -155,7 +155,39 @@ } function edit() { } - function state() { + function state($newstate) { + global $db, $cookie, $email, $cache, $user; + + if ($cache->obtain('status',$newstate)) + { + if ($newstate == CLOSED) { + $query = 'UPDATE ' . BUG_TABLE . ' SET status = ' . CLOSED . ', closed_by = \'' . $user->handle . '\', closed_at = NOW() WHERE bug_id = ' . $this->bug_id; + } else { + $query = 'UPDATE ' . BUG_TABLE . ' SET status = ' . $newstate . ' WHERE bug_id = ' . $this->bug_id; + } + $db->get_data($query); + if ($db->affected_rows) + { + //updateed ok! + //email time + $email_message = 'Greetings,' . "\n\r\n\r" . 'The bug ' . $cookie['host'] . 'bug/' . $this->bug_id . '/ has been updated'; + $email_message .= "\n\r\n\r" . 'The Update was: '; + $email_message .= 'Bug Changed State: From: ' . $cache->obtain('status', $this->bug_data['status']) . ' To: ' . $cache->obtain('status', $newstate); + $email_message .= "\n\r\n\r"; + $email_message .= 'This was done by: ' . $user->handle; + + $email->send_to_user($this->bug_data['reported_by'], 'PHP Bug Updated: #' . $this->bug_id, $email_message); + trace('send to reported'); + if (!empty($this->bug_data['assigned_to'])) { + trace('send to assigned'); + $email->send_to_user($this->bug_data['assigned_to'], 'PHP Bug Updated: #' . $this->bug_id, $email_message); + } + //email subscribed + + return TRUE; + } + } + return FALSE; } function close() { } http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache_generate.php?r1=1.9&r2=1.10&diff_format=u Index: bugtracker/includes/cache_generate.php diff -u bugtracker/includes/cache_generate.php:1.9 bugtracker/includes/cache_generate.php:1.10 --- bugtracker/includes/cache_generate.php:1.9 Wed Aug 13 22:33:33 2008 +++ bugtracker/includes/cache_generate.php Thu Aug 14 00:43:32 2008 @@ -37,7 +37,7 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: cache_generate.php,v 1.9 2008/08/13 22:33:33 bcarlyon Exp $ +* @version CVS: $Id: cache_generate.php,v 1.10 2008/08/14 00:43:32 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ @@ -77,7 +77,7 @@ $users .= "\n"; - $timetowrite = fopen('/cache/users.php',"w+"); + $timetowrite = fopen('../includes/cache/users.php',"w+"); fwrite($timetowrite,$users); fclose($timetowrite); } @@ -126,7 +126,7 @@ //// $cachetext .= '\?\>'; // } - $timetowrite = fopen('cache/' . $data . '.php',"w+"); + $timetowrite = fopen('../includes/cache/' . $data . '.php',"w+"); fwrite($timetowrite,$cachetext); fclose($timetowrite); } http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/state.php?view=markup&rev=1.1 Index: bugtracker/template/generic/admin/state.php +++ bugtracker/template/generic/admin/state.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:*/ /** * template/generic/admin/assign.php * Its the assign a bug to a handle * * Copyright (c) 2008, Barry Carlyon <bcarlyon@php.net> * All rights reserved. * * PHP versions 5 * * LICENSE: Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @category BugTracking * @package GSoC Bugtracker * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: state.php,v 1.1 2008/08/14 00:43:32 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ $bug_id = loadvar('method'); $newstate = loadvar('resource'); $bug->bug_id = $bug_id; if (!$user->logged_in) { $template->meta_refresh('/user/login/'); trigger_error('You need to be logged in', E_USER_ERROR); } elseif ($bug->is_bug()) { //bug exists if ($user->handle != $bug->bug_data['assigned_to'] && $user->check_karma('bugz_admin') != TRUE) { $template->meta_refresh(); trigger_error('You do not have access to this bug', E_USER_ERROR); } elseif ( !$cache->obtain('status', $newstate) ) { $template->meta_refresh(); trigger_error('The new bug state is invalid', E_USER_ERROR); } } else { $template->meta_refresh(); trigger_error('The bug does not exist', E_USER_ERROR); } $template->page_title .= 'State Change'; $template->content_title = 'Changing the state of a bug'; if ($bug->state($newstate)) { $template->prehtml = '<div id="success">Succssfully assigned the bug</div>'; $template->meta_refresh(); } else { trigger_error('Unable to change the bug state as requested', E_USER_ERROR); }
http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/cache.php?r1=1.11&r2=1.12&diff_format=u Index: bugtracker/htdocs/cache.php diff -u bugtracker/htdocs/cache.php:1.11 bugtracker/htdocs/cache.php:1.12 --- bugtracker/htdocs/cache.php:1.11 Wed Aug 13 22:33:33 2008 +++ bugtracker/htdocs/cache.php Thu Aug 14 00:43:32 2008 @@ -37,11 +37,11 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: cache.php,v 1.11 2008/08/13 22:33:33 bcarlyon Exp $ +* @version CVS: $Id: cache.php,v 1.12 2008/08/14 00:43:32 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ -set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)) . '/../includes/'); +set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)) . '/includes/'); include('config.php'); include('functions.php'); http://cvs.php.net/viewvc.cgi/bugtracker/includes/bug.php?r1=1.17&r2=1.18&diff_format=u Index: bugtracker/includes/bug.php diff -u bugtracker/includes/bug.php:1.17 bugtracker/includes/bug.php:1.18 --- bugtracker/includes/bug.php:1.17 Thu Aug 14 00:00:41 2008 +++ bugtracker/includes/bug.php Thu Aug 14 00:43:32 2008 @@ -38,7 +38,7 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: bug.php,v 1.17 2008/08/14 00:00:41 bcarlyon Exp $ +* @version CVS: $Id: bug.php,v 1.18 2008/08/14 00:43:32 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ @@ -118,7 +118,7 @@ function is_bug() { global $db; - $query = 'SELECT bug_id,status,reported_by FROM ' . BUG_TABLE . ' WHERE bug_id = ' . $this->bug_id; + $query = 'SELECT bug_id,status,reported_by,assigned_to FROM ' . BUG_TABLE . ' WHERE bug_id = ' . $this->bug_id; $db->get_data($query); if ($db->total_rows) { $this->bug_data = $db->fetch_row(); @@ -142,7 +142,7 @@ } //email time $email_message = 'Greetings,' . "\n\r\n\r" . 'The bug ' . $cookie['host'] . 'bug/' . $this->bug_id . '/ has been updated'; - $email_message .= "\n\r\n\r" . 'The update was '; + $email_message .= "\n\r\n\r" . 'The update was: '; $email_message .= 'Bug Assigned to: ' . $target . ', by ' . $user->handle . ', the bug\'s status is currently: ' . $cache->obtain('status',$this->bug_data['status']); //email the reportee $email->send_to_user($this->bug_data['reported_by'], 'Bug Update; #' . $this->bug_id, $email_message); @@ -155,7 +155,39 @@ } function edit() { } - function state() { + function state($newstate) { + global $db, $cookie, $email, $cache, $user; + + if ($cache->obtain('status',$newstate)) + { + if ($newstate == CLOSED) { + $query = 'UPDATE ' . BUG_TABLE . ' SET status = ' . CLOSED . ', closed_by = \'' . $user->handle . '\', closed_at = NOW() WHERE bug_id = ' . $this->bug_id; + } else { + $query = 'UPDATE ' . BUG_TABLE . ' SET status = ' . $newstate . ' WHERE bug_id = ' . $this->bug_id; + } + $db->get_data($query); + if ($db->affected_rows) + { + //updateed ok! + //email time + $email_message = 'Greetings,' . "\n\r\n\r" . 'The bug ' . $cookie['host'] . 'bug/' . $this->bug_id . '/ has been updated'; + $email_message .= "\n\r\n\r" . 'The Update was: '; + $email_message .= 'Bug Changed State: From: ' . $cache->obtain('status', $this->bug_data['status']) . ' To: ' . $cache->obtain('status', $newstate); + $email_message .= "\n\r\n\r"; + $email_message .= 'This was done by: ' . $user->handle; + + $email->send_to_user($this->bug_data['reported_by'], 'PHP Bug Updated: #' . $this->bug_id, $email_message); + trace('send to reported'); + if (!empty($this->bug_data['assigned_to'])) { + trace('send to assigned'); + $email->send_to_user($this->bug_data['assigned_to'], 'PHP Bug Updated: #' . $this->bug_id, $email_message); + } + //email subscribed + + return TRUE; + } + } + return FALSE; } function close() { } http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache_generate.php?r1=1.9&r2=1.10&diff_format=u Index: bugtracker/includes/cache_generate.php diff -u bugtracker/includes/cache_generate.php:1.9 bugtracker/includes/cache_generate.php:1.10 --- bugtracker/includes/cache_generate.php:1.9 Wed Aug 13 22:33:33 2008 +++ bugtracker/includes/cache_generate.php Thu Aug 14 00:43:32 2008 @@ -37,7 +37,7 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: cache_generate.php,v 1.9 2008/08/13 22:33:33 bcarlyon Exp $ +* @version CVS: $Id: cache_generate.php,v 1.10 2008/08/14 00:43:32 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ @@ -77,7 +77,7 @@ $users .= "\n"; - $timetowrite = fopen('/cache/users.php',"w+"); + $timetowrite = fopen('../includes/cache/users.php',"w+"); fwrite($timetowrite,$users); fclose($timetowrite); } @@ -126,7 +126,7 @@ //// $cachetext .= '\?\>'; // } - $timetowrite = fopen('cache/' . $data . '.php',"w+"); + $timetowrite = fopen('../includes/cache/' . $data . '.php',"w+"); fwrite($timetowrite,$cachetext); fclose($timetowrite); } http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/state.php?view=markup&rev=1.1 Index: bugtracker/template/generic/admin/state.php +++ bugtracker/template/generic/admin/state.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:*/ /** * template/generic/admin/assign.php * Its the assign a bug to a handle * * Copyright (c) 2008, Barry Carlyon <bcarlyon@php.net> * All rights reserved. * * PHP versions 5 * * LICENSE: Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @category BugTracking * @package GSoC Bugtracker * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: state.php,v 1.1 2008/08/14 00:43:32 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ $bug_id = loadvar('method'); $newstate = loadvar('resource'); $bug->bug_id = $bug_id; if (!$user->logged_in) { $template->meta_refresh('/user/login/'); trigger_error('You need to be logged in', E_USER_ERROR); } elseif ($bug->is_bug()) { //bug exists if ($user->handle != $bug->bug_data['assigned_to'] && $user->check_karma('bugz_admin') != TRUE) { $template->meta_refresh(); trigger_error('You do not have access to this bug', E_USER_ERROR); } elseif ( !$cache->obtain('status', $newstate) ) { $template->meta_refresh(); trigger_error('The new bug state is invalid', E_USER_ERROR); } } else { $template->meta_refresh(); trigger_error('The bug does not exist', E_USER_ERROR); } $template->page_title .= 'State Change'; $template->content_title = 'Changing the state of a bug'; if ($bug->state($newstate)) { $template->prehtml = '<div id="success">Succssfully assigned the bug</div>'; $template->meta_refresh(); } else { trigger_error('Unable to change the bug state as requested', E_USER_ERROR); }