config['type_name'][$type]; return $table; } # 获取列表 public function get($id, $type, $uid = false) { $where['type'] = $type; $where['type_id'] = $id; $table = $this->table($type); $data = Dever::db($table)->getAll($where); if ($data) { foreach ($data as $k => $v) { $user = Dever::load('passport/api')->info($v['uid']); $data[$k]['time'] = Dever::mdate($v['cdate'], 2); $data[$k]['username'] = $user['username']; $data[$k]['avatar'] = $user['avatar']; $data[$k]['cdate_time'] = date('Y-m-d H:i:s', $v['cdate']); # 检查是否点赞 if ($uid > 0) { $data[$k]['up'] = Dever::load('act/lib/like')->get($uid, $v['id'], 11); } else { $data[$k]['up'] = 0; } $data[$k]['content'] = $this->getContent($v['content']); } } return $data; } # 获取当前用户的信息列表 public function getList($uid) { $where['uid'] = $uid; $where['type'] = '1,2,3'; $info = Dever::db('community/comment')->getAll($where); if ($info) { foreach ($info as $k => $v) { $info[$k]['content'] = $this->getContent($v['content']); } } return $info; } public function content($content, $id) { $content = $this->getContent($content); return ''.$content.''; } public function getContent($content) { if (strstr($content, '_b64')) { $content = str_replace('_b64', '', $content); $content = base64_decode($content); } return $content; } # 发表信息 public function submit($uid, $id, $type, $content) { $where['uid'] = $uid; $where['type_id'] = $id; $where['type'] = $type; $where['content'] = base64_encode($content) . '_b64'; $table = $this->table($type); $info = Dever::db($table)->one($where); $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); } Dever::score($uid, 'submit_commit', '发表评论'); # 更新评论数 $where = array(); $where['data_id'] = $id; $where['type'] = $type; $where['state'] = 1; $total = Dever::db($table)->total($where); //Dever::db($data_table)->update(array('where_id' => $id, 'num_comment' => $total)); return true; } }