[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.6-400-gf408bee
Alex Vandiver
alexmv at bestpractical.com
Tue Dec 7 15:16:30 EST 2010
The branch, 3.9-trunk has been updated
via f408beefa34c77ee822ebc6063075777a47f0060 (commit)
via e0fc7782c05ed0faa59d33603a9701da3f28ec1e (commit)
from 91049e775f12fb1de7a055d93f3de751ff0bc30d (commit)
Summary of changes:
lib/RT/Dashboard.pm | 39 +++++++++++++++++++++++++++++++++++++++
share/html/Elements/Tabs | 2 +-
2 files changed, 40 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit e0fc7782c05ed0faa59d33603a9701da3f28ec1e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Dec 7 14:57:30 2010 -0500
Limit ObjectsForLoading further to Groups which have a Dashboard attrbiute
This saves O(groups without dashboards) useless attribute queries
diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
index b0cc928..0b3890d 100644
--- a/lib/RT/Dashboard.pm
+++ b/lib/RT/Dashboard.pm
@@ -378,6 +378,23 @@ sub ObjectsForLoading {
Right => 'SeeGroupDashboard',
IncludeSuperusers => 1,
);
+ 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 => 'Dashboard',
+ );
+
push @objects, @{ $groups->ItemsArrayRef };
commit f408beefa34c77ee822ebc6063075777a47f0060
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Dec 7 14:59:10 2010 -0500
We don't care about the list of objects, only if it is empty or not
diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
index 0b3890d..495cd0d 100644
--- a/lib/RT/Dashboard.pm
+++ b/lib/RT/Dashboard.pm
@@ -404,6 +404,28 @@ sub ObjectsForLoading {
return @objects;
}
+sub CurrentUserCanCreateAny {
+ my $self = shift;
+ my @objects;
+
+ my $CurrentUser = $self->CurrentUser;
+ return 1
+ if $CurrentUser->HasRight(Object => $RT::System, Right => 'CreateOwnDashboard');
+
+ my $groups = RT::Groups->new($CurrentUser);
+ $groups->LimitToUserDefinedGroups;
+ $groups->ForWhichCurrentUserHasRight(
+ Right => 'CreateGroupDashboard',
+ IncludeSuperusers => 1,
+ );
+ return 1 if $groups->Count;
+
+ return 1
+ if $CurrentUser->HasRight(Object => $RT::System, Right => 'CreateDashboard');
+
+ return 0;
+}
+
RT::Base->_ImportOverlays();
1;
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 87cd11a..131d206 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -90,7 +90,7 @@ if ( $request_path !~ qr{^/SelfService/} ) {
$dashes->child( select => title => loc('Select'), path => "/Dashboards/index.html" );
my $dashboard = RT::Dashboard->new( $session{CurrentUser} );
- if ( $dashboard->ObjectsForCreating ) {
+ if ( $dashboard->CurrentUserCanCreateAny ) {
$dashes->child( loc('Create') => path => "/Dashboards/Modify.html?Create=1" );
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list