summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Queue.pm
blob: 1656903b36dc9f1c0b226e110df2dcba3d0d41a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
# $Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Queue.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $

=head1 NAME

  RT::Queue - an RT Queue object

=head1 SYNOPSIS

  use RT::Queue;

=head1 DESCRIPTION


=head1 METHODS

=begin testing 
use RT::TestHarness;

use RT::Queue;

=end testing

=cut



package RT::Queue;
use RT::Record;

@ISA= qw(RT::Record);

use vars (@STATUS);

@STATUS = qw(new open stalled resolved dead); 

=head2 StatusArray

Returns an array of all statuses for this queue

=cut

sub StatusArray {
    my $self = shift;
    return (@STATUS);
}


=head2 IsValidStatus VALUE

Returns true if VALUE is a valid status.  Otherwise, returns 0

=for testing
my $q = new RT::Queue($RT::SystemUser);
ok($q->IsValidStatus('new')== 1, 'New is a valid status');
ok($q->IsValidStatus('f00')== 0, 'f00 is not a valid status');

=cut

sub IsValidStatus {
	my $self = shift;
	my $value = shift;

	my $retval = grep (/^$value$/, $self->StatusArray);
 	return ($retval);	

}
	



# {{{  sub _Init 
sub _Init  {
    my $self = shift;
    $self->{'table'} = "Queues";
    return ($self->SUPER::_Init(@_));
}
# }}}

# {{{ sub _Accessible 

sub _Accessible  {
    my $self = shift;
    my %Cols = ( Name => 'read/write',
		 CorrespondAddress => 'read/write',
		 Description => 'read/write',
		 CommentAddress =>  'read/write',
		 InitialPriority =>  'read/write',
		 FinalPriority =>  'read/write',
		 DefaultDueIn =>  'read/write',
		 Creator => 'read/auto',
		 Created => 'read/auto',
		 LastUpdatedBy => 'read/auto',
		 LastUpdated => 'read/auto',
		 Disabled => 'read/write',
		 
	       );
    return($self->SUPER::_Accessible(@_, %Cols));
}

# }}}

# {{{ sub Create

=head2 Create

Create takes the name of the new queue 
If you pass the ACL check, it creates the queue and returns its queue id.

=cut

sub Create  {
    my $self = shift;
    my %args = ( Name => undef,
		 CorrespondAddress => '',
		 Description => '',
		 CommentAddress => '',
		 InitialPriority => "0",
		 FinalPriority =>  "0",
		 DefaultDueIn =>  "0",
		 @_); 
    
    unless ($self->CurrentUser->HasSystemRight('AdminQueue')) {    #Check them ACLs
	return (0, "No permission to create queues") 
    }

    unless ($self->ValidateName($args{'Name'})) {
	return(0, 'Queue already exists');
    }
    #TODO better input validation
    
    my $id = $self->SUPER::Create(%args);
    unless ($id) {
	return (0, 'Queue could not be created');
    }

    return ($id, "Queue $id created");
}

# }}}

# {{{ sub Delete 

sub Delete {
    my $self = shift;
    return (0, 'Deleting this object would break referential integrity');
}

# }}}

# {{{ sub SetDisabled

=head2 SetDisabled

Takes a boolean.
1 will cause this queue to no longer be avaialble for tickets.
0 will re-enable this queue

=cut

# }}}

# {{{ sub Load 

=head2 Load

Takes either a numerical id or a textual Name and loads the specified queue.
  
=cut

sub Load  {
    my $self = shift;
    
    my $identifier = shift;
    if (!$identifier) {
	return (undef);
    }	    
    
    if ($identifier !~ /\D/) {
	$self->SUPER::LoadById($identifier);
    }
    else {
	$self->LoadByCol("Name", $identifier);
    }

    return ($self->Id);


}
# }}}

# {{{ sub ValidateName

=head2 ValidateName NAME

Takes a queue name. Returns true if it's an ok name for
a new queue. Returns undef if there's already a queue by that name.

=cut

sub ValidateName {
    my $self = shift;
    my $name = shift;
   
    my $tempqueue = new RT::Queue($RT::SystemUser);
    $tempqueue->Load($name);

    #If we couldn't load it :)
    unless ($tempqueue->id()) {
	return(1);
    }

    #If this queue exists, return undef
    #Avoid the ACL check.
    if ($tempqueue->Name()){
        return(undef);
    }

    #If the queue doesn't exist, return 1
    else {
        return(1);
    }

}


# }}}

# {{{ sub Templates

=head2 Templates

Returns an RT::Templates object of all of this queue's templates.

=cut

sub Templates {
    my $self = shift;
    

    my $templates = RT::Templates->new($self->CurrentUser);

    if ($self->CurrentUserHasRight('ShowTemplate')) {
	$templates->LimitToQueue($self->id);
    }
    
    return ($templates); 
}

# }}}

# {{{ Dealing with watchers

# {{{ sub Watchers

=head2 Watchers

Watchers returns a Watchers object preloaded with this queue\'s watchers.

=cut

sub Watchers {
    my $self = shift;
    
    require RT::Watchers;
    my $watchers =RT::Watchers->new($self->CurrentUser);
    
    if ($self->CurrentUserHasRight('SeeQueue')) {
	$watchers->LimitToQueue($self->id);	
    }	
    
    return($watchers);
}

# }}}

# {{{ sub WatchersAsString
=head2 WatchersAsString

Returns a string of all queue watchers email addresses concatenated with ','s.

=cut

sub WatchersAsString {
    my $self=shift;
    return($self->Watchers->EmailsAsString());
}

# }}}

# {{{ sub AdminCcAsString 

=head2 AdminCcAsString

Takes nothing. returns a string: All Ticket/Queue AdminCcs.

=cut


sub AdminCcAsString {
    my $self=shift;
    
    return($self->AdminCc->EmailsAsString());
  }

# }}}

# {{{ sub CcAsString

=head2 CcAsString

B<Returns> String: All Queue Ccs as a comma delimited set of email addresses.

=cut

sub CcAsString {
    my $self=shift;
    
    return ($self->Cc->EmailsAsString());
}

# }}}

# {{{ sub Cc

=head2 Cc

Takes nothing.
Returns a watchers object which contains this queue\'s Cc watchers

=cut

sub Cc {
    my $self = shift;
    my $cc = $self->Watchers();
    if ($self->CurrentUserHasRight('SeeQueue')) {
	$cc->LimitToCc();
    }
    return ($cc);
}

# A helper function for Cc, so that we can call it from the ACL checks 
# without going through acl checks.

sub _Cc {
    my $self = shift;
    my $cc = $self->Watchers();
    $cc->LimitToCc();
    return($cc);
    
}

# }}}

# {{{ sub AdminCc

=head2 AdminCc

Takes nothing.
Returns this queue's administrative Ccs as an RT::Watchers object

=cut

sub AdminCc {
    my $self = shift;
    my $admin_cc = $self->Watchers();
    if ($self->CurrentUserHasRight('SeeQueue')) {
 	$admin_cc->LimitToAdminCc();
    }
    return($admin_cc);
}

#helper function for AdminCc so we can call it without ACLs
sub _AdminCc {
    my $self = shift;
    my $admin_cc = $self->Watchers();
    $admin_cc->LimitToAdminCc();
    return($admin_cc);
}

# }}}

# {{{ IsWatcher, IsCc, IsAdminCc

# {{{ sub IsWatcher

# a generic routine to be called by IsRequestor, IsCc and IsAdminCc

=head2 IsWatcher

Takes a param hash with the attributes Type and User. User is either a user object or string containing an email address. Returns true if that user or string
is a queue watcher. Returns undef otherwise

=cut

sub IsWatcher {
    my $self = shift;
    
    my %args = ( Type => 'Requestor',
		 Id => undef,
		 Email => undef,
		 @_
	       );
    #ACL check - can't do it. we need this method for ACL checks
    #    unless ($self->CurrentUserHasRight('SeeQueue')) {
    #	return(undef);
    #    }


    my %cols = ('Type' => $args{'Type'},
		'Scope' => 'Queue',
		'Value' => $self->Id
	       );
    if (defined ($args{'Id'})) {
	if (ref($args{'Id'})){ #If it's a ref, assume it's an RT::User object;
	    #Dangerous but ok for now
	    $cols{'Owner'} = $args{'Id'}->Id;
	}
	elsif ($args{'Id'} =~ /^\d+$/) { # if it's an integer, it's an RT::User obj
	    $cols{'Owner'} = $args{'Id'};
	}
	else {
	    $cols{'Email'} = $args{'Id'};
	}	
    }	
    
    if (defined $args{'Email'}) {
	$cols{'Email'} = $args{'Email'};
    }

    my ($description);
    $description = join(":",%cols);
    
    #If we've cached a positive match...
    if (defined $self->{'watchers_cache'}->{"$description"}) {
	if ($self->{'watchers_cache'}->{"$description"} == 1) {
	    return(1);
	}
	#If we've cached a negative match...
	else {
	    return(undef);
	}
    }

    require RT::Watcher;
    my $watcher = new RT::Watcher($self->CurrentUser);
    $watcher->LoadByCols(%cols);
    
    
    if ($watcher->id) {
	$self->{'watchers_cache'}->{"$description"} = 1;
	return(1);
    }	
    else {
	$self->{'watchers_cache'}->{"$description"} = 0;
	return(undef);
    }
    
}

# }}}

# {{{ sub IsCc

=head2 IsCc

Takes a string. Returns true if the string is a Cc watcher of the current queue

=item Bugs

Should also be able to handle an RT::User object

=cut


sub IsCc {
  my $self = shift;
  my $cc = shift;
  
  return ($self->IsWatcher( Type => 'Cc', Id => $cc ));
  
}

# }}}

# {{{ sub IsAdminCc

=head2 IsAdminCc

Takes a string. Returns true if the string is an AdminCc watcher of the current queue

=item Bugs

Should also be able to handle an RT::User object

=cut

sub IsAdminCc {
  my $self = shift;
  my $admincc = shift;
  
  return ($self->IsWatcher( Type => 'AdminCc', Id => $admincc ));
  
}

# }}}

# }}}

# {{{ sub AddWatcher

=head2 AddWatcher

Takes a paramhash of Email, Owner and Type. Type is one of 'Cc' or 'AdminCc',
We need either an Email Address in Email or a userid in Owner

=cut

sub AddWatcher {
    my $self = shift;
    my %args = ( Email => undef,
		 Type => undef,
		 Owner => 0,
		 @_
	       );
    
    # {{{ Check ACLS
    #If the watcher we're trying to add is for the current user
    if ( ( ( defined $args{'Email'})  && 
           ( $args{'Email'} eq $self->CurrentUser->EmailAddress) ) or 
	 ($args{'Owner'} eq $self->CurrentUser->Id)) {
	
	#  If it's an AdminCc and they don't have 
	#   'WatchAsAdminCc' or 'ModifyQueueWatchers', bail
	if ($args{'Type'} eq 'AdminCc') {
	    unless ($self->CurrentUserHasRight('ModifyQueueWatchers') or 
		    $self->CurrentUserHasRight('WatchAsAdminCc')) {
		return(0, 'Permission Denied');
	    }
	}

	#  If it's a Requestor or Cc and they don't have
	#   'Watch' or 'ModifyQueueWatchers', bail
	elsif ($args{'Type'} eq 'Cc') {
	    unless ($self->CurrentUserHasRight('ModifyQueueWatchers') or 
		    $self->CurrentUserHasRight('Watch')) {
		return(0, 'Permission Denied');
	    }
	}
	else {
	    $RT::Logger->warn("$self -> AddWatcher hit code".
			      " it never should. We got passed ".
			      " a type of ". $args{'Type'});
	    return (0,'Error in parameters to $self AddWatcher');
	}
    }
    # If the watcher isn't the current user 
    # and the current user  doesn't have 'ModifyQueueWatchers'
    # bail
    else {
	unless ($self->CurrentUserHasRight('ModifyQueueWatchers')) {
	    return (0, "Permission Denied");
	}
    }
    # }}}
        
    require RT::Watcher;
    my $Watcher = new RT::Watcher ($self->CurrentUser);
    return ($Watcher->Create(Scope => 'Queue', 
			     Value => $self->Id,
			     Email => $args{'Email'},
			     Type => $args{'Type'},
			     Owner => $args{'Owner'}
			    ));
}

# }}}

# {{{ sub AddCc

=head2 AddCc

Add a Cc to this queue.
Takes a paramhash of Email and Owner. 
We need either an Email Address in Email or a userid in Owner

=cut


sub AddCc {
    my $self = shift;
    return ($self->AddWatcher( Type => 'Cc', @_));
}
# }}}

# {{{ sub AddAdminCc

=head2 AddAdminCc

Add an Administrative Cc to this queue.
Takes a paramhash of Email and Owner. 
We need either an Email Address in Email or a userid in Owner

=cut

sub AddAdminCc {
    my $self = shift;
    return ($self->AddWatcher( Type => 'AdminCc', @_));
}
# }}}

# {{{ sub DeleteWatcher

=head2 DeleteWatcher id [type]

DeleteWatcher takes a single argument which is either an email address 
or a watcher id.  
If the first argument is an email address, you need to specify the watcher type you're talking
about as the second argument. Valid values are 'Cc' or 'AdminCc'.
It removes that watcher from this Queue\'s list of watchers.


=cut


sub DeleteWatcher {
    my $self = shift;
    my $id = shift;
    
    my $type;
    
    $type = shift if (@_);
    

    require RT::Watcher;
    my $Watcher = new RT::Watcher($self->CurrentUser);
    
    #If it\'s a numeric watcherid
    if ($id =~ /^(\d*)$/) {
	$Watcher->Load($id);
    }
    
    #Otherwise, we'll assume it's an email address
    elsif ($type) {
	my ($result, $msg) = 
	  $Watcher->LoadByValue( Email => $id,
				 Scope => 'Queue',
				 Value => $self->id,
				 Type => $type);
	return (0,$msg) unless ($result);
    }
    
    else {
	return(0,"Can\'t delete a watcher by email address without specifying a type");
    }
    
    # {{{ Check ACLS 

    #If the watcher we're trying to delete is for the current user
    if ($Watcher->Email eq $self->CurrentUser->EmailAddress) {
		
	#  If it's an AdminCc and they don't have 
	#   'WatchAsAdminCc' or 'ModifyQueueWatchers', bail
	if ($Watcher->Type eq 'AdminCc') {
	    unless ($self->CurrentUserHasRight('ModifyQueueWatchers') or 
		    $self->CurrentUserHasRight('WatchAsAdminCc')) {
		return(0, 'Permission Denied');
	    }
	}

	#  If it's a  Cc and they don't have
	#   'Watch' or 'ModifyQueueWatchers', bail
	elsif ($Watcher->Type eq 'Cc') {
	    unless ($self->CurrentUserHasRight('ModifyQueueWatchers') or 
		    $self->CurrentUserHasRight('Watch')) {
		return(0, 'Permission Denied');
	    }
	}
	else {
	    $RT::Logger->warn("$self -> DeleteWatcher hit code".
			      " it never should. We got passed ".
			      " a type of ". $args{'Type'});
	    return (0,'Error in parameters to $self DeleteWatcher');
	}
    }
    # If the watcher isn't the current user 
    # and the current user  doesn't have 'ModifyQueueWatchers'
    # bail
    else {
	unless ($self->CurrentUserHasRight('ModifyQueueWatchers')) {
	    return (0, "Permission Denied");
	}
    }

    # }}}
    
    unless (($Watcher->Scope eq 'Queue') and
	    ($Watcher->Value == $self->id) ) {
	return (0, "Not a watcher for this queue");
    }
    

    #Clear out the watchers hash.
    $self->{'watchers'} = undef;
    
    my $retval = $Watcher->Delete();
    
    unless ($retval) {
	return(0,"Watcher could not be deleted.");
    }
    
    return(1, "Watcher deleted");
}

# {{{ sub DeleteCc

=head2 DeleteCc EMAIL

Takes an email address. It calls DeleteWatcher with a preset 
type of 'Cc'


=cut

sub DeleteCc {
   my $self = shift;
   my $id = shift;
   return ($self->DeleteWatcher ($id, 'Cc'))
}

# }}}

# {{{ sub DeleteAdminCc

=head2 DeleteAdminCc EMAIL

Takes an email address. It calls DeleteWatcher with a preset 
type of 'AdminCc'


=cut

sub DeleteAdminCc {
   my $self = shift;
   my $id = shift;
   return ($self->DeleteWatcher ($id, 'AdminCc'))
}

# }}}


# }}}

# }}}

# {{{ Dealing with keyword selects

# {{{ sub AddKeywordSelect

=head2 AddKeywordSelect

Takes a paramhash of Name, Keyword, Depth and Single.  Adds a new KeywordSelect for 
this queue with those attributes.

=cut


sub AddKeywordSelect {
    my $self = shift;
    my %args = ( Keyword => undef,
		 Depth => undef,
		 Single => undef,
		 Name => undef,
		 @_);
    
    #ACLS get handled in KeywordSelect
    my $NewKeywordSelect = new RT::KeywordSelect($self->CurrentUser);
    
    return ($NewKeywordSelect->Create (Keyword => $args{'Keyword'},
			       Depth => $args{'Depth'},
			       Name => $args{'Name'},
			       Single => $args{'Single'},
			       ObjectType => 'Ticket',
			       ObjectField => 'Queue',
			       ObjectValue => $self->Id()
			      )	);
}

# }}}

# {{{ sub KeywordSelect

=head2 KeywordSelect([NAME])

Takes the name of a keyword select for this queue or that's global.
Returns the relevant KeywordSelect object.  Prefers a keywordselect that's 
specific to this queue over a global one.  If it can't find the proper
Keword select or the user doesn't have permission, returns an empty 
KeywordSelect object

=cut

sub KeywordSelect {
    my $self = shift;
    my $name = shift;
    
    require RT::KeywordSelect;

    my $select = RT::KeywordSelect->new($self->CurrentUser);
    if ($self->CurrentUserHasRight('SeeQueue')) {
	$select->LoadByName( Name => $name, Queue => $self->Id);
    }
    return ($select);
}


# }}}

# {{{ sub KeywordSelects

=head2 KeywordSelects

Returns an B<RT::KeywordSelects> object containing the collection of
B<RT::KeywordSelect> objects which apply to this queue. (Both queue specific keyword selects
and global keyword selects.

=cut

sub KeywordSelects {
  my $self = shift;


  use RT::KeywordSelects;
  my $KeywordSelects = new RT::KeywordSelects($self->CurrentUser);

  if ($self->CurrentUserHasRight('SeeQueue')) {
      $KeywordSelects->LimitToQueue($self->id);
      $KeywordSelects->IncludeGlobals();
  }
  return ($KeywordSelects);
}
# }}}

# }}}

# {{{ ACCESS CONTROL

# {{{ sub ACL 

=head2 ACL

#Returns an RT::ACL object of ACEs everyone who has anything to do with this queue.

=cut

sub ACL  {
    my $self = shift;
    
    use RT::ACL;
    my $acl = new RT::ACL($self->CurrentUser);
    
    if ($self->CurrentUserHasRight('ShowACL')) {
	$acl->LimitToQueue($self->Id);
    }
    
    return ($acl);
}

# }}}

# {{{ sub _Set
sub _Set {
    my $self = shift;

    unless ($self->CurrentUserHasRight('AdminQueue')) {
	return(0, 'Permission Denied');
    }	
    return ($self->SUPER::_Set(@_));
}
# }}}

# {{{ sub _Value

sub _Value {
    my $self = shift;

    unless ($self->CurrentUserHasRight('SeeQueue')) {
	return (undef);
    }

    return ($self->__Value(@_));
}

# }}}

# {{{ sub CurrentUserHasRight

=head2 CurrentUserHasRight

Takes one argument. A textual string with the name of the right we want to check.
Returns true if the current user has that right for this queue.
Returns undef otherwise.

=cut

sub CurrentUserHasRight {
  my $self = shift;
  my $right = shift;

  return ($self->HasRight( Principal=> $self->CurrentUser,
                            Right => "$right"));

}

# }}}

# {{{ sub HasRight

=head2 HasRight

Takes a param hash with the fields 'Right' and 'Principal'.
Principal defaults to the current user.
Returns true if the principal has that right for this queue.
Returns undef otherwise.

=cut

# TAKES: Right and optional "Principal" which defaults to the current user
sub HasRight {
    my $self = shift;
        my %args = ( Right => undef,
                     Principal => $self->CurrentUser,
                     @_);
        unless(defined $args{'Principal'}) {
                $RT::Logger->debug("Principal undefined in Queue::HasRight");

        }
        return($args{'Principal'}->HasQueueRight(QueueObj => $self,
          Right => $args{'Right'}));
}
# }}}

# }}}

1;