[Rt-commit] r6657 - rt/branches/3.6-RELEASE/html/Elements
ruz at bestpractical.com
ruz at bestpractical.com
Tue Dec 19 16:22:29 EST 2006
Author: ruz
Date: Tue Dec 19 16:22:29 2006
New Revision: 6657
Modified:
rt/branches/3.6-RELEASE/html/Elements/MyRT
rt/branches/3.6-RELEASE/html/Elements/ShowSearch
Log:
* add %Override option to html/Elements/ShowSearch
* html/Elements/MyRT should limit results according to user's preferences
Modified: rt/branches/3.6-RELEASE/html/Elements/MyRT
==============================================================================
--- rt/branches/3.6-RELEASE/html/Elements/MyRT (original)
+++ rt/branches/3.6-RELEASE/html/Elements/MyRT Tue Dec 19 16:22:29 2006
@@ -48,7 +48,7 @@
<td width="70%" class="boxcontainer">
% for my $portlet (@{$portlets->{body}}) {
-<% _show($portlet) %>
+<% $show_cb->( $portlet ) %>
<br />
% }
@@ -57,7 +57,7 @@
<td class="boxcontainer">
% for my $portlet (@{$portlets->{summary}}) {
-<% _show($portlet) %>
+<% $show_cb->( $portlet ) %>
<br />
% }
@@ -69,6 +69,7 @@
my %allowed_components = map {$_ => 1} @{$RT::HomepageComponents};
+my $user = $session{'CurrentUser'}->UserObj;
unless (exists $session{'my_rt_portlets'}) {
my ($default_portlets) = RT::System->new($session{'CurrentUser'})->Attributes->Named('HomepageSettings');
my $portlets;
@@ -77,13 +78,14 @@
} else {
$portlets = {};
}
- my $user = $session{'CurrentUser'}->UserObj;
$session{'my_rt_portlets'} = $user->Preferences('HomepageSettings', $portlets);
}
my $portlets = $session{'my_rt_portlets'};
-sub _show {
+my $Rows = $user->Preferences( 'SummaryRows', ( $RT::DefaultSummaryRows || 10 ) );
+
+my $show_cb = sub {
my $entry = shift;
my $type = $entry->{type};
if ( $type eq 'component' ) {
@@ -92,12 +94,12 @@
# security check etc.
$m->comp( $name, %{ $entry->{arguments} || {} } );
} elsif ( $type eq 'system' ) {
- $m->comp( '/Elements/ShowSearch', Name => $entry->{name} );
+ $m->comp( '/Elements/ShowSearch', Name => $entry->{name}, Override => { Rows => $Rows } );
} elsif ( $type eq 'saved' ) {
- $m->comp( '/Elements/ShowSearch', SavedSearch => $entry->{name} );
+ $m->comp( '/Elements/ShowSearch', SavedSearch => $entry->{name}, Override => { Rows => $Rows } );
} else {
$RT::Logger->error("unknown portlet type $type");
}
-}
+};
</%INIT>
Modified: rt/branches/3.6-RELEASE/html/Elements/ShowSearch
==============================================================================
--- rt/branches/3.6-RELEASE/html/Elements/ShowSearch (original)
+++ rt/branches/3.6-RELEASE/html/Elements/ShowSearch Tue Dec 19 16:22:29 2006
@@ -93,13 +93,13 @@
}
$SearchArg = $user->Preferences( $search, $search->Content );
- $SearchArg->{'Rows'}
- = $user->Preferences( 'SummaryRows', $RT::DefaultSummaryRows );
$customize = $RT::WebPath . '/Prefs/Search.html?'
. $m->comp( '/Elements/QueryString',
name => ref($search) . '-' . $search->Id );
}
+$SearchArg = { %$SearchArg, %Override } if keys %Override;
+
$SearchArg->{'Query'} =~ s/__CurrentUser__/$session{'CurrentUser'}->Id/ge;
$SearchArg->{'Format'} =~ s/__WebPath__/$RT::WebPath/g;
$SearchArg->{'Format'} =~ s/__loc\(["']?(\w+)["']?\)__/loc("$1")/ge;
@@ -113,10 +113,9 @@
my $QueryString = '?' . $m->comp( '/Elements/QueryString', %$SearchArg );
-#map { $_ => $SearchArg->{$_} } qw(Query Order OrderBy));
-
</%init>
<%ARGS>
-$Name => undef
+$Name => undef
$SavedSearch => undef
+%Override => ()
</%ARGS>
More information about the Rt-commit
mailing list