File: edit.pl

package info (click to toggle)
webmin-ldap-netgroups 0.17
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 240 kB
  • ctags: 35
  • sloc: perl: 856; makefile: 65; sh: 15
file content (198 lines) | stat: -rw-r--r-- 6,237 bytes parent folder | download
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
sub edit_netgroup {

    my $Netgroup = $struct->{netgroups}->{$in{group}};

    my $output = qq~
<a href="/ldap-netgroups">$text{back}</a><br>
<table width="500" border="0" class="ng">
    <tr>
      <td><div align="center">$in{group}</div></td>
    </tr>
    <tr>
      <td><table width="500" border="0" class="ng">
          <tr> 
            <td><table width="500" border="0" cellspacing="0" class="ng">
                <tr class="header"> 
                  <td width="20">&nbsp;</td>
                  <td width="500">$text{hostname}</td>
                </tr>
    <form action="$ENV{SCRIPT_NAME}" method=post>
    <input type="hidden" name="edit" value=1>
    <input type="hidden" name="rmentry" value=1>
    <input type="hidden" name="group" value="$in{group}">

    ~;


    if(keys %{$Netgroup->{hosts}}) {

       my $x = 0;
       foreach my $triple (sort keys %{$Netgroup->{hosts}}) {
           my $Triple = $Netgroup->{hosts}->{$triple};
           
           my $hostname = $Triple->{hostname};

	   my $style = ($x % 2) ? 'nc1' : 'nc2';
           
           $output .= qq~
                <tr class="$style"> 
                  <td width="20"><input name="delete" type="checkbox" value="$triple"></td>
                  <td width="480">$hostname</a></td>
                </tr>
	  ~;
	  $x++;
	}
          
        $output .= qq~
	<tr> 
            <td colspan=2 align="center">
                <input type="submit" value="$text{remove_selected_hosts}">
		</form>
              </td>
          </tr>
	~;
   } else {
      $output .= "<tr><td colspan=2 align=\"center\"></form>$text{notriples}</td></tr>";
   }

   $output .= qq~
        </table>
        <br>
        <table width="100%" border="0" class="ng">
          <tr> 
            <td><table width="100%" border="0" cellspacing="0" class="ng">
                <form action="$ENV{SCRIPT_NAME}" method=post>
                <input type="hidden" name="edit" value=1>
                <input type="hidden" name="rmsubgroup" value=1>
                <input type="hidden" name="group" value="$in{group}">
           <tr class="header"> 
                  <td width="20">&nbsp;</td>
                  <td width="100%">$text{subgroups}</td>
                </tr>
   ~;

   $struct->{netgroups}->{$in{group}};

   if(keys %{$struct->{netgroups}->{$in{group}}->{membergroups}}) {

     my $x = 0;
     foreach my $membergroup(sort keys %{$struct->{netgroups}->{$in{group}}->{membergroups}}) {
	
	my $style = ($x % 2) ? 'nc1' : 'nc2';

        $output .= qq~
                <tr class="$style">
                  <td width="20"> <input name="delete" type="checkbox" value="$membergroup"></td>
                  <td width="480">$membergroup</td>
                </tr>
        ~;
	$x++;
     }
   } else {
     $output .= qq~<tr><td colspan="2" align="center">$text{no_subgroups}</td></tr>~;
   }

   $output .= qq~
          </table></td>
          </tr>
          <tr> 
            <td align="center">
                <input type="submit" value="$text{remove_checked_subgroups}">
		</form>
            </td>
          </tr>
        </table>
        <br>
        <table width="100%" border="0" class="ng">
          <tr> 
            <td><table width="100%" border="0" cellspacing="0" class="ng">
                <form action="$ENV{SCRIPT_NAME}" method=post>
                <input type="hidden" name="edit" value=1>
                <input type="hidden" name="addsubgroup" value=1>
                <input type="hidden" name="group" value="$in{group}">
           <tr class="header"> 
                  <td width="20">&nbsp;</td>
                  <td width="100%">$text{netgroup}</td>
                </tr>
   ~;

   my %subgroups;

   #A list of available netgroups eligible for adding as a subgroup.
   foreach my $netgroup (keys %{ $struct->{netgroups} }) {
      $subgroups{$netgroup}++ unless($struct->{netgroups}->{$in{group}}->{membergroups}->{$netgroup} || $netgroup eq $in{group} || $struct->{netgroups}->{$netgroup}->{deleted});
   }

   if(keys %subgroups) {

     my $x = 0;
     foreach my $subgroup (sort keys %subgroups) {
	
	my $style = ($x % 2) ? 'nc1' : 'nc2';

        $output .= qq~
                <tr class="$style">
                  <td width="20"> <input name="add" type="checkbox" value="$subgroup"></td>
                  <td width="480">$subgroup</td>
                </tr>
        ~;
	$x++;
     }
   } else {
     $output .= qq~<tr><td colspan="2" align="center">$text{no_other_groups_available}</td></tr>~;
   }

   $output .= qq~
          </table></td>
          </tr>
          <tr> 
            <td align="center">
                <input type="submit" value="$text{add_selected_groups}">
		</form>
            </td>
          </tr>
        </table>
	<br>
        </td>
    </tr>
    <form action="$ENV{SCRIPT_NAME}" method=post>
    <input type="hidden" name="edit" value=1>
    <input type="hidden" name="addentry" value=1>
    <input type="hidden" name="group" value="$in{group}">
    <tr> 
      <td><table width="100%" border="0" class="ng">
          <tr> 
            <td align="center">$text{add_hosts}</td>
          </tr>
          <tr> 
            <td><div align="center"> 
                <p>$text{explanation}</p>
                <table width="100%" border="0" class="ng">
                  <tr> 
                    <td><p align="center"> 
                        <textarea name="hostnames" cols="40" rows="8"></textarea>
                      </p>
                      <p align="center"> 
                        <input type="checkbox" name="verify_forward" value="1">
                        $text{verify_forward}~ . hlink('<img src="images/help.gif" border=0>', "verify_forward") . qq~<br>
                        <input type="checkbox" name="verify_reverse" value="1">
                        $text{verify_reverse}~ . hlink('<img src="images/help.gif" border=0>', "verify_reverse") . qq~</p>
                      <p align="center"> 
                        <input type="submit" value="$text{add}">
                      </p></td>
                  </tr>
                </table>
              </div></td>
          </tr>
        </table></td>
    </tr>
    </form>
  </table>
  </table>
  ~;

   return $output;
}

1;