Skip to content
Snippets Groups Projects
menue.class.php 2.34 KiB
Newer Older
Eric Laufer's avatar
Eric Laufer committed
<?php
/*
 * Copyright vms1-Scripte
 * $au = Autentifikation (Admin oder User)
 * $sicht = Standartmäßig auf 1 somit wird alles angezeigt
 * $sicht = 2 = nur für Gäste (nicht eingeloggt)
 * 
 * function lkt_rally() muss nichts geändert werden
 * 
 */
class menue{
	private $db;
	private $num = 1;
	
	public function __construct(){
		global $datenbank;
		$this->db = $datenbank;
	}
	
	public function menue_box($au,$sicht = 1){
		if($au == 'Admin'){ $box = B_AD;}elseif($au == 'User'){ $box = B_US;}else{$box = '';}
		$bo = $this->db->get_results("SELECT id,name FROM ".PREFIX . $box ." WHERE sichtbar = '$sicht' ORDER BY ordnung ASC",true);
		foreach($bo AS $b){
			menuehead($b->name);
				$this->menue_punkt($b->id,$au,$b->name);
			menuefoot();
		}
	}
	
	private function unterpunkte($id,$me){
		$result = $this->db->get_results("SELECT link,name,id FROM ". PREFIX . $me ." WHERE uid = '$id' ");
		$aus = '';
		foreach($result AS $res){
			for($i = 0; $i <= $this->num; $i++){
				$aus .= '&nbsp;&nbsp;&nbsp;';
			}
			$aus .= '<a href="?page=/'. $res->link .'">'. nl2br($res->name) .'</a><br>';
			if($this->db->num_rows("SELECT id FROM ". PREFIX . $me ." WHERE uid = $res->id") != 0){$this->num++; $aus .= $this->unterpunkte($res->id,$me);}
		}
		return $aus;
	}
	
	private function menue_punkt($box,$au,$name){
		$name = str_replace(" ","_",$name);
		if($au == 'Admin'){ $me = M_AD;}elseif($au == 'User'){ $me = M_US;}else{ $au = '';}
		$men = $this->db->get_results("SELECT link,name,id FROM ".PREFIX . $me ." WHERE box = '$box' AND uid = '0' ORDER BY ordnung ASC",true);
		foreach($men AS $m){
			echo '
			<li>
                <a class="sidenav-item-link" href="?page=/'. $m->link .'">
                    <span class="nav-text">'. nl2br($m->name) .'</span>
				</a>
            </li>';
			if($this->db->num_rows("SELECT id FROM ". PREFIX . $me ." WHERE uid = $m->id") != 0){ $this->num = 1; echo $this->unterpunkte($m->id,$me);}
		}
	}
	
	function lkt_rally(){
		menuehead('LKT-Rallysystem bla');
			echo '&raquo;&nbsp;<a href="?page=/LKT_addons/LKT_rallysystem"><strong>Rally / Positionen</strong></a><br>';
			$rally = $this->db->get_results("SELECT id,name FROM ".PREFIX . RALLY ."",true);
			foreach($rally AS $r){
				echo '&nbsp;&nbsp;&nbsp;&nbsp;&#8627;&nbsp;<a href="?page=/LKT_addons/LKT_rallysystem2&rally='. $r->id .'">'. $r->name .'></a><br>';
			}
		menuefoot();
	}
}

?>