<?php 
//组件model
//todo:被调用的地方比较多，需要增加缓存
class Plugs_model{
	var $_plugs_m=null;
	public function __construct(){
		$this->_plugs_m=new M('plugs');
	}

	//获取所有组件的信息
	public function switchPlug($name,$switch){
		$where='name="'.$name.'"';
		$result=$this->_plugs_m->update($where,array('switch'=>$switch));
		return $result;
	}
	//设置快捷键
	public function setHotkey($name,$key){
		$where='name="'.$name.'"';
		$result=$this->_plugs_m->update($where,array('hotkey'=>$key));
		return $result;
	}
	//获取抽奖组件
	public function getChoujiangPlug(){
		return $this->_plugs_m->select('choujiang=1 order by ordernum desc');
	}
	//获取所有组件的信息
	public function getPlugs($switch=0){
		$where=' 1 ';
		if($switch>0){
			$where.=' and switch='.$switch.' ';
		}
		$where.=' order by ordernum asc';
		$plugs=$this->_plugs_m->select($where);
		return $plugs;
	}
}