An error occurred while loading the file. Please try again.
-
Eric Laufer authored
Es ist nun möglich, weitere User Adminrechte zu geben. Die Rechte können für jede einzelne Seite festgelegt werden. Somit ist es möglich, dem User einen bestimmten aufgabenbereich zu geben.
56c7da00
mver.class.php 7.62 KiB
<?php
class mver{
private $db;
private $art;
private $artB;
private $array = array();
private $num = 1;
private $error = 0;
private $meldung;
function __construct(){
global $datenbank;
$this->db = $datenbank;
}
public function set_art($art){
if($art == 'user'){ $this->art = M_US; $this->artB = B_US;}
if($art == 'admin'){ $this->art = M_AD; $this->artB = B_AD;}
}
public function select($id){
$aus = '<option value="0"';
if($id == 0){ $aus .= 'selected="selected"';}
$aus .= '>Hauptlink</option>';
$result = $this->db->get_results("SELECT id,name FROM ". PREFIX . $this->art ."");
foreach($result AS $res){
$aus .= "<option value='$res->id'";
if($res->id == $id){ $aus .= 'selected="selected"';}
$aus .= ">$res->name</option>";
}
return $aus;
}
public function selectBox($id){
$aus = '<option value="0"';
if($id == 0){ $aus .= 'selected="selected"';}
$aus .= '>Hauptbox</option>';
$result = $this->db->get_results("SELECT id,name FROM ". PREFIX . $this->artB ."");
foreach($result AS $res){
$aus .= "<option value='$res->id'";
if($res->id == $id){ $aus .= 'selected="selected"';}
$aus .= ">$res->name</option>";
}
return $aus;
}
public function save($post){
$this->make_array($post);
if(!isset($array['uid'])){ $array['uid'] = 0;}
$this->SavePost();
meldung($this->error,$this->meldung);
}
public function SaveInsert($post){
$this->make_array($post);
if(!isset($array['uid'])){ $array['uid'] = 0;}
$this->Insert();
meldung($this->error,$this->meldung);
}
private function Insert(){
if($this->db->insert(PREFIX . $this->art, $this->array) == true){
$this->meldung = MENUE_SAVE_TRUE;
}else{
$this->error = 1;
$this->meldung = MENUE_SAVE_FALSE;
}
}
private function SavePost(){
if($this->db->update(PREFIX . $this->art, $this->array, array("id" => $this->array['id'])) == true){
$this->meldung = MENUE_SAVE_TRUE;
}else{
$this->error = 1;
$this->meldung = MENUE_SAVE_FALSE;
}
}
private function make_array($post){
foreach($post AS $key => $value){
if($key != '' && $key != 'run' && $value != ''){
$this->array[$key] = $this->db->escape($value);
}
}
}
public function delete($post){
$this->make_array($post);
if($this->db->delete(PREFIX . $this->art, array("id" => $this->array['id'])) == true){
$this->meldung = DELETE_LINK_TRUE;
}else{
$this->error = 1;
$this->meldung = DELETE_LINK_FALSE;
}
}
public function NewListen(){
$aus = '';
$query = "SELECT id,name,link,ordnung,box FROM ". PREFIX . $this->art ." WHERE uid = '0' AND box = '0' ORDER by ordnung ASC";
if($this->db->num_rows($query) != 0){
$aus .= '<h3>Links ohne Zuordnung</h3><ul class="list-group">';
$result = $this->db->get_results($query);
foreach($result AS $res){
$aus .= '
<li class="list-group-item">
<form method="post" action="">
<input type="hidden" name="id" value="'. $res->id .'">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">'. $res->id .'</span>
</div>
<input type="text" class="form-control" name="name" value="'. $res->name .'" placeholder="Linkname">
<input type="text" class="form-control" name="link" value="'. $res->link .'" placeholder="link">
<input type="text" class="form-control" name="ordnung" value="'. $res->ordnung .'">
<select class="custom-select" id="inputGroupSelect01">';
$aus .= $this->select(0);
$aus .= '
</select>
<select class="custom-select" name="box" id="inputGroupSelect02">';
$aus .= $this->selectBox($res->box);
$aus .= '
</select>
<div class="input-group-append">
<input type="submit" class="btn btn-outline-danger" name="run[link_'. $this->art .'_delete]" value="Löschen">
<input type="submit" class="btn btn-outline-success" name="run[link_'. $this->art .'_update]" value="Speichern">
</div>
</div>
</form>
</li>';
}
$aus .= '</ul><hr>';
}
return $aus;
}
public function listen(){
$aus = '<ul class="list-group">';
$result = $this->db->get_results("SELECT id,name,link,ordnung,box FROM ". PREFIX . $this->art ." WHERE uid = '0' ORDER by ordnung ASC");
foreach($result AS $res){
$aus .= '
<li class="list-group-item">
<form method="post" action="">
<input type="hidden" name="id" value="'. $res->id .'">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">'. $res->id .'</span>
</div>
<input type="text" class="form-control" name="name" value="'. $res->name .'" placeholder="Linkname">
<input type="text" class="form-control" name="link" value="'. $res->link .'" placeholder="link">
<input type="text" class="form-control" name="ordnung" value="'. $res->ordnung .'">
<select class="custom-select" id="inputGroupSelect01">';
$aus .= $this->select(0);
$aus .= '
</select>
<select class="custom-select" id="inputGroupSelect01">';
$aus .= $this->selectBox($res->box);
$aus .= '
</select>
<div class="input-group-append">
<input type="submit" class="btn btn-outline-danger" name="run[link_'. $this->art .'_delete]" value="Löschen">
<input type="submit" class="btn btn-outline-success" name="run[link_'. $this->art .'_update]" value="Speichern">
</div>
</div>
</form>
</li>
';
$aus .= $this->unterlisten($res->id,$this->num);
}
$aus .= '</ul>';
return $aus;
}
private function Pfeil(){
$aus = '';
for($i = 0; $i <= $this->num; $i++){
if($i != $this->num){ $aus .= ' ';}
if($i == $this->num){
$aus .= '<img src="https://img.icons8.com/material/16/000000/down-right.png">';
}
}
return $aus;
}
private function unterlisten($id,$num){
$query = "SELECT id,name,link,ordnung,box FROM ". PREFIX . $this->art ." WHERE uid = '$id' ORDER by ordnung ASC";
$aus = '';
if($this->db->num_rows($query) != 0){
foreach($this->db->get_results($query) AS $res){
$aus .= '
<li class="list-group-item">
<form method="post" action="">
<input type="hidden" name="id" value="'. $res->id .'">
<div class="input-group mb-3">';
$aus .= $this->Pfeil();
$aus .= '
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">'. $res->id .'</span>
</div>
<input type="text" class="form-control" name="name" value="'. $res->name .'" placeholder="Linkname">
<input type="text" class="form-control" name="link" value="'. $res->link .'" placeholder="Link">
<input type="text" class="form-control" name="ordnung" value="'. $res->ordnung .'">
<select class="custom-select" id="inputGroupSelect01">';
$aus .= $this->select($id);
$aus .= '
</select>
<select class="custom-select" id="inputGroupSelect01">';
$aus .= $this->selectBox($res->box);
$aus .= '
</select>
<div class="input-group-append">
<input type="submit" class="btn btn-outline-danger" name="run[link_'. $this->art .'_delete]" value="Löschen">
<input type="submit" class="btn btn-outline-success" name="run[link_'. $this->art .'_update]" value="Speichern">
</div>
</div>
</form>
</li>
';
$aus .= $this->unterlisten($res->id,$this->num++);
}
}
return $aus;
}
}