discuz X3評分流程分析
650) this.width=650;" src="http://www.bkjia.com/uploads/allimg/131228/1519132a2-0.png" title="2013-09-11_142941.png" />
一、涉及到的檔案
discuzX3/source/template/default/forum/rate.htm
discuzX3/forum.php
discuzX3/source/module/forum/forum_misc.php
二、流程注意:流程順序也是按照上面檔案依次向下)
如評分->進入到forum_misc.php檔案中處理。大約第606行
elseif($_GET['action'] == 'rate' && $_GET['pid']) {
rate方法即為評分分值的加減操作。大約在672行
foreach($_G['group']['raterange'] as $id => $rating) { $score = intval($_GET['score'.$id]); if(isset($_G['setting']['extcredits'][$id]) && !empty($score)) { //showmessage($id); $arr_goldId[]=$id; $arr_goldValue[]=$score; if($rating['isself'] && (intval($_G['member']['extcredits'.$id]) - $score < 0)) { showmessage('thread_rate_range_self_invalid', '', array('extcreditstitle' => $_G['setting']['extcredits'][$id]['title'])); } if(abs($score) <= $maxratetoday[$id]) { if($score > $rating['max'] || $score < $rating['min']) { showmessage('thread_rate_range_invalid'); } else { $creditsarray[$id] = $score; if($rating['isself']) { $sub_self_credit[$id] = -abs($score); } $rate += $score; $ratetimes += ceil(max(abs($rating['min']), abs($rating['max'])) / 5); } } else { showmessage('thread_rate_ctrl'); } }}
這裡DZ通過foreach迴圈分別擷取使用者的評分種類及相應分值。
//showmessage($id);$arr_goldId[]=$id;$arr_goldValue[]=$score;
數組$arr_goldId評分種類id;數組$arr_goldValue評分分值。
這裡對“金錢”做二次開發:
if($arr_goldId[0] == 2){ $goldValue=$arr_goldValue[0];}elseif($arr_goldId[0] == 1 && $arr_goldId[1] == 2){ $goldValue=$arr_goldValue[1];} if($arr_goldId[0] == 2 || ($arr_goldId[0] != 2 && $arr_goldId[1] == 2)){ /***************************** /* /****** To do something /* /******************************/ //showmessage($goldValue); }showmessage('thread_rate_succeed', dreferer());
本文出自 “PHPer許琴-專註於PHP技術” 部落格,請務必保留此出處http://xuqin.blog.51cto.com/5183168/1294298