<?php
/**
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
* @version $Id: addclass.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) {

    $modifyclass = $model->getClasscode($classcode);
    if(!$modifyclass) cpmsg('修改的板块分类不存在。');
    $panelcode = substr($classcode, 0, 2);
    $panels = $model->getClasscodes();
    $config = $modifyclass['config'] ? unserialize($modifyclass['config']) : '';
    if($config) {
        extract($config, EXTR_SKIP);
    }
    empty($catemap_time) && $catemap_time=5000;
    $catemap_time = $catemap_time / 1000;
    if(!isset($catemap_level)||!is_numeric($catemap_level)) {
        $catemap_level=2;
    }
    include cptpl('classedit', MOD_ROOT.'./admin/templates/');

} else {

    $post['classname'] = html_special_chars_ex($classname);
    if(!$post['classname']) cpmsg('未填写分类名，请返回修改。');
    $post['classorder'] = intval($classorder);

    if(strlen($classcode) == 2) {
        $post['sorts'] = $sorts;
        $post['mapmark'] = $mapmark;
        $post['catemap'] = $catemap;
        $post['catemap_time'] = $catemap_time;
        $post['catemap_level'] = $catemap_level;
        $post['suitplaces'] = $suitplaces;
        $post['itemapply'] = $itemapply;
        $post['avgprice_need'] = $avgprice_need;
        $post['suitplace_enable'] = $suitplace_enable;
        $post['listorder'] = $listorder;
        $post['scoretype'] = $scoretype;
        $post['decimalpoint'] = $decimalpoint;
        $post['tplname_list'] = $tplname_list;
        $post['tplname_detail'] = $tplname_detail;
        $post['meta_keywords'] = $meta_keywords;
        $post['meta_description'] = $meta_description;

        $newclasscode = $model->saveClasscode($post, $classcode);
    } else {
        $post['panelcode'] = $panelcode;
        $model->saveSubClasscode($post,$classcode);
        $classcode = substr($classcode, 0, 2);
    }
    $model->cacheClass();
    $model->cachePanel();
    cpmsg("更新完毕!","admincp.php?action=shop&file=classlist&panelcode=".$classcode);
}
?>