<?php

/**
 *     个人中心通讯录
 *
 *     2016-4-25 wzf
 */
    if(!defined('IN_DISCUZ')) {
            exit('Access Denied');
    }
    require_once libfile('function/post');
    require_once libfile('function/misc');
    odz_loadforum();
    if(!$_G['uid']) {
        showmessage('user_not_login');
    }
    //我关注的人
    $home_follow_friend= DB::fetch_all('SELECT u.*,g.gender,p.sightml ,j.username  FROM '.DB::table('home_follow_friend')." as u "
                                . "LEFT JOIN ".DB::table('common_member_profile')." as g ON u.fuid  = g.uid    "
                                . "LEFT JOIN ".DB::table('common_member_field_forum')." as p ON u.fuid  = p.uid "
                                . "INNER JOIN ".DB::table('common_member')." as j ON j.uid  = u.fuid  "
                                . "WHERE u.uid = '$_G[uid]' ORDER BY u.dateline DESC ");
//            echo '<pre>';print_R($home_follow_friend);exit;
    //关注我的粉丝
    $home_follow_me= DB::fetch_all('SELECT u.*,g.gender,p.sightml,j.username  FROM '.DB::table('home_follow_friend')." as u "
                                . "LEFT JOIN ".DB::table('common_member_profile')." as g ON u.uid = g.uid  "
                                . "LEFT JOIN ".DB::table('common_member_field_forum')." as p ON u.uid = p.uid  "
                                . "INNER JOIN ".DB::table('common_member')." as j ON u.uid = j.uid  "
                                . "WHERE u.fuid = '$_G[uid]' ORDER BY u.dateline DESC ");

    //我的黑名单
    $home_black_list= DB::fetch_all('SELECT u.*,g.gender,p.sightml,j.username  FROM '.DB::table('mocuz_blackfriend')." as u "
                                . "LEFT JOIN " .DB::table('common_member_profile')." as g ON g.uid  = u.bid  "
                                . "LEFT JOIN ".DB::table('common_member_field_forum')." as p ON p.uid = u.bid  "
                                . "INNER JOIN ".DB::table('common_member')." as j ON j.uid= u.bid  "
                                . "WHERE u.uid = '$_G[uid]' ORDER BY u.dateline DESC ");

    //个人资料用户信息
    $profile['follow_friend']=array();
    foreach($home_follow_friend as $val){
        $profile['follow_friend'][] = array(
          'uid' => $val['fuid'],
          'gender' => $val['gender']?$val['gender']:'0',
          'username' => $val['username'],
          'sightml' => !empty($val['sightml'])?(strip_tags($val['sightml'])?strip_tags($val['sightml']):odz_lang('no_message_left')):odz_lang('no_message_left'),
          'avatar' => avatar($val['fuid'], 'small', true),
        );
    }
    $profile['follow_me']=array();

    foreach($home_follow_me as $vel){
        $profile['follow_me'][] = array(
          'uid' => $vel['uid'],
          'gender' => $vel['gender']?$vel['gender']:'0',
          'username' => (string)$vel['username'],
          'sightml' => !empty($sightml['sightml'])?(strip_tags($sightml['sightml'])?strip_tags($sightml['sightml']):odz_lang('no_message_left')):odz_lang('no_message_left'),
          'avatar' => avatar($vel['uid'], 'small', true),
        );
    }
    $profile['black_list']=array();
    foreach($home_black_list as $vol){
        $profile['black_list'][] = array(
          'uid' => $vol['bid'],
          'gender' => $vol['gender']?$vol['gender']:'0',
          'username' => (string)$vol['username'],
          'sightml' => !empty($vol['sightml'])?(strip_tags($vol['sightml'])?strip_tags($vol['sightml']):odz_lang('no_message_left')):odz_lang('no_message_left'),
          'avatar' => avatar($vol['bid'], 'small', true),
        );
    }
    odz_result($profile);
?>
