X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FDashboard.pm;h=24764b7f277cf1b6cb3498f1d99845172ca0b246;hp=14ffa6ad32834162e995c87fd4665d5cf6da770e;hb=44dd00a3ff974a17999e86e64488e996edc71e3c;hpb=a6fe07e49e3fc12169e801b1ed6874c3a5bd8500 diff --git a/rt/lib/RT/Dashboard.pm b/rt/lib/RT/Dashboard.pm index 14ffa6ad3..24764b7f2 100644 --- a/rt/lib/RT/Dashboard.pm +++ b/rt/lib/RT/Dashboard.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -67,41 +67,26 @@ package RT::Dashboard; -use RT::SavedSearch; - use strict; use warnings; use base qw/RT::SharedSetting/; +use RT::SavedSearch; + use RT::System; -RT::System::AddRights( - SubscribeDashboard => 'Subscribe to dashboards', #loc_pair - - SeeDashboard => 'View system dashboards', #loc_pair - CreateDashboard => 'Create system dashboards', #loc_pair - ModifyDashboard => 'Modify system dashboards', #loc_pair - DeleteDashboard => 'Delete system dashboards', #loc_pair - - SeeOwnDashboard => 'View personal dashboards', #loc_pair - CreateOwnDashboard => 'Create personal dashboards', #loc_pair - ModifyOwnDashboard => 'Modify personal dashboards', #loc_pair - DeleteOwnDashboard => 'Delete personal dashboards', #loc_pair -); - -RT::System::AddRightCategories( - SubscribeDashboard => 'Staff', - - SeeDashboard => 'General', - CreateDashboard => 'Admin', - ModifyDashboard => 'Admin', - DeleteDashboard => 'Admin', - - SeeOwnDashboard => 'Staff', - CreateOwnDashboard => 'Staff', - ModifyOwnDashboard => 'Staff', - DeleteOwnDashboard => 'Staff', -); +'RT::System'->AddRight( Staff => SubscribeDashboard => 'Subscribe to dashboards'); # loc + +'RT::System'->AddRight( General => SeeDashboard => 'View system dashboards'); # loc +'RT::System'->AddRight( Admin => CreateDashboard => 'Create system dashboards'); # loc +'RT::System'->AddRight( Admin => ModifyDashboard => 'Modify system dashboards'); # loc +'RT::System'->AddRight( Admin => DeleteDashboard => 'Delete system dashboards'); # loc + +'RT::System'->AddRight( Staff => SeeOwnDashboard => 'View personal dashboards'); # loc +'RT::System'->AddRight( Staff => CreateOwnDashboard => 'Create personal dashboards'); # loc +'RT::System'->AddRight( Staff => ModifyOwnDashboard => 'Modify personal dashboards'); # loc +'RT::System'->AddRight( Staff => DeleteOwnDashboard => 'Delete personal dashboards'); # loc + =head2 ObjectName @@ -109,7 +94,7 @@ An object of this class is called "dashboard" =cut -sub ObjectName { "dashboard" } +sub ObjectName { "dashboard" } # loc sub SaveAttribute { my $self = shift; @@ -270,8 +255,7 @@ sub _PrivacyObjects { my $groups = RT::Groups->new($CurrentUser); $groups->LimitToUserDefinedGroups; - $groups->WithMember( PrincipalId => $CurrentUser->Id, - Recursively => 1 ); + $groups->WithCurrentUser; push @objects, @{ $groups->ItemsArrayRef }; push @objects, RT::System->new($CurrentUser); @@ -401,10 +385,7 @@ sub ObjectsForLoading { Right => 'SeeGroupDashboard', IncludeSuperusers => $args{IncludeSuperuserGroups}, ); - $groups->WithMember( - Recursively => 1, - PrincipalId => $CurrentUser->UserObj->PrincipalId - ); + $groups->WithCurrentUser; my $attrs = $groups->Join( ALIAS1 => 'main', FIELD1 => 'id', @@ -454,6 +435,36 @@ sub CurrentUserCanCreateAny { return 0; } +=head2 Delete + +Deletes the dashboard and related subscriptions. +Returns a tuple of status and message, where status is true upon success. + +=cut + +sub Delete { + my $self = shift; + my $id = $self->id; + my ( $status, $msg ) = $self->SUPER::Delete(@_); + if ( $status ) { + # delete all the subscriptions + my $subscriptions = RT::Attributes->new( RT->SystemUser ); + $subscriptions->Limit( + FIELD => 'Name', + VALUE => 'Subscription', + ); + $subscriptions->Limit( + FIELD => 'Description', + VALUE => "Subscription to dashboard $id", + ); + while ( my $subscription = $subscriptions->Next ) { + $subscription->Delete(); + } + } + + return ( $status, $msg ); +} + RT::Base->_ImportOverlays(); 1;