<?php
/**
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
* @version $Id class.inc.php 5 2008-08-24 10:26 $
*/
(!defined('IN_ADMIN') || !defined('IN_MUDDER')) && exit('Access Denied');

if($dosubmit) {

    if(is_array($articleclass)) {
        foreach($articleclass_my as $classid => $value) {
            $classid = intval($classid);
            if(empty($classid)||$classid<0) continue;
            $value['displayorder'] = intval($value['displayorder']);
            $db->update_new($dbpre."articleclass","classid='$classid'", $value);          
        }
    }
    if($newclassname) {
        $db->query("INSERT INTO {$dbpre}articleclass SET classname='$newclassname'");
    }

    // 更新分类缓存
    write_cache_articleclass();

    cpmsg('操作完毕！', 'admincp.php?action=article&file=class');

} elseif($op == 'delete') {

    if(empty($classid)||$classid<0) cpmsg('无效的类别ID。','admincp.php?action='.$action.'&file='.$file.'&op=class');
    if($classid==1) cpmsg('必须保留一个分类，请返回。');
    $db->update("DELETE FROM {$dbpre}articles WHERE classid='$classid'");
    $db->update("DELETE FROM {$dbpre}articleclass WHERE classid='$classid'");
    cpmsg('删除完毕！', 'admincp.php?action=article&file=class');

    // 更新分类缓存
    write_cache_articleclass();

} else {

    $query = $db->query("SELECT * FROM {$dbpre}articleclass ORDER BY displayorder,classid");
    $total = $db->num_rows($query);

}
include cptpl('class', MOD_ROOT.'admin/templates/');
?>