qugc.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2017/11/7
  6. * Time: 下午4:30
  7. */
  8. namespace async;
  9. use message;
  10. use search;
  11. use ugc;
  12. use ugc_helper;
  13. use push_helper;
  14. class qugc extends IAsync
  15. {
  16. private $special;
  17. private $user;
  18. private $special_id;
  19. public function __construct($special_id)
  20. {
  21. $mod_special = Model('mb_special');
  22. $info = $mod_special->getMbSpecialByID($special_id,'*',true);
  23. $this->special = new ugc\special($info);
  24. $this->user = $this->special->memberid();
  25. $this->special_id = $special_id;
  26. }
  27. public function onPublish()
  28. {
  29. $read_type = $this->special->reader_type();
  30. if($read_type != ugc_helper::private_self) {
  31. $publisher = new message\publisher();
  32. $publisher->add_special($this->user,array(['type' => $read_type,'spid' => $this->special_id,'ugcat' => $this->special->ugcat_id()]));
  33. $follows = search\relation_client::instance()->fetch_follow(['user_id' => $this->user]);
  34. $this->nofity_pub($follows);
  35. }
  36. }
  37. private function nofity_pub($follows)
  38. {
  39. if(empty($follows)) return false;
  40. $title = $this->special->share_title();
  41. $this->ex_user($follows,$this->user);
  42. $i = 0;
  43. foreach ($follows as $follow)
  44. {
  45. if($i < self::max_level_pushs) {
  46. push_helper::nofity_ugc_pub($follow, $this->user, $this->special_id, $title);
  47. }
  48. $i++;
  49. }
  50. }
  51. public function onDel()
  52. {
  53. $read_type = $this->special->reader_type();
  54. $publisher = new message\publisher();
  55. $publisher->del_special($this->user,array(['type' => $read_type,'spid' => $this->special_id]));
  56. }
  57. public function onSubmit($reader)
  58. {
  59. $reader = intval($reader);
  60. if($reader > 0 && $this->user != $reader) {
  61. $title = $this->special->share_title();
  62. push_helper::nofity_ugc_submit($this->user,$reader,$this->special_id,$title);
  63. }
  64. }
  65. public function onSupport($comment_id,$user)
  66. {
  67. $content = null;
  68. if($comment_id > 0)
  69. {
  70. $mod = Model('ugc_comment');
  71. $comments = $mod->getCommentList(['comment_id' => $comment_id],'*',0);
  72. if(!empty($comments)) {
  73. $author = intval($comments[0]['user_id']);
  74. $content = $comments[0]['content'];
  75. $fcomment = true;
  76. }
  77. else {
  78. return false;
  79. }
  80. }
  81. else {
  82. $author = $this->user;
  83. $fcomment = false;
  84. }
  85. if($author != $user) {
  86. push_helper::nofity_ugc_support($author,$user,$fcomment,$this->special_id,$content,$this->special->share_title());
  87. }
  88. return true;
  89. }
  90. public function onComment($comment_id,$user)
  91. {
  92. if($user <= 0) return false;
  93. $content = null;
  94. if($comment_id > 0)
  95. {
  96. $mod = Model('ugc_comment');
  97. $comments = $mod->getCommentList(['comment_id' => $comment_id],'*',0);
  98. if(!empty($comments)) {
  99. $author = intval($comments[0]['user_id']);
  100. $content = $comments[0]['content'];
  101. $fcomment = true;
  102. }
  103. else {
  104. return false;
  105. }
  106. }
  107. else {
  108. $author = $this->user;
  109. $fcomment = false;
  110. }
  111. if($author != $user) {
  112. push_helper::nofity_ugc_comment($author,$user,$fcomment,$this->special_id,$content,$this->special->share_title());
  113. }
  114. return true;
  115. }
  116. public function onAppreciate($user,$rate,$amount)
  117. {
  118. if($user <= 0) return false;
  119. $author = $this->special->memberid();
  120. if($author != $user) {
  121. push_helper::nofity_ugc_appreciate($author,$user,$this->special_id,$this->special->share_title(),$rate,$amount);
  122. }
  123. return true;
  124. }
  125. public function run()
  126. {
  127. }
  128. }