cvs: bugtracker /htdocs .htaccess /htdocs/elements/js admin.js /includes bug.php cache.php cache_generate.php session.php template.php user.php
/includes/cache status.php users.php /template/generic/admin assign.php /template/generic/bug index.php
| From: | Barry Carlyon | Date: | Wed, 13 Aug 2008 14:21:04 +0000 |
| Subject: | cvs: bugtracker /htdocs .htaccess /htdocs/elements/js admin.js /includes bug.php cache.php cache_generate.php session.php template.php user.php /includes/cache status.php users.php /template/generic/admin assign.php /template/generic/bug index.php |
||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-2392@lists.php.net to get a copy of this message | ||
bcarlyon Wed Aug 13 14:21:04 2008 UTC
Added files:
/bugtracker/htdocs/elements/js admin.js
/bugtracker/template/generic/admin assign.php
Modified files:
/bugtracker/htdocs .htaccess
/bugtracker/includes bug.php cache.php cache_generate.php
session.php template.php user.php
/bugtracker/includes/cache status.php users.php
/bugtracker/template/generic/bug index.php
Log:
Committing the first karma block, with the ability for permitted users to assign bugs to other
users
http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/.htaccess?r1=1.8&r2=1.9&diff_format=u Index: bugtracker/htdocs/.htaccess diff -u bugtracker/htdocs/.htaccess:1.8 bugtracker/htdocs/.htaccess:1.9 --- bugtracker/htdocs/.htaccess:1.8 Mon Aug 11 22:00:34 2008 +++ bugtracker/htdocs/.htaccess Wed Aug 13 14:21:03 2008 @@ -8,7 +8,7 @@ #smaller rewrites, higher priority you know RewriteCond %{REQUEST_URI} !=/bug/comment/ - RewriteRule bug/(.*)$ index/index.php?page=bug&bug_id=$1&%{QUERY_STRING} [L,PT] + RewriteRule ^bug/(.*)$ index/index.php?page=bug&bug_id=$1&%{QUERY_STRING} [L,PT] #Some shuntage RedirectPermanent /gifs http://bugs.php.net/gifs http://cvs.php.net/viewvc.cgi/bugtracker/includes/bug.php?r1=1.8&r2=1.9&diff_format=u Index: bugtracker/includes/bug.php diff -u bugtracker/includes/bug.php:1.8 bugtracker/includes/bug.php:1.9 --- bugtracker/includes/bug.php:1.8 Mon Aug 11 10:51:22 2008 +++ bugtracker/includes/bug.php Wed Aug 13 14:21:03 2008 @@ -96,8 +96,37 @@ return; } - function assign() { + function is_bug() { + global $db; + $query = 'SELECT bug_id,status FROM ' . BUG_TABLE . ' WHERE bug_id = ' . $this->bug_id; + $db->get_data($query); + if ($db->total_rows) { + $this->bug_data = $db->fetch_row(); + return TRUE; + } + return FALSE; + } + + function assign($target) { + global $db; + $query = 'UPDATE ' . BUG_TABLE . ' SET assigned_to = \'' . $target . '\', assigned_on = NOW() WHERE bug_id = ' . $this->bug_id; + $db->get_data($query); + if ($db->affected_rows) + { + //check for need to update bug status + if ($this->bug_data['status'] == PENDING) + { + $query = 'UPDATE ' . BUG_TABLE . ' SET status = ' . ASSIGNED . ' WHERE bug_id = ' . $this->bug_id; + $db->get_data($query); + } + //email time + //email the reported + //email the assigned + //email the subscribed + return TRUE; + } + return FALSE; } function edit() { } http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache.php?r1=1.11&r2=1.12&diff_format=u Index: bugtracker/includes/cache.php diff -u bugtracker/includes/cache.php:1.11 bugtracker/includes/cache.php:1.12 --- bugtracker/includes/cache.php:1.11 Wed Aug 13 10:55:57 2008 +++ bugtracker/includes/cache.php Wed Aug 13 14:21:03 2008 @@ -118,7 +118,7 @@ $return_data = ''; //convert a given cache to another format - if ($method == 'select') + if ($method == 'select' || $method == 'selectvar') { //convert to a select - drop down menu format foreach ($thiscache as $ref => $data) @@ -126,7 +126,12 @@ //is the ref within our range? if ( ($ref >= $minrange && $ref <= $maxrange) || (!is_numeric($ref)) ) { - $return_data .= '<option value="' . $ref . '" '; + $return_data .= '<option value="'; + if ($method = 'selectvar') + $return_data .= $data; + else + $return_data .= $ref; + $return_data .= '" '; if ($selected == $ref) { $return_data .= ' selected="selected" '; http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache_generate.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache_generate.php diff -u bugtracker/includes/cache_generate.php:1.4 bugtracker/includes/cache_generate.php:1.5 --- bugtracker/includes/cache_generate.php:1.4 Mon Aug 11 10:51:22 2008 +++ bugtracker/includes/cache_generate.php Wed Aug 13 14:21:03 2008 @@ -46,6 +46,7 @@ while ($row = $db->fetch_row()) { $users .= ' + $cacher["users"][] = "' . $row['handle'] . '"; $users["' . $row['handle'] . '"]["handle"] = "' . $row['handle'] . '"; $users["' . $row['handle'] . '"]["email"] = "' . $row['email'] . '"; '; @@ -56,6 +57,7 @@ while ($row = $db->fetch_row()) { $users .= ' + $cacher["users"][] = "' . $row['handle'] . '"; $users["' . $row['handle'] . '"]["handle"] = "' . $row['handle'] . '"; $users["' . $row['handle'] . '"]["email"] = "' . $row['email'] . '"; '; http://cvs.php.net/viewvc.cgi/bugtracker/includes/session.php?r1=1.2&r2=1.3&diff_format=u Index: bugtracker/includes/session.php diff -u bugtracker/includes/session.php:1.2 bugtracker/includes/session.php:1.3 --- bugtracker/includes/session.php:1.2 Wed Aug 13 10:55:57 2008 +++ bugtracker/includes/session.php Wed Aug 13 14:21:03 2008 @@ -37,7 +37,7 @@ trace('session initialize'); global $db, $template, $user; - $this->current_page = $template->page; + $this->current_page = $_SERVER['REDIRECT_URL']; //first job tidy up old sessions, lets go for 15mins $later = time() - (15 * 60); @@ -59,6 +59,7 @@ $row = $db->fetch_row(); if ($row['ip_address'] == $this->ip_address) { + $this->last_page = $row['last_page']; trace('Session is valid, going for session update'); //then the session id is valid for this ip as well //update the cookie http://cvs.php.net/viewvc.cgi/bugtracker/includes/template.php?r1=1.18&r2=1.19&diff_format=u Index: bugtracker/includes/template.php diff -u bugtracker/includes/template.php:1.18 bugtracker/includes/template.php:1.19 --- bugtracker/includes/template.php:1.18 Wed Aug 13 11:33:12 2008 +++ bugtracker/includes/template.php Wed Aug 13 14:21:03 2008 @@ -105,7 +105,9 @@ return; } - function meta_refresh($target, $time = 3) { + function meta_refresh($target = '', $time = 3) { + global $session; + $target = $target ? $target : $session->last_page; $this->meta = '<meta http-equiv="refresh" content="' . $time . ';' . $target . '" />' . "\n"; } function load_jscript($jscripts) { @@ -122,6 +124,10 @@ function generate_header() { $this->html = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '../template/generic/header.html'); + global $user; + if ($user->check_karma('',$user->handle)) + $this->javascript .= "\n" . '<script type="text/javascript" src="/elements/js/admin.js"></script>'; + $this->swap('year', date('Y',time()) ); $this->swap('page_title', $this->page_title ); $this->swap('meta', $this->meta ); http://cvs.php.net/viewvc.cgi/bugtracker/includes/user.php?r1=1.16&r2=1.17&diff_format=u Index: bugtracker/includes/user.php diff -u bugtracker/includes/user.php:1.16 bugtracker/includes/user.php:1.17 --- bugtracker/includes/user.php:1.16 Wed Aug 13 11:33:12 2008 +++ bugtracker/includes/user.php Wed Aug 13 14:21:03 2008 @@ -61,14 +61,21 @@ function check_karma($check = '', $handle = '') { if ($check) { - global $db, $user; - $handle = $handle ? $handle : ( $user->handle ? $user->handle : '' ); + global $db; + $handle = $handle ? $handle : ( $this->handle ? $this->handle : '' ); if ($handle) { - $query = 'SELECT ref_id FROM ' . KARMA_TABLE . ' WHERE handle = \'' . $user->handle . '\' AND level = \'' . $check . '\''; + $query = 'SELECT ref_id FROM ' . KARMA_TABLE . ' WHERE handle = \'' . $handle . '\' AND level = \'' . $check . '\''; $db->get_data($query); if ($db->total_rows) return TRUE; } + } elseif ($handle) { + //does the user have any karma at all? + global $db; + $query = 'SELECT ref_id FROM ' . KARMA_TABLE . ' WHERE handle = \'' . $handle . '\''; + $db->get_data($query); + if ($db->total_rows) + return TRUE; } return FALSE; } http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/status.php?r1=1.7&r2=1.8&diff_format=u Index: bugtracker/includes/cache/status.php diff -u bugtracker/includes/cache/status.php:1.7 bugtracker/includes/cache/status.php:1.8 --- bugtracker/includes/cache/status.php:1.7 Thu Jul 31 12:34:21 2008 +++ bugtracker/includes/cache/status.php Wed Aug 13 14:21:03 2008 @@ -8,6 +8,10 @@ $cacher['status'][2] = "Is Bug"; $status[3] = "Fixed"; $cacher['status'][3] = "Fixed"; + $status[4] = "Investigating"; + $cacher['status'][4] = "Investigating"; + $status[5] = "Assigned"; + $cacher['status'][5] = "Assigned"; foreach($status as $ref => $data) { http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/users.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache/users.php diff -u bugtracker/includes/cache/users.php:1.4 bugtracker/includes/cache/users.php:1.5 --- bugtracker/includes/cache/users.php:1.4 Wed Aug 13 10:55:57 2008 +++ bugtracker/includes/cache/users.php Wed Aug 13 14:21:03 2008 @@ -1,11 +1,6 @@ <?php + $cacher["users"][] = "BarryCarlyon"; $users["BarryCarlyon"]["handle"] = "BarryCarlyon"; $users["BarryCarlyon"]["email"] = "barry@barrycarlyon.co.uk"; - $users["bob"]["handle"] = "bob"; - $users["bob"]["email"] = "b.carlyon@lsrfm.com"; - - $users["Fred"]["handle"] = "Fred"; - $users["Fred"]["email"] = "bcarlyon@php.net"; - http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/bug/index.php?r1=1.28&r2=1.29&diff_format=u Index: bugtracker/template/generic/bug/index.php diff -u bugtracker/template/generic/bug/index.php:1.28 bugtracker/template/generic/bug/index.php:1.29 --- bugtracker/template/generic/bug/index.php:1.28 Tue Aug 12 09:48:49 2008 +++ bugtracker/template/generic/bug/index.php Wed Aug 13 14:21:04 2008 @@ -121,14 +121,13 @@ //first some nice html //we are going to pass it to the loop function! I know! Shock Horror $html = ' +<input type="hidden" name="bug_id" id="bug_id" value="' . $bug->bug_id . '" /> <a href="/bug/" title="Back to Bug Listing" style="display: block; text-align: right;">Back to Bug Listing</a> <table> -<tr> <td style="width: 100px;"> </td> <td style="width: 100px;"> </td> <td style="width: 260px;"> </td> <td style="width: 150px;"> </td> </tr> +<tr> <td style="width: 100px;"> </td> <td style="width: 100px;"> </td> <td style="width: 260px;"> </td> <td style="width: 165px;"> </td> </tr> <tr> <td><h4>Bug: #{DSP_BUG_ID}</h4></td> <td colspan="3" style="width: 220px;">{DSP_SUMMARY}</td> </tr> <tr> <td><h4>{DSP_STATUS}</h4></td> <td>Opened:</td> <td>{DSP_REPORTED_ON}</td> <td>{DSP_REPORTED_BY}</td> </tr> -{DSP_SHOW_ASSIGNED} -<tr> <td> </td> <td>Assigned:</td> <td>{DSP_ASSIGNED_ON}</td> <td>{DSP_ASSIGNED_TO}</td> </tr> -{DSP_END_ASSIGNED} +{DSP_ASSIGNED} {DSP_SHOW_UPDATED} <tr> <td> </td> <td>Last Updated:</td> <td colspan="2">{DSP_UPDATED}</td> </tr> {DSP_END_UPDATED}{DSP_SHOW_CLOSED} @@ -165,8 +164,8 @@ {DSP_END_REPRODUCE} '; - $bug_row['show_assigned'] = $bug_row['show_updated'] = $bug_row['show_reproduce'] = $bug_row['show_closed'] = '<!--'; - $bug_row['end_assigned'] = $bug_row['end_updated'] = $bug_row['end_reproduce'] = $bug_row['end_closed'] = '-->'; + $bug_row['show_updated'] = $bug_row['show_reproduce'] = $bug_row['show_closed'] = '<!--'; + $bug_row['end_updated'] = $bug_row['end_reproduce'] = $bug_row['end_closed'] = '-->'; if (($bug_row['UNIX_TIMESTAMP(updated)'] != $bug_row['UNIX_TIMESTAMP(reported_on)']) && ($bug_row['UNIX_TIMESTAMP(closed_on)'] != '0')) { $bug_row['show_updated'] = $bug_row['end_updated'] = ''; @@ -180,6 +179,20 @@ $bug_row['show_reproduce'] = $bug_row['end_reproduce'] = ''; } + if ($bug_row['assigned_to'] || ( $user->check_karma('bugz_assign_any') || $user->check_karma('bugz_admin') )) + { + $code = '<tr> <td> </td> <td>Assigned:</td> <td>{DSP_ASSIGNED_ON}</td> <td>{DSP_ASSIGNED_TO}</td> </tr>'; + if ( $user->check_karma('bugz_assign_any') || $user->check_karma('bugz_admin') ) + { + $users_list = $cache->convert('users', 'selectvar', $bug_row['assigned_to']); + if ($bug_row['UNIX_TIMESTAMP(assigned_on)'] == 0) + $code = $template->swap('dsp_assigned_on', 'Unassigned', $code); + $code = $template->swap('DSP_ASSIGNED_TO', '<select name="assign_to" id="assign_to">' . $users_list . '</select><input type="button" value="Go!" onclick="updateAssignTo();" />', $code); + } + $html = $template->swap('DSP_ASSIGNED', $code, $html); + } + $html = $template->swap('dsp_assigned', '', $html); + $content .= $template->loop(array($bug_row), $html); $comment_html = '<tr><td></td><td colspan="3" class="comment">{DSP_HANDLE} commented<br /> {DSP_COMMENT}<br /><div style="text-align: right; float: right;">@ {DSP_UPDATED}</div></td></tr>'; http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/elements/js/admin.js?view=markup&rev=1.1 Index: bugtracker/htdocs/elements/js/admin.js +++ bugtracker/htdocs/elements/js/admin.js //collection of admin functions function updateAssignTo() { var assignto = document.getElementById('assign_to').value; window.location = '/admin/assign/' + document.getElementById('bug_id').value + '/' + assignto; } http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/assign.php?view=markup&rev=1.1 Index: bugtracker/template/generic/admin/assign.php +++ bugtracker/template/generic/admin/assign.php <?php /* Copyright (c) 2008, Barry Carlyon <bcarlyon@php.net> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * Neither the name of the GSOC_PHP_BUGTRACKER nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER 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. */ $bug_id = loadvar('method'); $handle = loadvar('resource'); if (!$user->logged_in) { $template->meta_refresh('/user/login/'); trigger_error('You need to be logged in', E_USER_ERROR); } elseif ( !$user->check_karma('bugz_admin') && !$user->check_karma('bugz_assign_any') ) { $template->meta_refresh(); trigger_error('You do not have the required karma to perform this action', E_USER_ERROR); } elseif ( !$user->check_karma('bugz_assign_self') && $handle != $user->handle) { $template->meta_refresh(); trigger_error('You do not have the required karma to assign this to yourself or you are not assigning this to yourself', E_USER_ERROR); } elseif (!$user->fetch_handle($handle)) { $template->meta_refresh(); trigger_error('You have selected an invalid handle', E_USER_ERROR); } $template->page_title .= 'Assigning'; $template->content_title = 'Assigning someone to a bug'; $bug->bug_id = $bug_id; if ($bug->is_bug()) { if ($bug->assign($handle)) { $template->prehtml = '<div id="success">Succssfully assigned the bug</div>'; $template->meta_refresh(); } else { trigger_error('Unable to assign the bug to the handle you requested', E_USER_ERROR); } } else { $template->meta_refresh(); trigger_error('The bug does not exist', E_USER_ERROR); }
http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/.htaccess?r1=1.8&r2=1.9&diff_format=u Index: bugtracker/htdocs/.htaccess diff -u bugtracker/htdocs/.htaccess:1.8 bugtracker/htdocs/.htaccess:1.9 --- bugtracker/htdocs/.htaccess:1.8 Mon Aug 11 22:00:34 2008 +++ bugtracker/htdocs/.htaccess Wed Aug 13 14:21:03 2008 @@ -8,7 +8,7 @@ #smaller rewrites, higher priority you know RewriteCond %{REQUEST_URI} !=/bug/comment/ - RewriteRule bug/(.*)$ index/index.php?page=bug&bug_id=$1&%{QUERY_STRING} [L,PT] + RewriteRule ^bug/(.*)$ index/index.php?page=bug&bug_id=$1&%{QUERY_STRING} [L,PT] #Some shuntage RedirectPermanent /gifs http://bugs.php.net/gifs http://cvs.php.net/viewvc.cgi/bugtracker/includes/bug.php?r1=1.8&r2=1.9&diff_format=u Index: bugtracker/includes/bug.php diff -u bugtracker/includes/bug.php:1.8 bugtracker/includes/bug.php:1.9 --- bugtracker/includes/bug.php:1.8 Mon Aug 11 10:51:22 2008 +++ bugtracker/includes/bug.php Wed Aug 13 14:21:03 2008 @@ -96,8 +96,37 @@ return; } - function assign() { + function is_bug() { + global $db; + $query = 'SELECT bug_id,status FROM ' . BUG_TABLE . ' WHERE bug_id = ' . $this->bug_id; + $db->get_data($query); + if ($db->total_rows) { + $this->bug_data = $db->fetch_row(); + return TRUE; + } + return FALSE; + } + + function assign($target) { + global $db; + $query = 'UPDATE ' . BUG_TABLE . ' SET assigned_to = \'' . $target . '\', assigned_on = NOW() WHERE bug_id = ' . $this->bug_id; + $db->get_data($query); + if ($db->affected_rows) + { + //check for need to update bug status + if ($this->bug_data['status'] == PENDING) + { + $query = 'UPDATE ' . BUG_TABLE . ' SET status = ' . ASSIGNED . ' WHERE bug_id = ' . $this->bug_id; + $db->get_data($query); + } + //email time + //email the reported + //email the assigned + //email the subscribed + return TRUE; + } + return FALSE; } function edit() { } http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache.php?r1=1.11&r2=1.12&diff_format=u Index: bugtracker/includes/cache.php diff -u bugtracker/includes/cache.php:1.11 bugtracker/includes/cache.php:1.12 --- bugtracker/includes/cache.php:1.11 Wed Aug 13 10:55:57 2008 +++ bugtracker/includes/cache.php Wed Aug 13 14:21:03 2008 @@ -118,7 +118,7 @@ $return_data = ''; //convert a given cache to another format - if ($method == 'select') + if ($method == 'select' || $method == 'selectvar') { //convert to a select - drop down menu format foreach ($thiscache as $ref => $data) @@ -126,7 +126,12 @@ //is the ref within our range? if ( ($ref >= $minrange && $ref <= $maxrange) || (!is_numeric($ref)) ) { - $return_data .= '<option value="' . $ref . '" '; + $return_data .= '<option value="'; + if ($method = 'selectvar') + $return_data .= $data; + else + $return_data .= $ref; + $return_data .= '" '; if ($selected == $ref) { $return_data .= ' selected="selected" '; http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache_generate.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache_generate.php diff -u bugtracker/includes/cache_generate.php:1.4 bugtracker/includes/cache_generate.php:1.5 --- bugtracker/includes/cache_generate.php:1.4 Mon Aug 11 10:51:22 2008 +++ bugtracker/includes/cache_generate.php Wed Aug 13 14:21:03 2008 @@ -46,6 +46,7 @@ while ($row = $db->fetch_row()) { $users .= ' + $cacher["users"][] = "' . $row['handle'] . '"; $users["' . $row['handle'] . '"]["handle"] = "' . $row['handle'] . '"; $users["' . $row['handle'] . '"]["email"] = "' . $row['email'] . '"; '; @@ -56,6 +57,7 @@ while ($row = $db->fetch_row()) { $users .= ' + $cacher["users"][] = "' . $row['handle'] . '"; $users["' . $row['handle'] . '"]["handle"] = "' . $row['handle'] . '"; $users["' . $row['handle'] . '"]["email"] = "' . $row['email'] . '"; '; http://cvs.php.net/viewvc.cgi/bugtracker/includes/session.php?r1=1.2&r2=1.3&diff_format=u Index: bugtracker/includes/session.php diff -u bugtracker/includes/session.php:1.2 bugtracker/includes/session.php:1.3 --- bugtracker/includes/session.php:1.2 Wed Aug 13 10:55:57 2008 +++ bugtracker/includes/session.php Wed Aug 13 14:21:03 2008 @@ -37,7 +37,7 @@ trace('session initialize'); global $db, $template, $user; - $this->current_page = $template->page; + $this->current_page = $_SERVER['REDIRECT_URL']; //first job tidy up old sessions, lets go for 15mins $later = time() - (15 * 60); @@ -59,6 +59,7 @@ $row = $db->fetch_row(); if ($row['ip_address'] == $this->ip_address) { + $this->last_page = $row['last_page']; trace('Session is valid, going for session update'); //then the session id is valid for this ip as well //update the cookie http://cvs.php.net/viewvc.cgi/bugtracker/includes/template.php?r1=1.18&r2=1.19&diff_format=u Index: bugtracker/includes/template.php diff -u bugtracker/includes/template.php:1.18 bugtracker/includes/template.php:1.19 --- bugtracker/includes/template.php:1.18 Wed Aug 13 11:33:12 2008 +++ bugtracker/includes/template.php Wed Aug 13 14:21:03 2008 @@ -105,7 +105,9 @@ return; } - function meta_refresh($target, $time = 3) { + function meta_refresh($target = '', $time = 3) { + global $session; + $target = $target ? $target : $session->last_page; $this->meta = '<meta http-equiv="refresh" content="' . $time . ';' . $target . '" />' . "\n"; } function load_jscript($jscripts) { @@ -122,6 +124,10 @@ function generate_header() { $this->html = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '../template/generic/header.html'); + global $user; + if ($user->check_karma('',$user->handle)) + $this->javascript .= "\n" . '<script type="text/javascript" src="/elements/js/admin.js"></script>'; + $this->swap('year', date('Y',time()) ); $this->swap('page_title', $this->page_title ); $this->swap('meta', $this->meta ); http://cvs.php.net/viewvc.cgi/bugtracker/includes/user.php?r1=1.16&r2=1.17&diff_format=u Index: bugtracker/includes/user.php diff -u bugtracker/includes/user.php:1.16 bugtracker/includes/user.php:1.17 --- bugtracker/includes/user.php:1.16 Wed Aug 13 11:33:12 2008 +++ bugtracker/includes/user.php Wed Aug 13 14:21:03 2008 @@ -61,14 +61,21 @@ function check_karma($check = '', $handle = '') { if ($check) { - global $db, $user; - $handle = $handle ? $handle : ( $user->handle ? $user->handle : '' ); + global $db; + $handle = $handle ? $handle : ( $this->handle ? $this->handle : '' ); if ($handle) { - $query = 'SELECT ref_id FROM ' . KARMA_TABLE . ' WHERE handle = \'' . $user->handle . '\' AND level = \'' . $check . '\''; + $query = 'SELECT ref_id FROM ' . KARMA_TABLE . ' WHERE handle = \'' . $handle . '\' AND level = \'' . $check . '\''; $db->get_data($query); if ($db->total_rows) return TRUE; } + } elseif ($handle) { + //does the user have any karma at all? + global $db; + $query = 'SELECT ref_id FROM ' . KARMA_TABLE . ' WHERE handle = \'' . $handle . '\''; + $db->get_data($query); + if ($db->total_rows) + return TRUE; } return FALSE; } http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/status.php?r1=1.7&r2=1.8&diff_format=u Index: bugtracker/includes/cache/status.php diff -u bugtracker/includes/cache/status.php:1.7 bugtracker/includes/cache/status.php:1.8 --- bugtracker/includes/cache/status.php:1.7 Thu Jul 31 12:34:21 2008 +++ bugtracker/includes/cache/status.php Wed Aug 13 14:21:03 2008 @@ -8,6 +8,10 @@ $cacher['status'][2] = "Is Bug"; $status[3] = "Fixed"; $cacher['status'][3] = "Fixed"; + $status[4] = "Investigating"; + $cacher['status'][4] = "Investigating"; + $status[5] = "Assigned"; + $cacher['status'][5] = "Assigned"; foreach($status as $ref => $data) { http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/users.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache/users.php diff -u bugtracker/includes/cache/users.php:1.4 bugtracker/includes/cache/users.php:1.5 --- bugtracker/includes/cache/users.php:1.4 Wed Aug 13 10:55:57 2008 +++ bugtracker/includes/cache/users.php Wed Aug 13 14:21:03 2008 @@ -1,11 +1,6 @@ <?php + $cacher["users"][] = "BarryCarlyon"; $users["BarryCarlyon"]["handle"] = "BarryCarlyon"; $users["BarryCarlyon"]["email"] = "barry@barrycarlyon.co.uk"; - $users["bob"]["handle"] = "bob"; - $users["bob"]["email"] = "b.carlyon@lsrfm.com"; - - $users["Fred"]["handle"] = "Fred"; - $users["Fred"]["email"] = "bcarlyon@php.net"; - http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/bug/index.php?r1=1.28&r2=1.29&diff_format=u Index: bugtracker/template/generic/bug/index.php diff -u bugtracker/template/generic/bug/index.php:1.28 bugtracker/template/generic/bug/index.php:1.29 --- bugtracker/template/generic/bug/index.php:1.28 Tue Aug 12 09:48:49 2008 +++ bugtracker/template/generic/bug/index.php Wed Aug 13 14:21:04 2008 @@ -121,14 +121,13 @@ //first some nice html //we are going to pass it to the loop function! I know! Shock Horror $html = ' +<input type="hidden" name="bug_id" id="bug_id" value="' . $bug->bug_id . '" /> <a href="/bug/" title="Back to Bug Listing" style="display: block; text-align: right;">Back to Bug Listing</a> <table> -<tr> <td style="width: 100px;"> </td> <td style="width: 100px;"> </td> <td style="width: 260px;"> </td> <td style="width: 150px;"> </td> </tr> +<tr> <td style="width: 100px;"> </td> <td style="width: 100px;"> </td> <td style="width: 260px;"> </td> <td style="width: 165px;"> </td> </tr> <tr> <td><h4>Bug: #{DSP_BUG_ID}</h4></td> <td colspan="3" style="width: 220px;">{DSP_SUMMARY}</td> </tr> <tr> <td><h4>{DSP_STATUS}</h4></td> <td>Opened:</td> <td>{DSP_REPORTED_ON}</td> <td>{DSP_REPORTED_BY}</td> </tr> -{DSP_SHOW_ASSIGNED} -<tr> <td> </td> <td>Assigned:</td> <td>{DSP_ASSIGNED_ON}</td> <td>{DSP_ASSIGNED_TO}</td> </tr> -{DSP_END_ASSIGNED} +{DSP_ASSIGNED} {DSP_SHOW_UPDATED} <tr> <td> </td> <td>Last Updated:</td> <td colspan="2">{DSP_UPDATED}</td> </tr> {DSP_END_UPDATED}{DSP_SHOW_CLOSED} @@ -165,8 +164,8 @@ {DSP_END_REPRODUCE} '; - $bug_row['show_assigned'] = $bug_row['show_updated'] = $bug_row['show_reproduce'] = $bug_row['show_closed'] = '<!--'; - $bug_row['end_assigned'] = $bug_row['end_updated'] = $bug_row['end_reproduce'] = $bug_row['end_closed'] = '-->'; + $bug_row['show_updated'] = $bug_row['show_reproduce'] = $bug_row['show_closed'] = '<!--'; + $bug_row['end_updated'] = $bug_row['end_reproduce'] = $bug_row['end_closed'] = '-->'; if (($bug_row['UNIX_TIMESTAMP(updated)'] != $bug_row['UNIX_TIMESTAMP(reported_on)']) && ($bug_row['UNIX_TIMESTAMP(closed_on)'] != '0')) { $bug_row['show_updated'] = $bug_row['end_updated'] = ''; @@ -180,6 +179,20 @@ $bug_row['show_reproduce'] = $bug_row['end_reproduce'] = ''; } + if ($bug_row['assigned_to'] || ( $user->check_karma('bugz_assign_any') || $user->check_karma('bugz_admin') )) + { + $code = '<tr> <td> </td> <td>Assigned:</td> <td>{DSP_ASSIGNED_ON}</td> <td>{DSP_ASSIGNED_TO}</td> </tr>'; + if ( $user->check_karma('bugz_assign_any') || $user->check_karma('bugz_admin') ) + { + $users_list = $cache->convert('users', 'selectvar', $bug_row['assigned_to']); + if ($bug_row['UNIX_TIMESTAMP(assigned_on)'] == 0) + $code = $template->swap('dsp_assigned_on', 'Unassigned', $code); + $code = $template->swap('DSP_ASSIGNED_TO', '<select name="assign_to" id="assign_to">' . $users_list . '</select><input type="button" value="Go!" onclick="updateAssignTo();" />', $code); + } + $html = $template->swap('DSP_ASSIGNED', $code, $html); + } + $html = $template->swap('dsp_assigned', '', $html); + $content .= $template->loop(array($bug_row), $html); $comment_html = '<tr><td></td><td colspan="3" class="comment">{DSP_HANDLE} commented<br /> {DSP_COMMENT}<br /><div style="text-align: right; float: right;">@ {DSP_UPDATED}</div></td></tr>'; http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/elements/js/admin.js?view=markup&rev=1.1 Index: bugtracker/htdocs/elements/js/admin.js +++ bugtracker/htdocs/elements/js/admin.js //collection of admin functions function updateAssignTo() { var assignto = document.getElementById('assign_to').value; window.location = '/admin/assign/' + document.getElementById('bug_id').value + '/' + assignto; } http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/assign.php?view=markup&rev=1.1 Index: bugtracker/template/generic/admin/assign.php +++ bugtracker/template/generic/admin/assign.php <?php /* Copyright (c) 2008, Barry Carlyon <bcarlyon@php.net> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * Neither the name of the GSOC_PHP_BUGTRACKER nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER 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. */ $bug_id = loadvar('method'); $handle = loadvar('resource'); if (!$user->logged_in) { $template->meta_refresh('/user/login/'); trigger_error('You need to be logged in', E_USER_ERROR); } elseif ( !$user->check_karma('bugz_admin') && !$user->check_karma('bugz_assign_any') ) { $template->meta_refresh(); trigger_error('You do not have the required karma to perform this action', E_USER_ERROR); } elseif ( !$user->check_karma('bugz_assign_self') && $handle != $user->handle) { $template->meta_refresh(); trigger_error('You do not have the required karma to assign this to yourself or you are not assigning this to yourself', E_USER_ERROR); } elseif (!$user->fetch_handle($handle)) { $template->meta_refresh(); trigger_error('You have selected an invalid handle', E_USER_ERROR); } $template->page_title .= 'Assigning'; $template->content_title = 'Assigning someone to a bug'; $bug->bug_id = $bug_id; if ($bug->is_bug()) { if ($bug->assign($handle)) { $template->prehtml = '<div id="success">Succssfully assigned the bug</div>'; $template->meta_refresh(); } else { trigger_error('Unable to assign the bug to the handle you requested', E_USER_ERROR); } } else { $template->meta_refresh(); trigger_error('The bug does not exist', E_USER_ERROR); }