import rt 3.4.6
[freeside.git] / rt / html / Admin / Groups / Modify.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC 
6 %#                                          <jesse@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., 675 Mass Ave, Cambridge, MA 02139, USA.
26 %# 
27 %# 
28 %# CONTRIBUTION SUBMISSION POLICY:
29 %# 
30 %# (The following paragraph is not intended to limit the rights granted
31 %# to you to modify and distribute this software under the terms of
32 %# the GNU General Public License and is only of importance to you if
33 %# you choose to contribute your changes and enhancements to the
34 %# community by submitting them to Best Practical Solutions, LLC.)
35 %# 
36 %# By intentionally submitting any modifications, corrections or
37 %# derivatives to this work, or any other work intended for use with
38 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 %# you are the copyright holder for those contributions and you grant
40 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
41 %# royalty-free, perpetual, license to use, copy, create derivative
42 %# works based on those contributions, and sublicense and distribute
43 %# those contributions and any derivatives thereof.
44 %# 
45 %# END BPS TAGGED BLOCK }}}
46 <& /Admin/Elements/Header, Title => $title  &>
47
48 <& /Admin/Elements/GroupTabs, 
49     GroupObj => $Group, 
50     current_tab => $current_tab, 
51     Title => $title &>
52 <& /Elements/ListActions, actions => \@results &>
53
54
55
56 <FORM ACTION="<%$RT::WebPath%>/Admin/Groups/Modify.html" METHOD=POST ENCTYPE="multipart/form-data">
57
58 %unless ($Group->Id) {
59 <INPUT TYPE=HIDDEN NAME=id VALUE="new">
60 % } else {
61 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$Group->Id%>">
62 % }
63 <TABLE>
64 <TR><TD ALIGN=RIGHT>
65 <&|/l&>Name</&>:
66 </TD>
67 <TD><INPUT name="Name" value="<%$Group->Name%>"></TD>
68 </TR>
69 <TR>
70 <TD ALIGN=RIGHT>
71 <&|/l&>Description</&>:</TD><TD COLSPAN=3><INPUT name="Description" value="<%$Group->Description%>" size=60></TD>
72 </TR>
73 % my $CFs = $Group->CustomFields;
74 % while (my $CF = $CFs->Next) {
75 <TR VALIGN="TOP"><TD ALIGN="RIGHT">
76 <% $CF->Name %>:
77 </TD><TD>
78 <& /Elements/EditCustomField, CustomField => $CF, Object => $Group &>
79 </TD></TR>
80 % }
81 <TR>
82 <TD COLSPAN=2>
83 <INPUT TYPE=HIDDEN NAME="SetEnabled" VALUE="1">
84 <INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>> <&|/l&>Enabled (Unchecking this box disables this group)</&><BR>
85 </TR>
86 <& /Elements/Callback, GroupObj => $Group, results => \@results, %ARGS &>
87 </TABLE>
88 <& /Elements/Submit, Label => loc('Save Changes'), Reset => 1 &>
89 </form>
90 <%INIT>
91
92 my $current_tab;
93 my  ($title, @results, $Disabled, $EnabledChecked);
94
95 my $Group = RT::Group->new($session{'CurrentUser'});
96
97 if ($Create) {
98     $current_tab = 'Admin/Groups/Modify.html?Create=1';
99     $title = loc("Create a new group");
100
101
102 else {
103     $current_tab = 'Admin/Groups/Modify.html?id='.$id;
104     if ($id eq 'new' ) {
105         
106         my ($create_id, $create_msg) = $Group->CreateUserDefinedGroup(Name =>
107     "$Name");
108         unless ($create_id) {
109             Abort (loc("Group could not be created: [_1]", $create_msg));
110      }
111         $id = $Group->Id;
112     }
113     else {
114         $Group->Load($id) || Abort('Could not load group');
115     }
116
117
118     if ($id) {
119         $title = loc("Modify the group [_1]", $Group->Name);
120
121     }   
122
123     # If the create failed
124     else {
125         $title = loc("Create a new group");
126         $Create = 1;
127     }    
128     
129 }
130
131 if ($id) {
132     
133     my @fields = qw(Description Name );
134     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
135                                             Object => $Group,
136                                             ARGSRef => \%ARGS );
137     push (@results,@fieldresults);
138     push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $Group );
139 }
140
141 #we're asking about enabled on the web page but really care about disabled.
142 if ($Enabled == 1) {
143     $Disabled = 0;
144 }       
145 else {
146     $Disabled = 1;
147 }
148 if  ( ($SetEnabled) and ( $Disabled != $Group->Disabled) ) { 
149     my  ($code, $msg) = $Group->SetDisabled($Disabled);
150     push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
151 }
152
153 unless ($Group->Disabled()) {
154     $EnabledChecked ="CHECKED";
155 }
156
157
158 </%INIT>
159
160
161 <%ARGS>
162 $Create => undef
163 $Name => undef
164 $Description => undef
165 $SetEnabled => undef
166 $Enabled => undef
167 $id => undef
168 </%ARGS>