1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
<& /Admin/Elements/Header, Title => 'Edit keywords' &>
<& /Admin/Elements/QueueTabs, id => $QueueObj->Id &>
<& /Elements/ListActions, actions => \@actions &>
<& /Elements/TitleBoxStart, title => $description &>
<h2>Global Keyword Selections</h2>
<& /Admin/Elements/ListGlobalKeywordSelects &>
<BR>
<FORM METHOD=POST ACTION="Keywords.html">
<INPUT TYPE=HIDDEN NAME=id VALUE="<%$id%>">
% if ($KeywordSelects->Count > 0 ) {
<h2>Queue Keyword Selections</h2>
<TABLE>
<TR><TD>Delete</TD></TR>
% while (my $keywordselect = $KeywordSelects->Next ) {
<TR>
<TD><INPUT TYPE="CHECKBOX" NAME="KeywordSelect-<%$keywordselect->Id%>-Delete"></TD>
<TD><& /Admin/Elements/SelectKeywordSelect, KeywordSelect => $keywordselect &></TD>
</TR>
% }
</TABLE>
% }
Add a keyword selection to this queue:
%my $ks = new RT::KeywordSelect($session{'CurrentUser'});
<ul>
<li><& /Admin/Elements/SelectKeywordSelect, KeywordSelect => $ks, NamePrefix => 'new' &></li>
</ul>
<& /Elements/TitleBoxEnd &>
<& /Elements/Submit &>
</FORM>
<%init>
my (@actions);
my $KeywordSelects = new RT::KeywordSelects ($session{'CurrentUser'});
unless ($id =~ /^\d+$/) {
Abort("$id isn't a valid Queue id.");
}
unless ($KeywordSelects->LimitToQueue($id)) {
Abort("Couldn't load KeywordSelects.");
}
my $QueueObj = new RT::Queue($session{'CurrentUser'});
$QueueObj->Load($id);
my $description = "Modify Keyword selections for queue '". $QueueObj->Name ."'";
# {{{ if we're trying to create a new keyword select
if ($ARGS{'KeywordSelect-new-Name'}) {
my $NewKeywordSelect = new RT::KeywordSelect($session{'CurrentUser'});
my ($retval, $msg) = $NewKeywordSelect->Create ( Keyword => $ARGS{'KeywordSelect-new-Keyword'},
ObjectField => 'Queue',
ObjectType => 'Ticket',
ObjectValue => $QueueObj->Id,
Name => $ARGS{'KeywordSelect-new-Name'},
Single => $ARGS{'KeywordSelect-new-Single'},
Depth => $ARGS{'KeywordSelect-new-Depth'}
);
push (@actions, $msg);
}
# }}}
# {{{ if we're trying to delete the keywordselect
foreach my $key (keys %ARGS) {
if ($key =~ /^KeywordSelect-(\d+)-Delete$/) {
my $id = $1;
my $keywordselect = new RT::KeywordSelect($session{'CurrentUser'});
$keywordselect->Load($id) || push @actions, "Couldn't load keywordSelect";
my ($val, $msg) = $keywordselect->SetDisabled(1);
if ($val) {
push @actions, 'KeywordSelect disabled.';
}
else {
push @actions, $msg;
}
}
}
# }}}
# {{{ if we're modifying keyword selects
my @fields = qw(Name Keyword Single Depth);
while (my $ks = $KeywordSelects->Next) {
foreach my $field (@fields) {
if (defined ($ARGS{"KeywordSelect-".$ks->Id."-".$field}) &&
($ARGS{"KeywordSelect-".$ks->Id."-".$field} ne $ks->$field())) {
my $method = "Set$field";
my ($val, $msg) = $ks->$method($ARGS{"KeywordSelect-".$ks->Id."-".$field});
push @actions, "Keyword Select ". $ks->Name."/$field:".$msg;
}
}
}
# }}}
</%init>
<%ARGS>
$id => undef #some identifier that a Queue could
</%ARGS>
|