Comment.php 1.7 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. if ($v['pic']) {
  18. $data['info'][$k]['pic'] = explode(',', $v['pic']);
  19. }
  20. if ($user) {
  21. $data['info'][$k]['user'] = Dever::load('collection/lib/user')->get($v['uid'], $collection_id);
  22. $data['info'][$k]['cdate_string'] = Dever::mdate($v['cdate'], 2);
  23. }
  24. }
  25. }
  26. return $data;
  27. }
  28. # 发表信息
  29. public function submit($uid, $id, $type, $pic, $content, $score_type = false, $score_type_id = false)
  30. {
  31. # 如果是商品,要先验证是否购买
  32. if ($type == 'content/product') {
  33. }
  34. $where['uid'] = $uid;
  35. $where['type_id'] = $id;
  36. $where['type'] = $type;
  37. $where['content'] = $content;
  38. if ($pic) {
  39. $where['pic'] = $pic;
  40. }
  41. $table = 'community/comment';
  42. $info = false;
  43. if (!$info) {
  44. Dever::db($table)->insert($where);
  45. Dever::score($uid, 'submit_comment', '发布弹幕/评论', false, false, false, $score_type, $score_type_id);
  46. }
  47. return true;
  48. }
  49. }