eliminate needless backtraces
[freeside.git] / rt / lib / RT / URI / fsck_com_rt.pm
index ba98b1d..d6c194d 100644 (file)
@@ -1,8 +1,8 @@
 # BEGIN BPS TAGGED BLOCK {{{
 # 
 # COPYRIGHT:
-#  
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC 
+# 
+# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
 #                                          <jesse@bestpractical.com>
 # 
 # (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
 # 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
 # 
 # 
 # CONTRIBUTION SUBMISSION POLICY:
 # those contributions and any derivatives thereof.
 # 
 # END BPS TAGGED BLOCK }}}
+
 package RT::URI::fsck_com_rt;
 
 use RT::Ticket;
 
-use RT::URI::base;
+use base 'RT::URI::base';
 
 use strict;
-use vars qw(@ISA);
-@ISA = qw/RT::URI::base/;
 
 
 
@@ -60,24 +61,6 @@ use vars qw(@ISA);
 
 Returns the prefix for a local URI. 
 
-=begin testing
-
-use_ok("RT::URI::fsck_com_rt");
-my $uri = RT::URI::fsck_com_rt->new($RT::SystemUser);
-
-ok(ref($uri));
-
-use Data::Dumper;
-
-
-ok (UNIVERSAL::isa($uri,RT::URI::fsck_com_rt), "It's an RT::URI::fsck_com_rt");
-
-ok ($uri->isa('RT::URI::base'), "It's an RT::URI::base");
-ok ($uri->isa('RT::Base'), "It's an RT::Base");
-
-is ($uri->LocalURIPrefix , 'fsck.com-rt://'.$RT::Organization);
-
-=end testing
 
 
 
@@ -86,7 +69,7 @@ is ($uri->LocalURIPrefix , 'fsck.com-rt://'.$RT::Organization);
 sub LocalURIPrefix {
     my $self = shift;
     
-    my $prefix = $self->Scheme. "://$RT::Organization";
+    my $prefix = $self->Scheme. "://". RT->Config->Get('Organization');
 
     return ($prefix);
 }
@@ -114,21 +97,13 @@ sub ObjectType {
 
 Returns the RT URI for a local RT::Record object
 
-=begin testing
-
-my $ticket = RT::Ticket->new($RT::SystemUser);
-$ticket->Load(1);
-my $uri = RT::URI::fsck_com_rt->new($ticket->CurrentUser);
-is($uri->LocalURIPrefix. "/ticket/1" , $uri->URIForObject($ticket));
-
-=end testing
 
 =cut
 
 sub URIForObject {
     my $self = shift;
     my $obj = shift;
-    return ($self->LocalURIPrefix."/".$self->ObjectType($obj)."/". $obj->Id);
+    return ($self->LocalURIPrefix ."/". $self->ObjectType($obj) ."/". $obj->Id);
 }
 
 
@@ -143,12 +118,12 @@ sub ParseURI {
     my $self = shift;
     my $uri  = shift;
 
-    if ( $uri =~ /^(\d+)$/ ) {
+    if ( $uri =~ /^\d+$/ ) {
         my $ticket = RT::Ticket->new( $self->CurrentUser );
-        $ticket->Load($uri);
+        $ticket->Load( $uri );
         $self->{'uri'} = $ticket->URI;
         $self->{'object'} = $ticket;
-        return($ticket->id);
+        return ($ticket->id);
     }
     else {
         $self->{'uri'} = $uri;
@@ -156,9 +131,8 @@ sub ParseURI {
 
     #If it's a local URI, load the ticket object and return its URI
     if ( $self->IsLocal ) {
-
         my $local_uri_prefix = $self->LocalURIPrefix;
-        if ( $self->{'uri'} =~ /^$local_uri_prefix\/(.*?)\/(\d+)$/i ) {
+        if ( $self->{'uri'} =~ /^\Q$local_uri_prefix\E\/(.*?)\/(\d+)$/i ) {
             my $type = $1;
             my $id   = $2;
 
@@ -192,9 +166,9 @@ Returns undef otherwise.
 
 sub IsLocal {
        my $self = shift;
-        my $local_uri_prefix = $self->LocalURIPrefix;
-       if ($self->{'uri'} =~ /^$local_uri_prefix/i) {
-               return 1;
+    my $local_uri_prefix = $self->LocalURIPrefix;
+    if ( $self->{'uri'} =~ /^\Q$local_uri_prefix/i ) {
+        return 1;
     }
        else {
                return undef;
@@ -238,7 +212,7 @@ Otherwise, return its URI
 sub HREF {
     my $self = shift;
     if ($self->IsLocal && $self->Object && ($self->ObjectType eq 'ticket')) {
-        return ( $RT::WebURL . "Ticket/Display.html?id=".$self->Object->Id);
+        return ( RT->Config->Get('WebURL') . "Ticket/Display.html?id=".$self->Object->Id);
     }   
     else {
         return ($self->URI);