Comment.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Community\Lib;
  3. use Dever;
  4. class Comment
  5. {
  6. public function getData($method = 'getAll', $uid, $type = false, $type_id = false, $user = false, $collection_id = false)
  7. {
  8. $where['type'] = $type;
  9. $where['type_id'] = $type_id;
  10. $info = Dever::db('community/comment')->$method($where);
  11. $data['info'] = array();
  12. $data['total'] = Dever::total();
  13. if ($info) {
  14. foreach ($info as $k => $v) {
  15. $data['info'][$k]['uid'] = $v['uid'];
  16. $data['info'][$k]['content'] = $v['content'];
  17. $data['info'][$k]['playtime'] = $v['playtime'];
  18. if ($v['pic']) {
  19. $data['info'][$k]['pic'] = explode(',', $v['pic']);
  20. }
  21. if ($user) {
  22. $data['info'][$k]['user'] = Dever::load('user/lib/info')->get($v['uid'], $collection_id, true);
  23. $data['info'][$k]['cdate_string'] = Dever::mdate($v['cdate'], 2);
  24. }
  25. }
  26. }
  27. return $data;
  28. }
  29. # 发表信息
  30. public function submit($uid, $id, $type, $pic, $content, $playtime, $score_type = false, $score_type_id = false)
  31. {
  32. $where['uid'] = $uid;
  33. $where['type_id'] = $id;
  34. $where['type'] = $type;
  35. $where['content'] = $content;
  36. if ($pic) {
  37. $where['pic'] = $pic;
  38. }
  39. if ($playtime) {
  40. $where['playtime'] = $playtime;
  41. }
  42. $table = 'community/comment';
  43. $info = false;
  44. if (!$info) {
  45. Dever::db($table)->insert($where);
  46. Dever::score($uid, 'submit_comment', '发布弹幕/评论', false, false, false, $score_type, $score_type_id);
  47. }
  48. return true;
  49. }
  50. }