[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.7-789-g29b4d3e
Alex Vandiver
alexmv at bestpractical.com
Thu Dec 9 17:27:35 EST 2010
The branch, 3.9-trunk has been updated
via 29b4d3e1dc4165227f58e067aa22a237debde6bf (commit)
from b5b357766929465521281c2886456c6b1fe24824 (commit)
Summary of changes:
lib/RT/SavedSearch.pm | 24 ++++++++++++++++++++++++
share/html/Admin/Users/MyRT.html | 2 +-
share/html/Dashboards/Queries.html | 2 +-
share/html/Elements/SavedSearches | 2 +-
share/html/Prefs/MyRT.html | 2 +-
share/html/Widgets/SavedSearch | 8 ++++----
share/html/m/_elements/menu | 2 +-
7 files changed, 33 insertions(+), 9 deletions(-)
- Log -----------------------------------------------------------------
commit 29b4d3e1dc4165227f58e067aa22a237debde6bf
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Dec 9 17:27:18 2010 -0500
When listing searches for loading, only iterate through groups which have the attribute
diff --git a/lib/RT/SavedSearch.pm b/lib/RT/SavedSearch.pm
index cbe6f52..323cd65 100644
--- a/lib/RT/SavedSearch.pm
+++ b/lib/RT/SavedSearch.pm
@@ -134,16 +134,40 @@ sub Type {
sub _PrivacyObjects {
my $self = shift;
+ my ($has_attr) = @_;
my $CurrentUser = $self->CurrentUser;
my $groups = RT::Groups->new($CurrentUser);
$groups->LimitToUserDefinedGroups;
$groups->WithMember( PrincipalId => $CurrentUser->Id,
Recursively => 1 );
+ if ($has_attr) {
+ my $attrs = $groups->Join(
+ ALIAS1 => 'main',
+ FIELD1 => 'id',
+ TABLE2 => 'Attributes',
+ FIELD2 => 'ObjectId',
+ );
+ $groups->Limit(
+ ALIAS => $attrs,
+ FIELD => 'ObjectType',
+ VALUE => 'RT::Group',
+ );
+ $groups->Limit(
+ ALIAS => $attrs,
+ FIELD => 'Name',
+ VALUE => $has_attr,
+ );
+ }
return ( $CurrentUser->UserObj, @{ $groups->ItemsArrayRef() } );
}
+sub ObjectsForLoading {
+ my $self = shift;
+ return grep { $self->CurrentUserCanSee($_) } $self->_PrivacyObjects( "SavedSearch" );
+}
+
RT::Base->_ImportOverlays();
1;
diff --git a/share/html/Admin/Users/MyRT.html b/share/html/Admin/Users/MyRT.html
index 097e70b..b0d065a 100644
--- a/share/html/Admin/Users/MyRT.html
+++ b/share/html/Admin/Users/MyRT.html
@@ -88,7 +88,7 @@ push @items, map {["component-$_", $_]} sort keys %allowed_components;
my $sys = RT::System->new( RT::CurrentUser->new($UserObj) );
my @objs = ($sys);
-push @objs, RT::SavedSearch->new( RT::CurrentUser->new( $UserObj ) )->_PrivacyObjects;
+push @objs, RT::SavedSearch->new( RT::CurrentUser->new( $UserObj ) )->ObjectsForLoading;
for my $object (@objs) {
for ($m->comp("/Search/Elements/SearchesForObject", Object => $object)) {
diff --git a/share/html/Dashboards/Queries.html b/share/html/Dashboards/Queries.html
index 6bf1dd5..57f9fee 100644
--- a/share/html/Dashboards/Queries.html
+++ b/share/html/Dashboards/Queries.html
@@ -115,7 +115,7 @@ for my $dashboard (@dashboards) {
# add saved searches
my @objs = RT::System->new($session{'CurrentUser'});
-push @objs, RT::SavedSearch->new( $session{CurrentUser} )->_PrivacyObjects
+push @objs, RT::SavedSearch->new( $session{CurrentUser} )->ObjectsForLoading
if $session{'CurrentUser'}->HasRight( Right => 'LoadSavedSearch',
Object => $RT::System );
diff --git a/share/html/Elements/SavedSearches b/share/html/Elements/SavedSearches
index ede9ea0..a547fe3 100644
--- a/share/html/Elements/SavedSearches
+++ b/share/html/Elements/SavedSearches
@@ -66,7 +66,7 @@
% }
</&>
<%init>
-my @Objects = RT::SavedSearch->new($session{CurrentUser})->_PrivacyObjects;
+my @Objects = RT::SavedSearch->new($session{CurrentUser})->ObjectsForLoading;
push @Objects, RT::System->new( $session{'CurrentUser'} )
if $session{'CurrentUser'}->HasRight( Object=> $RT::System,
Right => 'SuperUser' );
diff --git a/share/html/Prefs/MyRT.html b/share/html/Prefs/MyRT.html
index 9639c5e..42bc1ea 100644
--- a/share/html/Prefs/MyRT.html
+++ b/share/html/Prefs/MyRT.html
@@ -115,7 +115,7 @@ my @items = map ["component-$_", $_], grep !$seen{$_}++, @{RT->Config->Get('Home
my $sys = RT::System->new($session{'CurrentUser'});
my @objs = ($sys);
-push @objs, RT::SavedSearch->new( $session{CurrentUser} )->_PrivacyObjects
+push @objs, RT::SavedSearch->new( $session{CurrentUser} )->ObjectsForLoading
if $session{'CurrentUser'}->HasRight( Right => 'LoadSavedSearch',
Object => $RT::System );
diff --git a/share/html/Widgets/SavedSearch b/share/html/Widgets/SavedSearch
index 6080df9..6a2589a 100644
--- a/share/html/Widgets/SavedSearch
+++ b/share/html/Widgets/SavedSearch
@@ -55,10 +55,6 @@ return \%ARGS;
<%init>
my @actions;
-my @Objects = RT::SavedSearch->new( $session{CurrentUser} )->_PrivacyObjects;
-push @Objects, RT::System->new($session{'CurrentUser'})
- if $session{'CurrentUser'}->HasRight( Object=> $RT::System,
- Right => 'SuperUser' );
$self->{SearchId} ||= $args->{'SavedChartSearchId'} || 'new';
my $SearchParams = { map { $_ => $args->{$_} } @{$self->{SearchFields}} };
@@ -90,6 +86,10 @@ if ( my ( $container_object, $search_id ) = _parse_saved_search(
# look for the current one in the available saved searches
if ($self->{SearchId} eq 'new') {
+ my @Objects = RT::SavedSearch->new( $session{CurrentUser} )->ObjectsForLoading;
+ push @Objects, RT::System->new($session{'CurrentUser'})
+ if $session{'CurrentUser'}->HasRight( Object=> $RT::System,
+ Right => 'SuperUser' );
for my $obj (@Objects) {
for ( $m->comp( "/Search/Elements/SearchesForObject", Object => $obj ) ) {
my ( $desc, $search ) = @$_;
diff --git a/share/html/m/_elements/menu b/share/html/m/_elements/menu
index 82ce90f..7a1eca7 100644
--- a/share/html/m/_elements/menu
+++ b/share/html/m/_elements/menu
@@ -89,7 +89,7 @@ my @menu = (
if ( $session{'CurrentUser'}->HasRight( Right => 'LoadSavedSearch', Object => $RT::System))
{
- my @Objects = RT::SavedSearches->new( $session{CurrentUser} )->_PrivacyObjects;
+ my @Objects = RT::SavedSearches->new( $session{CurrentUser} )->ObjectsForLoading;
push @Objects, RT::System->new( $session{'CurrentUser'} )
if $session{'CurrentUser'}->HasRight(
Object => $RT::System,
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list