[Rt-commit] rt 12/12: Do not allow to delete system default dashboard

sunnavy sunnavy at bestpractical.com
Wed Jul 14 14:46:53 EDT 2021


This is an automated email from the git hooks/post-receive script.

sunnavy pushed a commit to branch 5.0/use-dashboard-for-homepage-select-ui
in repository rt.

commit 68e9a2e4113493f49daa90816f2a3a5a8d95c7e5
Author: sunnavy <sunnavy at bestpractical.com>
AuthorDate: Wed Jul 14 23:32:08 2021 +0800

    Do not allow to delete system default dashboard
    
    It's good to keep the default "RT at a glance" setting, to reduce the
    possibility of showing people an empty homepage.
---
 lib/RT/Dashboard.pm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
index b76c8e8370..0b45331674 100644
--- a/lib/RT/Dashboard.pm
+++ b/lib/RT/Dashboard.pm
@@ -331,7 +331,17 @@ sub CurrentUserCanDelete {
     my $self    = shift;
     my $privacy = shift;
 
-    $self->_CurrentUserCan($privacy, Right => 'Delete');
+    my $can = $self->_CurrentUserCan($privacy, Right => 'Delete');
+
+    # Don't allow to delete system default dashboard
+    if ($can) {
+        my ($system_default) = RT::System->new( RT->SystemUser )->Attributes->Named('DefaultDashboard');
+        if ( $system_default && $system_default->Content && $system_default->Content == $self->Id ) {
+            return 0;
+        }
+    }
+
+    return $can;
 }
 
 sub CurrentUserCanSubscribe {

-- 
To stop receiving notification emails like this one, please contact
sysadmin at bestpractical.com.


More information about the rt-commit mailing list