com web/bugs: - Added "Related reports" tab to display the related bug reports: include/functions.php www/bug.php
| From: | Felipe Pena | Date: | Sun, 23 Dec 2012 21:54:01 +0000 |
| Subject: | com web/bugs: - Added "Related reports" tab to display the related bug reports: include/functions.php www/bug.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-15135@lists.php.net to get a copy of this message | ||
Commit: 688153af0567592a26f72231e9bb3a9585d12f19
Author: Felipe Pena <felipensp@gmail.com> Sun, 23 Dec 2012 19:54:01 -0200
Parents: d63b0311be5dc790761359607934e242cc963830
Branches: master
Link: http://git.php.net/?p=web/bugs.git;a=commitdiff;h=688153af0567592a26f72231e9bb3a9585d12f19
Log:
- Added "Related reports" tab to display the related bug reports
Changed paths:
M include/functions.php
M www/bug.php
Diff:
diff --git a/include/functions.php b/include/functions.php
index 2a8647c..56df589 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -1882,6 +1882,15 @@ function make_ticket_links($text)
);
}
+function get_ticket_links($text)
+{
+ $matches = array();
+
+ preg_match_all('/(?<![>a-z])(?:bug(?:fix)?|feat(?:ure)?|doc(?:umentation)?|req(?:uest)?|duplicated
of)\s+#?([0-9]+)/i', $text, $matches);
+
+ return $matches;
+}
+
function handle_pear_errors ($error_obj)
{
response_header("Oops! We are sorry that you are unable to report an undocumented feature
today.");
diff --git a/www/bug.php b/www/bug.php
index db489b0..d33b56e 100644
--- a/www/bug.php
+++ b/www/bug.php
@@ -230,6 +230,8 @@ if (isset($_POST['ncomment']) &&
!isset($_POST['preview']) && $edit == 3) {
}
$res = bugs_add_comment($bug_id, $_POST['in']['commentemail'],
$_POST['in']['name'], $ncomment, 'comment');
+
+ mark_related_bugs($_POST['in']['commentemail'],
$_POST['in']['name'], $ncomment);
} while (false);
@@ -349,6 +351,8 @@ if (isset($_POST['ncomment']) &&
!isset($_POST['preview']) && $edit == 3) {
// Add normal comment
if (!empty($ncomment)) {
$res = bugs_add_comment($bug_id, $from, '', $ncomment, 'comment');
+
+ mark_related_bugs($from, '', $ncomment);
}
}
} elseif (isset($_POST['in']) && isset($_POST['preview']) &&
$edit == 2) {
@@ -523,6 +527,8 @@ if (isset($_POST['ncomment']) &&
!isset($_POST['preview']) && $edit == 3) {
// Add normal comment
if (!empty($ncomment)) {
$res = bugs_add_comment($bug_id, $from, $comment_name, $ncomment, 'comment');
+
+ mark_related_bugs($from, $comment_name, $ncomment);
}
}
} elseif (isset($_POST['in']) && isset($_POST['preview']) &&
$edit == 1) {
@@ -1062,7 +1068,8 @@ if ($show_bug_info && is_array($bug_comments) &&
count($bug_comments) && $bug['s
'type_all' => 'All',
'type_comment' => 'Comments',
'type_log' => 'Changes',
- 'type_svn' => 'Git/SVN commits'
+ 'type_svn' => 'Git/SVN commits',
+ 'type_related' => 'Related reports'
);
if (!isset($_COOKIE['history_tab']) ||
!isset($history_tabs[$_COOKIE['history_tab']])) {
@@ -1149,6 +1156,21 @@ response_footer($bug_JS);
// Helper functions
+function mark_related_bugs($from, $comment_name, $ncomment)
+{
+ global $bug_id;
+
+ $related = get_ticket_links($ncomment);
+
+ /**
+ * Adds a new comment on the related bug pointing to the current report
+ */
+ for ($i = 0; $i < count($related[0]); ++$i) {
+ bugs_add_comment($related[1][$i], $from, $comment_name,
+ 'Related To: Bug #'. $bug_id, 'related');
+ }
+}
+
function output_note($com_id, $ts, $email, $comment, $comment_type, $comment_name, $is_hidden =
false)
{
global $edit, $bug_id, $dbh, $is_trusted_developer, $logged_in;