Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / rt / lib / RT / ObjectCustomFields.pm
index 9864949..8c31047 100644 (file)
@@ -2,7 +2,7 @@
 #
 # COPYRIGHT:
 #
-# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 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;
@@ -112,22 +88,16 @@ sub HasEntryForCustomField {
     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'}) {
@@ -139,17 +109,6 @@ sub _DoSearch {
     $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;