import of rt 3.0.4
[freeside.git] / rt / html / Admin / Groups / Modify.html
1 %# BEGIN LICENSE BLOCK
2 %# 
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4 %# 
5 %# (Except where explictly superceded by other copyright notices)
6 %# 
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
10 %# from www.gnu.org.
11 %# 
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 %# General Public License for more details.
16 %# 
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
21 %# 
22 %# 
23 %# END LICENSE BLOCK
24 <& /Admin/Elements/Header, Title => $title  &>
25
26 <& /Admin/Elements/GroupTabs, 
27     GroupObj => $Group, 
28     current_tab => $current_tab, 
29     Title => $title &>
30 <& /Elements/ListActions, actions => \@results &>
31
32
33
34 <FORM ACTION="<%$RT::WebPath%>/Admin/Groups/Modify.html" METHOD=POST>
35
36 %unless ($Group->Id) {
37 <INPUT TYPE=HIDDEN NAME=id VALUE="new">
38 % } else {
39 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$Group->Id%>">
40 % }
41 <TABLE>
42 <TR><TD ALIGN=RIGHT>
43 <&|/l&>Name</&>:
44 </TD>
45 <TD><INPUT name="Name" value="<%$Group->Name%>"></TD>
46 </TR><TR>
47 <TD ALIGN=RIGHT>
48 <&|/l&>Description</&>:</TD><TD COLSPAN=3><INPUT name="Description" value="<%$Group->Description%>" size=60></TD>
49 </TR><TR>
50 <TD COLSPAN=2>
51 <INPUT TYPE=HIDDEN NAME="SetEnabled" VALUE="1">
52 <INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>> <&|/l&>Enabled (Unchecking this box disables this group)</&><BR>
53 </TR>
54 </TABLE>
55 <& /Elements/Submit, Caption => loc("Be sure to save your changes"), Reset => 1 &>
56 </form>
57 <%INIT>
58
59 my $current_tab;
60 my  ($title, @results, $Disabled, $EnabledChecked);
61
62 my $Group = RT::Group->new($session{'CurrentUser'});
63
64 if ($Create) {
65     $current_tab = 'Admin/Groups/Modify.html?Create=1';
66     $title = loc("Create a new group");
67
68
69 else {
70     $current_tab = 'Admin/Groups/Modify.html?id='.$id;
71     if ($id eq 'new' ) {
72         
73         my ($create_id, $create_msg) = $Group->CreateUserDefinedGroup(Name =>
74     "$Name");
75         unless ($create_id) {
76             Abort (loc("Group could not be created: [_1]", $create_msg));
77      }
78         $id = $Group->Id;
79     }
80     else {
81         $Group->Load($id) || Abort('Could not load group');
82     }
83
84
85     if ($id) {
86         $title = loc("Modify the group [_1]", $Group->Name);
87
88     }   
89
90     # If the create failed
91     else {
92         $title = loc("Create a new group");
93         $Create = 1;
94     }    
95     
96 }
97
98 if ($id) {
99     
100     my @fields = qw(Description Name );
101     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
102                                             Object => $Group,
103                                             ARGSRef => \%ARGS );
104     push (@results,@fieldresults);
105 }
106
107 #we're asking about enabled on the web page but really care about disabled.
108 if ($Enabled == 1) {
109     $Disabled = 0;
110 }       
111 else {
112     $Disabled = 1;
113 }
114 if  ( ($SetEnabled) and ( $Disabled != $Group->Disabled) ) { 
115     my  ($code, $msg) = $Group->SetDisabled($Disabled);
116     push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
117 }
118
119 unless ($Group->Disabled()) {
120     $EnabledChecked ="CHECKED";
121 }
122
123
124 </%INIT>
125
126
127 <%ARGS>
128 $Create => undef
129 $Name => undef
130 $Description => undef
131 $SetEnabled => undef
132 $Enabled => undef
133 $id => undef
134 </%ARGS>