Hallo Nero
Habs angepasst jedoch ohne Erfolg. Es sollten auch CoAdmins die Artikel freigeben können. Ich bin mir auch bewusst dass ich mit dem alten Artikelmodul arbeite aber dieses ist genau so wie ich es haben will. Das neue habe ich auch getestet jedoch kann ich mich nicht so damit anfreunden(der Mensch ist halt ein Gewohnheitstier:P)
Hier der Code der admin/articles.php wo Du mir vieleicht sagen kannst was angepasst werden muss damits klappt:
<?php
# Copyright by: Manuel Staechele
# Edit by: Nero
# Support: www.ilch.de
defined ('main') or die ( 'no direct access' );
defined ('admin') or die ( 'only admin access' );
#-> functions
function escape_arrays($ar,$check){#-> Escaped nach vorgaben Arrays
foreach($check as $Key=>$Value){
if (isset($ar[$Key]))
if($Value === 'str'){
$return[$Key] = trim(escape($ar[$Key],'string'));
}elseif($Value === 'txt'){
$return[$Key] = trim(escape($ar[$Key],'textarea'));
}else{
$return[$Key] = trim(escape($ar[$Key],'integer'));
}
}
return $return;
}
function cat_exist_and_has_right($id){#-> Prüfen ob User recht hat für die kategorie
if($id == '0'){return( false );}
global $design;
$erg = db_query('SELECT recht FROM `prefix_artsys_cats` WHERE id = '.$id);
if(db_num_rows($erg) <> 1){
wd('?articles','Diese Kategorie ist leider nicht vorhanden',3);
$design->footer();return( true );
}elseif(db_result($erg,0)<$_SESSION['authright']){
wd('?articles','Sie haben nicht die nötigen Rechte für diese Kategorie',3);
$design->footer();return( true );
}
return( false );
}
function get_cat_recht($recht,$cat,$count=1){#-> Prüfen ob die Rechte stimmen
if ($cat <> 0){
$erg = db_query("SELECT recht FROM `prefix_artsys_cats` WHERE id = ".$cat);
$Crecht = db_result($erg,0);
if($Crecht<$recht){$recht = $Crecht;}
}
if ($count === 1 AND $recht<$_SESSION['authright']){
get_cat_recht($recht=$_SESSION['authright'], $cat, $count=2);
echo '<span style="color:#FF0000;">Das Recht der Kategorie wurde auf Euer Recht zurückgestellt!</span><br><br>';
}elseif($count === 2 AND $recht<$_SESSION['authright']){
global $design;
wd('?articles','Kategorie Anlegen verweigert',3);
$design->footer();return( false );
}
return $recht;
}
function articles_show_cats($id, $stufe) {#-> Ausgabe der Kategoorien
$erg = db_query("SELECT id,name,pos,cat FROM `prefix_artsys_cats` WHERE cat = ".$id." AND recht >= ".$_SESSION['authright']." ORDER BY pos") OR die($erg.mysql_error());
if ( db_num_rows($erg) > 0 ) {
while ($row = db_fetch_object($erg) ) {
echo '<tr class="Cmite"><td>'.$stufe.'- <a href="admin.php?articles-C'.$row->id.'">'.$row->name.'</a></td>';
echo '<td align="center"><a href="admin.php?articles-E'.$row->id.'#edit"><img src="include/images/icons/edit.gif" border="0"></a></td>';
echo '<td align="center"><a href="javascript:Kdel('.$row->id.')"><img src="include/images/icons/del.gif" border="0"></a></td>';
echo '<td align="center"><a href="admin.php?articles-C'.$row->id.'-O'.$row->pos.'"><img src="include/images/icons/pfeilo.gif" border="0"></a></td>';
echo '<td align="center"><a href="admin.php?articles-C'.$row->id.'-U'.$row->pos.'"><img src="include/images/icons/pfeilu.gif" border="0"></a></td></tr>'."\n";
articles_show_cats($row->id, $stufe.' ' );
}
}
}
#-> Define same vars
$switchmenu = escape($menu->get(1),'string');
#-> menu
$design = new design ( 'Admins Area', 'Admins Area', 2);
$design->header();
switch($switchmenu){
case 'newArt':
if (isset($_POST['submit'])){
$insArr = array('txt'=>'txt','titel'=>'str','cat'=>'');
$insert = escape_arrays($_POST,$insArr);
if(cat_exist_and_has_right($insert['cat'])){return;}
db_query('INSERT INTO `prefix_artsys_articles` (art_uid,art_cat,art_time,art_title,art_content) VALUES
('.$_SESSION['authid'].','.$insert['cat'].',NOW(),"'.$insert['titel'].'","'.$insert['txt'].'")') OR die($erg.mysql_error());
#$lang['ArtSuccessfInsert'];
wd('?articles'.($insert['cat'] == 0?'':'-C'.$insert['cat']),'Artikel erfolgreich eingefügt',3);
}else{
if(isset($_POST['priview'])){
$art = array('txt'=>trim(escape($_POST['txt'],'textarea')),'titel'=>trim($_POST['titel']),'display'=>'','cat'=>escape($_POST['cat'],'integer'),'cat_link'=>($_POST['cat'] === '0'?'':'-C'.escape($_POST['cat'],'integer')));
$art['priview'] = bbcode(unescape($art['txt']));
}else{
$art = array('txt'=>'','titel'=>'','display'=>'style="display:none;"','cat_link'=>($menu->getA(2) === 'C'?'-C'.$menu->getE(2):''),'cat'=>($menu->getA(2) === 'C'?$menu->getE(2):0));
}
$tpl = new tpl('artsys/writeart', 1 );
$out = array('modul_titel' =>'Neuer Artikel schreiben',
'show_priview'=>$art['priview'],
'art_txt' =>escape_for_fields(unescape($art['txt'])),
'art_titel' =>$art['titel'],
'display' =>$art['display'],
'smilies' =>getsmilies(),
'kat' =>$art['cat_link'],
'cat_list' =>'<option value="0">Keine</option>'.dblistee($art['cat'],"SELECT id,name FROM `prefix_artsys_cats` WHERE recht >= ".$_SESSION['authright']." ORDER BY name ASC"),
'artID' =>'',
);
$tpl->set_ar_out($out,0);
}
break;
case 'editArt':
if ($menu->getA(2) === 'E'){
if ($row = @db_fetch_assoc(db_query('SELECT * FROM `prefix_artsys_articles` WHERE art_id = '.$menu->getE(2)))){
if(cat_exist_and_has_right($row['art_cat'])){return;}
if (isset($_POST['submit']) AND $_POST['artID'] == $menu->getE(2)){
$insArr = array('txt'=>'txt','titel'=>'str','cat'=>'','artID'=>'');
$insert = escape_arrays($_POST,$insArr);
if(cat_exist_and_has_right($insert['cat'])){return;}
if ($_SESSION['authid']<>$row['art_uid']){
$insert['txt'] = $insert['txt']."\n\n Editiert von ".get_n($_SESSION['authid'])."am "; #-> Datum hin!!!
}
db_query('UPDATE `prefix_artsys_articles` SET art_status = 0, art_cat = '.$insert['cat'].', art_title = "'.$insert['titel'].'", art_content = "'.$insert['txt'].'" WHERE art_id = '.$insert['artID'].' LIMIT 1') OR DIE(mysql_error());
#$lang['ArtSuccessfUpdatet'];
wd('?articles'.($insert['cat'] == 0?'':'-C'.$insert['cat']),'Artikel erfolgreich geändert',3);
}else{
if (isset($_POST['priview'])){
$art = array('txt'=>trim(escape($_POST['txt'],'textarea')),'titel'=>trim($_POST['titel']),'display'=>'');
$art['priview'] = bbcode(unescape($art['txt']));
$row['art_cat'] = escape($_POST['cat'],'integer');
}else{
$art = array('txt'=>$row['art_content'],'titel'=>$row['art_title'],'display'=>'style="display:none;"');
}
$tpl = new tpl('artsys/writeart', 1 );
$out = array('modul_titel' =>'Artikel editieren',
'show_priview'=>$art['priview'],
'art_txt' =>escape_for_fields(unescape($art['txt'])),
'art_titel' =>$art['titel'],
'display' =>$art['display'],
'smilies' =>getsmilies(),
'kat' =>($row['art_cat'] <> 0?'-C'.$row['art_cat']:''),
'cat_list' =>'<option value="0">Keine</option>'.dblistee($row['art_cat'],"SELECT id,name FROM `prefix_artsys_cats` WHERE recht >= ".$_SESSION['authright']." ORDER BY name ASC"),
'artID' =>$menu->getE(2),
);
$tpl->set_ar_out($out,0);
}
}else{
wd('?articles','Artikel mit der ID "'.$menu->getE(2).'" ist leider nicht vorhanden',3);
}
}else{
wd('?articles','Unbekanntes vorhaben',3);
}
break;
default;
#-> Template
$tpl = new tpl('artsys/articles', 1);
$tpl->out(0);
#-> Kategorie ID erfassen und prüfen
$artArr = array('cat'=>0);
if ($menu->getA(1) === 'C' OR $menu->getA(1) === 'E'){
$artArr['cat'] = $menu->getE(1);
if(cat_exist_and_has_right($artArr['cat'])){return;}
}
if ($menu->getA(2) === 'U' OR $menu->getA(2) === 'O' AND $artArr['cat'] <> 0){#-> kategorien verschieben
$pos = $menu->getE(2);
$id = $artArr['cat'];
$cat = db_result(db_query("SELECT cat FROM `prefix_artsys_cats` WHERE id = ".$id),0);
$nps = ( $menu->getA(2) == 'U' ? $pos + 1 : $pos - 1 );
$anz = db_result(db_query("SELECT COUNT(*) FROM `prefix_artsys_cats` WHERE cat = ".$cat),0);
if ($nps < 0) {
db_query("UPDATE `prefix_artsys_cats` SET pos = ".$anz." WHERE id = ".$id);
db_query("UPDATE `prefix_artsys_cats` SET pos = pos -1 WHERE cat = ".$cat);
}
if ($nps >= $anz) {
db_query("UPDATE `prefix_artsys_cats` SET pos = -1 WHERE id = ".$id);
db_query("UPDATE `prefix_artsys_cats` SET pos = pos +1 WHERE cat = ".$cat);
}
if ( $nps < $anz AND $nps >= 0 ) {
db_query("UPDATE `prefix_artsys_cats` SET pos = ".$pos." WHERE pos = ".$nps." AND cat = ".$cat);
db_query("UPDATE `prefix_artsys_cats` SET pos = ".$nps." WHERE id = ".$id);
}
}elseif (isset($_POST['Csub'])){#-> kategorie eintraege speichern oder aendern.
if (empty($_POST['Ccat'])){$_POST['Ccat'] = 0;}
$insArr = array('Cname'=>'str','Cdesc'=>'txt','Ccat'=>'','Crecht'=>'','Cid'=>'');
$insert = escape_arrays($_POST,$insArr);
if (empty($_POST['Cid'])){#-> Kategorie speicher
if(cat_exist_and_has_right($insert['Ccat'])){return;}
if (!$insert['Crecht'] = get_cat_recht($insert['Crecht'],$insert['Ccat']) AND get_cat_recht($insert['Crecht'],$insert['Ccat']) === false){
return;
}
$pos = db_result(db_query("SELECT COUNT(*) FROM `prefix_artsys_cats` WHERE cat = ".$insert['Ccat']),0);
db_query("INSERT INTO `prefix_artsys_cats` (`cat`,`name`,`desc`,pos,recht) VALUES (".$insert['Ccat'].",'".$insert['Cname']."','".$insert['Cdesc']."','".$pos."','".$insert['Crecht']."')");
$artArr['cat'] = db_last_id();
}elseif($artArr['cat'] == $_POST['Cid']){#-> Kategorie ändern
if (!$insert['Crecht'] = get_cat_recht($insert['Crecht'],$insert['Ccat'])){
return;
}
$alt_row = db_fetch_assoc(db_query("SELECT cat,pos FROM `prefix_artsys_cats` WHERE id = ".$insert['Cid']));
if ($alt_row['cat'] <> $insert['Ccat']){#-> Schauen ob neue Kategorie
$pos = db_result(db_query("SELECT COUNT(*) FROM `prefix_artsys_cats` WHERE cat = ".$insert['Ccat']),0);
db_query("UPDATE `prefix_artsys_cats` SET pos = pos - 1 WHERE pos > ".$alt_row['pos']." AND cat = ".$alt_row['cat']);
}else{
$pos = $alt_row['pos'];
}
db_query("UPDATE `prefix_artsys_cats` SET `cat` = '".$insert['Ccat']."',`name` = '".$insert['Cname']."',pos = '".$pos."',`desc` = '".$insert['Cdesc']."', recht = '".$insert['Crecht']."' WHERE `id` = '".$insert['Cid']."'");
}
}elseif($menu->getA(2) === 'S' AND $menu->getA(3) === 'A'){#-> Status eines Artikels ändern
if (is_admin()){
db_query("UPDATE `prefix_artsys_articles` SET art_status = ".$menu->getE(2)." WHERE art_id = ".$menu->getE(3));
}else{
echo '<span style="color:#FF0000">Nur ein Admin kann den status eines Artikels ändern!</span><br><br>';
}
}elseif($menu->get(2) === 'DelKat'){#-> Kategorien löschen
if ('0' === db_result(db_query("SELECT COUNT(art_id) FROM `prefix_artsys_articles` WHERE art_cat = '".$artArr['cat']."'"),0)){
$azk = db_result(db_query("SELECT cat FROM `prefix_artsys_cats` WHERE id = '".$artArr['cat']."'"),0);
$pos = db_result(db_query("SELECT pos FROM `prefix_artsys_cats` WHERE id = '".$artArr['cat']."'"),0);
db_query("DELETE FROM `prefix_artsys_cats` WHERE id = '".$artArr['cat']."'");
db_query("UPDATE `prefix_artsys_cats` SET pos = pos - 1 WHERE pos > ".$pos." AND cat = ".$azk);
$artArr['cat'] = 0;
}else{
echo '<span style="color:#FF0000">Bitte zuerst alle Artikel zu dieser Kategorie löschen!</span><br><br>';
}
}elseif($menu->getA(2) === 'd'){#-> Artikel löschen
if (1 <> db_result(db_query("SELECT COUNT(art_id) FROM `prefix_artsys_articles` WHERE art_id = ".$menu->getE(2)." AND art_cat = ".$artArr['cat']),0)){
echo '<span style="color:#FF0000">Artikel nicht vorhanden!</span><br><br>';
}elseif(is_admin()){
db_query("DELETE FROM `prefix_artsys_articles` WHERE art_id = '".$menu->getE(2)."' LIMIT 1");
echo '<span style="color:#00FF00;">Artikel erfolgreich gelöscht!</span><br><br>';
}else{
echo '<span style="color:#FF0000">Nur ein Admin kann Artikel löschen!</span><br><br>';
}
}
$erg_art = db_query('SELECT * FROM `prefix_artsys_articles` WHERE art_cat = '.$artArr['cat'])OR die(mysql_error());
if (db_num_rows($erg_art) <> 0){#-> Ausgabe der Artikeln der gewählten Kategorie
$class = 0;
WHILE($row_art = db_fetch_assoc($erg_art)){
$class = ($class == 'Cmite' ? 'Cnorm' : 'Cmite');
$row_art['class'] = $class;
if (has_right(-8)){
$row_art['art_status'] = ($row_art['art_status'] === '0'?
'<a title="Artikel freischalten" href="admin.php?articles-C'.$artArr['cat'].'-S1-A'.$row_art['art_id'].'"><img src="include/images/icons/nop.gif"></a>':
'<a title="Artikel zurückziehen" href="admin.php?articles-C'.$artArr['cat'].'-S0-A'.$row_art['art_id'].'"><img src="include/images/icons/jep.gif"></a>');
}else{
$row_art['art_status'] = ($row_art['art_status'] === '0'?'<img title="zurückgezogen, oder noch nicht freigeschalten" src="include/images/icons/nop.gif">':'<img title="freigeschalten" src="include/images/icons/jep.gif">');
}
$row_art['cat'] = $artArr['cat'];
$tpl->set_ar_out($row_art,1);
}
}
$tpl->set_out('kat',($artArr['cat']<>0?'-C'.$artArr['cat']:''),2);
articles_show_cats(0, '');
if ($menu->getA(1) === 'E'){
$edit_cat = db_fetch_assoc(db_query('SELECT id as Cid,cat as Ccat, recht as Crecht, name as Cname,pos as Cpos,`desc` as Cdesc
FROM `prefix_artsys_cats` WHERE id ='.$artArr['cat']));
$edit_cat['checkCid'] = '-C'.$edit_cat['Cid'];
}else{
$edit_cat = array('Cdesc'=>'','Cname'=>'','Cid' => 0,'Crecht' => '','Ccat'=>$artArr['cat'],'checkCid'=>'');
}
$edit_cat['Crecht'] = dblistee($edit_cat['Crecht'],"SELECT id,name FROM prefix_grundrechte WHERE id >= ".$_SESSION['authright']." ORDER BY id DESC");
$edit_cat['cat_list'] = '<option value="0">Keine</option>';
$edit_cat['cat_list'] .= dblistee($edit_cat['Ccat'], "SELECT id,name FROM `prefix_artsys_cats` WHERE id != ".$edit_cat['Cid']." AND recht >= ".$_SESSION['authright']." ORDER BY name ASC");
$tpl->set_ar_out($edit_cat,3);
}
$design->footer();
?>