import of rt 3.0.4
[freeside.git] / rt / html / Admin / Queues / People.html
1 %# BEGIN LICENSE BLOCK
2 %# 
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4 %# 
5 %# (Except where explictly superceded by other copyright notices)
6 %# 
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
10 %# from www.gnu.org.
11 %# 
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.
16 %# 
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.
21 %# 
22 %# 
23 %# END LICENSE BLOCK
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) &>
29
30 <& /Elements/ListActions, actions => \@results &>
31
32  
33 <FORM METHOD=POST ACTION="People.html">
34 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$QueueObj->Id%>">
35
36 <TABLE WIDTH=100%>
37 <TR>
38 <TD VALIGN=TOP >
39
40 <h3><&|/l&>Current watchers</&></h3>
41
42
43 <&|/l&>Cc</&>:
44
45 <& /Admin/Elements/EditQueueWatchers, QueueObj => $QueueObj, Watchers => $QueueObj->Cc &>
46
47 <&|/l&>Administrative Cc</&>:
48
49 <& /Admin/Elements/EditQueueWatchers, QueueObj => $QueueObj, Watchers => $QueueObj->AdminCc &>
50
51
52 </TD>
53 <TD VALIGN=TOP>
54 <h3><&|/l&>New watchers</&></h3>
55
56 <&|/l&>Find people whose</&><BR>
57 <& /Elements/SelectUsers &>
58 <input type=submit name="OnlySearchForPeople" value="<&|/l&>Go!</&>">
59 <BR>
60 <&|/l&>Find group whose</&><BR>
61 <& /Elements/SelectGroups &>
62 <input type=submit name="OnlySearchForGroup" value="<&|/l&>Go!</&>">
63
64 <p>
65 <&|/l&>Add new watchers</&>:<br>
66 <p>
67 <b><&|/l&>Users</&></b>
68 % if ($user_msg) {
69 <br>
70 <i><%$user_msg%></i>
71 % } elsif ($Users) {
72 <ul>
73 % while (my $u = $Users->Next ) {
74 <li><&/Elements/SelectWatcherType, Scope=>'queue', Name =>
75 "Queue-AddWatcher-Principal-".$u->PrincipalId &> <%$u->Name%>
76 (<%$u->RealName%>)
77 % }
78 </ul>
79 % }
80
81 <p>
82 <b><&|/l&>Groups</&></b>
83
84 % if ($group_msg) {
85 <br>
86 <i><%$group_msg%></i>
87 % } elsif ($Groups) {
88 <ul>
89 % while (my $g = $Groups->Next ) {
90 <li><&/Elements/SelectWatcherType, Scope=>'queue', Name =>
91 "Queue-AddWatcher-Principal-".$g->PrincipalId &> <%$g->Name%>
92 (<%$g->Description%>)
93 % }
94 </ul>
95 % }
96
97 </TD>
98 </TR>
99 </TABLE>
100
101
102
103
104 <& /Elements/Submit, Label => loc('Save Changes'), Caption => loc("If you've updated anything above, be sure to"), Reset => 1 &>
105 </form>
106
107 <%INIT>
108
109 my $current_tab;
110 my ($field, @results, $User, $Users, $Groups, $watcher, $user_msg, $group_msg);
111
112 # {{{ Load the queue
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
115 # to deal
116
117
118
119 my $QueueObj = new RT::Queue($session{'CurrentUser'});
120 $QueueObj->Load($id) || Abort(loc("Couldn't load queue", $id));
121 # }}}
122
123 # {{{ Delete deletable watchers
124
125 foreach my $key (keys %ARGS) {
126         my $id = $QueueObj->Id;
127
128     if (($key =~ /^Queue-$id-DelWatcher-Type-(.*?)-Principal-(\d*)$/)) {;
129             my ($code, $msg) = $QueueObj->DeleteWatcher(Type => $1,
130                                                     PrincipalId => $2);
131             push @results, $msg;
132     }
133 }
134 # }}}
135
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},
143                                                              PrincipalId => $1);
144         push @results, $msg;
145     }
146 }
147
148 # }}}
149
150  
151
152 if (!length $ARGS{'UserString'}) {
153 $user_msg = loc("No principals selected.");
154  }
155 else {
156     $Users = new RT::Users($session{'CurrentUser'});
157     $Users->Limit(FIELD => $ARGS{'UserField'},
158                  VALUE => $ARGS{'UserString'},
159                  OPERATOR => $ARGS{'UserOp'});
160      }
161
162 if (!length $ARGS{'GroupString'}) {
163 $group_msg = loc("No principals selected.");
164  }
165 else {
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'});
171      }
172
173 $current_tab = 'Admin/Queues/People.html?id='.$QueueObj->id;
174 </%INIT>
175
176 <%ARGS>
177 $UserField => 'Name'
178 $UserOp => '='
179 $UserString => undef
180 $GroupField => 'Name'
181 $GroupOp => '='
182 $GroupString => undef
183 $Type => undef
184 $id => undef
185 </%ARGS>
186