[Rt-commit] r6556 - in rt/branches/3.6-RELEASE: . html/Prefs
html/Search html/Search/Elements
jesse at bestpractical.com
jesse at bestpractical.com
Fri Dec 1 13:51:14 EST 2006
Author: jesse
Date: Fri Dec 1 13:51:12 2006
New Revision: 6556
Modified:
rt/branches/3.6-RELEASE/ (props changed)
rt/branches/3.6-RELEASE/html/Prefs/MyRT.html
rt/branches/3.6-RELEASE/html/Search/Chart.html
rt/branches/3.6-RELEASE/html/Search/Elements/EditSearches
rt/branches/3.6-RELEASE/lib/RT/SavedSearches.pm
Log:
r45280 at pinglin (orig r6490): clkao | 2006-11-22 03:57:46 -0500
refactor the code for loading saved search privacies to RT::SavedSearches.
Modified: rt/branches/3.6-RELEASE/html/Prefs/MyRT.html
==============================================================================
--- rt/branches/3.6-RELEASE/html/Prefs/MyRT.html (original)
+++ rt/branches/3.6-RELEASE/html/Prefs/MyRT.html Fri Dec 1 13:51:12 2006
@@ -65,6 +65,7 @@
</form>
</&>
<%INIT>
+use RT::SavedSearches;
my @actions;
my $title = loc("Customize").' '.loc("RT at a glance");
@@ -96,14 +97,9 @@
my $sys = RT::System->new($session{'CurrentUser'});
my @objs = ($sys);
-if ($session{'CurrentUser'}->HasRight( Right => 'LoadSavedSearch',
- Object=> $RT::System )) {
- my $groups = RT::Groups->new($session{'CurrentUser'});
- $groups->LimitToUserDefinedGroups;
- $groups->WithMember(PrincipalId => $session{'CurrentUser'}->Id,
- Recursively => 1);
- push @objs, ($user, @{$groups->ItemsArrayRef()});
-}
+push @objs, RT::SavedSearches->new( $session{CurrentUser} )->_PrivacyObjects
+ if $session{'CurrentUser'}->HasRight( Right => 'LoadSavedSearch',
+ Object => $RT::System );
my @sys_searches;
for my $object (@objs) {
Modified: rt/branches/3.6-RELEASE/html/Search/Chart.html
==============================================================================
--- rt/branches/3.6-RELEASE/html/Search/Chart.html (original)
+++ rt/branches/3.6-RELEASE/html/Search/Chart.html Fri Dec 1 13:51:12 2006
@@ -52,23 +52,12 @@
</%args>
<%init>
+my $title = loc( "Search results grouped by [_1]", $PrimaryGroupBy );
-my $title = loc("Search results grouped by [_1]", $PrimaryGroupBy);
-
-my @Objects;
-
-push @Objects, $session{CurrentUser}->UserObj;
-
-my $groups = RT::Groups->new($session{'CurrentUser'});
-
-$groups->LimitToUserDefinedGroups;
-$groups->WithMember(PrincipalId => $session{'CurrentUser'}->Id,
- Recursively => 1);
-
-push (@Objects, @{$groups->ItemsArrayRef()});
+my @Objects = RT::SavedSearches->new( $session{CurrentUser} )->_PrivacyObjects;
push @Objects, RT::System->new($session{'CurrentUser'})
if $session{'CurrentUser'}->HasRight( Object=> $RT::System,
- Right => 'SuperUser');
+ Right => 'SuperUser');
if ( $ARGS{Save} ) {
if ( $ARGS{'Owner'} =~ /^(.*?)-(\d+)$/ ) {
Modified: rt/branches/3.6-RELEASE/html/Search/Elements/EditSearches
==============================================================================
--- rt/branches/3.6-RELEASE/html/Search/Elements/EditSearches (original)
+++ rt/branches/3.6-RELEASE/html/Search/Elements/EditSearches Fri Dec 1 13:51:12 2006
@@ -74,25 +74,17 @@
</&>
<%init>
-
+use RT::SavedSearches;
unless ($session{'CurrentUser'}->HasRight( Right => 'LoadSavedSearch',
- Object=> $RT::System )) {
+ Object=> $RT::System )) {
return;
}
-my @Objects;
-
-push @Objects, $session{CurrentUser}->UserObj;
-
-my $groups = RT::Groups->new($session{'CurrentUser'});
-$groups->LimitToUserDefinedGroups;
-$groups->WithMember(PrincipalId => $session{'CurrentUser'}->Id,
- Recursively => 1);
-
-push (@Objects, @{$groups->ItemsArrayRef()});
+my @Objects = RT::SavedSearches->new($session{CurrentUser})->_PrivacyObjects;
push @Objects, RT::System->new($session{'CurrentUser'})
if $session{'CurrentUser'}->HasRight( Object=> $RT::System,
- Right => 'SuperUser');
+ Right => 'SuperUser');
+
</%INIT>
<%ARGS>
Modified: rt/branches/3.6-RELEASE/lib/RT/SavedSearches.pm
==============================================================================
--- rt/branches/3.6-RELEASE/lib/RT/SavedSearches.pm (original)
+++ rt/branches/3.6-RELEASE/lib/RT/SavedSearches.pm Fri Dec 1 13:51:12 2006
@@ -197,6 +197,22 @@
return $object;
}
+### Internal methods
+
+# _PrivacyObjects: returns a list of objects that can be used to load saved searches from.
+
+sub _PrivacyObjects {
+ my $self = shift;
+ my $CurrentUser = $self->CurrentUser;
+
+ my $groups = RT::Groups->new($CurrentUser);
+ $groups->LimitToUserDefinedGroups;
+ $groups->WithMember( PrincipalId => $CurrentUser->Id,
+ Recursively => 1 );
+
+ return ( $CurrentUser->UserObj, @{ $groups->ItemsArrayRef() } );
+}
+
eval "require RT::SavedSearches_Vendor";
die $@ if ($@ && $@ !~ qr{^Can't locate RT/SavedSearches_Vendor.pm});
eval "require RT::SavedSearches_Local";
More information about the Rt-commit
mailing list