[Rt-commit] r14829 - in rt/branches/3.6-EXPERIMENTAL-PAGING: lib/RT
ruz at bestpractical.com
ruz at bestpractical.com
Tue Aug 5 19:50:56 EDT 2008
Author: ruz
Date: Tue Aug 5 19:50:54 2008
New Revision: 14829
Modified:
rt/branches/3.6-EXPERIMENTAL-PAGING/ (props changed)
rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/ACL_Overlay.pm
rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/CustomFields_Overlay.pm
rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Groups_Overlay.pm
rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Links_Overlay.pm
rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Scrips_Overlay.pm
rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Templates_Overlay.pm
rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Transactions_Overlay.pm
Log:
r14822 at cubic-pc: cubic | 2008-08-05 05:41:24 +0400
* reuse FilterRecord
Modified: rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/ACL_Overlay.pm
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/ACL_Overlay.pm (original)
+++ rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/ACL_Overlay.pm Tue Aug 5 19:50:54 2008
@@ -280,32 +280,20 @@
# }}}
-# {{{ sub Next
-sub Next {
+# {{{ sub FilterRecord
+sub FilterRecord {
my $self = shift;
+ my $ACE = shift;
- my $ACE = $self->SUPER::Next();
- if ( ( defined($ACE) ) and ( ref($ACE) ) ) {
-
- if ( $self->CurrentUser->HasRight( Right => 'ShowACL',
- Object => $ACE->Object )
- or $self->CurrentUser->HasRight( Right => 'ModifyACL',
- Object => $ACE->Object )
- ) {
- return ($ACE);
- }
-
- #If the user doesn't have the right to show this ACE
- else {
- return ( $self->Next() );
- }
- }
-
- #if there never was any ACE
- else {
- return (undef);
- }
-
+ return 0 if $ACE->CurrentUser->HasRight(
+ Right => 'ShowACL',
+ Object => $ACE->Object,
+ );
+ return 0 if $ACE->CurrentUser->HasRight(
+ Right => 'ModifyACL',
+ Object => $ACE->Object,
+ );
+ return 1;
}
# }}}
Modified: rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/CustomFields_Overlay.pm
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/CustomFields_Overlay.pm (original)
+++ rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/CustomFields_Overlay.pm Tue Aug 5 19:50:54 2008
@@ -175,37 +175,16 @@
# }}}
-# {{{ sub Next
+=head2 FilterRecord
-=head2 Next
-
-Returns the next custom field that this user can see.
+Filters out custom fields this user can not see.
=cut
-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);
- }
-
+sub FilterRecord {
+ return 1 unless $_[1]->CurrentUserHasRight('SeeCustomField');
+ return 0;
}
-# }}}
sub LimitToLookupType {
my $self = shift;
Modified: rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Groups_Overlay.pm
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Groups_Overlay.pm (original)
+++ rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Groups_Overlay.pm Tue Aug 5 19:50:54 2008
@@ -498,28 +498,11 @@
}
# }}}
-# {{{ sub Next
-
-sub Next {
- my $self = shift;
-
- # Don't show groups which the user isn't allowed to see.
-
- my $Group = $self->SUPER::Next();
- if ((defined($Group)) and (ref($Group))) {
- unless ($Group->CurrentUserHasRight('SeeGroup')) {
- return $self->Next();
- }
-
- return $Group;
- }
- else {
- return undef;
- }
+sub FilterRecord {
+ return 1 unless $_[1]->CurrentUserHasRight('SeeGroup');
+ return 0;
}
-
-
sub _DoSearch {
my $self = shift;
Modified: rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Links_Overlay.pm
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Links_Overlay.pm (original)
+++ rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Links_Overlay.pm Tue Aug 5 19:50:54 2008
@@ -150,22 +150,20 @@
# }}}
-# {{{ Next
-sub Next {
+# {{{ FilterRecord
+sub FilterRecord {
my $self = shift;
+ my $link = shift;
- my $Link = $self->SUPER::Next();
- return $Link unless $Link && ref $Link;
-
# Skip links to local objects thast are deleted
- if ( $Link->TargetURI->IsLocal and UNIVERSAL::isa($Link->TargetObj,"RT::Ticket")
- and $Link->TargetObj->__Value('status') eq "deleted") {
- return $self->Next;
- } elsif ($Link->BaseURI->IsLocal and UNIVERSAL::isa($Link->BaseObj,"RT::Ticket")
- and $Link->BaseObj->__Value('status') eq "deleted") {
- return $self->Next;
+ if ( $link->TargetURI->IsLocal and UNIVERSAL::isa($link->TargetObj,"RT::Ticket")
+ and $link->TargetObj->__Value('status') eq "deleted") {
+ return 1;
+ } elsif ($link->BaseURI->IsLocal and UNIVERSAL::isa($link->BaseObj,"RT::Ticket")
+ and $link->BaseObj->__Value('status') eq "deleted") {
+ return 1;
} else {
- return $Link;
+ return 0;
}
}
Modified: rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Scrips_Overlay.pm
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Scrips_Overlay.pm (original)
+++ rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Scrips_Overlay.pm Tue Aug 5 19:50:54 2008
@@ -124,36 +124,19 @@
}
# }}}
-# {{{ sub Next
+# {{{ sub FilterRecord
-=head2 Next
+=head2 FilterRecord
-Returns the next scrip that this user can see.
+Filters out scrips this user can not see. See also L<RT::SearchBuilder/FilterRecord>.
=cut
-sub Next {
- my $self = shift;
-
-
- my $Scrip = $self->SUPER::Next();
- if ((defined($Scrip)) and (ref($Scrip))) {
-
- if ($Scrip->CurrentUserHasRight('ShowScrips')) {
- return($Scrip);
- }
-
- #If the user doesn't have the right to show this scrip
- else {
- return($self->Next());
- }
- }
- #if there never was any scrip
- else {
- return(undef);
- }
-
+sub FilterRecord {
+ return 1 unless $_[1]->CurrentUserHasRight('ShowScrips');
+ return 0;
}
+
# }}}
=head2 Apply
Modified: rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Templates_Overlay.pm
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Templates_Overlay.pm (original)
+++ rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Templates_Overlay.pm Tue Aug 5 19:50:54 2008
@@ -164,39 +164,29 @@
}
# }}}
-# {{{ sub Next
+# {{{ sub FilterRecord
-=head2 Next
+=head2 FilterRecord
Returns the next template that this user can see.
=cut
-sub Next {
+sub FilterRecord {
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')) {
- return($templ);
- }
-
- #If the user doesn't have the right to show this template
- else {
- return($self->Next());
- }
+ my $tmpl = shift;
+
+ if ( $tmpl->__Value('Queue') ) {
+ return 1 unless $tmpl->CurrentUserHasQueueRight('ShowTemplate');
+ } else {
+ return 1 if $tmpl->CurrentUser->HasRight(
+ Object => $RT::System,
+ Right => 'ShowTemplate',
+ );
}
- #if there never was any template
- else {
- return(undef);
- }
-
+ return 0;
}
+
# }}}
1;
Modified: rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Transactions_Overlay.pm
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Transactions_Overlay.pm (original)
+++ rt/branches/3.6-EXPERIMENTAL-PAGING/lib/RT/Transactions_Overlay.pm Tue Aug 5 19:50:54 2008
@@ -156,28 +156,12 @@
}
-# {{{ sub Next
-sub Next {
- my $self = shift;
-
- my $Transaction = $self->SUPER::Next();
- if ((defined($Transaction)) and (ref($Transaction))) {
- # If the user can see the transaction's type, then they can
- # see the transaction and we should hand it back.
- if ($Transaction->Type) {
- return($Transaction);
- }
-
- #If the user doesn't have the right to show this ticket
- else {
- return($self->Next());
- }
- }
-
- #if there never was any ticket
- else {
- return(undef);
- }
+# {{{ sub FilterRecord
+sub FilterRecord {
+ # If the user can see the transaction's type, then they can
+ # see the transaction and we should hand it back.
+ return 1 unless $_[1]->Type;
+ return 0;
}
# }}}
More information about the Rt-commit
mailing list