Comment.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. # 如果是商品,要先验证是否购买
  33. if ($type == 'content/product') {
  34. }
  35. $where['uid'] = $uid;
  36. $where['type_id'] = $id;
  37. $where['type'] = $type;
  38. $where['content'] = $content;
  39. if ($pic) {
  40. $where['pic'] = $pic;
  41. }
  42. if ($playtime) {
  43. $where['playtime'] = $playtime;
  44. }
  45. $table = 'community/comment';
  46. $info = false;
  47. if (!$info) {
  48. Dever::db($table)->insert($where);
  49. Dever::score($uid, 'submit_comment', '发布弹幕/评论', false, false, false, $score_type, $score_type_id);
  50. }
  51. return true;
  52. }
  53. }