Example #1
0
 /**
  * 用户信息初始化
  */
 private function initUser()
 {
     $GLOBALS['time_run_detail']['action_init_user_start'] = microtime(true);
     // 邀请跳转
     if (isset($_GET['invite']) && APP_NAME . '/' . MODULE_NAME != 'public/Register') {
         redirect(U('public/Register/index', array('invite' => t($_GET['invite']))));
         exit;
     }
     // 验证登陆
     if (intval($_SESSION['mid']) == 0 && model('Passport')->needLogin()) {
         if (defined('LOGIN_URL')) {
             redirect(LOGIN_URL);
         } else {
             if (APP_NAME == 'admin') {
                 if (MODULE_NAME != 'Public' && !model('Passport')->checkAdminLogin()) {
                     redirect(U('admin/Public/login'));
                     exit;
                 }
             } else {
                 redirect(U('public/Passport/login'));
                 exit;
             }
         }
     }
     $GLOBALS['time_run_detail']['action_init_user_login'] = microtime(true);
     //判断登录有效期
     $activeTime = cookie('TSV4_ACTIVE_TIME');
     if (C('COOKIE_EXPIRE') && $activeTime < time() && APP_NAME != 'admin' && ACTION_NAME != 'login') {
         unset($_SESSION['mid']);
         cookie('TSV4_LOGGED_USER', null);
         $this->assign('jumpUrl', U('public/Passport/login'));
         $this->error(L('PUBLIC_TIME_OUT'));
         exit;
     } else {
         cookie('TSV4_ACTIVE_TIME', time() + C('COOKIE_EXPIRE'));
     }
     //当前登录者uid
     $GLOBALS['ts']['mid'] = $this->mid = intval($_SESSION['mid']);
     //当前访问对象的uid
     $GLOBALS['ts']['uid'] = $this->uid = intval($_REQUEST['uid'] == 0 ? $this->mid : $_REQUEST['uid']);
     // 验证站点访问权限
     // 验证应用访问权限
     // 获取用户基本资料
     if ($this->mid > 0 || $this->uid > 0) {
         $GLOBALS['ts']['user'] = !empty($this->mid) ? $this->user = model('User')->getUserInfo($this->mid) : array();
         if ($this->mid != $this->uid) {
             $GLOBALS['ts']['_user'] = !empty($this->uid) ? model('User')->getUserInfo($this->uid) : array();
         } else {
             $GLOBALS['ts']['_user'] = $GLOBALS['ts']['user'];
         }
         $GLOBALS['time_run_detail']['action_init_user_info'] = microtime(true);
         // 未初始化
         $module_arr = array('Register' => 1, 'Passport' => 1, 'Account' => 1);
         if (0 < $this->mid && 0 == $this->user['is_init'] && APP_NAME != 'admin' && !isset($module_arr[MODULE_NAME])) {
             // 注册完成后就开启此功能
             if ($this->user['is_active'] == '0') {
                 U('public/Register/waitForActivation', 'uid=' . $this->mid, true);
             } else {
                 $init_config = model('Xdata')->get('admin_Config:register');
                 $user_tags = D('app_tag')->where('row_id=' . $this->mid)->findAll();
                 //若开启资料完善
                 if ($init_config['personal_open']) {
                     if (in_array('face', $init_config['personal_required']) && !model('Avatar')->hasAvatar()) {
                         U('public/Register/step2', '', true);
                     } elseif (in_array('location', $init_config['personal_required']) && $GLOBALS['ts']['_user']['location'] == '') {
                         U('public/Register/step3', '', true);
                     } elseif (in_array('intro', $init_config['personal_required']) && $GLOBALS['ts']['_user']['intro'] == '') {
                         U('public/Register/step3', '', true);
                     } elseif (in_array('tag', $init_config['personal_required']) && !$user_tags) {
                         U('public/Register/step3', '', true);
                     }
                 }
                 /*
                                     if ($init_config ['photo_open']) {
                                         U ( 'public/Register/step2', '', true );
                                     }
                                     if ($init_config ['tag_open']) {
                                         U ( 'public/Register/step3', '', true );
                                     }*/
                 // 添加双向关注用户
                 $registerConfig = model('Xdata')->get('admin_Config:register');
                 $eachFollow = $registerConfig['each_follow'];
                 if (!empty($eachFollow)) {
                     model('Follow')->eachDoFollow($this->mid, $eachFollow);
                 }
                 // 添加默认关注用户
                 $defaultFollow = $registerConfig['default_follow'];
                 $defaultFollow = array_diff(explode(',', $defaultFollow), explode(',', $eachFollow));
                 if (!empty($defaultFollow)) {
                     model('Follow')->bulkDoFollow($this->mid, $defaultFollow);
                 }
                 model('Register')->overUserInit($GLOBALS['ts']['mid']);
                 U('square/Index/index', '', true);
             }
         }
         $GLOBALS['time_run_detail']['action_init_user_inition'] = microtime(true);
         if ($this->uid > 0 && $this->initUserData) {
             //当前用户的所有已添加的应用
             $GLOBALS['ts']['_userApp'] = $userApp = model('UserApp')->getUserApp($this->uid);
             $GLOBALS['time_run_detail']['action_init_user_data_app'] = microtime(true);
             //当前用户的统计数据
             $GLOBALS['ts']['_userData'] = $userData = model('UserData')->getUserData($this->uid);
             $GLOBALS['time_run_detail']['action_init_user_data_data'] = microtime(true);
             $userCredit = model('Credit')->getUserCredit($this->uid);
             $GLOBALS['time_run_detail']['action_init_user_data_credit'] = microtime(true);
             $this->assign('userCredit', $userCredit);
             $this->assign('_userData', $userData);
             $this->assign('_userApp', $userApp);
         }
         $GLOBALS['time_run_detail']['action_init_user_data'] = microtime(true);
         $GLOBALS['time_run_detail']['action_init_user_disable'] = microtime(true);
     }
     $this->user = EmojiFormat::de($this->user);
     $this->assign('mid', $this->mid);
     //登录者
     $this->assign('uid', $this->uid);
     //访问对象
     $this->assign('user', $this->user);
     //当前登陆的人
     Addons::hook('core_filter_init_user');
     $GLOBALS['time_run_detail']['action_init_user_end'] = microtime(true);
     return true;
 }
Example #2
0
 public function getIntroAttribute($intro)
 {
     return EmojiFormat::de($intro);
 }
Example #3
0
/**
 * 格式化Emoji
 * 该方法兼容以前使用的地方~如果开发需要,请按照下面示例,使用新的依赖包。
 *
 * @param bool $type true为将emoji格式化为代码,false为将代码格式化为emoji
 * @param string|array 数据,如果数数组,就递归,解析多维内部数据
 * @return string
 * @author Seven Du <*****@*****.**>
 **/
function formatEmoji($type = false, $data)
{
    if ($type) {
        return \Medz\Component\EmojiFormat::en($data);
    }
    return \Medz\Component\EmojiFormat::de($data);
}
Example #4
0
 /**
  * 获取指定用户的相关信息
  *
  * @param  array $map
  *                    查询条件
  * @return array 指定用户的相关信息
  */
 private function _getUserInfo(array $map, $field = '*')
 {
     $user = $this->getUserDataByCache($map, $field);
     unset($user['password']);
     if (!$user) {
         $this->error = L('PUBLIC_GET_INFORMATION_FAIL');
         // 获取用户信息失败
         return false;
     } else {
         $uid = $user['uid'];
         $user = array_merge($user, model('Avatar')->init($user['uid'])->getUserAvatar());
         $user['avatar_url'] = U('public/Attach/avatar', array('uid' => $user['uid']));
         $user['space_url'] = !empty($user['domain']) ? U('public/Profile/index', array('uid' => $user['domain'])) : U('public/Profile/index', array('uid' => $user['uid']));
         $user['space_link'] = "<a href='" . $user['space_url'] . "' target='_blank' uid='{$user['uid']}' event-node='face_card'>" . $user['uname'] . '</a>';
         $user['space_link_no'] = "<a href='" . $user['space_url'] . "' title='" . $user['uname'] . "' target='_blank'>" . $user['uname'] . '</a>';
         // 用户勋章
         $user['medals'] = model('Medal')->getMedalByUid($user['uid']);
         // 用户认证图标
         $groupIcon = $authIcon = array();
         $aIcon[5] = '<i class="type-trade"></i>';
         $aIcon[6] = '<i class="type-hangjia"></i>';
         $aIcon[7] = '<i class="type-daren"></i>';
         $userGroup = model('UserGroupLink')->getUserGroupData($uid);
         $user['api_user_group'] = $userGroup[$uid];
         $user['user_group'] = $userGroup[$uid];
         $only = array(array(), array());
         // 			$authenticate = array();
         foreach ($userGroup[$uid] as $value) {
             ($value['user_group_id'] == 5 || $value['user_group_id'] == 6) && ($value['company'] = M('user_verified')->where("uid={$uid} and usergroup_id=" . $value['user_group_id'])->getField('company'));
             if ($value['is_authenticate'] == 1) {
                 $authIcon[] = $aIcon[$value['user_group_id']];
                 $authenticate[$value['user_group_id']] = $value;
             }
             $groupIcon[] = '<img title="' . $value['user_group_name'] . '" src="' . $value['user_group_icon_url'] . '" style="width:auto;height:auto;display:inline;cursor:pointer;" />';
             $type = $value['is_authenticate'] ? 1 : 0;
             if (empty($only[$type])) {
                 $only[$type] = $value;
             } elseif ($only[$type]['ctime'] < $value['ctime']) {
                 $only[$type] = $value;
             }
         }
         if (!empty($only[0])) {
             $user['group_icon_only'] = $only[0];
         } elseif (!empty($only[1])) {
             $user['group_icon_only'] = $only[1];
         } else {
             $user['group_icon_only'] = array();
         }
         /*group_icon_only end*/
         $user['group_icon'] = implode('&nbsp;', $groupIcon);
         //$user ['auth_icon'] = implode ( ' ', $authIcon );
         $user['credit_info'] = model('Credit')->getUserCredit($uid);
         $user['intro'] = $user['intro'] ? formatEmoji(false, $user['intro']) : '';
         $user['uname'] = EmojiFormat::de($user['uname']);
         model('Cache')->set('ui_' . $uid, $user, 600);
         static_cache('user_info_' . $uid, $user);
         return $user;
     }
 }
Example #5
0
 protected static function deEmoji($data)
 {
     return EmojiFormat::de($data);
 }