[Rt-commit] r6241 - in rt/branches/3.6-RELEASE: .
kevinr at bestpractical.com
kevinr at bestpractical.com
Fri Oct 20 00:06:00 EDT 2006
Author: kevinr
Date: Fri Oct 20 00:05:59 2006
New Revision: 6241
Modified:
rt/branches/3.6-RELEASE/ (props changed)
rt/branches/3.6-RELEASE/lib/RT/User_Overlay.pm
Log:
r28703 at sad-girl-in-snow: kevinr | 2006-10-20 00:02:48 -0400
* Pulled User::WatchedQueues in from RT::Extension::rt_cpan_org
Modified: rt/branches/3.6-RELEASE/lib/RT/User_Overlay.pm
==============================================================================
--- rt/branches/3.6-RELEASE/lib/RT/User_Overlay.pm (original)
+++ rt/branches/3.6-RELEASE/lib/RT/User_Overlay.pm Fri Oct 20 00:05:59 2006
@@ -1691,6 +1691,77 @@
# }}}
+
+=head2 WatchedQueues ROLE_LIST
+
+Returns a RT::Queues object containing every queue watched by the user.
+
+Takes a list of roles which is some subset of ('Cc', 'AdminCc'). Defaults to:
+
+$user->WatchedQueues('Cc', 'AdminCc');
+
+=cut
+
+sub WatchedQueues {
+
+ my $self = shift;
+ my @roles = @_ || ('Cc', 'AdminCc');
+
+ $RT::Logger->debug('WatcheQueues got user ' . $self->Name);
+
+ my $watched_queues = RT::Queues->new($self->CurrentUser);
+
+ my $group_alias = $watched_queues->Join(
+ ALIAS1 => 'main',
+ FIELD1 => 'id',
+ TABLE2 => 'Groups',
+ FIELD2 => 'Instance',
+ );
+
+ $watched_queues->Limit(
+ ALIAS => $group_alias,
+ FIELD => 'Domain',
+ VALUE => 'RT::Queue-Role',
+ ENTRYAGGREGATOR => 'AND',
+ );
+ if (grep { $_ eq 'Cc' } @roles) {
+ $watched_queues->Limit(
+ SUBCLAUSE => 'LimitToWatchers',
+ ALIAS => $group_alias,
+ FIELD => 'Type',
+ VALUE => 'Cc',
+ ENTRYAGGREGATOR => 'OR',
+ );
+ }
+ if (grep { $_ eq 'AdminCc' } @roles) {
+ $watched_queues->Limit(
+ SUBCLAUSE => 'LimitToWatchers',
+ ALIAS => $group_alias,
+ FIELD => 'Type',
+ VALUE => 'AdminCc',
+ ENTRYAGGREGATOR => 'OR',
+ );
+ }
+
+ my $queues_alias = $watched_queues->Join(
+ ALIAS1 => $group_alias,
+ FIELD1 => 'id',
+ TABLE2 => 'CachedGroupMembers',
+ FIELD2 => 'GroupId',
+ );
+ $watched_queues->Limit(
+ ALIAS => $queues_alias,
+ FIELD => 'MemberId',
+ VALUE => $self->PrincipalId,
+ );
+
+ $RT::Logger->debug("WatchedQueues got " . $watched_queues->Count . " queues");
+
+ return $watched_queues;
+
+}
+
+
# {{{ sub _CleanupInvalidDelegations
=head2 _CleanupInvalidDelegations { InsideTransaction => undef }
More information about the Rt-commit
mailing list