import rt 3.4.6
[freeside.git] / rt / html / Admin / Queues / People.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC 
6 %#                                          <jesse@bestpractical.com>
7 %# 
8 %# (Except where explicitly superseded by other copyright notices)
9 %# 
10 %# 
11 %# LICENSE:
12 %# 
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
16 %# from www.gnu.org.
17 %# 
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 %# General Public License for more details.
22 %# 
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 %# 
27 %# 
28 %# CONTRIBUTION SUBMISSION POLICY:
29 %# 
30 %# (The following paragraph is not intended to limit the rights granted
31 %# to you to modify and distribute this software under the terms of
32 %# the GNU General Public License and is only of importance to you if
33 %# you choose to contribute your changes and enhancements to the
34 %# community by submitting them to Best Practical Solutions, LLC.)
35 %# 
36 %# By intentionally submitting any modifications, corrections or
37 %# derivatives to this work, or any other work intended for use with
38 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 %# you are the copyright holder for those contributions and you grant
40 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
41 %# royalty-free, perpetual, license to use, copy, create derivative
42 %# works based on those contributions, and sublicense and distribute
43 %# those contributions and any derivatives thereof.
44 %# 
45 %# END BPS TAGGED BLOCK }}}
46 <& /Elements/Header, Title => loc('Modify people related to queue [_1]', $QueueObj->Name) &>
47 <& /Admin/Elements/QueueTabs, id => $id, 
48     QueueObj => $QueueObj,                                                      
49     current_tab => $current_tab, 
50     Title => loc('Modify people related to queue [_1]', $QueueObj->Name) &>
51
52 <& /Elements/ListActions, actions => \@results &>
53
54  
55 <FORM METHOD=POST ACTION="People.html">
56 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$QueueObj->Id%>">
57
58 <TABLE WIDTH=100%>
59 <TR>
60 <TD VALIGN=TOP >
61
62 <h3><&|/l&>Current watchers</&></h3>
63
64
65 <&|/l&>Cc</&>:
66
67 <& /Admin/Elements/EditQueueWatchers, QueueObj => $QueueObj, Watchers => $QueueObj->Cc &>
68
69 <&|/l&>Administrative Cc</&>:
70
71 <& /Admin/Elements/EditQueueWatchers, QueueObj => $QueueObj, Watchers => $QueueObj->AdminCc &>
72
73
74 </TD>
75 <TD VALIGN=TOP>
76 <h3><&|/l&>New watchers</&></h3>
77
78 <&|/l&>Find people whose</&><BR>
79 <& /Elements/SelectUsers &>
80 <input type=submit name="OnlySearchForPeople" value="<&|/l&>Go!</&>">
81 <BR>
82 <&|/l&>Find groups whose</&><BR>
83 <& /Elements/SelectGroups &>
84 <input type=submit name="OnlySearchForGroup" value="<&|/l&>Go!</&>">
85
86 <p>
87 <&|/l&>Add new watchers</&>:<br>
88 <p>
89 <b><&|/l&>Users</&></b>
90 % if ($user_msg) {
91 <br>
92 <i><%$user_msg%></i>
93 % } elsif ($Users) {
94 <ul>
95 % while (my $u = $Users->Next ) {
96 <li><&/Elements/SelectWatcherType, Scope=>'queue', Name =>
97 "Queue-AddWatcher-Principal-".$u->PrincipalId &> <%$u->Name%>
98 (<%$u->RealName%>)
99 % }
100 </ul>
101 % }
102
103 <p>
104 <b><&|/l&>Groups</&></b>
105
106 % if ($group_msg) {
107 <br>
108 <i><%$group_msg%></i>
109 % } elsif ($Groups) {
110 <ul>
111 % while (my $g = $Groups->Next ) {
112 <li><&/Elements/SelectWatcherType, Scope=>'queue', Name =>
113 "Queue-AddWatcher-Principal-".$g->PrincipalId &> <%$g->Name%>
114 (<%$g->Description%>)
115 % }
116 </ul>
117 % }
118
119 </TD>
120 </TR>
121 </TABLE>
122
123
124
125
126 <& /Elements/Submit, Label => loc('Save Changes'), Caption => loc("If you've updated anything above, be sure to"), Reset => 1 &>
127 </form>
128
129 <%INIT>
130
131 my $current_tab;
132 my ($field, @results, $User, $Users, $Groups, $watcher, $user_msg, $group_msg);
133
134 # {{{ Load the queue
135 #If we get handed two ids, mason will make them an array. bleck.
136 # We want teh first one. Just because there's no other sensible way
137 # to deal
138
139
140
141 my $QueueObj = new RT::Queue($session{'CurrentUser'});
142 $QueueObj->Load($id) || Abort(loc("Couldn't load queue", $id));
143 # }}}
144
145 # {{{ Delete deletable watchers
146
147 foreach my $key (keys %ARGS) {
148         my $id = $QueueObj->Id;
149
150     if (($key =~ /^Queue-$id-DeleteWatcher-Type-(.*?)-Principal-(\d*)$/)) {;
151             my ($code, $msg) = $QueueObj->DeleteWatcher(Type => $1,
152                                                     PrincipalId => $2);
153             push @results, $msg;
154     }
155 }
156 # }}}
157
158 # {{{ Add new watchers
159 foreach my  $key (keys %ARGS) {
160     #They're in this order because otherwise $1 gets clobbered :/
161     if ( ($ARGS{$key} =~ /^(AdminCc|Cc)$/) and
162          ($key =~ /^Queue-AddWatcher-Principal-(\d*)$/) ) {
163         $RT::Logger->debug("Adding a watcher $1 to ".$ARGS{$key}."\n");
164         my ($code, $msg) = $QueueObj->AddWatcher(Type => $ARGS{$key},
165                                                              PrincipalId => $1);
166         push @results, $msg;
167     }
168 }
169
170 # }}}
171
172  
173
174 if (!length $ARGS{'UserString'}) {
175 $user_msg = loc("No principals selected.");
176  }
177 else {
178     $Users = new RT::Users($session{'CurrentUser'});
179     $Users->Limit(FIELD => $ARGS{'UserField'},
180                  VALUE => $ARGS{'UserString'},
181                  OPERATOR => $ARGS{'UserOp'});
182      }
183
184 if (!length $ARGS{'GroupString'}) {
185 $group_msg = loc("No principals selected.");
186  }
187 else {
188 $Groups = new RT::Groups($session{'CurrentUser'});
189 $Groups->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'UserDefined');
190 $Groups->Limit(FIELD => $ARGS{'GroupField'},
191                 VALUE => $ARGS{'GroupString'},
192                 OPERATOR => $ARGS{'GroupOp'});
193      }
194
195 $current_tab = 'Admin/Queues/People.html?id='.$QueueObj->id;
196 </%INIT>
197
198 <%ARGS>
199 $UserField => 'Name'
200 $UserOp => '='
201 $UserString => undef
202 $GroupField => 'Name'
203 $GroupOp => '='
204 $GroupString => undef
205 $Type => undef
206 $id => undef
207 </%ARGS>
208