Commit e6113406 authored by Alex Vandiver's avatar Alex Vandiver
Browse files

Merge branch '4.2.5-releng' into 4.2-trunk

parents f9744abf 0dd62493
......@@ -279,6 +279,14 @@ granted. This is B<different> than the user/group/role receiving the right.
CF => 'Name',
Queue => 'Name',
=item Granted on a custom field applied to some other object
# This finds the CF named "Name" applied to Articles in the
# "Responses" class
CF => 'Name',
LookupType => RT::Article->CustomFieldLookupType,
ObjectId => 'Responses',
=item Granted on some other object (article Classes, etc)
ObjectType => 'RT::Class',
......
......@@ -1675,12 +1675,6 @@ sub AddValueForObject {
}
}
if (my $canonicalizer = $self->can('_CanonicalizeValue'.$self->Type)) {
$canonicalizer->($self, \%args);
}
my $newval = RT::ObjectCustomFieldValue->new( $self->CurrentUser );
my ($val, $msg) = $newval->Create(
ObjectType => ref($obj),
......@@ -1702,6 +1696,17 @@ sub AddValueForObject {
}
sub _CanonicalizeValue {
my $self = shift;
my $args = shift;
my $type = $self->_Value('Type');
return 1 unless $type;
my $method = '_CanonicalizeValue'. $type;
return 1 unless $self->can($method);
$self->$method($args);
}
sub _CanonicalizeValueDateTime {
my $self = shift;
......@@ -1710,6 +1715,7 @@ sub _CanonicalizeValueDateTime {
$DateObj->Set( Format => 'unknown',
Value => $args->{'Content'} );
$args->{'Content'} = $DateObj->ISO;
return 1;
}
# For date, we need to store Content as ISO date
......@@ -1724,6 +1730,33 @@ sub _CanonicalizeValueDate {
Value => $args->{'Content'},
);
$args->{'Content'} = $DateObj->Date( Timezone => 'user' );
return 1;
}
sub _CanonicalizeValueIPAddress {
my $self = shift;
my $args = shift;
$args->{Content} = RT::ObjectCustomFieldValue->ParseIP( $args->{Content} );
return (0, $self->loc("Content is not a valid IP address"))
unless $args->{Content};
return 1;
}
sub _CanonicalizeValueIPAddressRange {
my $self = shift;
my $args = shift;
my $content = $args->{Content};
$content .= "-".$args->{LargeContent} if $args->{LargeContent};
($args->{Content}, $args->{LargeContent})
= RT::ObjectCustomFieldValue->ParseIPRange( $content );
$args->{ContentType} = 'text/plain';
return (0, $self->loc("Content is not a valid IP address range"))
unless $args->{Content};
return 1;
}
=head2 MatchPattern STRING
......
......@@ -1058,7 +1058,8 @@ sub InsertData {
$object = RT::CustomField->new( RT->SystemUser );
my @columns = ( Name => $item->{'CF'} );
push @columns, LookupType => $item->{'LookupType'} if $item->{'LookupType'};
push @columns, ObjectId => $item->{'Queue'} if $item->{'Queue'} and not ref $item->{'Queue'};
push @columns, ObjectId => $item->{'ObjectId'} if $item->{'ObjectId'};
push @columns, Queue => $item->{'Queue'} if $item->{'Queue'} and not ref $item->{'Queue'};
my ($ok, $msg) = $object->LoadByName( @columns );
unless ( $ok ) {
RT->Logger->error("Unable to load CF ".$item->{CF}.": $msg");
......
......@@ -82,36 +82,11 @@ sub Create {
@_,
);
my $cf = RT::CustomField->new( $self->CurrentUser );
$cf->Load( $args{CustomField} );
my $cf_as_sys = RT::CustomField->new(RT->SystemUser);
$cf_as_sys->Load($args{'CustomField'});
if($cf_as_sys->Type eq 'IPAddress') {
if ( $args{'Content'} ) {
$args{'Content'} = $self->ParseIP( $args{'Content'} );
}
unless ( defined $args{'Content'} ) {
return
wantarray
? ( 0, $self->loc("Content is an invalid IP address") )
: 0;
}
}
if($cf_as_sys->Type eq 'IPAddressRange') {
if ($args{'Content'}) {
($args{'Content'}, $args{'LargeContent'}) = $self->ParseIPRange( $args{'Content'} );
}
$args{'ContentType'} = 'text/plain';
unless ( defined $args{'Content'} ) {
return
wantarray
? ( 0, $self->loc("Content is an invalid IP address range") )
: 0;
}
}
my ($val, $msg) = $cf->_CanonicalizeValue(\%args);
return ($val, $msg) unless $val;
if ( defined $args{'Content'} && length( Encode::encode_utf8($args{'Content'}) ) > 255 ) {
if ( defined $args{'LargeContent'} && length $args{'LargeContent'} ) {
......@@ -165,16 +140,9 @@ sub LoadByCols {
if ( $args{CustomField} ) {
$cf = RT::CustomField->new( $self->CurrentUser );
$cf->Load( $args{CustomField} );
if ( $cf->Type && $cf->Type eq 'IPAddressRange' ) {
my ( $sIP, $eIP ) = $cf->ParseIPRange( $args{'Content'} );
if ( $sIP && $eIP ) {
$self->SUPER::LoadByCols( %args,
Content => $sIP,
LargeContent => $eIP
);
}
}
my ($ok, $msg) = $cf->_CanonicalizeValue(\%args);
return ($ok, $msg) unless $ok;
}
return $self->SUPER::LoadByCols(%args);
}
......
......@@ -135,12 +135,8 @@ sub HasEntry {
my $args = $canon_value{ $cf->Type };
if ( !$args ) {
$args = { Content => $value, LargeContent => $large_content };
if ( my $canonicalizer =
$cf->can( '_CanonicalizeValue' . $cf->Type ) )
{
$canonicalizer->( $cf, $args );
}
my ($ok, $msg) = $cf->_CanonicalizeValue( $args );
next unless $ok;
$canon_value{ $cf->Type } = $args;
}
......@@ -149,7 +145,7 @@ sub HasEntry {
return $item if lc $item->Content eq lc $args->{Content};
}
else {
if ( $item->Content eq $args->{Content} ) {
if ( $item->_Value('Content') eq $args->{Content} ) {
if ( defined $item->LargeContent ) {
return $item
if defined $args->{LargeContent}
......
......@@ -1981,8 +1981,8 @@ sub _AddCustomFieldValue {
$i++;
if ( $i < $cf_values ) {
my ( $val, $msg ) = $cf->DeleteValueForObject(
Object => $self,
Content => $value->Content
Object => $self,
Id => $value->id,
);
unless ($val) {
return ( 0, $msg );
......
......@@ -529,13 +529,6 @@ sub _LimitCustomField {
$RT::Logger->warn("$value is not a valid IPAddress");
}
} elsif ( $type eq 'IPAddressRange' ) {
if ( $value =~ /^\s*$RE{net}{CIDR}{IPv4}{-keep}\s*$/o ) {
# convert incomplete 192.168/24 to 192.168.0.0/24 format
$value =
join( '.', map $_ || 0, ( split /\./, $1 )[ 0 .. 3 ] ) . "/$2"
|| $value;
}
my ( $start_ip, $end_ip ) =
RT::ObjectCustomFieldValue->ParseIPRange($value);
if ( $start_ip && $end_ip ) {
......
......@@ -95,27 +95,12 @@ while ( my $CF = $CustomFields->Next ) {
for my $value( @values ) {
if ($value) {
if ( $CF->Type eq 'IPAddress' ) {
use Regexp::Common qw(RE_net_IPv4);
my $ip = RT::ObjectCustomFieldValue->ParseIP( $value );
unless ( $ip ) {
my $msg =
loc( "Input can not be parsed as an IP address" );
$m->notes( ( 'InvalidField-' . $CF->Id ) => $msg );
push @res, $CF->Name .': '. $msg;
$valid = 0;
}
}
elsif ( $CF->Type eq 'IPAddressRange' ) {
my ( $start_ip, $end_ip ) =
RT::ObjectCustomFieldValue->ParseIPRange($value);
unless ( $start_ip && $end_ip ) {
my $msg =
loc( "Input can not be parsed as an IP address range" );
$m->notes( ( 'InvalidField-' . $CF->Id ) => $msg );
push @res, $CF->Name .': '. $msg;
$valid = 0;
}
my $ref = { Content => $value };
my ($ok, $msg) = $CF->_CanonicalizeValue( $ref );
unless ($ok) {
$m->notes( ( 'InvalidField-' . $CF->Id ) => $msg );
push @res, $CF->Name .': '. $msg;
$valid = 0;
}
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -7,17 +7,17 @@ msgid ""
msgstr ""
"Project-Id-Version: rt\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2014-05-05 18:39+0000\n"
"POT-Creation-Date: 2014-06-06 00:21+0000\n"
"PO-Revision-Date: 2013-10-03 21:30+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: English <en@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-05-05 18:57+0000\n"
"X-Generator: Launchpad (build 16985)\n"
"X-Launchpad-Export-Date: 2014-06-06 00:37+0000\n"
"X-Generator: Launchpad (build 17031)\n"
#: share/html/Elements/Tabs:444 share/html/m/_elements/header:69
#: share/html/Elements/Tabs:470 share/html/m/_elements/header:69
msgid "Homepage"
msgstr "Home"
......
......@@ -7,15 +7,15 @@ msgid ""
msgstr ""
"Project-Id-Version: rt\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2014-05-05 18:39+0000\n"
"PO-Revision-Date: 2014-05-02 03:19+0000\n"
"Last-Translator: Alex Vandiver <Unknown>\n"
"POT-Creation-Date: 2014-06-06 00:21+0000\n"
"PO-Revision-Date: 2014-05-14 07:36+0000\n"
"Last-Translator: Andi Chandler <Unknown>\n"
"Language-Team: English (United Kingdom) <en_GB@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-05-05 18:56+0000\n"
"X-Generator: Launchpad (build 16985)\n"
"X-Launchpad-Export-Date: 2014-06-06 00:38+0000\n"
"X-Generator: Launchpad (build 17031)\n"
#: share/html/Install/DatabaseDetails.html:180
#. ($RT::DatabaseName)
......@@ -87,7 +87,7 @@ msgstr "Click \"Initialise Database\" to create RT's database and insert initial
msgid "Click to choose a color"
msgstr "Click to choose a colour"
#: lib/RT/Scrip.pm:176 lib/RT/Scrip.pm:802
#: lib/RT/Scrip.pm:176 lib/RT/Scrip.pm:821
msgid "Condition is mandatory argument"
msgstr "Condition is a mandatory argument"
......@@ -164,7 +164,7 @@ msgstr "RT is used by Fortune 100 companies, one-person businesses, government a
msgid "RT's logging configuration is summarized below:"
msgstr "RT's logging configuration is summarised below:"
#: lib/RT/Config.pm:338
#: lib/RT/Config.pm:358
msgid "Rich text (HTML) shows formatting such as colored text, bold, italics, and more"
msgstr "Rich text (HTML) shows formatting such as coloured text, bold, italics, and more"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment