[Rt-commit] r13557 - in rt/3.8/trunk: . share/html/Dashboards

sartak at bestpractical.com sartak at bestpractical.com
Mon Jun 23 21:32:42 EDT 2008


Author: sartak
Date: Mon Jun 23 21:32:40 2008
New Revision: 13557

Modified:
   rt/3.8/trunk/   (props changed)
   rt/3.8/trunk/lib/RT/Dashboard.pm
   rt/3.8/trunk/lib/RT/SharedSetting.pm
   rt/3.8/trunk/share/html/Dashboards/Modify.html

Log:
 r63102 at onn:  sartak | 2008-06-23 21:32:30 -0400
 Add DeleteDashboard right, check it in SharedSetting->Delete


Modified: rt/3.8/trunk/lib/RT/Dashboard.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/Dashboard.pm	(original)
+++ rt/3.8/trunk/lib/RT/Dashboard.pm	Mon Jun 23 21:32:40 2008
@@ -76,6 +76,7 @@
 my %new_rights = (
     ModifyDashboard    => 'Create and modify dashboards', #loc_pair
     SubscribeDashboard => 'Subscribe to email dashboards', #loc_pair
+    DeleteDashboard    => 'Delete dashboards', #loc_pair
 );
 
 use RT::System;
@@ -91,6 +92,14 @@
 
 sub ObjectName { "dashboard" }
 
+=head2 DeleteRightName
+
+Objects of this class check the "DeleteDashboard" right
+
+=cut
+
+sub DeleteRightName { "DeleteDashboard" }
+
 sub SaveAttribute {
     my $self   = shift;
     my $object = shift;

Modified: rt/3.8/trunk/lib/RT/SharedSetting.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/SharedSetting.pm	(original)
+++ rt/3.8/trunk/lib/RT/SharedSetting.pm	Mon Jun 23 21:32:40 2008
@@ -248,11 +248,24 @@
 Deletes the existing shared setting. Returns a tuple of status and message,
 where status is true upon success.
 
+Uses the C<DeleteRightName> method for discovering which right to check.
+
 =cut
 
+sub DeleteRightName { undef }
+
 sub Delete {
     my $self = shift;
 
+    my $right_name = $self->DeleteRightName;
+    if ($right_name) {
+        return (0, $self->loc("Permission denied"))
+            unless $self->CurrentUser->HasRight(
+                Object => $RT::System,
+                Right  => $right_name,
+            );
+    }
+
     my ($status, $msg) = $self->{'Attribute'}->Delete;
     if ($status) {
         return (1, $self->loc("Deleted [_1]", $self->ObjectName));

Modified: rt/3.8/trunk/share/html/Dashboards/Modify.html
==============================================================================
--- rt/3.8/trunk/share/html/Dashboards/Modify.html	(original)
+++ rt/3.8/trunk/share/html/Dashboards/Modify.html	Mon Jun 23 21:32:40 2008
@@ -73,7 +73,7 @@
 </td></tr>
 </table>
 <& /Elements/Submit, Name => 'Save', Label => loc('Save Changes') &>
-% if ($Dashboard->Id) {
+% if ($Dashboard->Id && $can_delete) {
 <& /Elements/Submit, Name => 'Delete', Label => loc('Delete') &>
 % }
 </form>
@@ -88,6 +88,8 @@
 my $Dashboard = RT::Dashboard->new($session{'CurrentUser'});
 my @privacies = $Dashboard->_PrivacyObjects;
 
+my $can_delete = $session{'CurrentUser'}->HasRight(Right => 'DeleteDashboard', Object => $RT::System);
+
 # user went directly to Modify.html
 $Create = 1 if !$id;
 


More information about the Rt-commit mailing list