topicadmin_copy.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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: topicadmin_copy.php 31594 2012-09-12 04:14:54Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(!$_G['group']['allowcopythread'] || !$thread) {
  12. showmessage('no_privilege_copythread');
  13. }
  14. if(!submitcheck('modsubmit')) {
  15. require_once libfile('function/forumlist');
  16. $forumselect = forumselect();
  17. include template('forum/topicadmin_action');
  18. } else {
  19. $modaction = 'CPY';
  20. $reason = checkreasonpm();
  21. $copyto = $_GET['copyto'];
  22. $toforum = C::t('forum_forum')->fetch_info_by_fid($copyto);
  23. if(!$toforum || $toforum['status'] != 1 || $toforum['type'] == 'group') {
  24. showmessage('admin_copy_invalid');
  25. } else {
  26. $modnewthreads = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 1) && $toforum['modnewposts'] ? 1 : 0;
  27. $modnewreplies = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 2) && $toforum['modnewposts'] ? 1 : 0;
  28. if($modnewthreads || $modnewreplies) {
  29. showmessage('admin_copy_hava_mod');
  30. }
  31. }
  32. $toforum['threadsorts_arr'] = unserialize($toforum['threadsorts']);
  33. if($thread['sortid'] != 0 && $toforum['threadsorts_arr']['types'][$thread['sortid']]) {
  34. foreach(C::t('forum_typeoptionvar')->fetch_all_by_search($thread['sortid'], null, $thread['tid']) as $result) {
  35. $typeoptionvar[] = $result;
  36. }
  37. } else {
  38. $thread['sortid'] = '';
  39. }
  40. $sourcetid = $thread['tid'];
  41. unset($thread['tid']);
  42. $thread['fid'] = $copyto;
  43. $thread['dateline'] = $thread['lastpost'] = TIMESTAMP;
  44. $thread['lastposter'] = $thread['author'];
  45. $thread['views'] = $thread['replies'] = $thread['highlight'] = $thread['digest'] = 0;
  46. $thread['rate'] = $thread['displayorder'] = $thread['attachment'] = 0;
  47. $thread['typeid'] = $_GET['threadtypeid'];
  48. $thread = daddslashes($thread);
  49. $thread['posttableid'] = 0;
  50. $threadid = C::t('forum_thread')->insert($thread, true);
  51. if($post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['tid'])) {
  52. $post['pid'] = '';
  53. $post['tid'] = $threadid;
  54. $post['fid'] = $copyto;
  55. $post['dateline'] = TIMESTAMP;
  56. $post['attachment'] = 0;
  57. $post['invisible'] = $post['rate'] = $post['ratetimes'] = 0;
  58. $post['message'] .= "\n".lang('forum/thread', 'source').": [url=forum.php?mod=viewthread&tid={$sourcetid}]{$thread['subject']}[/url]";
  59. $post = daddslashes($post);
  60. $pid = insertpost($post);
  61. }
  62. $class_tag = new tag();
  63. $class_tag->copy_tag($_G['tid'], $threadid, 'tid');
  64. if($typeoptionvar) {
  65. foreach($typeoptionvar AS $key => $value) {
  66. $value['tid'] = $threadid;
  67. $value['fid'] = $toforum['fid'];
  68. C::t('forum_typeoptionvar')->insert($value);
  69. }
  70. }
  71. updatepostcredits('+', $post['authorid'], 'post', $copyto);
  72. updateforumcount($copyto);
  73. updateforumcount($_G['fid']);
  74. $modpostsnum ++;
  75. $resultarray = array(
  76. 'redirect' => "forum.php?mod=forumdisplay&fid=$_G[fid]",
  77. 'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_copy', 'notictype' => 'post') : array()),
  78. 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'threadid' => $threadid),
  79. 'modtids' => $thread['tid'],
  80. 'modlog' => array($thread, $other)
  81. );
  82. }
  83. ?>