IndexAction::showTalkBox PHP Method

showTalkBox() public method

public showTalkBox ( )
    public function showTalkBox()
    {
        $type = t($_GET['t']);
        $id = intval($_GET['id']);
        if (empty($id) || empty($type)) {
            return;
        }
        $share = array();
        $limit = 10;
        if (in_array($type, array('at', 'com'))) {
            if ($type === 'at') {
                $map['atme_id'] = $id;
                $source = model('Atme')->where($map)->find();
                switch (strtolower($source['table'])) {
                    case 'feed':
                        $ownFeed = model('Feed')->get($source['row_id']);
                        $share['row_id'] = $ownFeed['feed_id'];
                        $share['app'] = $ownFeed['app'];
                        $share['table'] = 'feed';
                        $share['to_uid'] = $ownFeed['uid'];
                        break;
                    case 'comment':
                        $ownComment = model('Comment')->getCommentInfo($source['row_id']);
                        $share['row_id'] = $ownComment['row_id'];
                        $share['app'] = $ownComment['app'];
                        $share['table'] = $ownComment['table'];
                        $share['to_uid'] = $ownComment['uid'];
                        break;
                }
            } elseif ($type === 'com') {
                $ownComment = model('Comment')->getCommentInfo($id);
                $share['row_id'] = $ownComment['row_id'];
                $share['app'] = $ownComment['app'];
                $share['table'] = $ownComment['table'];
                $share['to_uid'] = $ownComment['uid'];
            }
            $source = model('Feed')->get($share['row_id']);
            $source['url'] = U('public/Profile/feed', array('feed_id' => $source['feed_id'], 'uid' => $source['uid']));
            if ($source['is_audit'] == 0 && $source['uid'] != $this->mid) {
                $source['body'] = '内容正在审核';
            }
            $this->assign('source', $source);
            $this->assign('row_id', $source['feed_id']);
            $this->assign('app_uid', $source['uid']);
            $this->assign('app_row_id', $source['app_row_id']);
            $this->assign('app_row_table', $source['app_row_table']);
            $this->assign('app_name', $source['app']);
            $this->assign('table', 'feed');
            // 转发权限判断
            $canrepost = 1;
            $weiboSet = model('Xdata')->get('admin_Config:feed');
            if (!CheckPermission('core_normal', 'feed_share') || !in_array('repost', $weiboSet['weibo_premission'])) {
                $canrepost = 0;
            }
            $this->assign('canrepost', $canrepost);
            $cancomment = intval(CheckPermission('core_normal', 'feed_comment'));
            $this->assign('cancomment', $cancomment);
            $cmap['app'] = $share['app'];
            $cmap['table'] = $share['table'];
            $cmap['row_id'] = $share['row_id'];
            $cmap['_string'] = '( (uid = ' . $this->mid . ' AND to_comment_id = 0) OR (uid = ' . $share['to_uid'] . ' AND to_comment_id = 0) OR (uid = ' . $this->mid . ' AND to_uid = ' . $share['to_uid'] . ') OR (uid = ' . $share['to_uid'] . ' AND to_uid = ' . $this->mid . ') OR (uid = ' . $this->mid . ' AND to_uid = ' . $this->mid . ') OR (uid = ' . $share['to_uid'] . ' AND to_uid = ' . $share['to_uid'] . ') )';
            $talkList = model('Comment')->getCommentList($cmap, 'comment_id ASC', $limit);
            foreach ($talkList['data'] as &$value) {
                if ($value['is_audit'] == 0 && $value['uid'] != $this->mid) {
                    $value['content'] = '内容正在审核';
                }
            }
            $this->assign('talkList', $talkList);
            $this->assign('sourceId', $share['row_id']);
            $sinceId = end($talkList['data']);
            $sinceId = $sinceId['comment_id'];
            $this->assign('sinceId', $sinceId);
            $this->assign('toUid', $share['to_uid']);
            $this->assign('maxId', 0);
            $initNums = model('Xdata')->getConfig('weibo_nums', 'feed');
            $this->assign('initNums', $initNums);
        } elseif ($type === 'pmsg') {
            $message = model('Message')->isMember($id, $this->mid, true);
            // 验证数据
            if (empty($message)) {
                $this->error(L('PUBLIC_PRI_MESSAGE_NOEXIST'));
            }
            $message['member'] = model('Message')->getMessageMembers($id, 'member_uid');
            $message['to'] = array();
            // 添加发送用户ID
            foreach ($message['member'] as $v) {
                $this->mid != $v['member_uid'] && ($message['to'][] = $v);
            }
            // 设置信息已读(私信列表页去掉new标识)
            model('Message')->setMessageIsRead($id, $this->mid, 0);
            $message['since_id'] = model('Message')->getSinceMessageId($message['list_id'], $message['message_num']);
            $this->assign('message', $message);
            $userinfo = model('User')->getUserInfo($this->mid);
            $this->assign('userinfo', $userinfo);
            $talkList = model('Message')->getMessageByListId($id, $this->mid, $message['since_id'], 0, 10);
            foreach ($talkList['data'] as &$value) {
                $value['content'] == t($value['content']) && ($value['content'] = replaceUrl($value['content']));
            }
            $this->assign('talkList', $talkList);
            $this->assign('sourceId', $id);
            $this->assign('sinceId', $message['since_id']);
            $maxId = end($talkList['data']);
            $maxId = $maxId['message_id'];
            $this->assign('maxId', $maxId);
            $this->assign('toUid', 0);
            $this->assign('max_since_id', $talkList['data'][0]['message_id']);
        }
        $this->assign('type', $type);
        $this->display('talkBox');
    }