+ return $self->SetDisabled(1);
+}
+
+=head2 _FillInTemplateURL URL
+
+Takes a URL containing placeholders and returns the URL as filled in for this
+ObjectCustomFieldValue. The values for the placeholders will be URI-escaped.
+
+Available placeholders:
+
+=over
+
+=item __id__
+
+The id of the object in question.
+
+=item __CustomField__
+
+The value of this custom field for the object in question.
+
+=item __WebDomain__, __WebPort__, __WebPath__, __WebBaseURL__ and __WebURL__
+
+The value of the config option.
+
+=back
+
+=cut
+
+{
+my %placeholders = (
+ id => { value => sub { $_[0]->ObjectId }, escape => 1 },
+ CustomField => { value => sub { $_[0]->Content }, escape => 1 },
+ WebDomain => { value => sub { RT->Config->Get('WebDomain') } },
+ WebPort => { value => sub { RT->Config->Get('WebPort') } },
+ WebPath => { value => sub { RT->Config->Get('WebPath') } },
+ WebBaseURL => { value => sub { RT->Config->Get('WebBaseURL') } },
+ WebURL => { value => sub { RT->Config->Get('WebURL') } },
+);
+
+sub _FillInTemplateURL {
+ my $self = shift;
+ my $url = shift;
+
+ return undef unless defined $url && length $url;
+
+ # special case, whole value should be an URL
+ if ( $url =~ /^__CustomField__/ ) {
+ my $value = $self->Content;
+ # protect from javascript: URLs
+ if ( $value =~ /^\s*javascript:/i ) {
+ my $object = $self->Object;
+ $RT::Logger->error(
+ "Dangerouse value with JavaScript in custom field '". $self->CustomFieldObj->Name ."'"
+ ." on ". ref($object) ." #". $object->id
+ );
+ return undef;
+ }
+ $url =~ s/^__CustomField__/$value/;
+ }
+
+ # default value, uri-escape
+ for my $key (keys %placeholders) {
+ $url =~ s{__${key}__}{
+ my $value = $placeholders{$key}{'value'}->( $self );
+ $value = '' if !defined($value);
+ RT::Interface::Web::EscapeURI(\$value) if $placeholders{$key}{'escape'};
+ $value
+ }gxe;
+ }
+
+ return $url;
+} }
+
+
+=head2 ValueLinkURL
+
+Returns a filled in URL template for this ObjectCustomFieldValue, suitable for
+constructing a hyperlink in RT's webui. Returns undef if this custom field doesn't have
+a LinkValueTo
+
+=cut
+
+sub LinkValueTo {
+ my $self = shift;
+ return $self->_FillInTemplateURL($self->CustomFieldObj->LinkValueTo);
+}
+
+
+
+=head2 ValueIncludeURL
+
+Returns a filled in URL template for this ObjectCustomFieldValue, suitable for
+constructing a hyperlink in RT's webui. Returns undef if this custom field doesn't have
+a IncludeContentForValue
+
+=cut
+
+sub IncludeContentForValue {
+ my $self = shift;
+ return $self->_FillInTemplateURL($self->CustomFieldObj->IncludeContentForValue);