【插件资讯】插件名称:撤消投票
适用版本:7.0
语言编码:通用
插件作者:cheter520
版权所属:cheter520
原帖连结:
http://www.alan888.com/Discuz/...-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十进标记法图示: