#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
#
# END BPS TAGGED BLOCK }}}
-package RT::ObjectCustomFields;
-
use strict;
use warnings;
+package RT::ObjectCustomFields;
+use base 'RT::SearchBuilder::AddAndSort';
+use RT::CustomField;
use RT::ObjectCustomField;
-use base 'RT::SearchBuilder';
-
sub Table { 'ObjectCustomFields'}
-sub _Init {
- my $self = shift;
-
- # By default, order by SortOrder
- $self->OrderByCols(
- { ALIAS => 'main',
- FIELD => 'SortOrder',
- ORDER => 'ASC' },
- { ALIAS => 'main',
- FIELD => 'id',
- ORDER => 'ASC' },
- );
-
- return ( $self->SUPER::_Init(@_) );
-}
-
-
sub LimitToCustomField {
my $self = shift;
my $id = shift;
$self->Limit( FIELD => 'CustomField', VALUE => $id );
}
-sub LimitToObjectId {
- my $self = shift;
- my $id = shift || 0;
- $self->Limit( FIELD => 'ObjectId', VALUE => $id );
-}
-
sub LimitToLookupType {
my $self = shift;
my $lookup = shift;
my @items = grep {$_->CustomField == $id } @{$self->ItemsArrayRef};
if ($#items > 1) {
- die "$self HasEntry had a list with more than one of $id in it. this can never happen";
+ die "$self HasEntry had a list with more than one of $id in it. this can never happen";
}
if ($#items == -1 ) {
- return undef;
+ return undef;
}
else {
- return ($items[0]);
+ return ($items[0]);
}
}
-sub CustomFields {
- my $self = shift;
- my %seen;
- map { $_->CustomFieldObj } @{$self->ItemsArrayRef};
-}
-
sub _DoSearch {
my $self = shift;
if ($self->{'_cfs_alias'}) {
$self->SUPER::_DoSearch()
}
-
-=head2 NewItem
-
-Returns an empty new RT::ObjectCustomField item
-
-=cut
-
-sub NewItem {
- my $self = shift;
- return(RT::ObjectCustomField->new($self->CurrentUser));
-}
RT::Base->_ImportOverlays();
1;