topicadmin_stickreply.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_stickreply.php 35235 2015-03-19 06:27:54Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(!$_G['group']['allowstickreply'] && !$specialperm) {
  12. showmessage('no_privilege_stickreply');
  13. }
  14. $topiclist = $_GET['topiclist'];
  15. $modpostsnum = count($topiclist);
  16. if(empty($topiclist)) {
  17. showmessage('admin_stickreply_invalid');
  18. } elseif(!$_G['tid']) {
  19. showmessage('admin_nopermission', NULL);
  20. }
  21. $sticktopiclist = $posts = array();
  22. foreach($topiclist as $pid) {
  23. $post = C::t('forum_post')->fetch('tid:'.$_G['tid'], $pid, false);
  24. $sticktopiclist[$pid] = $post['position'];
  25. }
  26. if(!submitcheck('modsubmit')) {
  27. $stickpid = '';
  28. foreach($sticktopiclist as $id => $postnum) {
  29. $stickpid .= '<input type="hidden" name="topiclist[]" value="'.dintval($id).'" />';
  30. }
  31. include template('forum/topicadmin_action');
  32. } else {
  33. if($_GET['stickreply']) {
  34. foreach($sticktopiclist as $pid => $postnum) {
  35. C::t('forum_poststick')->insert(array(
  36. 'tid' => $_G['tid'],
  37. 'pid' => $pid,
  38. 'position' => $postnum,
  39. 'dateline' => $_G['timestamp'],
  40. ), false, true);
  41. }
  42. } else {
  43. foreach($sticktopiclist as $pid => $postnum) {
  44. C::t('forum_poststick')->delete($_G['tid'], $pid);
  45. }
  46. }
  47. $sticknum = C::t('forum_poststick')->count_by_tid($_G['tid']);
  48. $stickreply = intval($_GET['stickreply']);
  49. if($sticknum == 0 || $stickreply == 1) {
  50. C::t('forum_thread')->update($_G['tid'], array('moderated'=>1, 'stickreply'=>$stickreply));
  51. }
  52. $modaction = $_GET['stickreply'] ? 'SRE' : 'USR';
  53. $reason = checkreasonpm();
  54. $resultarray = array(
  55. 'redirect' => "forum.php?mod=viewthread&tid=$_G[tid]&page=$page",
  56. 'reasonpm' => ($sendreasonpm ? array('data' => array(array('authorid' => $post['authorid'])), 'var' => 'post', 'notictype' => 'post', 'item' => $_GET['stickreply'] ? 'reason_stickreply': 'reason_stickdeletereply') : array()),
  57. 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
  58. 'modlog' => $thread
  59. );
  60. }
  61. ?>