rt 4.2.13 ticket#13852
[freeside.git] / rt / share / html / Admin / Groups / Modify.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2016 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 <& /Admin/Elements/Header, Title => $title  &>
49
50 <& /Elements/Tabs &>
51 <& /Elements/ListActions, actions => \@results &>
52
53
54
55 <form action="<%RT->Config->Get('WebPath')%>/Admin/Groups/Modify.html" name="ModifyGroup" method="post" enctype="multipart/form-data">
56
57 %unless ($Group->Id) {
58 <input type="hidden" class="hidden" name="id" value="new" />
59 % } else {
60 <input type="hidden" class="hidden" name="id" value="<%$Group->Id%>" />
61 % }
62 <table>
63 <tr><td align="right">
64 <&|/l&>Name</&>:
65 </td>
66 <td><input name="Name" value="<%$Group->Name||$Name||''%>" /></td>
67 </tr>
68 <tr>
69 <td align="right">
70 <&|/l&>Description</&>:</td><td colspan="3"><input name="Description" value="<%$Group->Description||$Description||''%>" size="60" /></td>
71 </tr>
72 % my $CFs = $Group->CustomFields;
73 % while (my $CF = $CFs->Next) {
74 <tr valign="top"><td align="right">
75 <% $CF->Name %>:
76 </td><td>
77 <& /Elements/EditCustomField, CustomField => $CF, 
78                               Object => $Group, &>
79 </td></tr>
80 % }
81 <tr>
82 <td colspan="2">
83 <input type="hidden" class="hidden" name="SetEnabled" value="1" />
84 <input type="checkbox" class="checkbox" id="Enabled" name="Enabled" value="1" <%$EnabledChecked%> />
85 <label for="Enabled"><&|/l&>Enabled (Unchecking this box disables this group)</&></label><br />
86 </td>
87 </tr>
88 % $m->callback( %ARGS, GroupObj => $Group, results => \@results );
89 </table>
90 % if ( $Create ) {
91 <& /Elements/Submit, Label => loc('Create'), Reset => 1 &>
92 % } else {
93 <& /Elements/Submit, Label => loc('Save Changes'), Reset => 1 &>
94 % }
95 </form>
96 <%INIT>
97
98 my  ($title, @results, @warnings, $Disabled, $EnabledChecked);
99
100 my $Group = RT::Group->new($session{'CurrentUser'});
101
102 if ($Create) {
103     $title = loc("Create a new group");
104 } else {
105     if ($id eq 'new' ) {
106         my ($create_id, $create_msg) = $Group->CreateUserDefinedGroup(Name => $Name );
107         if ($create_id) {
108             $id = $Group->Id;
109             push @results, $create_msg;
110         } else {
111             push @results, loc("Group could not be created: [_1]", $create_msg);
112         }
113     } else {
114         $Group->Load($id) || Abort('Could not load group');
115     }
116
117     if ($Group->Id) {
118         $title = loc("Modify the group [_1]", $Group->Name);
119     }
120
121     # If the create failed
122     else {
123         $title = loc("Create a new group");
124         $Create = 1;
125     }
126 }
127
128 if ($Group->Id) {
129     my @fields = qw(Description Name );
130     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
131                                             Object => $Group,
132                                             ARGSRef => \%ARGS );
133     push (@results,@fieldresults);
134     push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $Group );
135
136     # Warn about duplicate groups
137     my $dupcheck = RT::Groups->new(RT->SystemUser);
138     $dupcheck->LimitToUserDefinedGroups();
139     $dupcheck->Limit( FIELD => 'Name', VALUE => $Group->Name, CASESENSITIVE => 0 );
140     if ($dupcheck->Count > 1) {
141         push @warnings, loc("There is more than one group with the name '[_1]'.  This may cause inconsistency in parts of the admin interface, and therefore it's recommended you rename the conflicting groups.", $Group->Name);
142     }
143 }
144
145 #we're asking about enabled on the web page but really care about disabled.
146 if (defined $Enabled && $Enabled == 1) {
147     $Disabled = 0;
148 } else {
149     $Disabled = 1;
150 }
151 if  ( $Group->Id and ($SetEnabled) and ( $Disabled != $Group->Disabled) ) {
152     my  ($code, $msg) = $Group->SetDisabled($Disabled);
153     push @results, $msg;
154 }
155
156 # This code does automatic redirection if any updates happen.
157 MaybeRedirectForResults(
158     Actions     => \@results,
159     Arguments   => { id => $Group->id },
160 ) if $Group->Id;
161
162 push @results, @warnings;
163
164 $EnabledChecked = ( $Group->Disabled() ? '' : 'checked="checked"' );
165
166 </%INIT>
167
168
169 <%ARGS>
170 $Create => undef
171 $Name => undef
172 $Description => undef
173 $SetEnabled => undef
174 $Enabled => undef
175 $id => '' unless defined $id
176 </%ARGS>