3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 %# (Except where explictly superceded by other copyright notices)
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 %# General Public License for more details.
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
24 <& /Elements/Header, Title => loc('Modify people related to queue [_1]', $QueueObj->Name) &>
25 <& /Admin/Elements/QueueTabs, id => $id,
26 QueueObj => $QueueObj,
27 current_tab => $current_tab,
28 Title => loc('Modify people related to queue [_1]', $QueueObj->Name) &>
30 <& /Elements/ListActions, actions => \@results &>
33 <FORM METHOD=POST ACTION="People.html">
34 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$QueueObj->Id%>">
40 <h3><&|/l&>Current watchers</&></h3>
45 <& /Admin/Elements/EditQueueWatchers, QueueObj => $QueueObj, Watchers => $QueueObj->Cc &>
47 <&|/l&>Administrative Cc</&>:
49 <& /Admin/Elements/EditQueueWatchers, QueueObj => $QueueObj, Watchers => $QueueObj->AdminCc &>
54 <h3><&|/l&>New watchers</&></h3>
56 <&|/l&>Find people whose</&><BR>
57 <& /Elements/SelectUsers &>
58 <input type=submit name="OnlySearchForPeople" value="<&|/l&>Go!</&>">
60 <&|/l&>Find group whose</&><BR>
61 <& /Elements/SelectGroups &>
62 <input type=submit name="OnlySearchForGroup" value="<&|/l&>Go!</&>">
65 <&|/l&>Add new watchers</&>:<br>
67 <b><&|/l&>Users</&></b>
73 % while (my $u = $Users->Next ) {
74 <li><&/Elements/SelectWatcherType, Scope=>'queue', Name =>
75 "Queue-AddWatcher-Principal-".$u->PrincipalId &> <%$u->Name%>
82 <b><&|/l&>Groups</&></b>
89 % while (my $g = $Groups->Next ) {
90 <li><&/Elements/SelectWatcherType, Scope=>'queue', Name =>
91 "Queue-AddWatcher-Principal-".$g->PrincipalId &> <%$g->Name%>
104 <& /Elements/Submit, Label => loc('Save Changes'), Caption => loc("If you've updated anything above, be sure to"), Reset => 1 &>
110 my ($field, @results, $User, $Users, $Groups, $watcher, $user_msg, $group_msg);
113 #If we get handed two ids, mason will make them an array. bleck.
114 # We want teh first one. Just because there's no other sensible way
119 my $QueueObj = new RT::Queue($session{'CurrentUser'});
120 $QueueObj->Load($id) || Abort(loc("Couldn't load queue", $id));
123 # {{{ Delete deletable watchers
125 foreach my $key (keys %ARGS) {
126 my $id = $QueueObj->Id;
128 if (($key =~ /^Queue-$id-DelWatcher-Type-(.*?)-Principal-(\d*)$/)) {;
129 my ($code, $msg) = $QueueObj->DeleteWatcher(Type => $1,
136 # {{{ Add new watchers
137 foreach my $key (keys %ARGS) {
138 #They're in this order because otherwise $1 gets clobbered :/
139 if ( ($ARGS{$key} =~ /^(AdminCc|Cc)$/) and
140 ($key =~ /^Queue-AddWatcher-Principal-(\d*)$/) ) {
141 $RT::Logger->debug("Adding a watcher $1 to ".$ARGS{$key}."\n");
142 my ($code, $msg) = $QueueObj->AddWatcher(Type => $ARGS{$key},
152 if (!length $ARGS{'UserString'}) {
153 $user_msg = loc("No principals selected.");
156 $Users = new RT::Users($session{'CurrentUser'});
157 $Users->Limit(FIELD => $ARGS{'UserField'},
158 VALUE => $ARGS{'UserString'},
159 OPERATOR => $ARGS{'UserOp'});
162 if (!length $ARGS{'GroupString'}) {
163 $group_msg = loc("No principals selected.");
166 $Groups = new RT::Groups($session{'CurrentUser'});
167 $Groups->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'UserDefined');
168 $Groups->Limit(FIELD => $ARGS{'GroupField'},
169 VALUE => $ARGS{'GroupString'},
170 OPERATOR => $ARGS{'GroupOp'});
173 $current_tab = 'Admin/Queues/People.html?id='.$QueueObj->id;
180 $GroupField => 'Name'
182 $GroupString => undef