示例#1
0
 /**
  * 保存商品分类
  *
  */
 private function saveGoodsClass()
 {
     /*权限检查*/
     $this->checkAdmin('goods_class_add');
     $input_param['txt_class_top_id'] = intval($this->_input['txt_class_top_id']);
     //父级分类id
     $input_param['txt_class_name'] = trim($this->_input['txt_class_name']);
     //分类名称
     $input_param['txt_class_state'] = intval($this->_input['txt_class_state']);
     //分类状态0、开启1、关闭
     $input_param['txt_class_keywords'] = trim($this->_input['txt_class_keywords']);
     //分类关键字
     $input_param['txt_class_description'] = trim($this->_input['txt_class_description']);
     //分类描述
     $input_param['txt_class_sort'] = intval($this->_input['txt_class_sort']);
     //分类排序
     $input_param['txt_class_language'] = intval($this->_input['txt_class_language']);
     //分类语言显示
     $input_param['txt_class_url'] = trim($this->_input['txt_class_url']);
     //分类指向的url外联
     $input_param['txt_class_menu'] = intval($this->_input['txt_class_menu']);
     //是否导航显示
     $input_param['txt_class_language'] = intval($this->_input['txt_class_language']);
     //选择语言
     $input_param['txt_goods_type_id'] = intval($this->_input['txt_goods_type_id']);
     //商品类型
     $input_param['txt_modify_sub'] = intval($this->_input['modify_sub']);
     //修改范围
     $input_param['txt_class_attr'] = serialize(array_filter($this->_input['txt_class_attr'], 'htmlspecialchars'));
     //序列化特殊属性
     /**
      * 验证注册信息
      */
     $this->obj_validate->setValidate(array("input" => $input_param['txt_class_name'], "require" => "true", "message" => $this->_lang['admin_goods_class_name_is_null']));
     //分类名称不能为空
     $error = $this->obj_validate->validate();
     if ($error != "") {
         //返回错误信息
         $this->adminMessage($error, $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=page_goods_class", 1, 4000);
     } else {
         if ($this->_input['class_id'] != "") {
             $class_id = intval($this->_input['class_id']);
             //检查修改的分类topid是否是当前分类的下级,如果是返回错误,不是的话,正常进行
             $productClassArray = $this->obj_goods_class->listClassDetail("");
             $class_top_id = $input_param['txt_class_top_id'];
             $sub_class = $this->obj_goods_class->getArrayById($productClassArray, $result, $class_id);
             $sub_class[] = $class_id;
             if ($sub_class != null) {
                 if (in_array($class_top_id, $sub_class)) {
                     $this->adminMessage($this->_lang['admin_goods_class_list_move_error'], $this->refer_url, 1, 3000);
                 }
             }
             $rs = $this->obj_goods_class->modifyGoodsClass($input_param, $class_id);
         } else {
             $rs = $this->obj_goods_class->addGoodsClass($input_param);
         }
         if ($rs) {
             $this->obj_goods_class->createGoodsClassArray();
             /*日志保存*/
             $log_array = array();
             $log_array['log_info'] = $this->_lang['admin_goods_class_save_ok'];
             $this->obj_log->inLog($log_array);
             $this->adminMessage($this->_lang['admin_goods_class_save_ok'], $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=list", 1, 1000);
         } else {
             /*日志保存*/
             $log_array = array();
             $log_array['log_info'] = $this->_lang['admin_goods_class_save_false'];
             $this->obj_log->inLog($log_array);
             $this->adminMessage($this->_lang['admin_goods_class_save_false'], $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=page_goods_class", 1, 4000);
         }
     }
 }