magic_bump.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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: magic_bump.php 29373 2012-04-09 07:55:30Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class magic_bump {
  12. var $version = '1.0';
  13. var $name = 'bump_name';
  14. var $description = 'bump_desc';
  15. var $price = '10';
  16. var $weight = '10';
  17. var $copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>';
  18. var $magic = array();
  19. var $parameters = array();
  20. function getsetting(&$magic) {
  21. global $_G;
  22. $settings = array(
  23. 'fids' => array(
  24. 'title' => 'bump_forum',
  25. 'type' => 'mselect',
  26. 'value' => array(),
  27. ),
  28. );
  29. loadcache('forums');
  30. $settings['fids']['value'][] = array(0, '&nbsp;');
  31. if(empty($_G['cache']['forums'])) $_G['cache']['forums'] = array();
  32. foreach($_G['cache']['forums'] as $fid => $forum) {
  33. $settings['fids']['value'][] = array($fid, ($forum['type'] == 'forum' ? str_repeat('&nbsp;', 4) : ($forum['type'] == 'sub' ? str_repeat('&nbsp;', 8) : '')).$forum['name']);
  34. }
  35. $magic['fids'] = explode("\t", $magic['forum']);
  36. return $settings;
  37. }
  38. function setsetting(&$magicnew, &$parameters) {
  39. global $_G;
  40. $magicnew['forum'] = is_array($parameters['fids']) && !empty($parameters['fids']) ? implode("\t",$parameters['fids']) : '';
  41. }
  42. function usesubmit() {
  43. global $_G;
  44. if(empty($_GET['tid'])) {
  45. showmessage(lang('magic/bump', 'bump_info_nonexistence'));
  46. }
  47. $thread = getpostinfo($_GET['tid'], 'tid', array('fid', 'authorid', 'subject'));
  48. $this->_check($thread['fid']);
  49. C::t('forum_thread')->update($_GET['tid'], array('moderated' => 1, 'lastpost' => TIMESTAMP));
  50. usemagic($this->magic['magicid'], $this->magic['num']);
  51. updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, 'tid', $_GET['tid']);
  52. updatemagicthreadlog($_GET['tid'], $this->magic['magicid'], 'BMP');
  53. if($thread['authorid'] != $_G['uid']) {
  54. notification_add($thread['authorid'], 'magic', lang('magic/bump', 'bump_notification'), array('tid' => $_GET['tid'], 'subject' => $thread['subject'], 'magicname' => $this->magic['name']));
  55. }
  56. showmessage(lang('magic/bump', 'bump_succeed'), dreferer(), array(), array('alert' => 'right', 'showdialog' => 1, 'locationtime' => true));
  57. }
  58. function show() {
  59. global $_G;
  60. $tid = !empty($_GET['id']) ? dhtmlspecialchars($_GET['id']) : '';
  61. if($tid) {
  62. $thread = getpostinfo($_GET['id'], 'tid', array('fid'));
  63. $this->_check($thread['fid']);
  64. }
  65. magicshowtype('top');
  66. magicshowsetting(lang('magic/bump', 'bump_info'), 'tid', $tid, 'text');
  67. magicshowtype('bottom');
  68. }
  69. function buy() {
  70. global $_G;
  71. if(!empty($_GET['id'])) {
  72. $thread = getpostinfo($_GET['id'], 'tid', array('fid'));
  73. $this->_check($thread['fid']);
  74. }
  75. }
  76. function _check($fid) {
  77. if(!checkmagicperm($this->parameters['forum'], $fid)) {
  78. showmessage(lang('magic/bump', 'bump_info_noperm'));
  79. }
  80. }
  81. }
  82. ?>