topicadmin_refund.php
2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_refund.php 30872 2012-06-27 10:11:44Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowrefund'] || $thread['price'] <= 0) {
showmessage('undefined_action', NULL);
}
if(!isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]])) {
showmessage('credits_transaction_disabled');
}
if($thread['special'] != 0) {
showmessage('special_refundment_invalid');
}
if(!submitcheck('modsubmit')) {
$payment = C::t('common_credit_log')->count_stc_by_relatedid($_G['tid'], $_G['setting']['creditstransextra'][1]);
$payment['payers'] = intval($payment['payers']);
$payment['netincome'] = intval($payment['netincome']);
include template('forum/topicadmin_action');
} else {
$modaction = 'RFD';
$modpostsnum ++;
$reason = checkreasonpm();
$totalamount = 0;
$amountarray = array();
$logarray = array();
foreach(C::t('common_credit_log')->fetch_all_by_uid_operation_relatedid(0, 'BTC', $_G['tid']) as $log) {
$totalamount += $log['amount'];
$amountarray[$log['amount']][] = $log['uid'];
}
updatemembercount($thread['authorid'], array($_G['setting']['creditstransextra'][1] => -$totalamount));
C::t('forum_thread')->update($_G['tid'], array('price'=>-1, 'moderated'=>1));
foreach($amountarray as $amount => $uidarray) {
updatemembercount($uidarray, array($_G['setting']['creditstransextra'][1] => $amount));
}
C::t('common_credit_log')->delete_by_operation_relatedid(array('BTC', 'STC'), $_G['tid']);
$resultarray = array(
'redirect' => "forum.php?mod=viewthread&tid=$_G[tid]",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_moderate', 'notictype' => 'post') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
'modtids' => $thread['tid'],
'modlog' => $thread
);
}
?>