Tips.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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, true);
  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. } else {
  45. $where['playtime'] = '-1';
  46. }
  47. $table = 'community/tips';
  48. $info = false;
  49. if (!$info) {
  50. Dever::db($table)->insert($where);
  51. Dever::score($uid, 'submit_tips', '发布聊天泡泡', false, false, false, $score_type, $score_type_id);
  52. }
  53. return true;
  54. }
  55. }