rt 4.0.23
[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-2015 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 <% loc($CF->Name) %>:
76 </td><td>
77 <& /Elements/EditCustomField, CustomField => $CF, 
78                               Object => $Group, 
79                               ($Create ? (NamePrefix => 'Object-RT::Group--CustomField-') 
80                                        : () )&>
81 </td></tr>
82 % }
83 <tr>
84 <td colspan="2">
85 <input type="hidden" class="hidden" name="SetEnabled" value="1" />
86 <input type="checkbox" class="checkbox" name="Enabled" value="1" <%$EnabledChecked%> /> <&|/l&>Enabled (Unchecking this box disables this group)</&><br />
87 </td>
88 </tr>
89 % $m->callback( %ARGS, GroupObj => $Group, results => \@results );
90 </table>
91 % if ( $Create ) {
92 <& /Elements/Submit, Label => loc('Create'), Reset => 1 &>
93 % } else {
94 <& /Elements/Submit, Label => loc('Save Changes'), Reset => 1 &>
95 % }
96 </form>
97 <%INIT>
98
99 my  ($title, @results, @warnings, $Disabled, $EnabledChecked);
100
101 my $Group = RT::Group->new($session{'CurrentUser'});
102
103 if ($Create) {
104     $title = loc("Create a new group");
105 } else {
106     if ($id eq 'new' ) {
107         my ($create_id, $create_msg) = $Group->CreateUserDefinedGroup(Name => $Name );
108         if ($create_id) {
109             $id = $Group->Id;
110             push @results, $create_msg;
111         } else {
112             push @results, loc("Group could not be created: [_1]", $create_msg);
113         }
114     } else {
115         $Group->Load($id) || Abort('Could not load group');
116     }
117
118     if ($Group->Id) {
119         $title = loc("Modify the group [_1]", $Group->Name);
120     }
121
122     # If the create failed
123     else {
124         $title = loc("Create a new group");
125         $Create = 1;
126     }
127 }
128
129 if ($Group->Id) {
130     my @fields = qw(Description Name );
131     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
132                                             Object => $Group,
133                                             ARGSRef => \%ARGS );
134     push (@results,@fieldresults);
135     push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $Group );
136
137     # Warn about duplicate groups
138     my $dupcheck = RT::Groups->new(RT->SystemUser);
139     $dupcheck->LimitToUserDefinedGroups();
140     $dupcheck->Limit( FIELD => 'Name', VALUE => $Group->Name );
141     if ($dupcheck->Count > 1) {
142         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);
143     }
144 }
145
146 #we're asking about enabled on the web page but really care about disabled.
147 if (defined $Enabled && $Enabled == 1) {
148     $Disabled = 0;
149 } else {
150     $Disabled = 1;
151 }
152 if  ( $Group->Id and ($SetEnabled) and ( $Disabled != $Group->Disabled) ) {
153     my  ($code, $msg) = $Group->SetDisabled($Disabled);
154     push @results, $msg;
155 }
156
157 # This code does automatic redirection if any updates happen.
158 MaybeRedirectForResults(
159     Actions     => \@results,
160     Arguments   => { id => $Group->id },
161 ) if $Group->Id;
162
163 push @results, @warnings;
164
165 $EnabledChecked = ( $Group->Disabled() ? '' : 'checked="checked"' );
166
167 </%INIT>
168
169
170 <%ARGS>
171 $Create => undef
172 $Name => undef
173 $Description => undef
174 $SetEnabled => undef
175 $Enabled => undef
176 $id => '' unless defined $id
177 </%ARGS>