This commit was generated by cvs2svn to compensate for changes in r2526,
[freeside.git] / rt / webrt / Admin / Queues / People.html
1 <& /Elements/Header, Title => 'Modify people related to queue ' . $QueueObj->Name &>
2 <& /Admin/Elements/QueueTabs, id => $id  &>
3
4 <& /Elements/ListActions, actions => \@results &>
5
6  
7 <FORM METHOD=POST ACTION="People.html">
8 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$QueueObj->Id%>">
9 <& /Elements/TitleBoxStart, title => 'Modify watchers for queue \''.$QueueObj->Name ."'",   width => "100%" &>
10
11 <TABLE WIDTH=100%>
12 <TR>
13 <TD VALIGN=TOP >
14
15 <h3>Current watchers</h3>
16 <i>(Check box to delete)</i><br><BR>
17
18
19 Cc:
20
21 <ul>
22
23 %# Print out a placeholder if there are none.
24 %if ($cc->Count == 0 ) {
25 <li><i>none</i>
26 % }
27
28 %while (my $watcher=$cc->Next) {
29 <li>
30 <INPUT TYPE=CHECKBOX NAME="DelWatcher<%$watcher->id%>" UNCHECKED>
31 %# account
32 %if ($watcher->IsUser) { 
33 <a href="<%$RT::WebPath%>/Admin/Users/Modify.html?id=<%$watcher->OwnerObj->id%>">
34 <%$watcher->OwnerObj->RealName%></a>:
35 %} else {
36 Email address:
37 %}
38 <i><%$watcher->Email%></i>
39 %}
40 </ul>
41
42
43 Administrative Cc:
44 <UL>
45 %# Print out a placeholder if there are none.
46 %if ($admincc->Count == 0 ) {
47 <li><i>none</i>
48 % }
49
50 %while (my $watcher=$admincc->Next) {
51 <li><INPUT TYPE=CHECKBOX NAME="DelWatcher<%$watcher->id%>" UNCHECKED>
52 %# account
53 %if ($watcher->IsUser) { 
54 <a href="<%$RT::WebPath%>/Admin/Users/Modify.html?id=<%$watcher->OwnerObj->id%>">
55 <%$watcher->OwnerObj->RealName%></a>:
56 %} else {
57 Email address:
58 %}
59 <i><%$watcher->Email%></i>
60 %}
61 </UL>
62 </TD>
63
64 <TD VALIGN=TOP>
65 <h3>New watchers</h3>
66 Find people whose<BR>
67 <& /Elements/SelectUsers &>
68
69 <BR>
70 Add new watchers:<br>
71
72 % if ($msg) {
73 <i><%$msg%></i>
74 % } elsif ($Users) {
75 <ul>
76 % while (my $u = $Users->Next ) {
77 <li><&/Elements/SelectWatcherType, Scope=>'queue', Name => "WatcherTypeUser".$u->Id &> <%$u->Name%>
78 (<%$u->RealName%>)
79 % }
80 </ul>
81 % }
82
83 </TD>
84 </TR>
85 </TABLE>
86
87
88
89
90
91 <& /Elements/TitleBoxEnd &>
92 <& /Elements/Submit, Label => 'Save Changes', Caption => "If you've updated anything above, be sure to" &>
93 </form>
94
95 <%INIT>
96
97 my ($field, @results, $User, $Users, $watcher, $key, $msg);
98 # {{{ Load the queue
99 #If we get handed two ids, mason will make them an array. bleck.
100 # We want teh first one. Just because there's no other sensible way
101 # to deal
102
103
104
105 my $QueueObj = new RT::Queue($session{'CurrentUser'});
106 $QueueObj->Load($id) || Abort("Couldn't load queue '$id'");
107 # }}}
108
109 # {{{ Delete deletable watchers
110
111 foreach $key (keys %ARGS) {
112     if (($key =~ /^DelWatcher(\d*)$/) and
113         ($ARGS{$key})) {
114         $RT::Logger->debug("Deleting watcher $1\n");
115         my ($code, $msg) = $QueueObj->DeleteWatcher($1);
116         
117         push @results, $msg;
118     }
119 }
120 # }}}
121
122 # {{{ Add new watchers
123 foreach $key (keys %ARGS) {
124     #They're in this order because otherwise $1 gets clobbered :/
125     if ( ($ARGS{$key} =~ /^(AdminCc|Cc)$/) and
126          ($key =~ /^WatcherTypeUser(\d*)$/) ) {
127         $RT::Logger->debug("Adding a watcher $1 to ".$ARGS{$key}."\n");
128         my ($code, $msg) = 
129           $QueueObj->AddWatcher(Type => $ARGS{$key},
130                                  Owner => $1);
131         push @results, $msg;
132     }
133 }
134
135 # }}}
136
137
138
139 my $admincc = $QueueObj->AdminCc;
140 my $cc = $QueueObj->Cc;
141  
142
143 if (!$ARGS{'UserString'}) {
144 $msg = "No users selected.";
145  }
146 else {
147     $Users = new RT::Users($session{'CurrentUser'});
148     $Users->Limit(FIELD => $ARGS{'UserField'},
149                  VALUE => $ARGS{'UserString'},
150                  OPERATOR => $ARGS{'UserOp'});
151      }
152 </%INIT>
153
154 <%ARGS>
155 $UserField => 'Name'
156 $UserOp => '='
157 $UserString => undef
158 $Type => undef
159 $id => undef
160 </%ARGS>
161