This commit was generated by cvs2svn to compensate for changes in r10640,
[freeside.git] / rt / share / html / Admin / Queues / People.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
6 %#                                          <sales@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,
99     Scope => 'queue',
100     Name => "Queue-AddWatcher-Principal-". $u->PrincipalId,
101 &>
102 <& /Elements/ShowUser, User => $u &></li>
103 % }
104 </ul>
105 % }
106
107 <p>
108 <strong><&|/l&>Groups</&></strong>
109
110 % if ($group_msg) {
111 <br />
112 <em><%$group_msg%></em>
113 % } elsif ($Groups) {
114 <ul>
115 % while (my $g = $Groups->Next ) {
116 <li><&/Elements/SelectWatcherType, Scope=>'queue', Name =>
117 "Queue-AddWatcher-Principal-".$g->PrincipalId &> <%$g->Name%>
118 (<%$g->Description%>)
119 % }
120 </ul>
121 % }
122
123 </td>
124 </tr>
125 </table>
126
127
128
129
130 <& /Elements/Submit, Label => loc('Save Changes'), Caption => loc("If you've updated anything above, be sure to"), Reset => 1 &>
131 </form>
132
133 <%INIT>
134
135 my $current_tab;
136 my ($field, @results, $User, $Users, $Groups, $watcher, $user_msg, $group_msg);
137
138 # {{{ Load the queue
139 #If we get handed two ids, mason will make them an array. bleck.
140 # We want teh first one. Just because there's no other sensible way
141 # to deal
142
143
144
145 my $QueueObj = new RT::Queue($session{'CurrentUser'});
146 $QueueObj->Load($id) || Abort(loc("Couldn't load queue", $id));
147 # }}}
148
149 unless ($OnlySearchForPeople or $OnlySearchForGroup) {
150 # {{{ Delete deletable watchers
151
152     foreach my $key (keys %ARGS) {
153             my $id = $QueueObj->Id;
154
155         if (($key =~ /^Queue-$id-DeleteWatcher-Type-(.*?)-Principal-(\d*)$/)) {;
156             my ($code, $msg) = $QueueObj->DeleteWatcher(Type => $1,
157                                                         PrincipalId => $2);
158             push @results, $msg;
159         }
160     }
161 # }}}
162
163 # {{{ Add new watchers
164     foreach my  $key (keys %ARGS) {
165         #They're in this order because otherwise $1 gets clobbered :/
166         if ( ($ARGS{$key} =~ /^(AdminCc|Cc)$/) and
167          ($key =~ /^Queue-AddWatcher-Principal-(\d*)$/) ) {
168         $RT::Logger->debug("Adding a watcher $1 to ".$ARGS{$key}."\n");
169         my ($code, $msg) = $QueueObj->AddWatcher(Type => $ARGS{$key},
170                                                  PrincipalId => $1);
171         push @results, $msg;
172         }
173     }
174
175 # }}}
176 }
177  
178
179 if (!length $ARGS{'UserString'}) {
180 $user_msg = loc("No principals selected.");
181  }
182 else {
183     $Users = new RT::Users($session{'CurrentUser'});
184     $Users->Limit(FIELD => $ARGS{'UserField'},
185                  VALUE => $ARGS{'UserString'},
186                  OPERATOR => $ARGS{'UserOp'});
187      }
188
189 if (!length $ARGS{'GroupString'}) {
190 $group_msg = loc("No principals selected.");
191  }
192 else {
193 $Groups = new RT::Groups($session{'CurrentUser'});
194 $Groups->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'UserDefined');
195 $Groups->Limit(FIELD => $ARGS{'GroupField'},
196                 VALUE => $ARGS{'GroupString'},
197                 OPERATOR => $ARGS{'GroupOp'});
198      }
199
200 $current_tab = 'Admin/Queues/People.html?id='.$QueueObj->id;
201 </%INIT>
202
203 <%ARGS>
204 $OnlySearchForPeople => undef
205 $OnlySearchForGroup => undef
206 $UserField => 'Name'
207 $UserOp => '='
208 $UserString => undef
209 $GroupField => 'Name'
210 $GroupOp => '='
211 $GroupString => undef
212 $Type => undef
213 $id => undef
214 </%ARGS>
215