summaryrefslogtreecommitdiff
path: root/rt/webrt/Admin/Keywords/index.html
blob: 12814ec0306ecc3586eedbb0528ca7de5180cf90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<& /Elements/Header, Title => 'Admin/Keywords' &>
<& /Admin/Elements/Tabs, current_tab => 'Admin/Keywords/' &>

<& /Elements/ListActions, actions => \@Actions &>

<& /Elements/TitleBoxStart, title => 'Keywords' &>
<a href="<%$RT::WebPath%>/Admin/Keywords/?RootId=<%$Root->Parent%>"><%$Root->Path%></a>
<UL>
<FORM METHOD=POST ACTION="index.html">
<input type=hidden name=RootId value="<%$RootId%>">


% while (my $key = $Keywords->Next) {
    <LI>
% if ($Edit == $key->id) {
      <input name="KeyName-<%$key->id%>" value="<%$key->Name%>">
	  <input type=submit value="Update">
	    <input type=submit name="Disable-<%$key->id%>" value="Disable">
% } else {
	      <A HREF="?RootId=<%$key->id%>"><%$key->Name%></A>
% if ($key->Disabled) {
	<input type=submit name="Enable-<%$key->id%>" value="Enable">
% } else {
      [<a href="?Edit=<%$key->id%>&RootId=<%$Root->Id%>">edit</a>]
% }
% }


	  </LI>
% }
	  <LI>
	    <input name="KeyName-New"> <input type=submit value="Add">
</UL>
<BR>
	  <input type="checkbox" name="ShowDisabled"> Include disabled items in listing.
	<input type=submit value="Go!">

</FORM>

<& /Elements/TitleBoxEnd &>
<%INIT>
my (@Actions);
  
if ($ARGS{'KeyName-New'}) {
    my $NewKey = new RT::Keyword($session{'CurrentUser'});
    my ($val, $msg) = $NewKey->Create( Parent => $RootId, Name => $ARGS{'KeyName-New'});
    push (@Actions, $msg);
}

my $arg;
foreach $arg (keys %ARGS) {
    if ($arg =~ /^Disable-(\d*)$/) {
	my $id = $1;
	my $keyword = new RT::Keyword($session{'CurrentUser'});
	$keyword->Load($id);
	my ($val, $msg) = $keyword->SetDisabled(1);
	push (@Actions, $msg);


    }	
    elsif ($arg =~ /^Enable-(\d*)$/) {
	my $id = $1;
	my $keyword = new RT::Keyword($session{'CurrentUser'});
	$keyword->Load($id);
	my ($val, $msg) = $keyword->SetDisabled(0);
	push (@Actions, $msg);
    }
    elsif ($arg =~ /^KeyName-(\d*)$/) {
	my $id = $1;
	my $keyword = new RT::Keyword ($session{'CurrentUser'});
	$keyword->Load($id);
	if ($keyword->Name() ne $ARGS{"$arg"}) {
	    my ($val, $msg) = $keyword->SetName($ARGS{"$arg"});
	    push (@Actions, $msg);
	}	
	if (($ARGS{"KeyParent-$id"}) && 
	    ($keyword->Parent ne $ARGS{"KeyParent-$id"})) {
	    my ($val, $msg) = $keyword->SetParent($ARGS{"KeyParent-$id"});
	    push (@Actions, $msg);
	}	
    }	
}


my $Root = new RT::Keyword($session{'CurrentUser'});
my $Keywords;
#If we have a root load it.
if ($RootId != 0) {
    $Root->Load($RootId);
    $Keywords = $Root->Children();
    
}
else {
    $Keywords = new RT::Keywords($session{'CurrentUser'});
    $Keywords->LimitToParent(0);
}

if ($ShowDisabled) {
    $Keywords->{'find_disabled_rows'} = 1;
}




</%INIT>
<%ARGS>
$RootId => 0
$Edit => undef
$ShowDisabled => 0
</%ARGS>