<?php

// 获取首页数据
require_once ("../user_include.inc");

ErrorLogger::doOutput("Compass...ajax_get_user_role.php....Start.", 0);

//获取参数
$unionId = ParamUtil::getRequestString("unionId");

$result = array();

//参数检查
if(empty($unionId)) {
	$result["message"] = "参数错误！";
	responseNG($result);
}

//判断用户是否存在
$param = array();
$param['unionid'] = $unionId;
$param['delete_flg'] = false;
$userList = UserMst::getList($param,'id','desc', 0, 1);
if(empty($userList)) {
	$result["message"] = "用户不存在！";
	responseNG($result);
}

$userMst = $userList[0];

//判断用户身份分别获取数据
$volunteerEventList = array();
$socialEventList = array();
$socialEventList = array();
$mediaList = array();

//[1：家园用户]
if($userMst->role == 1) {
	//志愿者活动[查找本校发布的志愿者活动+面向所属区域学校发布的志愿者活动]
	$param = array();
	$param['school_no'] = $userMst->school_no;
	$param['original_source'] = $userMst->school_no;
	$param['delete_flg'] = false;
	$volunteerEventList = VolunteerEventDat::getList($param,'id','desc', 0, 1);
	
	//社会实践【家园用户无社会实践】
	
	//亲子活动
	$param = array();
	$param['school_no'] = $userMst->school_no;
	$param['original_source'] = $userMst->school_no;
	$param['delete_flg'] = false;
	$familyEventList = FamilyEventDat::getList($param,'id','desc', 0, 1);
}

//[2：家校用户]
if($userMst->role == 1) {
	//志愿者活动
	
	//社会实践
	$param = array();
	$param['school_no'] = $userMst->school_no;
	$param['original_source'] = $userMst->school_no;
	$param['delete_flg'] = false;
	$socialEventList = SocialEventDat::getList($param,'id','desc', 0, 1);
	
	//亲子活动【家校用户无亲子活动】
	//公益课堂
}

//[3：高职用户]
if($userMst->role == 1) {
	//志愿者活动
	
	//社会实践【高职用户无亲子活动】
	//亲子活动【高职用户无亲子活动】
	//公益课堂
}

//[4：教育局领导]
if($userMst->role == 1) {
	//志愿者活动
	
	//社会实践【高职用户无亲子活动】
	//亲子活动【高职用户无亲子活动】
	//公益课堂
}

//[5：社会用户]
if($userMst->role == 1) {
	//志愿者活动
	
	//社会实践【高职用户无亲子活动】
	//亲子活动【高职用户无亲子活动】
	//公益课堂
}

//[6：机构用户]
if($userMst->role == 1) {
	//志愿者活动
	
	//社会实践【高职用户无亲子活动】
	//亲子活动【高职用户无亲子活动】
	//公益课堂
}

//公益课堂
$param = array();
$param['delete_flg'] = false;
$mediaList = CourseMediaDat::getList($param,'id','desc', 0, 3);

//组装返回数据
$result["volunteerEventList"] = $volunteerEventList;
$result["familyEventList"] = $familyEventList;
$result["socialEventList"] = $socialEventList;
$result["mediaList"] = $mediaList;

ErrorLogger::doOutput("Compass...ajax_get_user_role.php....End.", 0);

//返回结果
responseOK($result);

function responseNG($result) {
	$result = array("status"=>"NG", "result"=>$result);
	print json_encode($result);
	exit;
}
function responseOK($result) {
	$result = array("status"=>"OK", "result"=>$result);
	print json_encode($result);
	exit;
}
?>