说明:
分开不一样的主题不一样的投票权限,即某些特定的投票可以允许更多特定的人投票
文件列表:
./templates/default/post_newthread.htm
./templates/default/post_editpost.htm
./include/editpost.inc.php
./include/newthread.inc.php
./include/special.inc.php
./misc.php
修改方法:
1: ./templates/default/post_newthread.htm (对应的风格假如也存在该文件那也要同样修改)
post_newthread.htm
找
- <input type="text" name="maxchoices" value="$maxpolloptions" size="5"><br></span>
复制代码
在下面加上:
- <input class="checkbox" type="checkbox" name="allowpollchk" value="1" onclick="if(this.checked){$('allowpollscontrol').style.display='';$('chkallspan').style.display='';}else{$('allowpollscontrol').style.display='none';$('chkallspan').style.display='none';}" title="设置允许参与投票的用户组(对管理员无效){LF}如果全不选,就按照系统默认的设置{LF}如不是特别需要,请留空">参与用户组
- <span id="chkallspan" style="display: none">全选<input class="checkbox" type="checkbox" name="allowpollchkall" value="1" onclick="checkall(this.form, 'allowpolls', 'allowpollchkall');"></span><br><span id="allowpollscontrol" style="display: none">$allowpolls</span>
复制代码
2: ./templates/default/post_editpost.htm
找:
- <input type="text" name="maxchoices" value="$poll[maxchoices]" size="5"><br>
- </span></td><td class="altbg2">
复制代码
替换为:
- <input type="text" name="maxchoices" value="$poll[maxchoices]" size="5"><br></span>
- <input class="checkbox" type="checkbox" name="allowpollchk" value="1" onclick="if(this.checked){$('allowpollscontrol').style.display='';$('chkallspan').style.display='';}else{$('allowpollscontrol').style.display='none';$('chkallspan').style.display='none';}" title="设置允许参与投票的用户组(对管理员无效){LF}如果全不选,就按照系统默认的设置{LF}如不是特别需要,请留空">参与用户组
- <span id="chkallspan" style="display: none">全选<input class="checkbox" type="checkbox" name="allowpollchkall" value="1" onclick="checkall(this.form, 'allowpolls', 'allowpollchkall');"></span><br><span id="allowpollscontrol" style="display: none">$allowpolls</span>
- </td><td class="altbg2">
复制代码
3:./include/editpost.inc.php
找:
- $poll['polloption'][] = stripslashes($temppoll['polloption']);
- }
复制代码
下面加上:
- $i = 0;
- $allowpollgroups= explode(',', $db->result($db->query("SELECT allowpolls FROM {$tablepre}polls WHERE tid='$tid'"), 0));
- $allowpolls = '<div id="poplayer" style="padding:2px;background:#FFFFFF;border:#7FB9F8 1px solid;position:absolute;display:inline;margin-top:2px;"><table cellpadding="4" cellspacing="0" border="0" unselectable="on"><tr>';
- $query = $db->query("SELECT groupid,grouptitle FROM {$tablepre}usergroups WHERE type='special' || type='member' || (type='system' && radminid> 0) ORDER BY groupid");
- while($group = $db->fetch_array($query)){
- $ischecked = in_array($group[groupid], $allowpollgroups) ? 'checked' : '';
- $allowpolls .= "<td> $group[grouptitle]<input type="checkbox" name="allowpolls[]" class="checkbox" value="$group[groupid]" $ischecked></td>";
- $allowpolls .= (++$i)%3 == 0 ? '</tr><tr>' : '';
- }
- $allowpolls .= '</tr></table></div>';
- //每行显示3个, 请根据需要修改
复制代码
再找:
- $db->query("UPDATE {$tablepre}polls SET multiple='$pollarray[multiple]', visible='$pollarray[visible]', maxchoices='$pollarray[maxchoices]', expiration='$pollarray[expiration]' WHERE tid='$tid'", 'UNBUFFERED');
复制代码
替换为:
- $extsql = empty($allowpolls) ? ', allowpolls=\'\'' : ', allowpolls=\''.implode(',', $allowpolls).'\'';
- $db->query("UPDATE {$tablepre}polls SET multiple='$pollarray[multiple]', visible='$pollarray[visible]', maxchoices='$pollarray[maxchoices]', expiration='$pollarray[expiration]' $extsql WHERE tid='$tid'", 'UNBUFFERED');
复制代码
4:./include/newthread.inc.php
找:
- include template('post_newthread');
复制代码
上面加上:
- if($special == 1) {
- $i = 0;
- $allowpolls = '<div id="poplayer" style="padding:2px;background:#FFFFFF;border:#7FB9F8 1px solid;position:absolute;display:inline;margin-top:2px;"><table cellpadding="4" cellspacing="0" border="0" unselectable="on"><tr>';
- $query = $db->query("SELECT groupid,grouptitle FROM {$tablepre}usergroups WHERE type='special' || type='member' || (type='system' && radminid> 0) ORDER BY groupid");
- while($group = $db->fetch_array($query)){
- $allowpolls .= "<td> $group[grouptitle]<input type="checkbox" name="allowpolls[]" class="checkbox" value="$group[groupid]"></td>";
- $allowpolls .= (++$i)%3 == 0 ? '</tr><tr>' : '';
- }
- $allowpolls .= '</tr></table></div>';
- }//每行显示3个, 请根据需要修改
复制代码
再找
- $db->query("INSERT INTO {$tablepre}polls (tid, multiple, visible, maxchoices, expiration)
- VALUES ('$tid', '$pollarray[multiple]', '$pollarray[visible]', '$pollarray[maxchoices]', '$pollarray[expiration]')");
复制代码
替换为:
- $allowpolls = !empty($allowpolls) ? implode(',', $allowpolls) : '';
- $db->query("INSERT INTO {$tablepre}polls (tid, multiple, visible, maxchoices, expiration, allowpolls)
- VALUES ('$tid', '$pollarray[multiple]', '$pollarray[visible]', '$pollarray[maxchoices]', '$pollarray[expiration]', '$allowpolls')");
复制代码
5:./include/special.inc.php
找:
- $query = $db->query("SELECT multiple, visible, maxchoices, expiration FROM {$tablepre}polls WHERE tid='$tid'");
复制代码
替换为:
- $query = $db->query("SELECT multiple, visible, maxchoices, expiration, allowpolls FROM {$tablepre}polls WHERE tid='$tid'");
复制代码
再找:
- $expiration = $options['expiration'];
复制代码
下面加上:
- $allowvote = empty($options['allowpolls']) ? $allowvote : $discuz_uid == $thread['authorid'] || $adminid == 1 || in_array($groupid, explode(',', $options['allowpolls']));
复制代码
6:./misc.php
找:
- if($action == 'votepoll' && submitcheck('pollsubmit')) {
复制代码
下面加上:
- $allowpolls = $db->result($db->query("SELECT allowpolls FROM {$tablepre}polls WHERE tid='$tid'"), 0);
- $allowvote = empty($allowpolls) ? $allowvote : $discuz_uid == $thread['authorid'] || $adminid == 1 || in_array($groupid, explode(',', $allowpolls));
复制代码
7: 升级数据库
- ALTER TABLE `cdb_polls` ADD `allowpolls` VARCHAR( 255 ) NOT NULL ;
复制代码
完成了
说明:假如发投票没有设置哪个组可以投票的话,那么将按照系统本身设置的用户组设置哪个组可以投票
假如发投票那里设置了的话,就按照发投票设置,初管理员之外其他都受影响(受限的系统组是直接不可以投,如禁止发言).
[ 本帖最后由 lu5266 于 2006-11-30 11:45 编辑 ] |