summaryrefslogtreecommitdiffstats
path: root/ldap-site-mngmt/webinterface/computers/computers_menu.php
blob: 97ff55fa8ceb4b297520a314bd77a705f85df8a9 (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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?php

function createComputersMenu($rollen , $mnr, $auDN, $sbmnr, $mcnr) {
   
   global $template, $ds, $suffix, $START_PATH;
   
   $mipb_array = get_maxipblocks_au($auDN);
	#print_r($mipb_array);
	if ( $mipb_array[0] == "" ){
		$iprechnerlink = "no_ip.php?mnr=2";
	}else{
		$iprechnerlink = "ip_rechner.php";
	}
	
   # Struktur der Registerkartenleiste
   # Hauptmenu
   $hauptmenu = array(array("link" => "computers.php",
                             "text" => "&Uuml;bersicht",
                             "zugriff" => array("MainAdmin","HostAdmin","DhcpAdmin")),
    						  array("link" => "hostoverview.php",
                             "text" => "Rechner",
                             "zugriff" => array("MainAdmin","HostAdmin","DhcpAdmin")),
                       array("link" => $iprechnerlink,
                             "text" => "IP Adressen Rechner",
                             "zugriff" => array("MainAdmin","DhcpAdmin","HostAdmin")),
                       #array("link" => "groupoverview.php",
                       #      "text" => "Rechnergruppen",
                       #      "zugriff" => array("MainAdmin")),
                       #array("link" => "machineconfig_default.php",
                       #      "text" => "Default MachineConfigs",
                       #      "zugriff" => array("MainAdmin","HostAdmin")),
                       #array("link" => "new_mcdef.php",
                       #      "text" => "Neue MachineConfig",
                       #      "zugriff" => array("MainAdmin","HostAdmin")),
                       array("link" => "new_pxe.php",
                             "text" => "Neues PXE Bootmen&uuml;",
                             "zugriff" => array("MainAdmin")));
	
	# Submenus 
	/*$computers_array = get_hosts($auDN,array("dn","hostname","ou"));
  	for($n=0;$n<count($computers_array);$n++){
  		
  		$comps[] = array("link" => "host.php?dn=".$computers_array[$n]['dn']."&sbmnr=".$n,
  							"text" => $computers_array[$n]['hostname'],
                    	"zugriff" => array("MainAdmin","HostAdmin","DhcpAdmin"));
      # print_r($comps); echo "<br>";
  	}*/
  	$comps[] = array("link" => "new_host.php?sbmnr=0", #.$n,
                    "text" => "Neuen Rechner anlegen",
                    "zugriff" => array("MainAdmin","DhcpAdmin","HostAdmin"));
   
  	$groups_array = get_groups($auDN,array("dn","cn"));
  	for($n=0;$n<count($groups_array);$n++){
  		
  		$groups = array();
  		$groups[] = array("link" => "group.php?dn=".$groups_array[$n]['dn']."&sbmnr=".$n,
  								"text" => $groups_array[$n]['cn'],
      	              	"zugriff" => array("MainAdmin","DhcpAdmin","HostAdmin"));
      	              	
  	}
  	$groups[] = array("link" => "new_group.php?sbmnr=".$n,
                     "text" => "Neue Gruppe anlegen",
                     "zugriff" => array("MainAdmin","DhcpAdmin","HostAdmin"));
   
   # default machine-configs 
   $mcdef_array = get_machineconfigs("cn=computers,".$auDN,array("dn","cn","timerange"));
   for($n=0;$n<count($mcdef_array);$n++){
   	$defmc [] = array("link" => "mcdef.php?dn=".$mcdef_array[$n]['dn']."&mnr=3&sbmnr=".$n,
  								"text" => $mcdef_array[$n]['cn'],
      	              	"zugriff" => array("MainAdmin","DhcpAdmin","HostAdmin"));
   }
   
  	$submenu = array(array(),
    	              $comps,
    	              array(),
    	              #$groups,
    	              #$defmc,
    	              array());
   #echo "submenu: ";print_r($submenu);echo "<br><br>";
	
   # 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'])) {
  		
  			#########################################################################
  			# SUBMENU 
  			
  			$subempty = 0;
			$j=0;
			$maxsub = count($submenu[$mnr]);
			#echo "_"; print_r($maxsub); echo "_";
			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){$zwisch2="branchbottom2";}
		               else {$zwisch2="branch2";}
		               $lastaktive=true;
		               $farb="#505050";
		            }
		            else{
		            	if ($maxsub == 1) {$zwisch2="branchbottom2";}
		            	# Wenn Unter-Unter-Menu ...
		            	#if(count($subsubmenu[$i][$j][0]) != 0){
               		#if($maxsub == 1){$zwisch2="<a href='".$item2['link']."' style='border-style=none;text-decoration:none'>
               		#	<img style='border-width:0;border-style=none;' src='../pics/plus2.gif'></a>";}
		         		#else {$zwisch2="<a href='".$item2['link']."' style='border-style=none;text-decoration:none'>
               		#	<img style='border-width:0;border-style=none;' src='../pics/plus2.gif'></a>";}
			         	#}
		         		else{$zwisch2="branch2";}
		               $farb="#A0A0A0";  
		               $lastaktive=false;
		            }
		         }
		         else {
		         	if ($sbmnr==$j) { 
		            	if($maxsub == $j+1){$zwisch2="branchbottom2";}
		               else {$zwisch2="branch2";}
		               $lastaktive=true; 
		               $farb="#505050"; 
		            }
		            else {
		            	if ($maxsub == $j+1) {$zwisch2="branchbottom2";}
		            	# Wenn Unter-Unter-Menu ...
		            	#if(count($subsubmenu[$i][$j][0]) != 0){
               		#	if($maxsub == $i+1){$zwisch2="<a href='".$item2['link']."' style='border-style=none;text-decoration:none'>
               		#		<img style='border-width:0;border-style=none;' src='../pics/plus2.gif'></a>";}
		         		#	else {$zwisch2="<a href='".$item2['link']."' style='border-style=none;text-decoration:none'>
               		#		<img style='border-width:0;border-style=none;' src='../pics/plus2.gif'></a>";}
							#}		         		
		         		else{$zwisch2="branch2";}
		               $farb="#A0A0A0";
		               $lastaktive=false;
		            } 
		        	}
		   		$htmlcode= "
		   		<tr height='4'>
						<td></td><td align='right'><img src='../pics/line2.gif' height='4'></td><td></td><td></td>
		   		</tr>
		   		<tr>
						<td width='8%'>&nbsp;</td>
						<td width='8%' align='right'><img src='../pics/".$zwisch2.".gif'></td>
 						<td width='5%' align='left' style='border-width:1 0 1 1;border-color:#000000;border-style:solid;padding:4;background-color:{FARBE_S}'>&nbsp;</td>
		     			<td width='69%' align='left' style='border-width:1 1 1 0;border-color:#000000;border-style:solid;padding:4;padding-left:12px;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");
		    	
		   }
  			# SUBMENU		
  			#####################################################################		
  				
			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 {
               
               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="";}
               $farb="#A0A0A0";
               $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" => ""));
   } 
}
?>