Tips.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Community\Lib;
  3. use Dever;
  4. class Tips
  5. {
  6. public function getData($method = 'getAll', $uid, $type = false, $type_id = false, $user = false, $collection_id = false)
  7. {
  8. $where['type'] = $type;
  9. $info = Dever::db('community/tips')->$method($where);
  10. $data['info'] = array();
  11. $data['total'] = Dever::total();
  12. if ($info) {
  13. $temp = array();
  14. foreach ($info as $k => $v) {
  15. $temp['type'] = $v['type'];
  16. $temp['type_id'] = $v['type_id'];
  17. $temp['uid'] = $v['uid'];
  18. $temp['content'] = $v['content'];
  19. $temp['playtime'] = $v['playtime'];
  20. if ($v['pic']) {
  21. $temp['pic'] = explode(',', $v['pic']);
  22. }
  23. if ($user) {
  24. $temp['user'] = Dever::load('user/lib/info')->get($v['uid'], $collection_id);
  25. $temp['cdate_string'] = Dever::mdate($v['cdate'], 2);
  26. }
  27. $data['info'][$v['playtime']][] = $temp;
  28. }
  29. }
  30. return $data;
  31. }
  32. # 发表信息
  33. public function submit($uid, $id, $type, $pic, $content, $playtime, $score_type = false, $score_type_id = false)
  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/tips';
  46. $info = false;
  47. if (!$info) {
  48. Dever::db($table)->insert($where);
  49. Dever::score($uid, 'submit_tips', '发布聊天泡泡', false, false, false, $score_type, $score_type_id);
  50. }
  51. return true;
  52. }
  53. }