<?php
/*
 * 74cms 个人会员中心ajax弹出框
 * ============================================================================
 * 版权所有: 骑士网络，并保留所有权利。
 * 网站地址: http://www.74cms.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once(dirname(__FILE__) . '/personal_common.php');
//添加 屏蔽企业
if($act=="save_shield_company"){  
	$uid = intval($_SESSION['uid'])?intval($_SESSION['uid']):exit("-1");
	$setsqlarr['uid'] = $uid;
	$setsqlarr['comkeyword'] = trim($_POST['comkeyword'])?trim($_POST['comkeyword']):exit("-1");
	
	$num = $db->get_total("SELECT COUNT(*) AS num FROM ".table('personal_shield_company')." where uid = ".$_SESSION['uid']." and comkeyword = '".$_POST['comkeyword']."'");
	if($num != 0){
		exit('-2');	//这个屏蔽关键字已经纯在
	}	  
	$num = $db->get_total("SELECT COUNT(*) AS num FROM ".table('personal_shield_company')."  where uid = ".$_SESSION['uid']);  
	if($num >= 5){
		exit('-3');	// 这个是数量，最多不能超过5条
	}
	$insertid = inserttable(table("personal_shield_company"),$setsqlarr,1); 
	if($insertid){
		echo($insertid);
	}else{
		exit("-1");
	} 
}
//修改 屏蔽企业
elseif($act=="get_shield_com_keyword"){
	$id = intval($_POST['id'])?intval($_POST['id']):exit("-1");
	$uid = intval($_SESSION['uid'])?intval($_SESSION['uid']):exit("-1");
	$setsqlarr['comkeyword'] = trim($_POST['comkeyword'])?trim($_POST['comkeyword']):exit("-1");
	$wheresqlarr = " uid = {$uid} and id = {$id}";
	if(updatetable(table("personal_shield_company"),$setsqlarr,$wheresqlarr)){
		exit("1");
	}else{
		exit("-1");
	}
}
//删除 屏蔽企业
elseif($act=="del_shield_company"){
	$uid = intval($_SESSION['uid'])?intval($_SESSION['uid']):exit("-1");
	$keyword_id = intval($_POST['keyword_id'])?intval($_POST['keyword_id']):exit("-1");
	if(del_shield_company($uid,$keyword_id)){
		exit("1");
	}else{
		exit("-1");
	}
}
//设置简历的可见度
elseif($act == "set_visibility"){ 
	$uid = intval($_SESSION['uid']); 
	$visibility = intval($_POST['visibility'])?intval($_POST['visibility']):exit("0");
	$wheresqlarr = " uid={$uid}";  
	if(updatetable(table('resume'),array('display'=>$visibility),$wheresqlarr)){
		updatetable(table('resume_search'),array('display'=>$visibility),$wheresqlarr); 
		echo("1");
	}else{
		echo("0");
	} 
}
 
unset($smarty);
?>