[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-455-g3643b9b

Shawn Moore sartak at bestpractical.com
Tue Aug 17 21:58:00 EDT 2010


The branch, 3.9-trunk has been updated
       via  3643b9b5de487bb106f076776962bb8b8368cfb7 (commit)
      from  0f07aba226c4e777d238bd65c5e879ce3d46bf06 (commit)

Summary of changes:
 lib/RT/Queue_Overlay.pm |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

- Log -----------------------------------------------------------------
commit 3643b9b5de487bb106f076776962bb8b8368cfb7
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Aug 17 21:59:55 2010 -0400

    Factor _HasAddWatcherRight out into its own method for overriding

diff --git a/lib/RT/Queue_Overlay.pm b/lib/RT/Queue_Overlay.pm
index 0e790b2..a2033c4 100755
--- a/lib/RT/Queue_Overlay.pm
+++ b/lib/RT/Queue_Overlay.pm
@@ -799,24 +799,41 @@ sub AddWatcher {
         $args{'PrincipalId'} = $user->PrincipalId if $user->id;
     }
 
-    # {{{ Check ACLS
-    return ( $self->_AddWatcher(%args) )
-        if $self->CurrentUserHasRight('ModifyQueueWatchers');
+    return ( 0, "Unknown watcher type [_1]", $args{Type} )
+        unless $self->IsRoleGroupType($args{Type});
+
+    return ( 0, "Unmanageable watcher type [_1]", $args{Type} )
+        unless $self->IsManageableRoleGroupType($args{Type});
+
+    my ($ok, $msg) = $self->_HasAddWatcherRight(%args);
+    return ($ok, $msg) if !$ok;
+
+    return $self->_AddWatcher(%args);
+}
+
+sub _HasAddWatcherRight {
+    my $self = shift;
+    my %args = (
+        Type  => undef,
+        PrincipalId => undef,
+        Email => undef,
+        @_
+    );
+
+    return 1 if $self->CurrentUserHasRight('ModifyQueueWatchers');
 
     #If the watcher we're trying to add is for the current user
     if ( defined $args{'PrincipalId'} && $self->CurrentUser->PrincipalId  eq $args{'PrincipalId'}) {
         #  If it's an AdminCc and they don't have 
         #   'WatchAsAdminCc' or 'ModifyTicket', bail
-        if ( defined $args{'Type'} && ($args{'Type'} eq 'AdminCc') ) {
-            return ( $self->_AddWatcher(%args) )
-                if $self->CurrentUserHasRight('WatchAsAdminCc');
+        if ( $args{'Type'} eq 'AdminCc' ) {
+            return 1 if $self->CurrentUserHasRight('WatchAsAdminCc');
         }
 
         #  If it's a Requestor or Cc and they don't have
         #   'Watch' or 'ModifyTicket', bail
         elsif ( $args{'Type'} eq 'Cc' or $args{'Type'} eq 'Requestor' ) {
-            return ( $self->_AddWatcher(%args) )
-                if $self->CurrentUserHasRight('Watch');
+            return 1 if $self->CurrentUserHasRight('Watch');
         }
         else {
             $RT::Logger->warning( "$self -> AddWatcher got passed a bogus type");

-----------------------------------------------------------------------


More information about the Rt-commit mailing list