import rt 3.8.11
[freeside.git] / rt / html / Admin / Queues / People.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2009 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., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
28 %# 
29 %# 
30 %# CONTRIBUTION SUBMISSION POLICY:
31 %# 
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
37 %# 
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
46 %# 
47 %# END BPS TAGGED BLOCK }}}
48 <& /Elements/Header, Title => loc('Modify people related to queue [_1]', $QueueObj->Name) &>
49 <& /Admin/Elements/QueueTabs, id => $id, 
50     QueueObj => $QueueObj,                                                      
51     current_tab => $current_tab, 
52     Title => loc('Modify people related to queue [_1]', $QueueObj->Name) &>
53
54 <& /Elements/ListActions, actions => \@results &>
55
56  
57 <form method="post" action="People.html">
58 <input type="hidden" class="hidden" name="id" value="<%$QueueObj->Id%>" />
59
60 <table width="100%">
61 <tr>
62 <td valign="top" >
63
64 <h3><&|/l&>Current watchers</&></h3>
65
66
67 <&|/l&>Cc</&>:
68
69 <& /Admin/Elements/EditQueueWatchers, QueueObj => $QueueObj, Watchers => $QueueObj->Cc &>
70
71 <&|/l&>Administrative Cc</&>:
72
73 <& /Admin/Elements/EditQueueWatchers, QueueObj => $QueueObj, Watchers => $QueueObj->AdminCc &>
74
75
76 </td>
77 <td valign="top">
78 <h3><&|/l&>New watchers</&></h3>
79
80 <&|/l&>Find people whose</&><br />
81 <& /Elements/SelectUsers &>
82 <input type="submit" class="button" name="OnlySearchForPeople" value="<&|/l&>Go!</&>" />
83 <br />
84 <&|/l&>Find groups whose</&><br />
85 <& /Elements/SelectGroups &>
86 <input type="submit" class="button" name="OnlySearchForGroup" value="<&|/l&>Go!</&>" />
87
88 <p>
89 <&|/l&>Add new watchers</&>:<br />
90 <p>
91 <strong><&|/l&>Users</&></strong>
92 % if ($user_msg) {
93 <br />
94 <em><%$user_msg%></em>
95 % } elsif ($Users) {
96 <ul>
97 % while (my $u = $Users->Next ) {
98 <li><&/Elements/SelectWatcherType, Scope=>'queue', Name =>
99 "Queue-AddWatcher-Principal-".$u->PrincipalId &> <%$u->Name%>
100 (<%$u->RealName%>)
101 % }
102 </ul>
103 % }
104
105 <p>
106 <strong><&|/l&>Groups</&></strong>
107
108 % if ($group_msg) {
109 <br />
110 <em><%$group_msg%></em>
111 % } elsif ($Groups) {
112 <ul>
113 % while (my $g = $Groups->Next ) {
114 <li><&/Elements/SelectWatcherType, Scope=>'queue', Name =>
115 "Queue-AddWatcher-Principal-".$g->PrincipalId &> <%$g->Name%>
116 (<%$g->Description%>)
117 % }
118 </ul>
119 % }
120
121 </td>
122 </tr>
123 </table>
124
125
126
127
128 <& /Elements/Submit, Label => loc('Save Changes'), Caption => loc("If you've updated anything above, be sure to"), Reset => 1 &>
129 </form>
130
131 <%INIT>
132
133 my $current_tab;
134 my ($field, @results, $User, $Users, $Groups, $watcher, $user_msg, $group_msg);
135
136 # {{{ Load the queue
137 #If we get handed two ids, mason will make them an array. bleck.
138 # We want teh first one. Just because there's no other sensible way
139 # to deal
140
141
142
143 my $QueueObj = new RT::Queue($session{'CurrentUser'});
144 $QueueObj->Load($id) || Abort(loc("Couldn't load queue", $id));
145 # }}}
146
147 # {{{ Delete deletable watchers
148
149 foreach my $key (keys %ARGS) {
150         my $id = $QueueObj->Id;
151
152     if (($key =~ /^Queue-$id-DeleteWatcher-Type-(.*?)-Principal-(\d*)$/)) {;
153             my ($code, $msg) = $QueueObj->DeleteWatcher(Type => $1,
154                                                     PrincipalId => $2);
155             push @results, $msg;
156     }
157 }
158 # }}}
159
160 # {{{ Add new watchers
161 foreach my  $key (keys %ARGS) {
162     #They're in this order because otherwise $1 gets clobbered :/
163     if ( ($ARGS{$key} =~ /^(AdminCc|Cc)$/) and
164          ($key =~ /^Queue-AddWatcher-Principal-(\d*)$/) ) {
165         $RT::Logger->debug("Adding a watcher $1 to ".$ARGS{$key}."\n");
166         my ($code, $msg) = $QueueObj->AddWatcher(Type => $ARGS{$key},
167                                                              PrincipalId => $1);
168         push @results, $msg;
169     }
170 }
171
172 # }}}
173
174  
175
176 if (!length $ARGS{'UserString'}) {
177 $user_msg = loc("No principals selected.");
178  }
179 else {
180     $Users = new RT::Users($session{'CurrentUser'});
181     $Users->Limit(FIELD => $ARGS{'UserField'},
182                  VALUE => $ARGS{'UserString'},
183                  OPERATOR => $ARGS{'UserOp'});
184      }
185
186 if (!length $ARGS{'GroupString'}) {
187 $group_msg = loc("No principals selected.");
188  }
189 else {
190 $Groups = new RT::Groups($session{'CurrentUser'});
191 $Groups->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'UserDefined');
192 $Groups->Limit(FIELD => $ARGS{'GroupField'},
193                 VALUE => $ARGS{'GroupString'},
194                 OPERATOR => $ARGS{'GroupOp'});
195      }
196
197 $current_tab = 'Admin/Queues/People.html?id='.$QueueObj->id;
198 </%INIT>
199
200 <%ARGS>
201 $UserField => 'Name'
202 $UserOp => '='
203 $UserString => undef
204 $GroupField => 'Name'
205 $GroupOp => '='
206 $GroupString => undef
207 $Type => undef
208 $id => undef
209 </%ARGS>
210