<?php
 /**
 *      [XCECP] (C) Colorful Network Inc.
 *      This is NOT a freeware, use is subject to license terms
 */
if(!defined("IN_QKWEB")){exit("Access Denied");}
class NavModel extends BaseModel{
	function getInfo($id){
		if($id && settype($id,"integer")){
			$sql = "select * from qk_nav where id='$id'";
			$info = $this->db->getRow($sql);
			return $info;
		}
		return false;
	}

	function edit($param){
		$id = $param['id'];
		$name = $param['name'];
		if($id && settype($id,"integer") && $name){
			$url = $param['url'];
			$target = $param['target'];
			$sortId = $param['sortId'];
			$class = $param['class'];
			$positionId = $param['positionId'];
			$sql = "update qk_nav set ";
			$sql .= "name='$name',url='$url',target='$target',sortId='$sortId',class='$class',positionId='$positionId' where id='$id'";
			if($this->db->query($sql)){
				$this->msg='修改成功';
				return true;
			}
		}
		return false;
	}

	function add($param){
		$name = $param['name'];
		if($name){
			$url = $param['url'];
			$target = $param['target'];
			$sortId = $param['sortId'];
			$positionId = $param['positionId'];
			$class = $param['class'];
			if(!$sortId || !settype($sortId,"integer")){$sortId=50;}
			$sql = "insert into qk_nav set ";
			$sql .= "name='$name',url='$url',target='$target',sortId='$sortId',class='$class',positionId='$positionId',posttime=UNIX_TIMESTAMP()";
			if($this->db->query($sql)){
				$this->msg='添加成功';
				return true;
			}
		}
		return false;
	}

	function del($id){
		if($id && settype($id,"integer")){
			$sql = "delete from qk_nav where id='$id'";
			if($this->db->query($sql)){
				$this->msg='删除成功';
				return true;
			}
		}
		$this->msg='删除失败';
		return false;
	}
}
?>