table)->config['set']['table_name'][$type]; return $table; } public function del($uid, $id, $state = 2) { $where['id'] = $id; $where['uid'] = $uid; $info = Dever::db($this->table)->one($where); if ($info) { $update['where_id'] = $id; $update['state'] = $state; Dever::db($this->table)->update($update); } return true; } public function getData($method = 'getAll', $uid, $type = false, $type_id = false, $total = false, $id = false, $times = false, $day = false, $collection_id = false) { $where['type'] = $type; $where['type_id'] = $type_id; if ($id > 0) { $where['noid'] = $id; } if ($day && $day > 0) { $where['day'] = $day; } else { $where['day'] = -1; } $data['info'] = Dever::db($this->table)->$method($where); if ($total) { if ($method == 'getAll') { $data['total'] = Dever::total(); } else { $data['total'] = Dever::db($this->table)->getTotal($where); } } if ($data['info']) { foreach ($data['info'] as $k => $v) { $data['info'][$k] = $this->one($uid, $v, $times, $collection_id); } } return $data; } public function content($id) { $info = Dever::db($this->table)->one($id); $table = array(); $pic = ''; if ($info['pic']) { $temp = explode(',', $info['pic']); foreach ($temp as $k => $v) { $pic .= ''; } } $table['内容'] = $info['content']; $table['图片'] = $pic; return Dever::table($table); } # 发表信息 public function submit($uid, $id, $type, $pic, $content, $to_id, $to_uid, $day = false, $score_type = false, $score_type_id = false) { $where['uid'] = $uid; $where['type_id'] = $id; $where['type'] = $type; if ($day) { $where['day'] = $day; } $where['state'] = 1; $table = $this->table; $info = false; $where['content'] = $content; if ($pic) { $where['pic'] = $pic; } if ($to_id) { $where['to_id'] = $to_id; } if ($to_uid) { $where['to_uid'] = $to_uid; } if ($info && $type == 3 && !$to_id) { $info = Dever::db($table)->one($where); Dever::alert('已发布过动态,仅能发布一次,可删除旧动态后再添加'); } //$info = false; $data_table = $this->table($type); if (!$info) { $data = Dever::db($data_table)->one($id); if (isset($data['name']) && $data['name']) { $where['type_name'] = $data['name']; } Dever::db($table)->insert($where); if ($to_uid && $to_uid != $uid) { Dever::score($uid, 'reply_moment', '回复朋友圈', false, false, false, $score_type, $score_type_id); Dever::score($to_uid, 'reply_me_moment', '被回复朋友圈', false, false, false, $score_type, $score_type_id); } else { Dever::score($uid, 'submit_moment', '发表朋友圈', false, false, false, $score_type, $score_type_id); } } return true; } private function one($uid, $info, $times = false, $collection_id = false) { # 验证消息是否是自己的 $info['me'] = 2; $info['del'] = ''; if ($uid == $info['uid']) { $info['me'] = 1; $info['del'] = '删除'; $info['del_state'] = 2; } $key = 30; $info['pic'] = explode(',', $info['pic']); $info['user'] = Dever::load('user/lib/info')->get($info['uid'], $collection_id, true); $info['cdate_string'] = Dever::load('collection/lib/times')->getDate($info['day'], $info['cdate'], $times); # 点赞数 $info['num_up'] = $info['num_up'] + 0; $info['up_list'] = array(); $info['up_list']['user'] = (object) array(); $info['up_list']['total'] = 0; $info['up_list_total'] = 0; if ($info['num_up'] > 0) { # 批量获取最新的点赞名单 $info['up_list'] = Dever::load('community/lib/up')->getData($info['id'], $key, $collection_id); $info['up_list_total'] = count($info['up_list']['user']); } # 反对数 $info['num_oppose'] = $info['num_oppose'] + 0; $info['is_up'] = $info['is_oppose'] = false; if ($uid) { # 是否点赞 $info['is_up'] = Dever::load('community/lib/up')->get($uid, $info['id'], $key); # 是否反对 $info['is_oppose'] = Dever::load('community/lib/oppose')->get($uid, $info['id'], $key); } # 评论数 $info['num_comment'] = $info['num_comment'] + 0; # 获取引用的数据 $info['to_user'] = array(); if ($info['to_uid']) { $info['to_user'] = Dever::load('user/lib/info')->get($info['to_uid'], $collection_id, true); } # 获取热门的子信息 $info['child'] = array(); if ($info['type'] < 20) { $child = $this->getData('getHot', $uid, $key, $info['id'], true, false, $times, $info['day'], $collection_id); if ($child && $child['info']) { $info['child'] = $child['info']; $info['child_total'] = $child['total']; } } # 获取最新的服务器时间 $info['server_time'] = time(); return $info; } }