1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
6 %# <sales@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
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
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.
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.
30 %# CONTRIBUTION SUBMISSION POLICY:
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.)
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.
47 %# END BPS TAGGED BLOCK }}}
48 <& /Admin/Elements/Header, Title => $title &>
50 <& /Elements/ListActions, actions => \@results &>
52 <form name="ModifyClass" action="<% RT->Config->Get('WebPath') %>/Admin/Articles/Classes/Modify.html" method="post">
53 <input type="hidden" name="Submitted" value="1" />
55 <input type="hidden" name="id" value="new" />
57 <input type="hidden" name="id" value="<%$ClassObj->Id%>" />
62 <td align="right"><&|/l&>Class Name</&>: </td>
63 <td><input name="Name" value="<% $ClassObj->Name || $Name || ''%>" /></td>
66 <td align="right"><&|/l&>Description</&>:</td>
67 <td><input name="Description" value="<% $ClassObj->Description || $Description || '' %>" size=60 /></td>
72 <input type="checkbox" id="Enabled" name="Enabled" value="1" <%$EnabledChecked%>>
73 <label for="Enabled"><&|/l&>Enabled (Unchecking this box disables this class)</&></label>
79 <input type="checkbox" id="HotList" name="HotList" value="1" <%$HotListChecked%>>
80 <label for="HotList"><&|/l&>All Articles in this class should be listed in a dropdown of the ticket reply page</&></label>
85 <h3><&|/l&>When inserting articles in this class into emails:</&></h3>
88 <input type="checkbox" id="Include-Name" name="Include-Name" value="1" <% $include{Name} %>>
89 <label for="Include-Name"><&|/l&>Include article name</&></label>
92 <input type="checkbox" id="Include-Summary" name="Include-Summary" value="1" <% $include{Summary} %>>
93 <label for="Include-Summary"><&|/l&>Include article summary</&></label>
96 % while (my $cf = $cfs->Next) {
97 <li><&|/l, $cf->Name &>Include custom field '[_1]'</&>
100 <input type="checkbox" id="Include-CF-Title-<% $cf->Id %>" name="Include-CF-Title-<% $cf->Id %>" <% $include{"CF-Title-".$cf->Id} %> />
101 <label for="Include-CF-Title-<% $cf->Id %>"><&|/l&>Title</&></label>
104 <input type="checkbox" id="Include-CF-Value-<% $cf->Id %>" name="Include-CF-Value-<% $cf->Id %>" <% $include{"CF-Value-".$cf->Id} %> />
105 <label for="Include-CF-Value-<% $cf->Id %>"><&|/l&>Value</&></label>
112 % if ( @$subject_cfs ) {
113 <h3><&|/l&>Change email subject:</&></h3>
114 <p><&|/l&>If a Custom Field is selected, the Subject of your outgoing email will be overridden by this article.</&></p>
116 <& /Widgets/Form/Select,
117 Name => 'SubjectOverride',
118 DefaultLabel => loc('No Subject Override'),
119 Values => $subject_cfs,
120 ValuesLabel => $subject_cf_labels,
121 CurrentValue => $ClassObj->SubjectOverride,
125 %$m->callback( CallbackName => 'BeforeSubmit', CustomFields => $cfs, ClassObj => $ClassObj );
128 <& /Elements/Submit, Label => loc('Create') &>
130 <& /Elements/Submit, Label => loc('Save Changes') &>
136 my $ClassObj = RT::Class->new($session{'CurrentUser'});
137 my ($title, @results, $Disabled);
140 $title = loc("Create a Class");
144 ($val, $msg) = $ClassObj->Create(Name => $Name);
149 push @results, loc('Class could not be created: [_1]', $msg);
152 $ClassObj->Load($id) || $ClassObj->Load($Name) || $m->comp("/Elements/Error", Why => "Couldn't load class '$Name'");
153 $val = $ClassObj->id;
157 $title = loc('Modify the Class [_1]', $ClassObj->Name);
160 $title = loc("Create a Class");
165 if ($ClassObj->Id()) {
167 if ($ARGS{SubjectOverride}) {
168 $ARGS{SubjectOverride} = $m->comp('/Widgets/Form/Select:Process',
170 Name => 'SubjectOverride',
171 DefaultValue => (''),
175 $ARGS{HotList} ||= 0 if $Submitted;
176 my @attribs= qw(Description Name HotList SubjectOverride);
177 $m->callback( CallbackName => 'AttributeList', Attributes => \@attribs, ARGSRef => \%ARGS );
178 push @results, UpdateRecordObject( AttributesRef => \@attribs,
183 #we're asking about enabled on the web page but really care about disabled.
184 if ((defined $Enabled && $Enabled == 1) or (not defined $Enabled and $Create)) {
190 my %include = (Name => 1, Summary => 1);
191 my $subject_cfs = [];
192 my $subject_cf_labels = {};
195 if ( $ClassObj->id ) {
196 $cfs = $ClassObj->ArticleCustomFields;
197 while ( my $cf = $cfs->Next ) {
198 $include{"CF-Title-".$cf->Id} = $include{"CF-Value-".$cf->Id} = 1;
199 push @$subject_cfs,$cf->Id;
200 $subject_cf_labels->{$cf->Id} = $cf->Name;
204 if ( $ClassObj->id && $Submitted ) {
205 if ( $Disabled != $ClassObj->Disabled) {
206 my ($code, $msg) = $ClassObj->SetDisabled($Disabled);
207 push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
210 for (keys %include) {
211 if ($ARGS{"Include-$_"}) {
212 $ClassObj->DeleteAttribute("Skip-$_");
214 $ClassObj->SetAttribute(Name => "Skip-$_", Content => 1);
219 # This code does automatic redirection if any updates happen.
220 MaybeRedirectForResults(
221 Actions => \@results,
222 Arguments => { id => $ClassObj->Id },
226 if ( $ClassObj->id ) {
227 $include{$_} = not $ClassObj->FirstAttribute("Skip-$_") for keys %include;
230 $include{$_} = $include{$_} ? " CHECKED" : "" for keys %include;
232 my $EnabledChecked = ($Create ? $Disabled : $ClassObj->Disabled()) ? "" : "CHECKED";
233 my $HotListChecked = $ClassObj->id && $ClassObj->HotList ? "CHECKED" : "";
242 $Description => undef