<?php
/**
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
* @version $Id: classlist.inc.php 20 2008-10-04 14:59 $
*/
(!defined('IN_ADMIN') || !defined('IN_MUDDER')) && exit('Access Denied');
require_once(MOD_ROOT."./model/class.php");
$model = new ClassModle();

if(!$dosubmit) {

    $classsort = @intval($classsort);
    if($delete=='confirm') {
        if(!$classcode) cpmsg('未选择删除的分类项。');
        if(strlen($classcode)==2 && $model->getSubClassCount($classcode)) {
            cpmsg('该板块内，存在分类，请返回删除该板块下的分类。');
        } elseif(strlen($classcode)==4) {
            $classinfo = $model->getClasscode($classcode);
            if(empty($classinfo)) cpmsg('删除的分类不存在或已删除，请返回操作。');
        }
    } else {
        $panels = $classes = array();
        $panels = $model->getClasscodes();
        // 子板块
        if($panels && $panelcode) {
            $classes = $model->getClasscodes($panelcode);
        }
    }

    include cptpl('classlist', MOD_ROOT.'./admin/templates/');

} else {

    //大类排序 子类排序
    if($submitclassorder) { 
        if($model->updateListOrder($orders)) {
            $model->cacheClass();
            $model->cachePanel();
        }
        header("Location:admincp.php?action=$action&file=$file&panelcode=$panelcode");
    }

    if($delete=='yes') {
        if(!$classcode) cpmsg("没有删除的板块分类。",'stop');
        if(strlen($classcode)==4) {
            if(!function_exists('deleteItemFromClass')) {
                require_once(MOD_ROOT."./include/fun_item.php");
            }
            deleteItemFromClass($classcode);
        }
        $model->deleteClass($classcode);
        $model->cacheClass();
        $model->cachePanel();
        if(strlen($classcode)==4) {
            $panelcode = substr($classcode, 0, 2);
            cpmsg('分类删除完毕！', 'admincp.php?action='.$action.'&file=classlist&panelcode='.$panelcode);
        } else {
            cpmsg('板块删除完毕！', 'admincp.php?action='.$action.'&file=classlist');
        }
    }
}
?>