<?php
/*
	[Office 515158] (C) 2009-2012 天生创想 Inc.
	$Id: mod_home 1209087 2012-01-08 08:58:28Z baiwei.jiang $
*/
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
get_key("config_usergroup");
empty($do) && $do = 'list';
if ($do == 'list') {
	//列表信息 
	$wheresql = '';
	$page = max(1, getGP('page','G','int'));
	$pagesize = $_CONFIG->config_data('pagenum');
	$offset = ($page - 1) * $pagesize;
	$url = 'admin.php?ac='.$ac.'&fileurl='.$fileurl.'';
	$num = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE.DB_JT."homekey");
     $sql = "SELECT * FROM ".DB_TABLEPRE.DB_JT."homekey ORDER BY numbers ASC";
	$result = $db->fetch_all($sql);

	include_once('template/home.php');

}elseif ($do == 'add') {
	if(getGP('view','P')!=''){
		$id = getGP('id','P','int');
		if($id!=''){
			$homekey = array();
			if(getGP('user','P')!=''){
				$homekey['user'] = ','.getGP('user','P').',';
			}else{
				$homekey['user'] ='0';
			}
			$homekey['title'] = getGP('title','P');
			$homekey['type1'] = getGP('type1','P');
			$homekey['numbers'] = getGP('numbers','P');
			update_db(DB_JT.'homekey',$homekey, array('id' => $id));
		}else{
			$homekey = array();
			$homekey['title'] = getGP('title','P');
			$homekey['modname'] = getGP('modname','P');
			$homekey['type'] = getGP('type','P');
			$homekey['type1'] = getGP('type1','P');
			$homekey['tables'] = getGP('tables','P');
			if(getGP('user','P')!=''){
				$homekey['user'] = ','.getGP('user','P').',';
			}else{
				$homekey['user'] ='0';
			}
			$homekey['numbers'] = 999;
			insert_db(DB_JT.'homekey',$homekey);
		}
		show_msg('桌面权限设定成功！', 'admin.php?ac='.$ac.'&fileurl='.$fileurl.'');
	}else{
		$id = getGP('id','G','int');
		if($id!=''){
			$row = $db->fetch_one_array("SELECT * FROM ".DB_TABLEPRE.DB_JT."homekey WHERE id = '".$id."'");
			$_title['name']='设置';
		}else{
			$_title['name']='发布';
		}
		$row['type']=2;
		$row['type1']=1;
		$row['tables']=0;
		include_once('template/homeadd.php');
		
	}
	
}
?>