topicadmin_refund.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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_refund.php 30872 2012-06-27 10:11:44Z liulanbo $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(!$_G['group']['allowrefund'] || $thread['price'] <= 0) {
  12. showmessage('undefined_action', NULL);
  13. }
  14. if(!isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]])) {
  15. showmessage('credits_transaction_disabled');
  16. }
  17. if($thread['special'] != 0) {
  18. showmessage('special_refundment_invalid');
  19. }
  20. if(!submitcheck('modsubmit')) {
  21. $payment = C::t('common_credit_log')->count_stc_by_relatedid($_G['tid'], $_G['setting']['creditstransextra'][1]);
  22. $payment['payers'] = intval($payment['payers']);
  23. $payment['income'] = intval($payment['income']);
  24. include template('forum/topicadmin_action');
  25. } else {
  26. $modaction = 'RFD';
  27. $modpostsnum ++;
  28. $reason = checkreasonpm();
  29. $totalamount = 0;
  30. $amountarray = array();
  31. $logarray = array();
  32. foreach(C::t('common_credit_log')->fetch_all_by_uid_operation_relatedid(0, 'BTC', $_G['tid']) as $log) {
  33. $amount = abs($log['extcredits'.$_G['setting']['creditstransextra'][1]]);
  34. $totalamount += $amount;
  35. $amountarray[$amount][] = $log['uid'];
  36. }
  37. updatemembercount($thread['authorid'], array($_G['setting']['creditstransextra'][1] => -$totalamount));
  38. C::t('forum_thread')->update($_G['tid'], array('price'=>-1, 'moderated'=>1));
  39. foreach($amountarray as $amount => $uidarray) {
  40. updatemembercount($uidarray, array($_G['setting']['creditstransextra'][1] => $amount));
  41. }
  42. C::t('common_credit_log')->delete_by_operation_relatedid(array('BTC', 'STC'), $_G['tid']);
  43. $resultarray = array(
  44. 'redirect' => "forum.php?mod=viewthread&tid=$_G[tid]",
  45. 'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_moderate', 'notictype' => 'post') : array()),
  46. 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
  47. 'modtids' => $thread['tid'],
  48. 'modlog' => $thread
  49. );
  50. }
  51. ?>