r1337: Adding the option to allow parsing of links in comment text
authorRobert Sesek <rsesek@bluestatic.org>
Thu, 7 Dec 2006 02:04:26 +0000 (02:04 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Thu, 7 Dec 2006 02:04:26 +0000 (02:04 +0000)
docs/changes.txt
docs/schema_changes.sql
docs/todo.txt
editcomment.php
editreport.php
includes/api_comment.php
newreport.php
templates/editcomment.tpl
templates/newreport.tpl
templates/showreport.tpl

index 6a1f2e02d356453e1142d1ecd3e6f58d7f9cecd2..5f2198d59ec56d7be570a8e45d9bac20ff31d409 100644 (file)
@@ -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
 ===============================
index ec911e50724ac9a541d802d9ded28e2563aa3c6a..a7636af26164838ce85d045f362ac08c9759e250 100644 (file)
@@ -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;
index 79c6ac9a1d75c0d1b8546f3fb5c604c81db97157..30d57371647362cfb0846faae42998cc32304d31 100755 (executable)
@@ -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
 
index f555ef820e148bb59b296015050428a57bcff6db..7b0354f7ff186f715c1d48bc296a4b2520cdc159 100644 (file)
@@ -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'])
index 5c4c986b9594e1be3e40d336980d1e6331f736dd..e2ee512f464a626f89acf3a05efed51158120ab8 100644 (file)
@@ -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
index 62769eceec08c1d21407113704d0b14f655d5225..2923f026194ecf8aa784556a9bf6e0cd59a287b2 100644 (file)
@@ -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', '<a href="newreport.php">New Bug</a>', $comment);
+                       $comment = preg_replace('#bug://((report|problem)/)?([0-9]*)#i', '<a href="showreport.php?bugid=\3">bug \3</a>', $comment);
+                       $comment = preg_replace('#(https?://|www\.)\S+#i', '<a href="\0">\0</a>', $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));
                }
        }
        
index 15b04b8b77e20c0d8c8e111e3aeb4e548a7dca74..be63d4e0849dd52ec956544be826c714b23ac59c 100755 (executable)
@@ -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
index 4accfcc93a02b6bbfd72eb69cb4bd0e104540354..7fc14b3615a2c68710aad85d26eab3f8908d4081 100644 (file)
@@ -30,6 +30,7 @@ $header
        
        <div class="box-mid" style="text-align: $stylevar[left]">
                <if condition="$show['hide']"><div><strong<if condition="$comment['hidden']"> style="color: red"</if>>{@"Hidden"}:</strong> <input type="checkbox" name="hidden" value="1"<if condition="$comment['hidden']"> checked="checked"</if> /></div></if>
+               <div><strong>{@"Parse Links in the Comment"}:</strong> <input type="checkbox" name="parselinks" value="1"<if condition="$comment['parselinks']"> checked="checked"</if> /></div>
                <textarea name="comment" cols="50" rows="15" class="textarea">$comment[comment]</textarea>
        </div>
 </div>
index 6de0b3dc7a45371bc8302ded337c1ccdcd4f5993..1f417e3374c126d4d09e4d02bc6715299e21d164 100644 (file)
@@ -111,6 +111,8 @@ $header
                <legend>{@"Description/Initial Report"}</legend>
        
                <textarea name="comment" cols="50" rows="10" class="textarea"><if condition="$bugsys->in['comment']">{$bugsys->in['comment']}<else />{$bugsys->options['defaultcomment']}</if></textarea>
+               
+               <div><input type="checkbox" name="parselinks" value="1"<if condition="$bugsys->in['parselinks']"> checked="checked"</if> /> {@"Parse Links in the Comment"}</div>
        </fieldset>
 </div>
 <!-- / new reply -->
index bd025a571b8b4885be62ee1f764b325a32ae4416..812936d669419c31057fcc2e274d4bbf15ee4e77 100644 (file)
@@ -191,6 +191,8 @@ $header
                <legend>{@"New Reply"}<if condition="$show['automations']"> : <a href="explain.php?do=automations">{@"Automation"}</a> <select name="automation">$select[automation]</select></if> $help[newreply]</legend>
        
                <textarea name="comment" cols="50" rows="10" class="textarea"></textarea>
+               
+               <div><input type="checkbox" name="parselinks" value="1"<if condition="$bugsys->in['parselinks']"> checked="checked"</if> /> {@"Parse Links in the Comment"}</div>
        </fieldset>
 </div>
 <!-- / new reply -->