[Rt-commit] rt 03/03: Provide backward compatibility for RTIR older than 5.0.2
Jim Brandt
jbrandt at bestpractical.com
Thu Jul 15 17:58:58 UTC 2021
This is an automated email from the git hooks/post-receive script.
jbrandt pushed a commit to branch 5.0/use-dashboard-for-homepage-select-ui
in repository rt.
commit dee83121b6325949bf52571786d8a02922f93936
Author: Jim Brandt <jbrandt at bestpractical.com>
AuthorDate: Thu Jul 15 13:58:05 2021 -0400
Provide backward compatibility for RTIR older than 5.0.2
---
share/html/Elements/MyRT | 86 +++++++++++++++++++++++++++++++++---------------
1 file changed, 59 insertions(+), 27 deletions(-)
diff --git a/share/html/Elements/MyRT b/share/html/Elements/MyRT
index 0ebf9a4145..52885664b7 100644
--- a/share/html/Elements/MyRT
+++ b/share/html/Elements/MyRT
@@ -111,37 +111,69 @@ my $Rows = $user->Preferences( 'SummaryRows', ( RT->Config->Get('DefaultSummaryR
my $show_cb;
$show_cb = sub {
my $entry = shift;
- my $depth = shift || 0;
- Abort("Possible recursive dashboard detected.", SuppressHeader => 1) if $depth > 8;
+ my $type;
+ my $name;
- my $type = $entry->{portlet_type};
- my $name = $entry->{component};
- if ( $type eq 'component' ) {
- if (!$allowed_components{$name}) {
- $m->out( $m->interp->apply_escapes( loc("Invalid portlet [_1]", $name), "h" ) );
- RT->Logger->info("Invalid portlet $name found on user " . $user->Name . "'s homepage");
- if ($name eq 'QueueList' && $allowed_components{Quicksearch}) {
- RT->Logger->warning("You may need to replace the component 'Quicksearch' in the HomepageComponents config with 'QueueList'. See the UPGRADING-4.4 document.");
+ # Back compat for RTIR older than 5.0.2
+ if ( defined $RT::IR::VERSION
+ && RT::Handle::cmp_version($RT::IR::VERSION, '5.0.1') <= 0
+ && $m->callers(1)->path eq '/RTIR/index.html' ) {
+
+ $type = $entry->{type};
+ $name = $entry->{'name'};
+ if ( $type eq 'component' ) {
+ if (!$allowed_components{$name}) {
+ $m->out( $m->interp->apply_escapes( loc("Invalid portlet [_1]", $name), "h" ) );
+ RT->Logger->info("Invalid portlet $name found on user " . $user->Name . "'s homepage");
+ if ($name eq 'QueueList' && $allowed_components{Quicksearch}) {
+ RT->Logger->warning("You may need to replace the component 'Quicksearch' in the HomepageComponents config with 'QueueList'. See the UPGRADING-4.4 document.");
+ }
}
+ else {
+ $m->comp( $name, %{ $entry->{arguments} || {} } );
+ }
+ } elsif ( $type eq 'system' ) {
+ $m->comp( '/Elements/ShowSearch', Name => $name, Override => { Rows => $Rows } );
+ } elsif ( $type eq 'saved' ) {
+ $m->comp( '/Elements/ShowSearch', SavedSearch => $name, Override => { Rows => $Rows } );
+ } else {
+ $RT::Logger->error("unknown portlet type '$type'");
}
- else {
- $m->comp( $name, %{ $entry->{arguments} || {} } );
- }
- } elsif ( $type eq 'search' ) {
- $m->comp( '/Elements/ShowSearch', RT::Dashboard->ShowSearchName($entry), Override => { Rows => $Rows } );
- } elsif ( $type eq 'dashboard' ) {
- my $current_dashboard = RT::Dashboard->new($session{CurrentUser});
- my ($ok, $msg) = $current_dashboard->LoadById($entry->{id});
- if (!$ok) {
- $m->out($msg);
- return;
- }
- my @panes = @{ $current_dashboard->Panes->{$entry->{pane}} || [] };
- for my $portlet (@panes) {
- $show_cb->($portlet, $depth + 1);
+ }
+ else {
+ # Normal handling for RT 5.0.2 and newer
+ my $depth = shift || 0;
+ Abort("Possible recursive dashboard detected.", SuppressHeader => 1) if $depth > 8;
+
+ $type = $entry->{portlet_type};
+ $name = $entry->{component};
+ if ( $type eq 'component' ) {
+ if (!$allowed_components{$name}) {
+ $m->out( $m->interp->apply_escapes( loc("Invalid portlet [_1]", $name), "h" ) );
+ RT->Logger->info("Invalid portlet $name found on user " . $user->Name . "'s homepage");
+ if ($name eq 'QueueList' && $allowed_components{Quicksearch}) {
+ RT->Logger->warning("You may need to replace the component 'Quicksearch' in the HomepageComponents config with 'QueueList'. See the UPGRADING-4.4 document.");
+ }
+ }
+ else {
+ $m->comp( $name, %{ $entry->{arguments} || {} } );
+ }
+ } elsif ( $type eq 'search' ) {
+ $m->comp( '/Elements/ShowSearch', RT::Dashboard->ShowSearchName($entry), Override => { Rows => $Rows } );
+ } elsif ( $type eq 'dashboard' ) {
+ my $current_dashboard = RT::Dashboard->new($session{CurrentUser});
+ my ($ok, $msg) = $current_dashboard->LoadById($entry->{id});
+ if (!$ok) {
+ $m->out($msg);
+ return;
+ }
+ my @panes = @{ $current_dashboard->Panes->{$entry->{pane}} || [] };
+ for my $portlet (@panes) {
+ $show_cb->($portlet, $depth + 1);
+ }
+ } else {
+ $RT::Logger->error("unknown portlet type '$type'");
}
- } else {
- $RT::Logger->error("unknown portlet type '$type'");
}
};
--
To stop receiving notification emails like this one, please contact
sysadmin at bestpractical.com.
More information about the rt-commit
mailing list