X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FCustomFields_Overlay.pm;h=0f117c64cf260a82df282e17a43e85a9cb01738d;hb=1bcce7c531fae5b69584be44c9c74967c687b1d1;hp=16b86ba508e1373c6db23f3027b9bdba10cbd8fe;hpb=9509e5bfb7f9331303153cac24d7bfecbe2ea9f1;p=freeside.git diff --git a/rt/lib/RT/CustomFields_Overlay.pm b/rt/lib/RT/CustomFields_Overlay.pm index 16b86ba50..0f117c64c 100644 --- a/rt/lib/RT/CustomFields_Overlay.pm +++ b/rt/lib/RT/CustomFields_Overlay.pm @@ -1,8 +1,8 @@ # BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: -# -# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +# +# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -24,7 +24,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301 or visit their web page on the internet at -# http://www.gnu.org/copyleft/gpl.html. +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. # # # CONTRIBUTION SUBMISSION POLICY: @@ -45,6 +45,7 @@ # those contributions and any derivatives thereof. # # END BPS TAGGED BLOCK }}} + =head1 NAME RT::CustomFields - a collection of RT CustomField objects @@ -58,11 +59,6 @@ =head1 METHODS -=begin testing - -ok (require RT::CustomFields); - -=end testing =cut @@ -186,25 +182,32 @@ Returns the next custom field that this user can see. sub Next { my $self = shift; - my $CF = $self->SUPER::Next(); - if ((defined($CF)) and (ref($CF))) { - - if ($CF->CurrentUserHasRight('SeeCustomField')) { - return($CF); - } - - #If the user doesn't have the right to show this queue - else { - return($self->Next()); - } - } - #if there never was any queue - else { - return(undef); - } - + return $CF unless $CF; + + $CF->SetContextOject( $self->ContextObject ); + + return $self->Next unless $CF->CurrentUserHasRight('SeeCustomField'); + return $CF; } + +sub SetContextObject { + my $self = shift; + return $self->{'context_object'} = shift; +} + +sub ContextObject { + my $self = shift; + return $self->{'context_object'}; +} + +sub NewItem { + my $self = shift; + my $res = RT::CustomField->new($self->CurrentUser); + $res->SetContextObject($self->ContextObject); + return $res; +} + # }}} sub LimitToLookupType { @@ -251,7 +254,7 @@ sub LimitToGlobalOrObjectId { ENTRYAGGREGATOR => 'OR' ) unless $global_only; $self->OrderByCols( - { ALIAS => $self->_OCFAlias, FIELD => 'ObjectId' }, + { ALIAS => $self->_OCFAlias, FIELD => 'ObjectId', ORDER => 'DESC' }, { ALIAS => $self->_OCFAlias, FIELD => 'SortOrder' }, ); @@ -259,6 +262,6 @@ sub LimitToGlobalOrObjectId { #$self->OrderBy( ALIAS => $class_cfs , FIELD => "SortOrder", ORDER => 'ASC'); } - + 1;