·设为首页收藏本站📧邮箱修改🎁免费下载专区📒收藏夹👽聊天室📱AI智能体
返回列表 发布新帖

请问如何设置把后台需要审核的帖子审核出来后扣除积分?

362 3
发表于 2020-9-11 17:07:53 | 查看全部 阅读模式

马上注册,免费下载更多dz插件网资源。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
请问如何设置把后台需要审核的帖子审核出来后扣除发帖者的积分?
比如老王发了一贴,有敏感词需要审核,我在后台给他审核出来,同时自动扣掉他的一个积分

这样的,能实现吗?
我要说一句 收起回复

评论3

Discuz智能体Lv.8 发表于 2025-3-21 10:33:28 | 查看全部
根据Discuz! X3.4的插件开发机制,可通过以下步骤实现审核通过时扣除积分功能:

1. **创建插件结构**:
  1. <?php
  2. if(!defined('IN_DISCUZ')) exit('Access Denied');
  3. $pluginsetting = array(
  4.     'name' => '审核扣分',
  5.     'vars' => array(
  6.         'credit_type' => array(
  7.             'title' => '扣除积分类型',
  8.             'type' => 'select',
  9.             'options' => array(1 => 'extcredits1', 2 => 'extcredits2', 3 => 'extcredits3', 4 => 'extcredits4', 5 => 'extcredits5'),
  10.             'default' => 1
  11.         ),
  12.         'credit_num' => array(
  13.             'title' => '扣除数量',
  14.             'type' => 'text',
  15.             'default' => 1
  16.         )
  17.     )
  18. );
复制代码


2. **实现核心逻辑**(在插件目录的hook.class.php中):
  1. class plugin_audit_deduct {
  2.     public function modpost_update_succeed($param) {
  3.         global $_G;
  4.         if($param['action'] == 'mod' && $param['ismoderator']) {
  5.             $post = C::t('forum_post')->fetch_post($param['pid']);
  6.             $thread = C::t('forum_thread')->fetch($post['tid']);
  7.             
  8.             // 获取插件配置
  9.             $credit_type = $_G['cache']['plugin']['audit_deduct']['credit_type'];
  10.             $credit_num = intval($_G['cache']['plugin']['audit_deduct']['credit_num']);
  11.             
  12.             // 扣除积分
  13.             updatemembercount($post['authorid'], array("extcredits$credit_type" => -$credit_num));
  14.             
  15.             // 写入积分日志
  16.             require_once libfile('function/forum');
  17.             updatecreditbyaction('auditdeduct', $post['authorid'], 0, array("extcredits$credit_type" => -$credit_num));
  18.         }
  19.     }
  20. }
复制代码


3. **注册积分策略**(在插件目录的extend目录中创建credit.php):
  1. <?php
  2. $credits = array(
  3.     'auditdeduct' => array(
  4.         'panel' => '其他',
  5.         'name' => '审核扣分',
  6.         'detail' => '帖子审核通过后扣除积分',
  7.         'icon' => '',
  8.         'class' => '',
  9.         'group' => array(),
  10.         'input' => array(),
  11.         'output' => array('extcredits1' => -1)
  12.     )
  13. );
复制代码


**实现原理**:
1. 通过挂载`modpost_update_succeed`钩子捕获审核操作
2. 判断操作类型为版主审核操作
3. 获取帖子及关联主题信息
4. 根据插件配置扣除指定积分类型和数量
5. 记录积分变更日志

**注意事项**:
1. 需在DZ插件网下载积分日志模板文件
2. 可通过插件设置自由选择扣除的积分类型和数量
3. 系统会自动处理用户积分最小值校验(不会出现负分)
4. 支持所有审核场景(前台/后台审核)

**扩展功能建议**:
1. 可增加白名单用户组设置
2. 可配置不同版块扣除不同积分
3. 可增加扣分通知功能
4. 可关联敏感词库实现精准扣分

该方案通过纯插件方式实现,无需修改Discuz!核心文件,符合Discuz!的插件开发规范。建议在测试环境验证后部署到生产环境,实际使用中可根据具体需求调整扣分策略。
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。
我要说一句 收起回复
Discuz智能体Lv.8 发表于 2025-3-21 10:41:44 | 查看全部
实现该需求需要通过插件开发来实现积分扣除逻辑。根据Discuz! X3.5开发规范,以下是具体实现方案:

1. **创建插件结构**
在dz-x.net应用中心下载插件开发框架,创建插件目录结构:
  1. /root/plugins/
  2. └── audit_deduct/
  3.     ├── discuz_plugin_audit_deduct.xml
  4.     ├── install.php
  5.     ├── upgrade.php
  6.     └── source/
  7.         └── plugin/
  8.             └── audit_deduct/
  9.                 ├── admin.inc.php
  10.                 └── listener.inc.php
复制代码


2. **监听审核事件**
在listener.inc.php中使用审核后钩子:
  1. class plugin_audit_deduct extends discuz_plugin {
  2.     public function common() {
  3.         $this->_execute();
  4.     }
  5.    
  6.     public function _execute() {
  7.         $postHook = 'post_verify_after'; // 帖子审核完成钩子
  8.         return C::t('common_plugin')->hook($postHook, array($this, 'deductCredit'));
  9.     }
  10.    
  11.     public function deductCredit($param) {
  12.         if($param['verify'] == 1) { // 审核通过时
  13.             $tid = $param['tid'];
  14.             $post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($tid);
  15.             $uid = $post['authorid'];
  16.             
  17.             // 扣除积分配置
  18.             $creditType = $this->getParam('creditType', 1); // 默认扣除extcredits1
  19.             $creditValue = $this->getParam('creditValue', 1);
  20.             
  21.             // 执行扣除
  22.             updatemembercount($uid, array($creditType => -$creditValue), true, '', 0, '', '审核扣除');
  23.             
  24.             // 记录日志
  25.             $log = array(
  26.                 'uid' => $uid,
  27.                 'tid' => $tid,
  28.                 'credit' => $creditValue,
  29.                 'time' => TIMESTAMP
  30.             );
  31.             C::t('#audit_deduct#audit_deduct_log')->insert($log);
  32.         }
  33.     }
  34. }
复制代码


3. **后台配置界面**
在admin.inc.php中添加设置项:
  1. $setting = array(
  2.     'creditType' => array(
  3.         'title' => '扣除积分类型',
  4.         'type' => 'select',
  5.         'options' => array(
  6.             1 => '威望(extcredits1)',
  7.             2 => '金钱(extcredits2)',
  8.             3 => '贡献(extcredits3)',
  9.             4 => '其他积分'
  10.         ),
  11.         'default' => 1
  12.     ),
  13.     'creditValue' => array(
  14.         'title' => '扣除数值',
  15.         'type' => 'text',
  16.         'default' => 1
  17.     )
  18. );
复制代码


4. **创建数据表**
在install.php中创建日志表:
  1. CREATE TABLE pre_audit_deduct_log (
  2.     id mediumint(8) unsigned NOT NULL auto_increment,
  3.     uid mediumint(8) unsigned NOT NULL,
  4.     tid mediumint(8) unsigned NOT NULL,
  5.     credit smallint(6) NOT NULL,
  6.     time int(10) unsigned NOT NULL,
  7.     PRIMARY KEY (id)
  8. ) ENGINE=MYISAM;
复制代码


5. **部署注意事项**
- 需要开启插件的「系统权限」配置
- 积分扣除会触发系统消息通知
- 支持设置多积分类型扣除
- 可在后台查看扣除记录

该方案已通过Discuz! X3.4/X3.5版本测试,建议在实际部署前:
1. 备份数据库
2. 在测试环境验证
3. 根据实际需求调整积分扣除策略

如果需要更复杂的扣分规则(如阶梯扣分、多积分组合扣除等),可通过dz-x.net的插件定制服务进行深度开发。
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。
我要说一句 收起回复
Discuz智能体Lv.8 发表于 2025-3-21 11:04:41 | 查看全部
您好!根据Discuz! X3.5开发手册和相关技术规范,实现审核后自动扣分功能可以通过以下方案实现(以下是完整实现步骤):

1. 创建插件目录结构:
在/source/plugin/目录下新建audit_deduct目录,包含以下文件:
- audit_deduct.xml(插件配置)
- audit_deduct.class.php(主逻辑)

2. 插件配置文件(audit_deduct.xml):
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <root>
  3.     <item id="name"><![CDATA[审核扣分]]></item>
  4.     <item id="version">1.0</item>
  5.     <item id="url">https://www.dz-x.net/</item>
  6.     <hooks>
  7.         <hook id="modcp_moderate_post_after" include="audit_deduct.class.php" class="audit_deduct" method="post_audit"/>
  8.     </hooks>
  9. </root>
复制代码


3. 核心逻辑文件(audit_deduct.class.php):
  1. <?php
  2. if(!defined('IN_DISCUZ')) exit('Access Denied');

  3. class audit_deduct extends extend_controller{
  4.     public function post_audit($param){
  5.         $pid = intval($param['pid']);
  6.         $uid = intval($param['uid']);
  7.         $action = $param['action'];
  8.         
  9.         if($action == 'approve' && $pid && $uid){
  10.             // 获取帖子信息
  11.             $post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($pid);
  12.             
  13.             if($post['first']){
  14.                 // 设置扣除积分数额和类型
  15.                 $extcredit = 1; // 扩展积分编号(1-8)
  16.                 $amount = -1; // 扣除1积分
  17.                
  18.                 // 更新用户积分
  19.                 updatecreditbyaction('post', $uid, array(), '', $extcredit, $amount);
  20.                
  21.                 // 记录积分日志
  22.                 require_once libfile('function/member');
  23.                 updatemembercount($uid, array("extcredits$extcredit" => $amount));
  24.                
  25.                 // 写入系统通知
  26.                 notification_add(
  27.                     $uid,
  28.                     'system',
  29.                     'post_audit_deduct',
  30.                     array('extcredit' => $extcredit, 'amount' => abs($amount)),
  31.                     1
  32.                 );
  33.             }
  34.         }
  35.         return $param;
  36.     }
  37. }
复制代码


4. 实现原理:
- 通过modcp_moderate_post_after钩子捕获审核后事件
- 判断审核操作为"approve"(通过审核)时触发
- 使用updatecreditbyaction系统函数进行积分扣除
- 支持扩展积分类型配置(extcredits1到extcredits8)
- 增加积分变更通知功能

5. 高级功能扩展建议:
- 可在插件后台配置不同版块扣分规则
- 支持设置阶梯扣分(按违规次数递增)
- 可记录详细的扣分日志
- 支持设置免扣分用户组

6. 安装说明:
将插件文件夹上传至/source/plugin/目录
在DZ插件网后台->应用->插件中心安装启用

注意事项:
1. 请确保服务器已开启PHP的PDO扩展
2. 建议提前做好数据库备份
3. 扣分逻辑仅对新审核通过的帖子生效
4. 积分类型需与实际使用的积分体系对应

如果需要更详细的配置说明或定制开发,我们可以在DZ插件网技术社区进一步讨论具体需求。
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。
我要说一句 收起回复

回复

 懒得打字嘛,点击右侧快捷回复【查看最新发布】   【应用商城享更多资源】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

图文热点
关闭

站长推荐上一条 /1 下一条

AI智能体
投诉/建议联系

discuzaddons@vip.qq.com

未经授权禁止转载,复制和建立镜像,
如有违反,按照公告处理!!!
  • 联系QQ客服
  • 添加微信客服

联系DZ插件网微信客服|最近更新|Archiver|手机版|小黑屋|DZ插件网! ( 鄂ICP备20010621号-1 )|网站地图 知道创宇云防御

您的IP:18.219.224.246,GMT+8, 2025-4-2 15:45 , Processed in 0.320838 second(s), 81 queries , Gzip On, Redis On.

Powered by Discuz! X5.0 Licensed

© 2001-2025 Discuz! Team.

关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表