硬汉工作室

搜索
热搜: 活动 交友 discuz

[开发技术] Discuz最佳答案可以设置为自己的回复

[复制链接]
发表于 2021-5-19 09:44:31 | 显示全部楼层 |阅读模式
默认情况,如果楼主发布悬赏贴,那么最佳答案无法设置为自己的回复,但是有时候我们却想要把最佳答案设置为自己的,那么这个情况只能通过修改源码解决。模板和源码都需要修改,不过改动不大。
首先是修改模板文件,打开贴子详情模板viewthread_node.htm,可以直接搜索setanswer,这个js方法就是用来设置最佳答案的,这几行代码是:
{if $_G['forum_thread']['special'] == 3 && ($_G['forum']['ismoderator'] && (!$_G['setting']['rewardexpiration'] || $_G['setting']['rewardexpiration'] > 0 && ($_G[timestamp] - $_G['forum_thread']['dateline']) / 86400 > $_G['setting']['rewardexpiration']) || $_G['forum_thread']['authorid'] == $_G['uid']) && $post['authorid'] != $_G['forum_thread']['authorid'] && $post['first'] == 0 && $_G['uid'] != $post['authorid'] && $_G['forum_thread']['price'] > 0}
        <a href="javascript:;">{lang reward_set_bestanswer}</a>
{/if}

加粗的两行是需要删除的,这两行就是判断如果是楼主回复就不显示设置最佳答案按钮的。

其次就需要修改source/module/forum/forum_misc.php,找到下面代码
if(!($thread['special'] == 3 && $post && ($_G['forum']['ismoderator'] && (!$_G['setting']['rewardexpiration'] || $_G['setting']['rewardexpiration'] > 0 && ($_G['timestamp'] - $thread['dateline']) / 86400 > $_G['setting']['rewardexpiration']) || $thread['authorid'] == $_G['uid']) && $post['authorid'] != $thread['authorid'] && $post['first'] == 0 && $_G['uid'] != $post['authorid'] && $thread['price'] > 0)) {
        showmessage('reward_cant_operate');
} elseif($post['authorid'] == $thread['authorid']) {
        showmessage('reward_cant_self');
} elseif($thread['price'] < 0) {
        showmessage('reward_repeat_selection');
}

加粗的是需要删除的,其实判断逻辑跟模板里判断差不多,第三个showmessage感觉有点多余了,因为第一个已经判断了。

完事

有关PHP系统、Discuz或网站等各种问题,可以联系QQ1069971363寻求付费支持
Discuz插件商店:http://addon.dismall.com/?@56030.developer
回复

使用道具 举报

QQ|Archiver|手机版|小黑屋|硬汉工作室 ( 冀ICP备13021567号-9 )

GMT+8, 2024-4-20 11:28 , Processed in 0.057918 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表