import rt 3.0.12
[freeside.git] / rt / html / User / 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 <& /Elements/Header, Title => $title &>
25
26 <& /User/Elements/GroupTabs, 
27     GroupObj => $Group, 
28     current_subtab => $current_tab, 
29     Title => $title &>
30
31 <& /Elements/ListActions, actions => \@results &>
32
33
34 <FORM ACTION="<%$RT::WebPath%>/User/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, Label => loc('Create'), 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 = 'User/Groups/Modify.html?Create=1';
66     $title = loc("Create a new personal group");
67
68 else {
69     if ( $id eq 'new' ) {
70
71         my ( $id, $msg ) = $Group->CreatePersonalGroup(
72                              Name        => "$Name",
73                              PrincipalId => $session{'CurrentUser'}->PrincipalId
74         );
75         unless ($id) {
76             Abort( loc("Could not create group") );
77         }
78         $id = $Group->Id;
79     }
80     else {
81         $Group->Load($id) || Abort( loc('Could not load group') );
82     }
83
84     if ($id) {
85         $title = loc( "Modify the group [_1]", $Group->Name );
86
87     }
88
89     # If the create failed
90     else {
91         $title  = loc("Create a new personal group");
92         $Create = 1;
93     }
94
95     $current_tab = 'User/Groups/Modify.html?id=' . $Group->Id;
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 </%INIT>
124
125
126 <%ARGS>
127 $Create => undef
128 $Name => undef
129 $Description => undef
130 $SetEnabled => undef
131 $Enabled => undef
132 $id => undef
133 </%ARGS>