[Rt-commit] r5685 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Wed Aug 2 15:48:22 EDT 2006
Author: ruz
Date: Wed Aug 2 15:48:20 2006
New Revision: 5685
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/lib/RT/CustomFieldValue_Overlay.pm
rt/branches/3.7-EXPERIMENTAL/lib/RT/CustomFieldValues_Overlay.pm
rt/branches/3.7-EXPERIMENTAL/lib/RT/ObjectCustomFieldValue_Overlay.pm
rt/branches/3.7-EXPERIMENTAL/lib/RT/ObjectCustomFieldValues_Overlay.pm
Log:
r3578 at cubic-pc: cubic | 2006-08-02 01:35:13 +0400
* minor
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/CustomFieldValue_Overlay.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/CustomFieldValue_Overlay.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/CustomFieldValue_Overlay.pm Wed Aug 2 15:48:20 2006
@@ -15,24 +15,27 @@
sub Create {
my $self = shift;
- my %args = @_;
- (defined $args{$_} or delete $args{$_}) for keys %args;
- %args = ((CustomField => '0',
- Name => '',
- Description => '',
- SortOrder => '0',
- Category => ''), %args);
+ my %args = (
+ CustomField => 0,
+ Name => '',
+ Description => '',
+ SortOrder => 0,
+ Category => '',
+ @_,
+ );
my ($id, $msg) = $self->SUPER::Create(
- map {$_ => $args{$_}} qw(CustomField Name Description SortOrder)
+ map { $_ => $args{$_} } qw(CustomField Name Description SortOrder)
);
- if ($id and length $args{Category}) {
+
+ if ( $id && length $args{Category} ) {
# $self would be loaded at this stage
my ($status, $msg) = $self->SetCategory( $args{Category} );
unless ( $status ) {
$RT::Logger->error("Couldn't set category: $msg");
}
}
+
return ($id, $msg);
}
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/CustomFieldValues_Overlay.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/CustomFieldValues_Overlay.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/CustomFieldValues_Overlay.pm Wed Aug 2 15:48:20 2006
@@ -46,6 +46,7 @@
package RT::CustomFieldValues;
use strict;
+use warnings;
no warnings qw(redefine);
# {{{ sub LimitToCustomField
@@ -59,13 +60,13 @@
sub LimitToCustomField {
my $self = shift;
my $cf = shift;
- return ($self->Limit( FIELD => 'CustomField',
- VALUE => $cf,
- OPERATOR => '='));
-
+ return $self->Limit(
+ FIELD => 'CustomField',
+ VALUE => $cf,
+ OPERATOR => '=',
+ );
}
# }}}
1;
-
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/ObjectCustomFieldValue_Overlay.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/ObjectCustomFieldValue_Overlay.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/ObjectCustomFieldValue_Overlay.pm Wed Aug 2 15:48:20 2006
@@ -46,9 +46,9 @@
package RT::ObjectCustomFieldValue;
use strict;
+use warnings;
no warnings qw(redefine);
-
sub Create {
my $self = shift;
my %args = (
@@ -75,35 +75,31 @@
}
( $args{'ContentEncoding'}, $args{'LargeContent'} ) =
- $self->_EncodeLOB( $args{'LargeContent'}, $args{'ContentType'} )
- if ( $args{'LargeContent'} );
-
- $self->SUPER::Create(
- CustomField => $args{'CustomField'},
- ObjectType => $args{'ObjectType'},
- ObjectId => $args{'ObjectId'},
- Disabled => $args{'Disabled'},
- Content => $args{'Content'},
- LargeContent => $args{'LargeContent'},
- ContentType => $args{'ContentType'},
- ContentEncoding => $args{'ContentEncoding'},
-);
-
-
+ $self->_EncodeLOB( $args{'LargeContent'}, $args{'ContentType'} )
+ if defined $args{'LargeContent'};
+ return $self->SUPER::Create(
+ CustomField => $args{'CustomField'},
+ ObjectType => $args{'ObjectType'},
+ ObjectId => $args{'ObjectId'},
+ Disabled => $args{'Disabled'},
+ Content => $args{'Content'},
+ LargeContent => $args{'LargeContent'},
+ ContentType => $args{'ContentType'},
+ ContentEncoding => $args{'ContentEncoding'},
+ );
}
sub LargeContent {
my $self = shift;
- $self->_DecodeLOB( $self->ContentType, $self->ContentEncoding,
- $self->_Value( 'LargeContent', decode_utf8 => 0 ) );
-
+ return $self->_DecodeLOB(
+ $self->ContentType,
+ $self->ContentEncoding,
+ $self->_Value( 'LargeContent', decode_utf8 => 0 )
+ );
}
-
-
-
=head2 LoadByTicketContentAndCustomField { Ticket => TICKET, CustomField => CUSTOMFIELD, Content => CONTENT }
Loads a custom field value by Ticket, Content and which CustomField it's tied to
@@ -113,40 +109,40 @@
sub LoadByTicketContentAndCustomField {
my $self = shift;
- my %args = ( Ticket => undef,
- CustomField => undef,
- Content => undef,
- @_
- );
-
-
- $self->LoadByCols( Content => $args{'Content'},
- CustomField => $args{'CustomField'},
- ObjectType => 'RT::Ticket',
- ObjectId => $args{'Ticket'},
- Disabled => 0
- );
+ my %args = (
+ Ticket => undef,
+ CustomField => undef,
+ Content => undef,
+ @_
+ );
-
+ return $self->LoadByCols(
+ Content => $args{'Content'},
+ CustomField => $args{'CustomField'},
+ ObjectType => 'RT::Ticket',
+ ObjectId => $args{'Ticket'},
+ Disabled => 0
+ );
}
sub LoadByObjectContentAndCustomField {
my $self = shift;
- my %args = ( Object => undef,
- CustomField => undef,
- Content => undef,
- @_
- );
+ my %args = (
+ Object => undef,
+ CustomField => undef,
+ Content => undef,
+ @_
+ );
my $obj = $args{'Object'} or return;
- $self->LoadByCols( Content => $args{'Content'},
- CustomField => $args{'CustomField'},
- ObjectType => ref($obj),
- ObjectId => $obj->Id,
- Disabled => 0
- );
-
+ return $self->LoadByCols(
+ Content => $args{'Content'},
+ CustomField => $args{'CustomField'},
+ ObjectType => ref($obj),
+ ObjectId => $obj->Id,
+ Disabled => 0
+ );
}
@@ -157,18 +153,16 @@
=cut
-
sub Content {
my $self = shift;
my $content = $self->SUPER::Content;
- if (!$content && $self->ContentType eq 'text/plain') {
- return $self->LargeContent();
+ if ( !$content && $self->ContentType eq 'text/plain' ) {
+ return $self->LargeContent;
} else {
return $content;
}
}
-
=head2 Object
Returns the object this value applies to
@@ -177,9 +171,9 @@
sub Object {
my $self = shift;
- my $Object = $self->__Value('ObjectType')->new($self->CurrentUser);
- $Object->Load($self->__Value('ObjectId'));
- return($Object);
+ my $Object = $self->__Value('ObjectType')->new( $self->CurrentUser );
+ $Object->LoadById( $self->__Value('ObjectId') );
+ return $Object;
}
@@ -192,7 +186,7 @@
sub Delete {
my $self = shift;
- $self->SetDisabled(1);
+ return $self->SetDisabled(1);
}
=head2 _FillInTemplateURL URL
@@ -257,7 +251,4 @@
return $self->_FillInTemplateURL($self->CustomFieldObj->IncludeContentForValue);
}
-
-
-
1;
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/ObjectCustomFieldValues_Overlay.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/ObjectCustomFieldValues_Overlay.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/ObjectCustomFieldValues_Overlay.pm Wed Aug 2 15:48:20 2006
@@ -59,10 +59,10 @@
sub LimitToCustomField {
my $self = shift;
my $cf = shift;
- return ($self->Limit( FIELD => 'CustomField',
- VALUE => $cf,
- OPERATOR => '='));
-
+ return $self->Limit(
+ FIELD => 'CustomField',
+ VALUE => $cf,
+ );
}
# }}}
@@ -78,12 +78,14 @@
sub LimitToObject {
my $self = shift;
my $object = shift;
- $self->Limit( FIELD => 'ObjectType',
- VALUE => ref($object),
- OPERATOR => '=');
- return ($self->Limit( FIELD => 'ObjectId',
- VALUE => $object->Id,
- OPERATOR => '='));
+ $self->Limit(
+ FIELD => 'ObjectType',
+ VALUE => ref($object),
+ );
+ return $self->Limit(
+ FIELD => 'ObjectId',
+ VALUE => $object->Id,
+ );
}
@@ -91,7 +93,8 @@
=sub HasEntry VALUE
-Returns true if this CustomFieldValues collection has an entry with content that eq VALUE
+Returns true if this CustomFieldValues collection
+has an entry with content that eq VALUE
=cut
@@ -101,35 +104,34 @@
my $value = shift;
#TODO: this could cache and optimize a fair bit.
- foreach my $item (@{$self->ItemsArrayRef}) {
- return(1) if ($item->Content eq $value);
+ foreach my $item ( @{$self->ItemsArrayRef} ) {
+ return 1 if $item->Content eq $value;
}
return undef;
-
}
sub _DoSearch {
my $self = shift;
- #unless we really want to find disabled rows, make sure we\'re only finding enabled ones.
- unless($self->{'find_expired_rows'}) {
+ # unless we really want to find disabled rows,
+ # make sure we\'re only finding enabled ones.
+ unless ( $self->{'find_expired_rows'} ) {
$self->LimitToEnabled();
}
- return($self->SUPER::_DoSearch(@_));
-
+ return $self->SUPER::_DoSearch(@_);
}
sub _DoCount {
my $self = shift;
- #unless we really want to find disabled rows, make sure we\'re only finding enabled ones.
- unless($self->{'find_expired_rows'}) {
+ # unless we really want to find disabled rows,
+ # make sure we\'re only finding enabled ones.
+ unless ( $self->{'find_expired_rows'} ) {
$self->LimitToEnabled();
}
- return($self->SUPER::_DoCount(@_));
-
+ return $self->SUPER::_DoCount(@_);
}
1;
More information about the Rt-commit
mailing list