X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FTemplates.pm;h=c5a49fe44f1b03b419b686bd1bd7b8e96ee857dd;hp=7d117fae360df2b4fce4e3c1f5119e708ce5ae72;hb=de9d037528895f7151a9aead6724ce2df95f9586;hpb=45d35d5739d05e602bc317739485693e0e9ff0b5 diff --git a/rt/lib/RT/Templates.pm b/rt/lib/RT/Templates.pm index 7d117fae3..c5a49fe44 100755 --- a/rt/lib/RT/Templates.pm +++ b/rt/lib/RT/Templates.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -68,10 +68,10 @@ package RT::Templates; use strict; use warnings; -use RT::Template; - use base 'RT::SearchBuilder'; +use RT::Template; + sub Table { 'Templates'} @@ -125,50 +125,20 @@ sub LimitToQueue { } -=head2 Next - -Returns the next template that this user can see. - -=cut - -sub Next { - my $self = shift; - - - my $templ = $self->SUPER::Next(); - if ((defined($templ)) and (ref($templ))) { - - # If it's part of a queue, and the user can read templates in - # that queue, or the user can globally read templates, show it - if ($templ->Queue && $templ->CurrentUserHasQueueRight('ShowTemplate') or - $templ->CurrentUser->HasRight(Object => $RT::System, Right => 'ShowTemplate') or - $templ->CurrentUser->HasRight(Object => $RT::System, Right => 'ShowGlobalTemplates')) { - return($templ); - } - - #If the user doesn't have the right to show this template - else { - return($self->Next()); - } - } - #if there never was any template - else { - return(undef); - } - -} +=head2 AddRecord -=head2 NewItem - -Returns an empty new RT::Template item +Overrides the collection to ensure that only templates the user can see +are returned. =cut -sub NewItem { +sub AddRecord { my $self = shift; - return(RT::Template->new($self->CurrentUser)); -} + my ($record) = @_; + return unless $record->CurrentUserCanRead; + return $self->SUPER::AddRecord( $record ); +} RT::Base->_ImportOverlays();