撤消投票

Home Home
引用 | 編輯 香吉士
2009-09-12 13:57
樓主
推文 x0
【插件資訊】

插件名稱:撤消投票
適用版本:7.0
語言編碼:通用
插件作者:cheter520
版權所屬:cheter520
原帖連結:http://www.alan888.com/Discuz/thread-174491-1-1.html###
支持網站:http://allen.ncc.to/viewthread.php?tid=134&extra=page%3D1

【插件說明】

這個功能可以方便會員在投票失誤時撤消自己的投票。注意,撤消投票後,對應獲得的積分會減去。

打開templates/default/viewthread_poll.htm
在文件最後加上:
複製程式
<!--{if !$allowvotepolled && $discuz_uid}--> 
<form id="poll" name="poll" method="post" action="misc.php?action=unvotepoll&fid=$fid&tid=$tid&unpollsubmit=yes&quickforward=yes"> 
<button class="submit" type="submit" name="unpollsubmit" id="unpollsubmit" value="true">撤消投票</button> 
</form> 
<!--{/if}-->


打開misc.php
找到:
複製程式
} elseif($action == 'viewvote') {

在上面加:
複製程式
} elseif($action == 'unvotepoll' && submitcheck('unpollsubmit', 1)) { 
$optionarray = array(); 
$optionids = '0'; 
$query = $db->query("SELECT * FROM {$tablepre}polloptions WHERE tid='$tid'"); 
while($pollarray = $db->fetch_array($query)) { 
if(in_array($discuz_uid, explode("\t", $pollarray['voterids']))){ 
$optionids .= ','.$pollarray['polloptionid']; 
} 
} 
$db->query("update {$tablepre}polloptions set voterids=replace(voterids, '$discuz_uid\t', '') where polloptionid IN ($optionids)"); 
$db->query("UPDATE {$tablepre}polloptions SET votes=votes-1 WHERE polloptionid IN ($optionids)"); 
updatecredits($discuz_uid, $creditspolicy['votepoll'], -1); 
$pid = $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND first='1'"); 
if(!empty($inajax)) { 
showmessage('投票撤消成功\', "viewthread.php?tid=$tid&viewpid=$pid&inajax=1"); 
} else { 
showmessage('投票撤消成功\', "viewthread.php?tid=$tid"); 
}

溫馨提醒:用UTF-8的請記得 把繁體字 轉成 HTML十進標記法

圖示:




獻花 x1