<?php
/*
	[Office 515158] (C) 2009-2012 天生创想 Inc.
	$Id: mod_user.php 1209087 2012-01-08 08:58:28Z baiwei.jiang $
*/
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
empty($do) && $do = 'list';

if ($do == 'list') {
	if ($result = $db->fetch_one_array("SELECT * FROM ".DB_TABLEPRE."user a,".DB_TABLEPRE."user_view b WHERE a.id=b.uid and a.id = '$_USER->id' ")) {
		include_once('template/user.php');
	} else {
		prompt('信息不存在。');
	}
}elseif ($do == 'home') {
	$sqls = "SELECT homemana FROM ".DB_TABLEPRE."user_view  WHERE uid='".$_USER->id."'";
	$bghome = $db->fetch_one_array($sqls);
	if($_GET['view']=='add'){
		$id = getGP('menuid','G');
		$idarr=explode('_',$id);
		$homemana=explode('|',$bghome['homemana']);
		$html='';
		for($i=0;$i<sizeof($homemana);$i++){
			$j=$j+1;
			if($idarr[0]==$j){
				$html.=$homemana[$i].'"'.$idarr[1].'",|';
			}else{
				$html.=$homemana[$i].'|';
			}
		}
		$user_view = array(
			'homemana' => substr($html, 0, -1)
		);
		update_db('user_view',$user_view, array('uid'=>$_USER->id));
	}
	if($_GET['view']=='removeIcon'){
		$id = getGP('menuid','G');
		$user_view = array(
			'homemana' => str_replace('"'.trim($id).'",','',$bghome['homemana'])
		);
		update_db('user_view',$user_view, array('uid'=>$_USER->id));
	}
	if($_GET['view']=='moveIconTo'){
		$id = getGP('menuid','G');
		$idarr=explode('_',$id);
		$homemana=str_replace('"'.$idarr[1].'",','',$bghome['homemana']);
		$homemana=explode('|',$homemana);
		$html='';
		for($i=0;$i<sizeof($homemana);$i++){
			$j=$j+1;
			if($idarr[0]==$j){
				$html.=$homemana[$i].'"'.$idarr[1].'",|';
			}else{
				$html.=$homemana[$i].'|';
			}
		}
		$user_view = array(
			'homemana' => substr($html, 0, -1)
		);
		update_db('user_view',$user_view, array('uid'=>$_USER->id));
	}
	include_once('template/home.php');
} elseif ($do == 'bg') {
	if($_GET['view']!=''){
		$user_view = array(
			'homebg' => check_str(getGP('value','G'))
		);
		update_db('user_view',$user_view, array('uid'=>$_USER->id));
		//header('Location: home.php?mid='.$_GET['mid']);
	}
	include_once('template/bg.php');
} elseif ($do == 'save') {
	$savetype = getGP('savetype','P');
	$uid = getGP('uid','P','int');
	$user_view = array(
		'pic' => check_str(getGP('pic','P')),
		'birthdate' => getGP('birthdate','P'),
		'sex' => getGP('sex','P'),
		'phone' => getGP('phone','P'),
		'tel' => check_str(getGP('tel','P')),
		'fax' => getGP('fax','P','int'),
		'email' => check_str(getGP('email','P')),
		'qq' => check_str(getGP('qq','P')),
		'contact' => check_str(getGP('contact','P')),
		'hometype' => check_str(getGP('hometype','P')),
		'address' => check_str(getGP('address','P'))
	);
	update_db('user_view',$user_view, array('uid'=>$uid));
	show_msg('个人信息更新成功！', 'admin.php?ac='.$ac.'&fileurl='.$fileurl.'');	

} elseif ($do == 'home_txt') {
	print_r(strpos($biuuu,$search));
	//$txt='home_workclass,home_news_34,home_news_1,home_news_6,home_news_5,home_workdate,home_plan,home_duty,home_blog,home_document_1,home_document_2,home_document_3,home_document_4,home_document_5,home_document_6,home_knowledge,home_app1,home_bbs,home_file,home_project,home_training,home_book,home_goods,home_conference,home_company,home_care,home_service,home_complaints,home_offer,home_program,home_contract,home_order,home_price,home_payment,home_supplier,home_purchase,home_business';
	//$txtname='工作流,公告,新闻,电子期刊,大事记,日程安排,工作计划,我的任务,工作日记,个人文件柜,公共文件柜,网络硬盘,下载管理,规章制度,报表管理,知识阅读,投票,论坛,档案管理,项目审批,培训管理,图书管理,办公用品,会议管理,客户信息,客户关怀,客户回访,客户投诉,报价单,解决方案,合同,订单,收款单,付款单,供应商信息,采购信息,代理商信息';
	//$txt=explode(',',$txt); 
	//$txtname=explode(',',$txtname); 
	$sqls = "SELECT home_txt FROM ".DB_TABLEPRE."user_view  WHERE uid='".$_USER->id."'";
	$bghome = $db->fetch_one_array($sqls);
	if($_GET['view']!=''){
		//$home_txt = str_replace("),",")|",getGP('home_txt','G'));
		//$home_txt = str_replace(",","!",$home_txt);
		//echo getGP('home_txt','G');
		//exit;
		$user_view = array(
			'home_txt' => check_str(getGP('home_txt','G'))
		);
		update_db('user_view',$user_view, array('uid'=>$_USER->id));
		//header('Location: home.php');
		show_msg('桌面信息保存成功！', 'admin.php?ac=user&fileurl=member&do=home_txt');
	}
	include_once('template/home_txt.php');
}
function home_txt($type){
	global $db;
	if($type!=''){
		$sqls = "SELECT title,type FROM ".DB_TABLEPRE."homekey  WHERE modname='".$type."'";
		$row = $db->fetch_one_array($sqls);
		echo $row['title'];
		echo '[';
		if($row['type']==1){
			echo '<font color=red>汇总版块</font>';
		}elseif($row['type']==2){
			echo '内容版本';
		}elseif($row['type']==3){
			echo '统计版块';
		}
		echo ']';
	}
	return ;
}
?>