ich möchte das nur eine bestimmte Gruppe sowie User ab dem Status SiteAdmin die Möglichkeit haben Einträge zu editieren und zu löschen.
Eintragen soll jeder können der das Recht für das Modul besitzt.
Wie kann ich das am besten machen?
<?php defined ('main') or die ( 'no direct access' ); defined ('admin') or die ( 'only admin access' ); $design = new design ( 'Admins Area', 'Admins Area', 2 ); $design->header(); $tpl = new tpl ('radio/sendeplan.htm', 1); if ($menu->getA(1) == 'd') { $id = escape($menu->getE(1),'integer'); db_query("DELETE FROM `prefix_radio_sendeplan` WHERE `id` = '$id'"); wd('admin.php?sendeplan', 'Eintrag Nr.'.$id.' wurde gelöscht!'); } elseif (isset($_POST['save'])) { $date = escape($_POST['date'],'string'); $time = escape($_POST['time'],'string'); $dj = escape($_POST['dj'],'integer'); $txt = escape($_POST['txt'],'textarea'); db_query("INSERT INTO `prefix_radio_sendeplan` (`date`,`time`,`dj_id`,`content`) VALUES ('$date','$time','$dj','$txt')"); wd('admin.php?sendeplan', 'Neuer Eintrag wurde hinzugefügt.'); } elseif (isset($_POST['edit'])) { $date = escape($_POST['date'],'string'); $time = escape($_POST['time'],'string'); $dj = escape($_POST['dj'],'integer'); $txt = escape($_POST['txt'],'textarea'); $id = escape($_POST['id'],'integer'); db_query("UPDATE `prefix_radio_sendeplan` SET `date` = '$date', `time` = '$time', `dj_id` = '$dj', `content` = '$txt' WHERE `id` = '$id'"); echo $dj; wd('admin.php?sendeplan', 'Eintrag erfolgreich geändert.'); } else { $tpl->out(0); $limit = 5; // Limit $page = ($menu->getA(1) == 'p' ? $menu->getE(1) : 1 ); $MPL = db_make_sites ($page , '' , $limit , "admin.php?sendeplan" , 'radio_sendeplan' ); $anfang = ($page - 1) * $limit; $q = db_query("SELECT `id`,`date`,`time`,`dj_id` FROM `prefix_radio_sendeplan` LIMIT $anfang,$limit"); while($row = db_fetch_assoc($q)) { $dj = db_result(db_query("SELECT `name` FROM `prefix_user` WHERE `id` = '".$row['dj_id']."'")); $dj = empty($dj) ? 'Ex-DJ' : $dj; $entry = $row['date'].', '.$row['time']; $tpl->set('ID',$row['id']); $tpl->set('DJ',$dj); $tpl->set('ENTRY',$entry); $tpl->out(1); } $tpl->set('MPL', $MPL); if ($menu->getA(1) == 'e') { $id = escape($menu->getE(1),'integer'); $row = db_fetch_assoc(db_query("SELECT * FROM `prefix_radio_sendeplan` WHERE `id` = '$id'")); $q = db_query("SELECT `a`.`name`,`b`.`userid` as djid FROM `prefix_radio_djs` b LEFT JOIN `prefix_user` a ON `a`.`id` = `b`.`userid`"); $djs = '<select name="dj">'; while ($row2 = db_fetch_assoc($q)) $djs .= '<option value="'.$row2['djid'].'"'.($row2['djid'] == $row['dj_id'] ? 'selected="selected"' : '').'>'.$row2['name'].'</option>'; $djs .= '</select>'; $date = $row['date']; $time = $row['time']; $text = $row['content']."\n\n\n[i]Letzte Änderung am ".date('d.m.Y').' um '.date('H:i').'[/i]'; $editid = '<input type="hidden" name="id" value="'.$id.'" />'; $tpl->set('DJ',$djs); $tpl->set('DATE',$date); $tpl->set('TIME',$time); $tpl->set('TEXT',$text); $tpl->set('METHOD','edit'); $tpl->set('EDITID',$editid); $tpl->out(2); } else { $q = db_query("SELECT `a`.`name`,`b`.`userid` as djid FROM `prefix_radio_djs` b LEFT JOIN `prefix_user` a ON `a`.`id` = `b`.`userid`"); $djs = '<select name="dj">'; while ($row = db_fetch_assoc($q)) $djs .= '<option value="'.$row['djid'].'"'.($row['djid'] == $_SESSION['authid'] ? 'selected="selected"' : '').'>'.$row['name'].'</option>'; $djs .= '</select>'; $date = date('Y-m-d'); $time = date('H:i').' - '.date('H:i',mktime(date('H')+1,date('i'),date('s'),date('n'),date('j'),date('Y'))); $text = ''; $tpl->set('DJ',$djs); $tpl->set('DATE',$date); $tpl->set('TIME',$time); $tpl->set('TEXT',$text); $tpl->set('METHOD','save'); $tpl->set('EDITID',''); $tpl->out(2); } } require_once('include/includes/class/scRadioModul.php'); echo getCopyright(false); $design->footer(); ?>