1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace Community\Lib;
- use Dever;
- class Comment
- {
- public function getData($method = 'getAll', $uid, $type = false, $type_id = false, $user = false, $collection_id = false)
- {
- $where['type'] = $type;
- $where['type_id'] = $type_id;
- $info = Dever::db('community/comment')->$method($where);
- $data['info'] = array();
- $data['total'] = Dever::total();
- if ($info) {
- foreach ($info as $k => $v) {
- $data['info'][$k]['uid'] = $v['uid'];
- $data['info'][$k]['content'] = $v['content'];
- $data['info'][$k]['playtime'] = $v['playtime'];
- if ($v['pic']) {
- $data['info'][$k]['pic'] = explode(',', $v['pic']);
- }
- if ($user) {
- $data['info'][$k]['user'] = Dever::load('user/lib/info')->get($v['uid'], $collection_id, true);
- $data['info'][$k]['cdate_string'] = Dever::mdate($v['cdate'], 2);
- }
- }
- }
- return $data;
- }
- # 发表信息
- public function submit($uid, $id, $type, $pic, $content, $playtime, $score_type = false, $score_type_id = false)
- {
- $where['uid'] = $uid;
- $where['type_id'] = $id;
- $where['type'] = $type;
- $where['content'] = $content;
- if ($pic) {
- $where['pic'] = $pic;
- }
- if ($playtime) {
- $where['playtime'] = $playtime;
- }
- $table = 'community/comment';
- $info = false;
- if (!$info) {
- Dever::db($table)->insert($where);
- Dever::score($uid, 'submit_comment', '发布弹幕/评论', false, false, false, $score_type, $score_type_id);
- }
- return true;
- }
- }
|