summaryrefslogtreecommitdiff
path: root/rt/share/html/Dashboards
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-06-07 00:56:06 -0700
committerIvan Kohler <ivan@freeside.biz>2012-06-07 00:56:06 -0700
commit43a06151e47d2c59b833cbd8c26d97865ee850b6 (patch)
tree42c51d94e7fa265461b508d061562be204ccc2c1 /rt/share/html/Dashboards
parent6587f6ba7d047ddc1686c080090afe7d53365bd4 (diff)
starting to work...
Diffstat (limited to 'rt/share/html/Dashboards')
-rw-r--r--rt/share/html/Dashboards/Elements/DashboardsForObject2
-rw-r--r--rt/share/html/Dashboards/Elements/DashboardsForObjects81
-rw-r--r--rt/share/html/Dashboards/Elements/Deleted2
-rw-r--r--rt/share/html/Dashboards/Elements/HiddenSearches2
-rw-r--r--rt/share/html/Dashboards/Elements/ListOfDashboards30
-rw-r--r--rt/share/html/Dashboards/Elements/SelectPrivacy2
-rw-r--r--rt/share/html/Dashboards/Elements/ShowDashboards85
-rw-r--r--rt/share/html/Dashboards/Elements/ShowPortlet/component2
-rw-r--r--rt/share/html/Dashboards/Elements/ShowPortlet/dashboard2
-rw-r--r--rt/share/html/Dashboards/Elements/ShowPortlet/search2
-rw-r--r--rt/share/html/Dashboards/Elements/ShowSubscription75
-rwxr-xr-xrt/share/html/Dashboards/Elements/Tabs113
-rwxr-xr-xrt/share/html/Dashboards/Modify.html70
-rw-r--r--rt/share/html/Dashboards/Queries.html22
-rw-r--r--rt/share/html/Dashboards/Render.html43
-rw-r--r--rt/share/html/Dashboards/Subscription.html166
-rw-r--r--rt/share/html/Dashboards/dhandler2
-rw-r--r--rt/share/html/Dashboards/index.html64
18 files changed, 214 insertions, 551 deletions
diff --git a/rt/share/html/Dashboards/Elements/DashboardsForObject b/rt/share/html/Dashboards/Elements/DashboardsForObject
index 9e9e9fd60..e96afbd6a 100644
--- a/rt/share/html/Dashboards/Elements/DashboardsForObject
+++ b/rt/share/html/Dashboards/Elements/DashboardsForObject
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
diff --git a/rt/share/html/Dashboards/Elements/DashboardsForObjects b/rt/share/html/Dashboards/Elements/DashboardsForObjects
deleted file mode 100644
index c676dfb1b..000000000
--- a/rt/share/html/Dashboards/Elements/DashboardsForObjects
+++ /dev/null
@@ -1,81 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-%# <sales@bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<%args>
-$Objects => undef
-$dashboards => {}
-$flatten => 0
-</%args>
-<%init>
-# Returns a hash of dashboards associated with @Objects
-if (!defined($Objects)) {
- @$Objects = RT::Dashboard->new($session{CurrentUser})->_PrivacyObjects;
-}
-
-for my $object (@$Objects) {
- my $new_dashboards = $m->comp("/Dashboards/Elements/DashboardsForObject", Object => $object);
-
- push @{ $dashboards->{$_} }, @{ $new_dashboards->{$_} || [] }
- for qw/personal system/;
-
- push @{ $dashboards->{group}{$_} }, @{ $new_dashboards->{group}{$_} }
- for keys %{ $new_dashboards->{group} || {} };
-}
-
-if ($flatten) {
- my @dashboards;
- push @dashboards, @{ $dashboards->{personal} || [] };
- push @dashboards, map { @{ $_ || [] } } values %{ $dashboards->{group} };
- push @dashboards, @{ $dashboards->{system} || [] };
-
- return \@dashboards;
-}
-
-return $dashboards;
-</%init>
-
-
diff --git a/rt/share/html/Dashboards/Elements/Deleted b/rt/share/html/Dashboards/Elements/Deleted
index 32fdf5515..8a54754af 100644
--- a/rt/share/html/Dashboards/Elements/Deleted
+++ b/rt/share/html/Dashboards/Elements/Deleted
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
diff --git a/rt/share/html/Dashboards/Elements/HiddenSearches b/rt/share/html/Dashboards/Elements/HiddenSearches
index a9dff69a1..4d0d9e5e2 100644
--- a/rt/share/html/Dashboards/Elements/HiddenSearches
+++ b/rt/share/html/Dashboards/Elements/HiddenSearches
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
diff --git a/rt/share/html/Dashboards/Elements/ListOfDashboards b/rt/share/html/Dashboards/Elements/ListOfDashboards
index 55d632e52..a7398bccc 100644
--- a/rt/share/html/Dashboards/Elements/ListOfDashboards
+++ b/rt/share/html/Dashboards/Elements/ListOfDashboards
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -49,18 +49,34 @@
# put the list of dashboards into the navigation
use RT::Dashboard;
-my @objs = RT::Dashboard->new($session{CurrentUser})->_PrivacyObjects(ShowSystem => 1);
-my $dashboard_map = $m->comp("/Dashboards/Elements/DashboardsForObjects", Objects => \@objs);
+my @objs = RT::Dashboard->new($session{CurrentUser})->ObjectsForLoading(
+ IncludeSuperuserGroups => $IncludeSuperuserGroups
+ );
+
+my %dashboard_map;
+
+for my $object (@objs) {
+ my $new_dashboards = $m->comp("/Dashboards/Elements/DashboardsForObject", Object => $object);
+
+ push @{ $dashboard_map{$_} }, @{ $new_dashboards->{$_} || [] }
+ for qw/personal system/;
+
+ push @{ $dashboard_map{group}{$_} }, @{ $new_dashboards->{group}{$_} }
+ for keys %{ $new_dashboards->{group} || {} };
+}
my @dashboards = (
- (sort { $a->Id <=> $b->Id } @{ $dashboard_map->{personal} || [] }),
- (sort { $a->Id <=> $b->Id } @{ $dashboard_map->{system} || [] }),
+ (sort { $a->Id <=> $b->Id } @{ $dashboard_map{personal} || [] }),
+ (sort { $a->Id <=> $b->Id } @{ $dashboard_map{system} || [] }),
- map { sort { $a->Id <=> $b->Id } @{ $dashboard_map->{group}{$_} } }
- keys %{ $dashboard_map->{group} || {} },
+ map { sort { $a->Id <=> $b->Id } @{ $dashboard_map{group}{$_} } }
+ keys %{ $dashboard_map{group} || {} },
);
$m->callback(%ARGS, dashboards => \@dashboards, CallbackName => 'ModifyDashboards');
return @dashboards;
</%init>
+<%args>
+$IncludeSuperuserGroups => 1
+</%args>
diff --git a/rt/share/html/Dashboards/Elements/SelectPrivacy b/rt/share/html/Dashboards/Elements/SelectPrivacy
index da02300be..523790bba 100644
--- a/rt/share/html/Dashboards/Elements/SelectPrivacy
+++ b/rt/share/html/Dashboards/Elements/SelectPrivacy
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
diff --git a/rt/share/html/Dashboards/Elements/ShowDashboards b/rt/share/html/Dashboards/Elements/ShowDashboards
index 8dcc733eb..56c757bf0 100644
--- a/rt/share/html/Dashboards/Elements/ShowDashboards
+++ b/rt/share/html/Dashboards/Elements/ShowDashboards
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -45,68 +45,27 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<&| /Widgets/TitleBox, title => $Title &>
-<& SELF:table, %ARGS &>
-</&>
-<%ARGS>
-$Title => undef
-</%ARGS>
-
-<%METHOD table>
-<%ARGS>
-$Dashboards => undef
-$Verbose => 1
-</%ARGS>
-<%INIT>
-# map each subscription to a dashboard ID
-my %subscription_for;
-
-for my $attr ($session{'CurrentUser'}->UserObj->Attributes->Named('Subscription')) {
- $subscription_for{$attr->SubValue('DashboardId')} = $attr;
-}
-</%INIT>
-
-% if (@$Dashboards == 0) {
-% if ($Verbose) {
- <p><% loc("No dashboards.") %></p>
+% foreach my $Object (@Objects) {
+% my $Dashboards = RT::Dashboards->new($session{CurrentUser});
+% $Dashboards->LimitToPrivacy(join('-',ref($Object),$Object->Id));
+% my $title;
+% if (ref $Object eq 'RT::User' && $Object->Id == $session{CurrentUser}->Id) {
+% $title = loc("My dashboards");
+% } else {
+% $title = loc("[_1]'s dashboards",$Object->Name);
% }
-% } else {
- <table class="collection-as-table">
- <tr class="collection-as-table">
-% if ($Verbose) {
- <th class="collection-as-table"><% loc("#") %></th>
-% }
- <th class="collection-as-table"><% loc("Name") %></th>
- <th class="collection-as-table"><% loc("Subscription") %></th>
- </tr>
-
-% my $i = 0;
-% for my $dashboard (@$Dashboards) {
-% my $url = sprintf '%s/Dashboards/%d/%s',
-% RT->Config->Get('WebPath'),
-% $dashboard->Id,
-% $dashboard->Name;
-
- <tr class="collection-as-table <% ++$i % 2 ? 'oddline' : 'evenline' %>">
-% if ($Verbose) {
- <td class="collection-as-table">
- <a href="<% $url %>">
- <% $dashboard->Id %>
- </a>
- </td>
-% }
- <td class="collection-as-table">
- <a href="<% $url %>">
- <% $dashboard->Name %>
- </a>
- </td>
- <td class="collection-as-table">
- <& /Dashboards/Elements/ShowSubscription, Dashboard => $dashboard, Subscription => $subscription_for{$dashboard->Id} &>
- </td>
- </tr>
-% }
-
- </table>
+% $title = $m->interp->apply_escapes($title, 'h');
+<& /Elements/CollectionList,
+ %ARGS,
+ Format => qq{'<a href="__WebPath__/__ShowURL__">__Name__</a>/TITLE:$title', __Subscription__},
+ Collection => $Dashboards,
+&>
% }
-</%METHOD>
+<%init>
+use RT::Dashboards;
+my @Objects = RT::Dashboard->new($session{CurrentUser})->ObjectsForLoading(IncludeSuperuserGroups => $IncludeSuperuserGroups);
+</%init>
+<%args>
+$IncludeSuperuserGroups => 1
+</%args>
diff --git a/rt/share/html/Dashboards/Elements/ShowPortlet/component b/rt/share/html/Dashboards/Elements/ShowPortlet/component
index 230a15cc1..dbdfe320e 100644
--- a/rt/share/html/Dashboards/Elements/ShowPortlet/component
+++ b/rt/share/html/Dashboards/Elements/ShowPortlet/component
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
diff --git a/rt/share/html/Dashboards/Elements/ShowPortlet/dashboard b/rt/share/html/Dashboards/Elements/ShowPortlet/dashboard
index 06f9f75cd..92f2488bb 100644
--- a/rt/share/html/Dashboards/Elements/ShowPortlet/dashboard
+++ b/rt/share/html/Dashboards/Elements/ShowPortlet/dashboard
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
diff --git a/rt/share/html/Dashboards/Elements/ShowPortlet/search b/rt/share/html/Dashboards/Elements/ShowPortlet/search
index 44fba313d..ce2c24cd2 100644
--- a/rt/share/html/Dashboards/Elements/ShowPortlet/search
+++ b/rt/share/html/Dashboards/Elements/ShowPortlet/search
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
diff --git a/rt/share/html/Dashboards/Elements/ShowSubscription b/rt/share/html/Dashboards/Elements/ShowSubscription
deleted file mode 100644
index c188853e4..000000000
--- a/rt/share/html/Dashboards/Elements/ShowSubscription
+++ /dev/null
@@ -1,75 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-%# <sales@bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<a href="<% $url %>"><% $frequency %></a>
-<%ARGS>
-$Dashboard => undef
-$Subscription => undef
-</%ARGS>
-<%INIT>
-my $url = sprintf '%s/Dashboards/Subscription.html?DashboardId=%d',
- RT->Config->Get('WebPath'),
- $Dashboard->Id,;
-
-my $frequency = loc("None");
-
-if (defined $Subscription) {
- my $freq = $Subscription->SubValue('Frequency');
- my $hour = $Subscription->SubValue('Hour');
-
- if ($freq eq 'weekly') {
- my $day = $Subscription->SubValue('Dow');
- $frequency = loc("weekly (on [_1]) at [_2]", loc($day), $hour);
- }
- elsif ($freq eq 'monthly') {
- $frequency = loc("monthly (day [_1]) at [_2]", $Subscription->SubValue('Dom'), $hour);
- }
- elsif ($freq eq 'daily') {
- $frequency = loc("daily at [_1]", $hour);
- }
-}
-</%INIT>
diff --git a/rt/share/html/Dashboards/Elements/Tabs b/rt/share/html/Dashboards/Elements/Tabs
deleted file mode 100755
index 5e4815cad..000000000
--- a/rt/share/html/Dashboards/Elements/Tabs
+++ /dev/null
@@ -1,113 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-%# <sales@bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<& /Tools/Elements/Tabs,
- subtabs => $subtabs,
- current_tab => 'Dashboards/index.html',
- current_subtab => $current_subtab,
- actions => $actions,
- Title => $Title &>
-
-<%INIT>
-my $subtabs;
-my $actions;
-
-if ( $DashboardObj and $DashboardObj->Id ) {
- my $id = $DashboardObj->Id;
- my $name = $DashboardObj->Name;
-
- my $modify = "Dashboards/Modify.html?id=$id";
- my $queries = "Dashboards/Queries.html?id=$id";
- my $render = "Dashboards/$id/$name";
- my $subscribe = "Dashboards/Subscription.html?DashboardId=$id";
-
- $subtabs = $m->comp('/Elements/DashboardTabs', CurrentDashboard => $DashboardObj);
- $current_subtab = $render;
-
- $actions = {
- a_Basics => {
- title => loc('Basics'),
- path => $modify,
- },
-
- b_Queries => {
- title => loc('Queries'),
- path => $queries,
- },
-
- c_Subscription => {
- title => loc('Subscription'),
- path => $subscribe,
- },
- };
-
- delete $actions->{"c_Subscription"}
- unless $DashboardObj->CurrentUserCanSubscribe;
-}
-else {
- $subtabs->{"a_Select"} = {
- title => loc('Select'),
- path => "Dashboards/index.html",
- };
-
- my $dashboard = RT::Dashboard->new($session{'CurrentUser'});
- my @objects = $dashboard->_PrivacyObjects(Create => 1);
-
- if (@objects) {
- $subtabs->{"b_Create"} = {
- title => loc('New'),
- path => "Dashboards/Modify.html?Create=1",
- separator => 1,
- };
- }
-}
-</%INIT>
-<%ARGS>
-$DashboardObj => undef
-$current_subtab => undef
-$Title => undef
-</%ARGS>
diff --git a/rt/share/html/Dashboards/Modify.html b/rt/share/html/Dashboards/Modify.html
index 11fc1791a..95cf318aa 100755
--- a/rt/share/html/Dashboards/Modify.html
+++ b/rt/share/html/Dashboards/Modify.html
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -46,59 +46,55 @@
%#
%# END BPS TAGGED BLOCK }}}
<& /Elements/Header, Title => $title &>
-<& /Dashboards/Elements/Tabs,
- current_subtab => $current_subtab,
- Title => $title,
- $Create ? () : (DashboardObj => $Dashboard),
-&>
+<& /Elements/Tabs &>
<& /Elements/ListActions, actions => \@results &>
-<form action="<%RT->Config->Get('WebPath')%>/Dashboards/Modify.html" method="post" enctype="multipart/form-data" name="ModifyDashboard">
+<form action="<%RT->Config->Get('WebPath')%>/Dashboards/Modify.html" method="post" enctype="multipart/form-data" name="ModifyDashboard" id="ModifyDashboard">
%unless ($Dashboard->Id) {
<input type="hidden" class="hidden" name="id" value="new" />
% } else {
<input type="hidden" class="hidden" name="id" value="<%$Dashboard->Id%>" />
% }
+
+<&|/Widgets/TitleBox, title => loc('Basics') &>
<table>
-<tr><td align="right">
-<&|/l&>Name</&>:
-</td>
-<td><input name="Name" value="<%$Dashboard->Name%>" /></td>
+ <tr>
+ <td class="label"><&|/l&>Name</&>:</td>
+ <td class="value"><input name="Name" value="<%$Dashboard->Name%>" /></td>
+ </tr>
+ <tr>
+ <td class="label"><&|/l&>Privacy</&>:</td>
+ <td><& /Dashboards/Elements/SelectPrivacy, Name => "Privacy", Objects => \@privacies, Default => $Dashboard->Privacy &></td>
</tr>
-<tr><td align="right">
-<&|/l&>Privacy</&>:
-</td><td>
-<& /Dashboards/Elements/SelectPrivacy, Name => "Privacy", Objects => \@privacies, Default => $Dashboard->Privacy &>
-</td></tr>
</table>
-% if ( $Create ) {
-<& /Elements/Submit, Name => 'Save', Label => loc('Create') &>
-% } else {
-<& /Elements/Submit, Name => 'Save', Label => loc('Save Changes') &>
-% }
+</&>
+<& /Elements/Submit, Name => 'Save', Label =>( $Create ? loc('Create') : loc('Save Changes') ) &>
+
% if ($Dashboard->Id && $can_delete) {
<& /Elements/Submit, Name => 'Delete', Label => loc('Delete') &>
% }
</form>
<%INIT>
-my $current_subtab;
my ($title, @results);
my $tried_create = 0;
# user went directly to Modify.html
$Create = 1 if !$id;
+
+my $redirect_to ='/Dashboards/Modify.html';
+
use RT::Dashboard;
my $Dashboard = RT::Dashboard->new($session{'CurrentUser'});
-my @privacies = $Dashboard->_PrivacyObjects(($Create ? 'Create' : 'Modify') => 1);
+my $method = $Create ? 'ObjectsForCreating' : 'ObjectsForModifying';
+my @privacies = $Dashboard->$method;
Abort(loc("Permission denied")) if @privacies == 0;
if ($Create) {
- $current_subtab = 'Dashboards/Modify.html?Create=1';
$title = loc("Create a new dashboard");
}
else {
@@ -116,20 +112,22 @@ else {
push @results, $msg;
$id = $Dashboard->Id;
+ if (!$Dashboard->id || ! $Dashboard->CurrentUserCanSee) {
+ $redirect_to='/Dashboards/index.html';
+
+ }
}
else {
my ($ok, $msg) = $Dashboard->LoadById($id);
- $ok || Abort($msg);
+ $ok || Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg));
}
if ($id) {
$title = loc("Modify the dashboard [_1]", $Dashboard->Name);
- $current_subtab = 'Dashboards/Modify.html?id=' . $id;
}
# If the create failed
else {
$Create = 1;
- $current_subtab = 'Dashboards/Modify.html?Create=1';
$title = loc("Create a new dashboard");
}
}
@@ -147,16 +145,26 @@ if (!$Create && !$tried_create && $id && $ARGS{'Save'}) {
}
+
my $can_delete = $Dashboard->CurrentUserCanDelete;
if (!$Create && !$tried_create && $id && $ARGS{'Delete'}) {
my ($ok, $msg) = $Dashboard->Delete();
- $ok || Abort(loc("Couldn't delete dashboard [_1]: [_2]", $id, $msg));
-
- # put the user back into a useful place with a message
- RT::Interface::Web::Redirect(RT->Config->Get('WebURL')."Dashboards/index.html?Deleted=$id");
+ if (!$ok) {
+ Abort(loc("Couldn't delete dashboard [_1]: [_2]", $id, $msg));
+ }
+ push @results, $msg;
+ $redirect_to = '/Dashboards/index.html';
}
+
+# This code does automatic redirection if any updates happen.
+MaybeRedirectForResults(
+ Actions => \@results,
+ Path => $redirect_to,
+ Arguments => { id => $id },
+);
+
</%INIT>
<%ARGS>
diff --git a/rt/share/html/Dashboards/Queries.html b/rt/share/html/Dashboards/Queries.html
index bef0eee84..c00503143 100644
--- a/rt/share/html/Dashboards/Queries.html
+++ b/rt/share/html/Dashboards/Queries.html
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -46,10 +46,7 @@
%#
%# END BPS TAGGED BLOCK }}}
<& /Elements/Header, Title => $title &>
-<& /Dashboards/Elements/Tabs,
- current_subtab => $current_subtab,
- Title => $title,
- DashboardObj => $Dashboard &>
+<& /Elements/Tabs &>
<& /Widgets/SelectionBox:header, nojs => 1 &>
@@ -78,14 +75,13 @@
<%INIT>
-my $current_subtab = 'Dashboards/Queries.html?id=' . $id;
my @results;
use RT::Dashboard;
-my $Dashboard = new RT::Dashboard($session{'CurrentUser'});
+my $Dashboard = RT::Dashboard->new($session{'CurrentUser'});
my ($ok, $msg) = $Dashboard->LoadById($id);
$ok || Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg));
-my $title = loc("Modify the queries of dashboard [_1]", $Dashboard->Name);
+my $title = loc("Modify the content of dashboard [_1]", $Dashboard->Name);
my %desc_of;
my @items;
@@ -103,8 +99,8 @@ for my $desc (@components) {
}
# add dashboards
-my $dashboards = $m->comp("/Dashboards/Elements/DashboardsForObjects", flatten => 1);
-for my $dashboard (@{ $dashboards || [] }) {
+my @dashboards = $m->comp("/Dashboards/Elements/ListOfDashboards");
+for my $dashboard (@dashboards) {
# Users *can* set up mutually recursive dashboards, but don't make it THIS
# easy for them to shoot themselves in the foot.
next if $dashboard->Id == $Dashboard->Id;
@@ -119,7 +115,7 @@ for my $dashboard (@{ $dashboards || [] }) {
# add saved searches
my @objs = RT::System->new($session{'CurrentUser'});
-push @objs, RT::SavedSearches->new( $session{CurrentUser} )->_PrivacyObjects
+push @objs, RT::SavedSearch->new( $session{CurrentUser} )->ObjectsForLoading
if $session{'CurrentUser'}->HasRight( Right => 'LoadSavedSearch',
Object => $RT::System );
@@ -137,7 +133,7 @@ for my $object (@objs) {
}
}
-# Get the list of queries already in use
+# Get the list of portlets already in use
my @deleted;
do {
my $panes = $Dashboard->Panes;
@@ -177,7 +173,7 @@ $m->callback(
selected => \%selected,
);
-# Create selectionbox widgets for those queries
+# Create selectionbox widgets for those portlets
my %pane_name = (
'body' => loc('Body'),
diff --git a/rt/share/html/Dashboards/Render.html b/rt/share/html/Dashboards/Render.html
index da9d487ac..59861ebbe 100644
--- a/rt/share/html/Dashboards/Render.html
+++ b/rt/share/html/Dashboards/Render.html
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -53,18 +53,14 @@
&>
% if ($Preview) {
-<& /Dashboards/Elements/Tabs,
- current_subtab => $current_subtab,
- Title => $title,
- DashboardObj => $DashboardObj &>
+<& /Elements/Tabs &>
% }
-% $m->callback(CallbackName => 'BeforeTable', Dashboard => $DashboardObj, show_cb => $show_cb);
+% $m->callback(CallbackName => 'BeforeTable', Dashboard => $Dashboard, show_cb => $show_cb);
-<table class="dashboard">
-<!-- Dashboard #<%$id%> -->
+<table class="dashboard" id="dashboard-<%$id%>">
-% $m->callback(CallbackName => 'BeforePanes', Dashboard => $DashboardObj, show_cb => $show_cb);
+% $m->callback(CallbackName => 'BeforePanes', Dashboard => $Dashboard, show_cb => $show_cb);
<tr valign="top">
@@ -78,26 +74,29 @@
</tr>
-% $m->callback(CallbackName => 'AfterPanes', Dashboard => $DashboardObj, show_cb => $show_cb);
+% $m->callback(CallbackName => 'AfterPanes', Dashboard => $Dashboard, show_cb => $show_cb);
</table>
-% $m->callback(CallbackName => 'AfterTable', Dashboard => $DashboardObj, show_cb => $show_cb);
-
-</td>
+% $m->callback(CallbackName => 'AfterTable', Dashboard => $Dashboard, show_cb => $show_cb);
+% if (!$Preview) {
+% my $edit = RT->Config->Get('WebPath') . '/Dashboards/Modify.html?id='.$id;
+% my $subscription = RT->Config->Get('WebPath') . '/Dashboards/Subscription.html?id='.$id;
+<p><&|/l, $edit, $subscription &>You <a href="[_1]">may edit this dashboard</a> and <a href="[_2]">your subscription</a> to it in RT.</&></p>
+% }
-</tr>
-</table>
+%# Matches the closing div in /Elements/Footer that it expects
+%# from PageLayout (which we don't use here)
+<div>
<%INIT>
-my $current_subtab = 'Dashboards/Render.html?id=' . $id;
use RT::Dashboard;
-my $DashboardObj = RT::Dashboard->new($session{'CurrentUser'});
-my ($ok, $msg) = $DashboardObj->LoadById($id);
-Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg)) if !$ok;
+my $Dashboard = RT::Dashboard->new($session{'CurrentUser'});
+my ($ok, $msg) = $Dashboard->LoadById($id);
+$ok || Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg));
my $SubscriptionObj = RT::Attribute->new($session{'CurrentUser'});
my $rows;
@@ -117,15 +116,15 @@ unless (defined($rows)) {
$rows = defined($prefs->{'RowsPerPage'}) ? $prefs->{'RowsPerPage'} : 50;
}
-my $title = loc 'Dashboard [_1]', $DashboardObj->Name;
+my $title = loc '[_1] Dashboard', $Dashboard->Name;
my $show_cb = sub {
my $pane = shift;
$m->comp('Elements/ShowPortlet/dashboard',
- Portlet => $DashboardObj,
+ Portlet => $Dashboard,
Rows => $rows,
Preview => $Preview,
- Dashboard => $DashboardObj,
+ Dashboard => $Dashboard,
Pane => $pane,
Depth => 0,
);
diff --git a/rt/share/html/Dashboards/Subscription.html b/rt/share/html/Dashboards/Subscription.html
index 7f0278a05..3669e4687 100644
--- a/rt/share/html/Dashboards/Subscription.html
+++ b/rt/share/html/Dashboards/Subscription.html
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -46,15 +46,12 @@
%#
%# END BPS TAGGED BLOCK }}}
<& /Elements/Header, Title => $title &>
-<& /Dashboards/Elements/Tabs,
- current_subtab => $current_subtab,
- Title => $title,
- DashboardObj => $DashboardObj &>
+<& /Elements/Tabs &>
<& /Elements/ListActions, actions => \@results &>
<form action="<%RT->Config->Get('WebPath')%>/Dashboards/Subscription.html" method="post" enctype="multipart/form-data" name="SubscribeDashboard">
-<input type="hidden" class="hidden" name="DashboardId" value="<% $fields{'DashboardId'} %>" />
+<input type="hidden" class="hidden" name="id" value="<% $fields{'DashboardId'} %>" />
<table width="100%" border="0">
<tr>
@@ -65,13 +62,13 @@
<tr><td class="label">
<&|/l&>Dashboard</&>:
</td><td class="value">
-<% $DashboardObj->Name %>
+<% $Dashboard->Name %>
</td></tr>
<tr><td class="label">
<&|/l&>Queries</&>:
</td><td class="value">
-% my @portlets = grep { defined } $DashboardObj->Portlets;
+% my @portlets = grep { defined } $Dashboard->Portlets;
% if (!@portlets) {
(<&|/l&>none</&>)
% } else {
@@ -95,44 +92,44 @@
<&|/l&>Frequency</&>:
</td><td class="value">
-<input type="radio" name="Frequency" value="daily" <% $fields{'Frequency'} eq 'daily' ? 'checked="checked"' : "" %>>
+<input type="radio" name="Frequency" value="daily" <% $fields{'Frequency'} eq 'daily' ? 'checked="checked"' : "" |n %>>
<&|/l&>daily</&>
</input><br />
-<input type="radio" name="Frequency" value="m-f" <% $fields{'Frequency'} eq 'm-f' ? 'checked="checked"' : "" %>>
+<input type="radio" name="Frequency" value="m-f" <% $fields{'Frequency'} eq 'm-f' ? 'checked="checked"' : "" |n %>>
<&|/l&>Monday through Friday</&>
</input><br />
-<input type="radio" name="Frequency" value="weekly"<% $fields{'Frequency'} eq 'weekly' ? 'checked="checked"' : "" %>>
+<input type="radio" name="Frequency" value="weekly"<% $fields{'Frequency'} eq 'weekly' ? 'checked="checked"' : "" |n %>>
<&|/l&>weekly</&></input>, <&|/l&>on</&>
<select name="Dow">
- <option value="Monday" <% $fields{'Dow'} eq 'Monday' ? 'selected="selected"' : '' %>><&|/l&>Monday</&></option>
- <option value="Tuesday" <% $fields{'Dow'} eq 'Tuesday' ? 'selected="selected"' : '' %>><&|/l&>Tuesday</&></option>
- <option value="Wednesday" <% $fields{'Dow'} eq 'Wednesday' ? 'selected="selected"' : '' %>><&|/l&>Wednesday</&></option>
- <option value="Thursday" <% $fields{'Dow'} eq 'Thursday' ? 'selected="selected"' : '' %>><&|/l&>Thursday</&></option>
- <option value="Friday" <% $fields{'Dow'} eq 'Friday' ? 'selected="selected"' : '' %>><&|/l&>Friday</&></option>
- <option value="Saturday" <% $fields{'Dow'} eq 'Saturday' ? 'selected="selected"' : '' %>><&|/l&>Saturday</&></option>
- <option value="Sunday" <% $fields{'Dow'} eq 'Sunday' ? 'selected="selected"' : '' %>><&|/l&>Sunday</&></option>
+ <option value="Monday" <% $fields{'Dow'} eq 'Monday' ? 'selected="selected"' : '' |n %>><&|/l&>Monday</&></option>
+ <option value="Tuesday" <% $fields{'Dow'} eq 'Tuesday' ? 'selected="selected"' : '' |n %>><&|/l&>Tuesday</&></option>
+ <option value="Wednesday" <% $fields{'Dow'} eq 'Wednesday' ? 'selected="selected"' : '' |n %>><&|/l&>Wednesday</&></option>
+ <option value="Thursday" <% $fields{'Dow'} eq 'Thursday' ? 'selected="selected"' : '' |n %>><&|/l&>Thursday</&></option>
+ <option value="Friday" <% $fields{'Dow'} eq 'Friday' ? 'selected="selected"' : '' |n %>><&|/l&>Friday</&></option>
+ <option value="Saturday" <% $fields{'Dow'} eq 'Saturday' ? 'selected="selected"' : '' |n %>><&|/l&>Saturday</&></option>
+ <option value="Sunday" <% $fields{'Dow'} eq 'Sunday' ? 'selected="selected"' : '' |n %>><&|/l&>Sunday</&></option>
</select>
<&|/l&>every</&>
<select name="Fow">
% for my $f ( qw/1 2 3 4/ ) {
- <option value="<%$f%>" <% $fields{'Fow'} == $f ? 'selected="selected"' : '' %>><% $f %></option>
+ <option value="<%$f%>" <% $fields{'Fow'} == $f ? 'selected="selected"' : '' |n %>><% $f %></option>
% }
</select>
<&|/l&>weeks</&>
<br />
-<input type="radio" name="Frequency" value="monthly"<% $fields{'Frequency'} eq 'monthly' ? 'checked="checked"' : "" %>>
+<input type="radio" name="Frequency" value="monthly"<% $fields{'Frequency'} eq 'monthly' ? 'checked="checked"' : "" |n %>>
<&|/l&>monthly</&></input> , <&|/l&>on day</&>
<select name="Dom">
% for my $dom (1..31) {
- <option value="<% $dom %>" <% $fields{'Dom'} == $dom ? 'selected="selected"' : '' %>><% loc($dom) %></option>
+ <option value="<% $dom %>" <% $fields{'Dom'} == $dom ? 'selected="selected"' : '' |n %>><% loc($dom) %></option>
% }
</select>
<br />
-<input type="radio" name="Frequency" value="never" <% $fields{'Frequency'} eq 'never' ? 'checked="checked"' : "" %>>
+<input type="radio" name="Frequency" value="never" <% $fields{'Frequency'} eq 'never' ? 'checked="checked"' : "" |n %>>
<&|/l&>never</&>
</input>
@@ -141,13 +138,21 @@
<&|/l&>Hour</&>:
</td><td class="value">
<select name="Hour">
+% my $formatter = RT::Date->new($session{CurrentUser})->LocaleObj;
+% my $dt = DateTime->now;
+% $dt->set_minute(0);
+% $dt->set_second(0);
+
% for my $hour (0..23) {
-% my $formatted = sprintf '%02d:00', $hour;
-% my $selected = $formatted eq $fields{'Hour'}
+% $dt->set_hour($hour);
+% my $formatted = $dt->format_cldr($formatter->time_format_short);
+
+% my $value = sprintf '%02d:00', $hour;
+% my $selected = $value eq $fields{'Hour'}
% ? 'selected="selected"'
% : '';
- <option value="<% $formatted %>" <%$selected%>><% $formatted %></option>
+ <option value="<% $value %>" <%$selected|n %>><% $formatted %></option>
% }
</select>
(<%$timezone%>)
@@ -157,7 +162,7 @@
</td><td class="value">
<select name="Rows">
% for my $rows (1, 2, 5, 10, 15, 20, 25, 50, 75, 100, 0) {
- <option value="<% $rows %>" <% $fields{'Rows'} eq $rows ? 'selected="selected"' : '' %>><% loc($rows || 'Unlimited') %></option>
+ <option value="<% $rows %>" <% $fields{'Rows'} eq $rows ? 'selected="selected"' : '' |n %>><% loc($rows || 'Unlimited') %></option>
% }
</select>
</td></tr>
@@ -174,7 +179,7 @@
</tr>
</table>
-% if ($SubscriptionObj->Id) {
+% if ($SubscriptionObj) {
<& /Elements/Submit, Name => "Save", Label => loc('Save Changes') &>
% } else {
<& /Elements/Submit, Name => "Save", Label => loc('Subscribe') &>
@@ -183,34 +188,21 @@
<%INIT>
-my $current_subtab = 'Dashboards/Subscription.html?DashboardId=' . $DashboardId;
-
my ($title, @results);
-my ($val, $msg);
my $Loaded = 0;
my $timezone = $session{'CurrentUser'}->UserObj->Timezone || RT->Config->Get('Timezone');
use RT::Dashboard;
-my $DashboardObj = RT::Dashboard->new($session{'CurrentUser'});
-
-my $SubscriptionObj = RT::Attribute->new($session{'CurrentUser'});
-
-# first let's see if we already have a subscription to this DashboardId
-for my $sub ($session{'CurrentUser'}->UserObj->Attributes->Named('Subscription')) {
- next unless $sub->SubValue('DashboardId') == $DashboardId;
- $SubscriptionObj = $sub;
- last;
-}
+my $Dashboard = RT::Dashboard->new($session{'CurrentUser'});
+my ($ok, $msg) = $Dashboard->LoadById($id);
+$ok || Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg));
-$DashboardId = $SubscriptionObj->Id
- ? $SubscriptionObj->SubValue('DashboardId')
- : $ARGS{'DashboardId'};
+my $SubscriptionObj = $Dashboard->Subscription;
-($val, $msg) = $DashboardObj->LoadById($DashboardId);
-$val || Abort(loc("Couldn't load dashboard [_1]: [_2].", $DashboardId, $msg));
+$id = $SubscriptionObj ? $SubscriptionObj->SubValue('DashboardId') : $ARGS{'id'};
my %fields = (
- DashboardId => $DashboardId,
+ DashboardId => $id,
Frequency => 'daily',
Hour => '06:00',
Dow => 'Monday',
@@ -222,7 +214,7 @@ my %fields = (
);
# update any fields with the values from the subscription object
-if ($SubscriptionObj->Id) {
+if ($SubscriptionObj) {
for my $field (keys %fields) {
$fields{$field} = $SubscriptionObj->SubValue($field);
}
@@ -234,54 +226,70 @@ for my $field (keys %fields) {
$fields{$field} = $ARGS{$field}
if defined($ARGS{$field});
}
+
+
# this'll be defined on submit
if (defined $ARGS{Save}) {
- # update
- if ($SubscriptionObj->Id) {
- $DashboardId = delete $fields{'DashboardId'}; # immutable
- ($val, $msg) = $SubscriptionObj->SetSubValues(%fields);
- $fields{'DashboardId'} = $DashboardId;
-
- # not so good to spew base64-encoded data at the user :)
- if ($msg =~ /^Content changed from/) {
- $msg = "Subscription updated.";
+ my $ok = 1;
+
+ # validation
+ if ($fields{Recipient}) {
+ my @addresses = Email::Address->parse($fields{Recipient});
+ if (@addresses == 0) {
+ push @results, loc('Recipient must be an email address');
+ $ok = 0;
}
-
- push @results, $msg;
}
- # create
- else {
- Abort(loc("Unable to subscribe to dashboard [_1]: Permission denied", $DashboardId))
- unless $DashboardObj->CurrentUserCanSubscribe;
-
- my ($val, $msg) = $SubscriptionObj->Create(
- Name => 'Subscription',
- Description => 'Subscription to dashboard ' . $DashboardId,
- ContentType => 'storable',
- Object => $session{'CurrentUser'}->UserObj,
- Content => \%fields,
- );
- if ($val) {
- push @results, loc("Subscribed to dashboard [_1]", $DashboardObj->Name);
- push @results, loc("Warning: you have no email address set, so you will not receive this dashboard until you have it set")
- unless $session{'CurrentUser'}->EmailAddress || $fields{Recipient};
+
+ if ($ok) {
+ # update
+ if ($SubscriptionObj) {
+ $id = delete $fields{'DashboardId'}; # immutable
+ ($ok, $msg) = $SubscriptionObj->SetSubValues(%fields);
+ $fields{'DashboardId'} = $id;
+
+ # not so good to spew base64-encoded data at the user :)
+ if ($msg =~ /^Content changed from/) {
+ $msg = "Subscription updated.";
+ }
+
+ push @results, $msg;
}
+ # create
else {
- push @results, loc('Subscription could not be created: [_1]', $msg);
+ Abort(loc("Unable to subscribe to dashboard [_1]: Permission denied", $id))
+ unless $Dashboard->CurrentUserCanSubscribe;
+
+ $SubscriptionObj = RT::Attribute->new($session{CurrentUser});
+ ($ok, $msg) = $SubscriptionObj->Create(
+ Name => 'Subscription',
+ Description => 'Subscription to dashboard ' . $id,
+ ContentType => 'storable',
+ Object => $session{'CurrentUser'}->UserObj,
+ Content => \%fields,
+ );
+ if ($ok) {
+ push @results, loc("Subscribed to dashboard [_1]", $Dashboard->Name);
+ push @results, loc("Warning: you have no email address set, so you will not receive this dashboard until you have it set")
+ unless $session{'CurrentUser'}->EmailAddress || $fields{Recipient};
+ }
+ else {
+ push @results, loc('Subscription could not be created: [_1]', $msg);
+ }
}
}
}
-if ($SubscriptionObj->Id) {
- $title = loc("Modify the subscription to dashboard [_1]", $DashboardObj->Name);
+if ($SubscriptionObj) {
+ $title = loc("Modify the subscription to dashboard [_1]", $Dashboard->Name);
}
else {
- $title = loc("Subscribe to dashboard [_1]", $DashboardObj->Name);
+ $title = loc("Subscribe to dashboard [_1]", $Dashboard->Name);
}
</%INIT>
<%ARGS>
-$DashboardId => undef
+$id => undef
$Frequency => undef
$Hour => undef
$Dow => undef
diff --git a/rt/share/html/Dashboards/dhandler b/rt/share/html/Dashboards/dhandler
index f144ccef7..f4d0c6a96 100644
--- a/rt/share/html/Dashboards/dhandler
+++ b/rt/share/html/Dashboards/dhandler
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
diff --git a/rt/share/html/Dashboards/index.html b/rt/share/html/Dashboards/index.html
index afc0dbd13..f6a352ef7 100644
--- a/rt/share/html/Dashboards/index.html
+++ b/rt/share/html/Dashboards/index.html
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -45,63 +45,9 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<& /Elements/Header, Title => $title &>
-<& /Dashboards/Elements/Tabs,
- current_subtab => 'Dashboards/index.html',
- Title => $title &>
+<& /Elements/Header, Title => loc("Dashboards") &>
+<& /Elements/Tabs &>
-<& /Elements/ListActions, actions => \@actions &>
-
-<& /Dashboards/Elements/ShowDashboards,
- Title => loc('Personal Dashboards'),
- Dashboards => \@personal_dashboards,
-&>
-
-<& /Dashboards/Elements/ShowDashboards,
- Title => loc('System Dashboards'),
- Dashboards => \@system_dashboards,
-&>
-
-% for (@grouped_dashboards) {
-% my $group = $_->{name};
-% my $dashboards = $_->{dashboards};
-
- <& /Dashboards/Elements/ShowDashboards,
- Title => loc('[_1] DashBoards', $group),
- Dashboards => $dashboards,
- &>
-% }
-
-<%INIT>
-my $title = loc("Dashboards");
-use RT::Dashboard;
-
-my $dashboards = $m->comp("/Dashboards/Elements/DashboardsForObjects");
-
-my @actions;
-if (defined $Deleted) {
- push @actions, loc("Deleted dashboard [_1]", $Deleted);
-}
-
-my @personal_dashboards = sort { $a->Id <=> $b->Id } @{ $dashboards->{personal} || [] };
-my @system_dashboards = sort { $a->Id <=> $b->Id } @{ $dashboards->{system} || [] };
-
-my @groups = sort keys %{ $dashboards->{group} || {} };
-my @grouped_dashboards = map {
- {
- name => $_,
- dashboards => [ sort { $a->Id <=> $b->Id } @{ $dashboards->{group}{$_} || [] } ],
- }
-} @groups;
-
-$m->callback(
- PersonalDashboards => \@personal_dashboards,
- SystemDashboards => \@system_dashboards,
- GroupedDashboards => \@grouped_dashboards,
- CallbackName => 'MassageDashboards',
-);
-</%INIT>
-<%ARGS>
-$Deleted => undef
-</%ARGS>
+<& /Elements/ListActions &>
+<& /Dashboards/Elements/ShowDashboards &>