summaryrefslogtreecommitdiffstats
path: root/ldap-site-mngmt/webinterface/dhcp/dhcp_menu.php
blob: a51ee6d59c6454a95d73736d699be4bddc3d0400 (plain) (blame)
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php

function createDhcpMenu($rollen , $mnr, $auDN, $sbmnr) {
   
   global $template, $START_PATH, $rootAU; 
   
   $mipbs = get_maxipblocks_au($auDN);
   #echo "MIPB: "; print_r ($mipbs); echo "<br>";
   if ($mipbs[0] != ""){
      $hauptmenu = array(array("link" => "dhcp.php",
                             "text" => "&Uuml;bersicht",
                             "zugriff" => "alle"));
   }else{
      $hauptmenu = array(array("link" => "no_dhcp.php",
                             "text" => "&Uuml;bersicht",
                             "zugriff" => "alle"));
   }
   
	$pools = get_dhcppools($auDN, array("dn"));
	if (count($pools) == 0){
		$poollink = "dhcpnopool.php";
	}else{
		$poollink = "dhcppool.php";
	}   
   
   $i=1;
   if ( $auDN == $rootAU ) {
      $dhcpservice_array = get_dhcpservices($auDN,array("dn","cn"));
      if (count($dhcpservice_array) == 0){
      	$dhcpsvlink = "new_dhcpservice.php?mnr=1";
      }
      else {
      	$dhcpsvlink = "dhcpservice.php?mnr=1";
      }
      $hauptmenu []= array("link" => $dhcpsvlink,
                             "text" => "DHCP Service",
                             "zugriff" => array("MainAdmin","DhcpAdmin"));
      $i++;
   }
   if ($mipbs[0] != ""){
      if ( check_if_max_networks() ){
         $hauptmenu [] = array("link" => "dhcpsubnets.php?mnr=".$i,
                                "text" => "DHCP Subnets",
                                "zugriff" => array("MainAdmin","DhcpAdmin"));
         
         $subnets = array();
   	   # falls komplette Netze verfügbar, link zum Neuanlegen
   	   if ( check_if_free_networks() ){
   	      #$dhcpsubnet_array = get_dhcpsubnets($auDN,array("dn","cn"));
   	      /*for ($j=0;$j<count($dhcpsubnet_array);$j++){
      	  		$subnets[] = array("link" => "dhcpsubnet.php?dn=".$dhcpsubnet_array[$j]['dn']."&mnr=".$i."&sbmnr=".$j,
      	  							"text" => $dhcpsubnet_array[$j]['cn'],
      								"zugriff" => array("MainAdmin","DhcpAdmin"));
      	  	}*/
      	   $subnets[] = array("link" => "new_dhcpsubnet.php?mnr=".$i."&sbmnr=0",
      	                   "text" => "Neues DHCP Subnet anlegen",
      	                   "zugriff" => array("MainAdmin","DhcpAdmin"));
   	   }
   	   $i++;
         $hauptmenu [] = array("link" => $poollink."?mnr=".$i,
                                "text" => "Dynamische DHCP Pools",
                                "zugriff" => array("MainAdmin","DhcpAdmin"));
   	                  
         $submenu = array(array(),
          	              $subnets,
          	              array());                       
                                
      }else{
         $hauptmenu [] = array("link" => $poollink."?mnr=".$i,
                                "text" => "Dynamische DHCP Pools",
                                "zugriff" => array("MainAdmin","DhcpAdmin"));
      }
   }
   
	#print_r ($hauptmenu);cho "<br>";
   #print_r ($submenu);
	#$rollen = array_keys($roles);

   # Zusammenstellen der Menuleiste
   $template->define_dynamic("Hauptmenu", "Menu");
   $template->define_dynamic("Submenu", "Menu");
   $i=0;
   $maxmenu = count($hauptmenu);
   
   foreach($hauptmenu as $item) {
      $template->clear_parse("SUBMENU_LIST");
      if($item['zugriff'] === "alle" || vergleicheArrays($rollen , $item['zugriff'])) {
         
         $subempty = 0;
			$j=0;
			$maxsub = count($submenu[$mnr]);
			if($maxsub > 0){
     			foreach($submenu[$mnr] as $item2) {
            
               if($item2['zugriff'] === "alle" || vergleicheArrays($rollen, $item2['zugriff'])) {		   		
   		   		if($i != $mnr){
   		   		   $template->assign(array("SUB" => ""));
      		         # 								"LINK_S" => "", 
      		         #                       "TEXT_S" => ""));
      		         $template->parse("SUBMENU_LIST", ".Submenu"); 
      		         $template->clear_dynamic("Submenu");
   		   		}
   		   		else{
      		   		if ($j==0) {
      		         	if ($sbmnr==0) { 
      		               if($maxsub == 1){$zwisch="";}
      		               else {$zwisch="";}
      		               $lastaktive=true;
      		               $farb="#505050";
      		            }
      		            else{
      		               if($maxsub == 1){$zwisch="";}
      		               else {$zwisch="";}
      		               $farb="#A0A0A0";  
      		               $lastaktive=false;
      		            }
      		         }
      		         else {
      		         	if ($sbmnr==$j) { 
      		            	if($maxsub == $j+1){$zwisch="";}
      		               else {$zwisch="";}
      		               $lastaktive=true; 
      		               $farb="#505050"; 
      		            }
      		            else {
      		               $farb="#A0A0A0";
      		               if($maxsub == $j+1){$zwisch="";}
      		               else {$zwisch="";}
      		               # if ($lastaktive) {$zwisch="branch";} 
      		               # else {$zwisch="branch";}
      		               $lastaktive=false;
      		            } 
      		        	}
      		   		$htmlcode= "
      		   		<tr height='4'>
      						<td></td><td></td><td></td><td></td>
      		   		</tr>
      		   		<tr>
      						<td width='8%'>&nbsp;</td>
      						<td width='8%' align='right'>".$zwisch."</td>
      		     			<td width='74%' align='left' style='border-width:1 1 1 1;border-color:#000000;border-style:solid;padding:2;padding-left:15px;background-color:{FARBE_S}'> 
      		     			<a href='".$item2['link']."' style='text-decoration:none'><b class='standard_schrift'>".$item2['text']."</b></a></td>
      						<td width='10%'>&nbsp;</td> 						
      					</tr>
      					";
      		         $template->assign(array("SUB" => $htmlcode));		         
        		         $template->assign(array("FARBE_S" => $farb));
      		         $template->parse("SUBMENU_LIST", ".Submenu"); 
      		         $template->clear_dynamic("Submenu");
   		         }
   		      }
   		      else {
   		         $subempty++;
   		      }
   		      $j=$j+1;
            }    
   	  	}
   	   if($subempty == count($submenu[$mnr])) {
   	      $template->assign(array("SUB" => ""));
   	     	#							  "LINK_S" => "",
   	 	   #                       "TEXT_S" => ""));
   	    	$template->parse("SUBMENU_LIST", ".Submenu"); 
   	    	$template->clear_dynamic("Submenu");
   	   }
         
         # weiter im Hauptmenü
         if ($i==0) {
				if ($mnr==0) {
         		if(count($submenu[$i][0]) != 0){
               if($maxmenu == 1){$zwisch="";} # {$zwisch="<img style='border-width:0;border-style=none;' src='../pics/minus2.gif'>";}
		         else {$zwisch="";}
		         }else{$zwisch="";}
               $lastaktive=true;
               $farb="#505050";
            }
            else{
            	if(count($submenu[$i][0]) != 0){
               if($maxmenu == 1){$zwisch="<a href='{LINK_M}' style='border-style=none;text-decoration:none'>
               	<img style='border-width:0;border-style=none;' src='../pics/plus2.gif'></a>";}
		         else {$zwisch="<a href='{LINK_M}' style='border-style=none;text-decoration:none'>
               	<img style='border-width:0;border-style=none;' src='../pics/plus2.gif'></a>";}
		         }else{$zwisch="";}
               $farb="#A0A0A0";
               $lastaktive=false;
            }
         }
         else {
         	if ($mnr==$i) {
         		if(count($submenu[$mnr][0]) != 0){
	            	if($maxmenu == $i+1){$zwisch="";}
			         else {$zwisch="";}
   				}else{$zwisch="";}
               $lastaktive=true;
               $farb="#505050";
            }
            else {
               $farb="#A0A0A0";
               if(count($submenu[$i][0]) != 0){
               if($maxmenu == $i+1){$zwisch="<a href='{LINK_M}' style='border-style=none;text-decoration:none'>
               	<img style='border-width:0;border-style=none;' src='../pics/plus2.gif'></a>";}
		         else {$zwisch="<a href='{LINK_M}' style='border-style=none;text-decoration:none'>
               	<img style='border-width:0;border-style=none;' src='../pics/plus2.gif'></a>";}
		         }else{$zwisch="";}
               #if ($lastaktive) {$zwisch="";}
               #else {$zwisch="";}
               $lastaktive=false;
            } 
        	}
         $template->assign(array("ICON" => $zwisch,
                                 "FARBE" => $farb,
                                 "LINK_M" => $item["link"],
                                 "TEXT_M" => $item["text"]));
         $template->parse("HAUPTMENU_LIST", ".Hauptmenu");
			$template->clear_dynamic("Hauptmenu");
     	}
     	$i=$i+1;
	}
   if ($lastaktive) {$template->assign(array("ENDE" => ""));}
   else {$template->assign(array("ENDE" => ""));}
}

?>