Discuz space_merge函数 获取用户附属表信息
//获取用户附属表信息,累加到第一个变量$values
//$values['uid'] 可以指定UID
function space_merge(&$values, $tablename, $isarchive = false) {
global $_G;
$uid = empty($values['uid'])?$_G['uid']:$values['uid'];
$var = "member_{$uid}_{$tablename}";
if($uid) {
if(!isset($_G[$var])) {
$ext = $isarchive ? '_archive' : '';
if(($_G[$var] = C::t('common_member_'.$tablename.$ext)->fetch($uid)) !== false) {
if($tablename == 'field_home') {
$_G['setting']['privacy'] = empty($_G['setting']['privacy']) ? array() : (is_array($_G['setting']['privacy']) ? $_G['setting']['privacy'] : dunserialize($_G['setting']['privacy']));
$_G[$var]['privacy'] = empty($_G[$var]['privacy'])? array() : is_array($_G[$var]['privacy']) ? $_G[$var]['privacy'] : dunserialize($_G[$var]['privacy']);
foreach (array('feed','view','profile') as $pkey) {
if(empty($_G[$var]['privacy'][$pkey]) && !isset($_G[$var]['privacy'][$pkey])) {
$_G[$var]['privacy'][$pkey] = isset($_G['setting']['privacy'][$pkey]) ? $_G['setting']['privacy'][$pkey] : array();
}
}
$_G[$var]['acceptemail'] = empty($_G[$var]['acceptemail'])? array() : dunserialize($_G[$var]['acceptemail']);
if(empty($_G[$var]['acceptemail'])) {
$_G[$var]['acceptemail'] = empty($_G['setting']['acceptemail'])?array():dunserialize($_G['setting']['acceptemail']);
}
}
} else {
C::t('common_member_'.$tablename.$ext)->insert(array('uid'=>$uid));
$_G[$var] = array();
}
}
$values = array_merge($values, $_G[$var]);
}
}
页:
[1]