svn: /web/php-bugs/trunk/ include/functions.php www/bug.php www/patch-add.php
| From: | Felipe Pena | Date: | Wed, 08 Dec 2010 21:47:12 +0000 |
| Subject: | svn: /web/php-bugs/trunk/ include/functions.php www/bug.php www/patch-add.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-9647@lists.php.net to get a copy of this message | ||
felipe Wed, 08 Dec 2010 21:47:12 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=306094
Log:
- Added bugs_has_access() function to simplify the user access check to bug data
Changed paths:
U web/php-bugs/trunk/include/functions.php
U web/php-bugs/trunk/www/bug.php
U web/php-bugs/trunk/www/patch-add.php
Modified: web/php-bugs/trunk/include/functions.php
===================================================================
--- web/php-bugs/trunk/include/functions.php 2010-12-08 21:44:36 UTC (rev 306093)
+++ web/php-bugs/trunk/include/functions.php 2010-12-08 21:47:12 UTC (rev 306094)
@@ -90,6 +90,32 @@
return true;
}
+function bugs_has_access ($bug_id, $bug, $pw)
+{
+ global $is_trusted_developer, $auth_user, $logged_in;
+
+ if ($bug['private'] != 'Y') {
+ return true;
+ }
+
+ // When the bug is private, only the submitter, trusted devs and assigned dev
+ // should see the report info
+
+ if ($is_trusted_developer) {
+ // trusted dev
+ return true;
+ } else if ($logged_in != 'developer' && $pw != '' &&
verify_bug_passwd($bug_id, $pw)) {
+ // The submitter
+ return true;
+ } else if ($logged_in == 'developer' && $bug['assign'] != ''
&&
+ strtolower($bug['assign']) == strtolower($auth_user->handle)) {
+ // The assigned dev
+ return true;
+ }
+
+ return false;
+}
+
function bugs_authenticate (&$user, &$pw, &$logged_in, &$is_trusted_developer)
{
global $auth_user, $ROOT_DIR;
Modified: web/php-bugs/trunk/www/bug.php
===================================================================
--- web/php-bugs/trunk/www/bug.php 2010-12-08 21:44:36 UTC (rev 306093)
+++ web/php-bugs/trunk/www/bug.php 2010-12-08 21:47:12 UTC (rev 306094)
@@ -138,24 +138,8 @@
exit;
}
-$show_bug_info = ($bug['private'] == 'Y' ? false : true);
+$show_bug_info = bugs_has_access($bug_id, $bug, $pw);
-// When the bug is private, just the reporter, trusted developer and assigned
-// dev should see the report info
-if ($show_bug_info === false) {
- if ($is_trusted_developer) {
- // trusted dev
- $show_bug_info = true;
- } else if ($logged_in != 'developer' && $edit == 0 && $pw !=
'' && verify_bug_passwd($bug_id, $pw)) {
- // The submitter
- $show_bug_info = true;
- } else if ($logged_in == 'developer' && $bug['assign'] != ''
&&
- strtolower($bug['assign']) == strtolower($auth_user->handle)) {
- // The assigned dev
- $show_bug_info = true;
- }
-}
-
if (isset($_POST['ncomment'])) {
/* Bugs blocked to user comments can only be commented by the team */
if ($bug['block_user_comment'] == 'Y' && $logged_in !=
'developer') {
Modified: web/php-bugs/trunk/www/patch-add.php
===================================================================
--- web/php-bugs/trunk/www/patch-add.php 2010-12-08 21:44:36 UTC (rev 306093)
+++ web/php-bugs/trunk/www/patch-add.php 2010-12-08 21:47:12 UTC (rev 306094)
@@ -38,6 +38,15 @@
$numeralCaptcha = new Text_CAPTCHA_Numeral();
}
+$show_bug_info = bugs_has_access($bug_id, $buginfo, $pw);
+
+if (!$show_bug_info) {
+ response_header('Private report');
+ display_bug_error("The bug #{$bug_id} is not available to public");
+ response_footer();
+ exit;
+}
+
require_once "{$ROOT_DIR}/include/classes/bug_patchtracker.php";
$patchinfo = new Bug_Patchtracker;