extend_thread_follow.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: extend_thread_follow.php 34174 2013-10-28 07:18:04Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class extend_thread_follow extends extend_thread_base {
  12. public function after_newthread() {
  13. $tid = $this->tid;
  14. $pid = $this->pid;
  15. $uid = $this->member['uid'];
  16. if($this->param['displayorder'] >= 0 && helper_access::check_module('follow') && !$this->param['isanonymous']) {
  17. $values = array();
  18. require_once libfile('function/discuzcode');
  19. require_once libfile('function/followcode');
  20. $feedcontent = array(
  21. 'tid' => $tid,
  22. 'content' => followcode($this->param['message'], $tid, $pid, 1000),
  23. );
  24. C::t('forum_threadpreview')->insert($feedcontent);
  25. C::t('forum_thread')->update_status_by_tid($tid, '512');
  26. $followfeed = array(
  27. 'uid' => $uid,
  28. 'username' => $this->member['username'],
  29. 'tid' => $tid,
  30. 'note' => '',
  31. 'dateline' => TIMESTAMP
  32. );
  33. $values['feedid'] = C::t('home_follow_feed')->insert($followfeed, true);
  34. C::t('common_member_count')->increase($uid, array('feeds'=>1));
  35. $this->param['values'] = array_merge((array)$this->param['values'], $values);
  36. }
  37. }
  38. public function after_newreply() {
  39. $feedid = 0;
  40. if(helper_access::check_module('follow') && !$this->param['isanonymous']) {
  41. require_once libfile('function/discuzcode');
  42. require_once libfile('function/followcode');
  43. $feedcontent = C::t('forum_threadpreview')->count_by_tid($this->thread['tid']);
  44. $firstpost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($this->thread['tid']);
  45. if(empty($feedcontent)) {
  46. $feedcontent = array(
  47. 'tid' => $this->thread['tid'],
  48. 'content' => followcode($firstpost['message'], $this->thread['tid'], $this->pid, 1000),
  49. );
  50. C::t('forum_threadpreview')->insert($feedcontent);
  51. C::t('forum_thread')->update_status_by_tid($this->thread['tid'], '512');
  52. } else {
  53. C::t('forum_threadpreview')->update_relay_by_tid($this->thread['tid'], 1);
  54. }
  55. $notemsg = cutstr(followcode($this->param['message'], $this->thread['tid'], $this->pid, 0, false), 140);
  56. $followfeed = array(
  57. 'uid' => $this->member['uid'],
  58. 'username' => $this->member['username'],
  59. 'tid' => $this->thread['tid'],
  60. 'note' => $notemsg,
  61. 'dateline' => TIMESTAMP
  62. );
  63. $feedid = C::t('home_follow_feed')->insert($followfeed, true);
  64. C::t('common_member_count')->increase($this->member['uid'], array('feeds'=>1));
  65. }
  66. if($feedid) {
  67. $this->param['showmsgparam'] = array_merge((array)$this->param['showmsgparam'], array('feedid' => $feedid));
  68. }
  69. }
  70. public function after_editpost() {
  71. $isfirstpost = $this->post['first'] ? 1 : 0;
  72. if($isfirstpost) {
  73. require_once libfile('function/discuzcode');
  74. require_once libfile('function/followcode');
  75. $feed = C::t('forum_threadpreview')->fetch($this->thread['tid']);
  76. if($feed) {
  77. C::t('forum_threadpreview')->update($this->thread['tid'], array('content' => followcode($this->param['message'], $this->thread['tid'], $this->post['pid'], 1000)));
  78. }
  79. }
  80. }
  81. }
  82. ?>