From dbc3b84464ddb48824da231ff0968e6c54c5baf2 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 7 Dec 2006 02:04:26 +0000 Subject: [PATCH] r1337: Adding the option to allow parsing of links in comment text --- docs/changes.txt | 1 + docs/schema_changes.sql | 2 +- docs/todo.txt | 1 - editcomment.php | 1 + editreport.php | 1 + includes/api_comment.php | 13 +++++++++++-- newreport.php | 1 + templates/editcomment.tpl | 1 + templates/newreport.tpl | 2 ++ templates/showreport.tpl | 2 ++ 10 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 6a1f2e0..5f2198d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -3,6 +3,7 @@ - When a user does not have any favorites in his list, show a message instead of an empty screen - Added the ability to show all the users in a paginated list in the admin section (bug://report/55) - Can export search results to an XML file (bug://report/41) +- Links in comments are now parsed if the user so desires (bug://report/2) 1.1.4 =============================== diff --git a/docs/schema_changes.sql b/docs/schema_changes.sql index ec911e5..a7636af 100644 --- a/docs/schema_changes.sql +++ b/docs/schema_changes.sql @@ -1,3 +1,3 @@ ## SVN $Id$ -ALTER TABLE user CHANGE timezone timezone float(4) NOT NULL DEFAULT 0; +ALTER TABLE `comment` ADD parselinks BOOL NULL; diff --git a/docs/todo.txt b/docs/todo.txt index 79c6ac9..30d5737 100755 --- a/docs/todo.txt +++ b/docs/todo.txt @@ -11,7 +11,6 @@ BUGDAR 1.2 - Mass updates and deletes - Ability to show votes on bug listings (bug://report/13) - Ability to show components on bug listings (bug://report/43) -- Parse links in bug comments (bug://report/2) - Importing from other bug systems (bug://report/41) - Workflow interface diff --git a/editcomment.php b/editcomment.php index f555ef8..7b0354f 100644 --- a/editcomment.php +++ b/editcomment.php @@ -129,6 +129,7 @@ if ($_POST['do'] == 'update') } $commentapi->set('comment', $bugsys->in['comment']); + $commentapi->set('parselinks', $bugsys->in['parselinks']); $commentapi->set('hidden', $bugsys->in['hidden']); if ($bugsys->in['commentid'] == $bug['initialreport'] AND $bugsys->in['hidden']) diff --git a/editreport.php b/editreport.php index 5c4c986..e2ee512 100644 --- a/editreport.php +++ b/editreport.php @@ -162,6 +162,7 @@ if ($_POST['do'] == 'update') $comment->set('bugid', $bugsys->in['bugid']); $comment->set('userid', $bugsys->userinfo['userid']); $comment->set('comment', $commenttext); + $comment->set('parselinks', $bugsys->in['parselinks']); $comment->insert(); // we redefine the bug data later, but it needs to be here in order to generate the user list diff --git a/includes/api_comment.php b/includes/api_comment.php index 62769ec..2923f02 100644 --- a/includes/api_comment.php +++ b/includes/api_comment.php @@ -42,6 +42,7 @@ class CommentAPI extends API 'bugid' => array(TYPE_UINT, REQ_YES, 'verify_nozero'), 'userid' => array(TYPE_UINT, REQ_NO, null, array('includes/api_user.php', 'UserAPI')), 'dateline' => array(TYPE_UINT, REQ_SET), + 'parselinks' => array(TYPE_BOOL, REQ_NO), 'comment' => array(TYPE_STR, REQ_YES, 'verify_noempty'), 'comment_parsed' => array(TYPE_NONE, REQ_SET), 'hidden' => array(TYPE_BOOL, REQ_NO) @@ -80,13 +81,21 @@ class CommentAPI extends API */ function set_comment_parsed() { + $comment = $this->values['comment']; + if ($this->values['parselinks']) + { + $comment = str_replace('bug://new', 'New Bug', $comment); + $comment = preg_replace('#bug://((report|problem)/)?([0-9]*)#i', 'bug \3', $comment); + $comment = preg_replace('#(https?://|www\.)\S+#i', '\0', $comment); + } + if ($this->registry->options['allowhtml']) { - $this->set('comment_parsed', nl2br($this->registry->unsanitize($this->values['comment']))); + $this->set('comment_parsed', nl2br($this->registry->unsanitize($comment))); } else { - $this->set('comment_parsed', nl2br($this->values['comment'])); + $this->set('comment_parsed', nl2br($comment)); } } diff --git a/newreport.php b/newreport.php index 15b04b8..be63d4e 100755 --- a/newreport.php +++ b/newreport.php @@ -65,6 +65,7 @@ if ($_POST['do'] == 'insert') $comment->set('userid', $bugsys->userinfo['userid']); $comment->set('comment', $bugsys->in['comment']); + $comment->set('parselinks', $bugsys->in['parselinks']); // ------------------------------------------------------------------- // check permissions on various input values diff --git a/templates/editcomment.tpl b/templates/editcomment.tpl index 4accfcc..7fc14b3 100644 --- a/templates/editcomment.tpl +++ b/templates/editcomment.tpl @@ -30,6 +30,7 @@ $header
style="color: red">{@"Hidden"}: checked="checked" />
+
{@"Parse Links in the Comment"}: checked="checked" />
diff --git a/templates/newreport.tpl b/templates/newreport.tpl index 6de0b3d..1f417e3 100644 --- a/templates/newreport.tpl +++ b/templates/newreport.tpl @@ -111,6 +111,8 @@ $header {@"Description/Initial Report"} + +
checked="checked" /> {@"Parse Links in the Comment"}
diff --git a/templates/showreport.tpl b/templates/showreport.tpl index bd025a5..812936d 100644 --- a/templates/showreport.tpl +++ b/templates/showreport.tpl @@ -191,6 +191,8 @@ $header {@"New Reply"} : {@"Automation"} $help[newreply] + +
checked="checked" /> {@"Parse Links in the Comment"}
-- 2.22.5