[Rt-devel] Two patches

Todd Chapman todd at chaka.net
Thu May 18 17:25:00 EDT 2006


BTW, all regression tests pass.

On Thu, May 18, 2006 at 05:22:22PM -0400, Todd Chapman wrote:
> The first patch fixes a broken regexp.
> 
> The second simplifies the logic for Queue::AddWatcher.
> Lett CurrentUserHasRight calls are potentially made too.
> (yes, I know it is cached)
> 
> Why all then parens around arguments to return?
> 
> -Todd
> 

> === html/Ticket/Elements/Tabs
> ==================================================================
> --- html/Ticket/Elements/Tabs	(revision 6963)
> +++ html/Ticket/Elements/Tabs	(local)
> @@ -213,13 +213,13 @@
>                     title     => loc('Show Results'),
>                     separator => 1,
>                     subtabs   => $searchtabs };
> -  if ($current_tab =~  "Search/Results.html") {
> +  if ($current_tab =~  m{Search/Results.html}) {
>      $current_tab = "Search/Results.html$args";
>    }
>    $tabs->{"j"} = { path      => "Search/Bulk.html$args",
>                     title     => loc('Bulk Update'),
>                     };
> -  if ($current_tab =~  "Search/Bulk.html") {
> +  if ($current_tab =~  m{Search/Bulk.html}) {
>      $current_tab = "Search/Bulk.html$args";
>    }
>  }

> === lib/RT/Queue_Overlay.pm
> ==================================================================
> --- lib/RT/Queue_Overlay.pm	(revision 6963)
> +++ lib/RT/Queue_Overlay.pm	(local)
> @@ -648,44 +648,31 @@
>      );
>  
>      # {{{ Check ACLS
> +    return ( $self->_AddWatcher(%args) )
> +        if $self->CurrentUserHasRight('ModifyQueueWatchers');
> +
>      #If the watcher we're trying to add is for the current user
>      if ( $self->CurrentUser->PrincipalId  eq $args{'PrincipalId'}) {
>          #  If it's an AdminCc and they don't have 
>          #   'WatchAsAdminCc' or 'ModifyTicket', bail
>          if ( $args{'Type'} eq 'AdminCc' ) {
> -            unless ( $self->CurrentUserHasRight('ModifyQueueWatchers')
> -                or $self->CurrentUserHasRight('WatchAsAdminCc') ) {
> -                return ( 0, $self->loc('Permission Denied'))
> -            }
> +                return ( $self->_AddWatcher(%args) )
> +                    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' ) ) {
> -
> -            unless ( $self->CurrentUserHasRight('ModifyQueueWatchers')
> -                or $self->CurrentUserHasRight('Watch') ) {
> -                return ( 0, $self->loc('Permission Denied'))
> -            }
> +        elsif ( $args{'Type'} eq 'Cc' or $args{'Type'} eq 'Requestor' ) {
> +                return ( $self->_AddWatcher(%args) )
> +                    if $self->CurrentUserHasRight('Watch');
>          }
> -     else {
> +        else {
>              $RT::Logger->warning( "$self -> AddWatcher got passed a bogus type");
>              return ( 0, $self->loc('Error in parameters to Queue->AddWatcher') );
>          }
>      }
>  
> -    # If the watcher isn't the current user 
> -    # and the current user  doesn't have 'ModifyQueueWatcher'
> -    # bail
> -    else {
> -        unless ( $self->CurrentUserHasRight('ModifyQueueWatchers') ) {
> -            return ( 0, $self->loc("Permission Denied") );
> -        }
> -    }
> -
> -    # }}}
> -
> -    return ( $self->_AddWatcher(%args) );
> +    return ( 0, $self->loc("Permission Denied") );
>  }
>  
>  #This contains the meat of AddWatcher. but can be called from a routine like

> _______________________________________________
> List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
> 
> Best Practical is hiring! Come hack Perl for us: http://bestpractical.com/about/jobs.html


More information about the Rt-devel mailing list