1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
6 # <sales@bestpractical.com>
8 # (Except where explicitly superseded by other copyright notices)
13 # This work is made available to you under the terms of Version 2 of
14 # the GNU General Public License. A copy of that license should have
15 # been provided with this software, but in any event can be snarfed
18 # This work is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 # 02110-1301 or visit their web page on the internet at
27 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
30 # CONTRIBUTION SUBMISSION POLICY:
32 # (The following paragraph is not intended to limit the rights granted
33 # to you to modify and distribute this software under the terms of
34 # the GNU General Public License and is only of importance to you if
35 # you choose to contribute your changes and enhancements to the
36 # community by submitting them to Best Practical Solutions, LLC.)
38 # By intentionally submitting any modifications, corrections or
39 # derivatives to this work, or any other work intended for use with
40 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 # you are the copyright holder for those contributions and you grant
42 # Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 # royalty-free, perpetual, license to use, copy, create derivative
44 # works based on those contributions, and sublicense and distribute
45 # those contributions and any derivatives thereof.
47 # END BPS TAGGED BLOCK }}}
52 package RT::URI::fsck_com_rt;
53 use base 'RT::URI::base';
57 Returns the prefix for a local URI.
64 my $prefix = $self->Scheme. "://". RT->Config->Get('Organization');
75 my $object = shift || $self->Object;
78 if (ref($object) && (ref($object) ne 'RT::Ticket')) {
86 =head2 URIForObject RT::Record
88 Returns the RT URI for a local RT::Record object
95 return ($self->LocalURIPrefix ."/". $self->ObjectType($obj) ."/". $obj->Id);
101 When handed an fsck.com-rt: URI, figures out things like whether its a local record and what its ID is
110 if ( $uri =~ /^\d+$/ ) {
112 my $ticket = RT::Ticket->new( $self->CurrentUser );
113 $ticket->Load( $uri );
114 $self->{'uri'} = $ticket->URI;
115 $self->{'object'} = $ticket;
116 return ($ticket->id);
119 $self->{'uri'} = $uri;
122 #If it's a local URI, load the ticket object and return its URI
123 if ( $self->IsLocal ) {
124 my $local_uri_prefix = $self->LocalURIPrefix;
125 if ( $self->{'uri'} =~ /^\Q$local_uri_prefix\E\/(.*?)\/(\d+)$/i ) {
129 if ( $type eq 'ticket' ) { $type = 'RT::Ticket' }
131 # We can instantiate any RT::Record subtype. but not anything else
133 if ( UNIVERSAL::isa( $type, 'RT::Record' ) ) {
134 my $record = $type->new( $self->CurrentUser );
138 $self->{'object'} = $record;
139 return ( $record->Id );
150 Returns true if this URI is for a local ticket.
151 Returns undef otherwise.
157 my $local_uri_prefix = $self->LocalURIPrefix;
158 if ( $self->{'uri'} =~ /^\Q$local_uri_prefix/i ) {
169 Returns the object for this URI, if it's local. Otherwise returns undef.
175 return ($self->{'object'});
180 Return the URI scheme for RT records
187 return "fsck.com-rt";
192 If this is a local ticket, return an HTTP url to it.
193 Otherwise, return its URI
200 return $self->URI unless $self->IsLocal;
202 my $obj = $self->Object;
203 if ( $obj && $self->ObjectType eq 'ticket' ) {
204 return RT->Config->Get('WebURL') ."Ticket/Display.html?id=". $obj->id;
212 Returns either a localized string 'ticket #23' or the full URI if the object is not local
218 if ($self->IsLocal && $self->Object) {
219 return $self->loc("[_1] #[_2]", $self->ObjectType, $self->Object->Id);
226 RT::Base->_ImportOverlays();