extend_thread_comment.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_comment.php 33709 2013-08-06 09:06:56Z andyzheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class extend_thread_comment extends extend_thread_base {
  12. private $postcomment;
  13. public function before_newreply($parameters) {
  14. global $nauthorid;
  15. list(, $this->param['modnewreplies']) = threadmodstatus($this->param['subject']."\t".$this->param['message'].$this->param['extramessage']);
  16. if($this->thread['displayorder'] == -4) {
  17. $this->param['modnewreplies'] = 0;
  18. }
  19. $pinvisible = $parameters['modnewreplies'] ? -2 : ($this->thread['displayorder'] == -4 ? -3 : 0);
  20. $this->postcomment = in_array(2, $this->setting['allowpostcomment']) && $this->group['allowcommentreply'] && !$pinvisible && !empty($_GET['reppid']) && ($nauthorid != $this->member['uid'] || $this->setting['commentpostself']) ? messagecutstr($parameters['message'], 200, ' ') : '';
  21. }
  22. public function after_newreply() {
  23. if(!empty($_GET['noticeauthor']) && !$this->param['isanonymous'] && !$this->param['modnewreplies']) {
  24. if($this->postcomment) {
  25. $rpid = intval($_GET['reppid']);
  26. if($rpost = C::t('forum_post')->fetch('tid:'.$this->thread['tid'], $rpid)) {
  27. if(!$rpost['first']) {
  28. $cid = C::t('forum_postcomment')->insert(array(
  29. 'tid' => $this->thread['tid'],
  30. 'pid' => $rpid,
  31. 'rpid' => $this->pid,
  32. 'author' => $this->member['username'],
  33. 'authorid' => $this->member['uid'],
  34. 'dateline' => TIMESTAMP,
  35. 'comment' => $this->postcomment,
  36. 'score' => 0,
  37. 'useip' => getglobal('clientip'),
  38. 'port'=>getglobal('remoteport')
  39. ), true);
  40. C::t('forum_post')->update('tid:'.$this->thread['tid'], $rpid, array('comment' => 1));
  41. C::t('forum_postcache')->delete($rpid);
  42. }
  43. }
  44. unset($this->postcomment);
  45. }
  46. }
  47. }
  48. public function after_deletepost() {
  49. C::t('forum_postcomment')->delete_by_rpid($this->post['pid']);
  50. }
  51. }
  52. ?>