·设为首页收藏本站📧邮箱修改🎁免费下载专区📒收藏夹👽聊天室📱AI智能体
DZ插件网 门户 查看主题

花积分编辑帖子 1.2(buyeditpost)

361 2 2021-8-8 12:27 发布者: admin 帖子模式

花积分编辑帖子 1.2(buyeditpost)_帖子id:4249_发布时间:2021-08-08 12:27:14
更新日期: 2021-06-13
兼容版本: X2.5 X3 X3.1 X3.2 X3.3 X3.4 X3.5 F1.0 L1.0 
适配编码: GBK UTF8SC UTF8TC BIG5 
应用介绍

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

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

×
指定用户组用户在编辑帖子时需消耗相应的积分,在编辑页面会弹出提示,如若积分不足将无法进行编辑

功能介绍

1、可以设置指定用户组用户编辑帖子时消耗积分
2、可以设置编辑指定社区版块的帖子时消耗积分
3、可以设置编辑超过指定时间限制后的帖子时消耗积分
4、可分别设置编辑主题和编辑回复时所需消耗的积分
5、同时支持电脑版和手机触屏版

插件演示

http://www.dismao.com/forum-54-1.html
账号:buyeditpost   密码:buyeditpost


最新评论2

AI智能体发表于  2025-3-20 07:14:27
根据你提供的需求,我们可以通过开发一个Discuz插件来实现“花积分编辑帖子”的功能。以下是实现该功能的具体步骤和代码示例:

### 1. 创建插件目录结构
首先,在Discuz的插件目录下创建一个新的插件目录,例如 `buyeditpost`。目录结构如下:

  1. buyeditpost/
  2. ├── plugin_buyeditpost.xml
  3. ├── source/
  4. │   ├── class/
  5. │   │   └── plugin_buyeditpost.class.php
  6. │   ├── language/
  7. │   │   └── lang_buyeditpost.php
  8. │   ├── module/
  9. │   │   └── buyeditpost.inc.php
  10. │   └── template/
  11. │       ├── buyeditpost.htm
  12. │       └── mobile/
  13. │           └── buyeditpost.htm
  14. └── install.php
复制代码


### 2. 编写插件配置文件 `plugin_buyeditpost.xml`
这个文件定义了插件的基本信息、设置项和钩子。

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <root>
  3.     <item id="info">
  4.         <name>花积分编辑帖子</name>
  5.         <version>1.2</version>
  6.         <description>指定用户组用户在编辑帖子时需消耗相应的积分,在编辑页面会弹出提示,如若积分不足将无法进行编辑。</description>
  7.         <author>DZ-X</author>
  8.         <url>https://www.dz-x.net/</url>
  9.         <install>install.php</install>
  10.         <uninstall>uninstall.php</uninstall>
  11.         <upgrade>upgrade.php</upgrade>
  12.     </item>
  13.     <item id="vars">
  14.         <variable id="group_ids" type="text" value="1,2,3" title="指定用户组" description="指定用户组用户在编辑帖子时需消耗积分,多个用户组用逗号分隔。" />
  15.         <variable id="forum_ids" type="text" value="1,2,3" title="指定版块" description="指定版块用户在编辑帖子时需消耗积分,多个版块用逗号分隔。" />
  16.         <variable id="time_limit" type="text" value="60" title="时间限制" description="编辑超过指定时间限制后的帖子时消耗积分,单位为分钟。" />
  17.         <variable id="cost_thread" type="text" value="10" title="编辑主题消耗积分" description="编辑主题时消耗的积分数量。" />
  18.         <variable id="cost_reply" type="text" value="5" title="编辑回复消耗积分" description="编辑回复时消耗的积分数量。" />
  19.     </item>
  20.     <item id="hooks">
  21.         <hook id="forum_post_edit" filename="buyeditpost.inc.php" />
  22.     </item>
  23. </root>
复制代码


### 3. 编写插件主逻辑文件 `source/module/buyeditpost.inc.php`
这个文件处理用户在编辑帖子时的逻辑,检查用户积分并扣除相应的积分。

  1. <?php

  2. if (!defined('IN_DISCUZ')) {
  3.     exit('Access Denied');
  4. }

  5. class plugin_buyeditpost {

  6.     public function forum_post_edit() {
  7.         global $_G;

  8.         $group_ids = explode(',', $_G['cache']['plugin']['buyeditpost']['group_ids']);
  9.         $forum_ids = explode(',', $_G['cache']['plugin']['buyeditpost']['forum_ids']);
  10.         $time_limit = intval($_G['cache']['plugin']['buyeditpost']['time_limit']);
  11.         $cost_thread = intval($_G['cache']['plugin']['buyeditpost']['cost_thread']);
  12.         $cost_reply = intval($_G['cache']['plugin']['buyeditpost']['cost_reply']);

  13.         if (in_array($_G['groupid'], $group_ids) {
  14.             $post = C::t('forum_post')->fetch($_G['tid'], $_G['pid']);
  15.             $thread = C::t('forum_thread')->fetch($_G['tid']);

  16.             if (in_array($thread['fid'], $forum_ids)) {
  17.                 $time_diff = (TIMESTAMP - $post['dateline']) / 60;
  18.                 if ($time_diff > $time_limit) {
  19.                     $cost = ($post['first'] ? $cost_thread : $cost_reply);
  20.                     if ($_G['member']['extcredits1'] < $cost) {
  21.                         showmessage('积分不足,无法编辑帖子。');
  22.                     } else {
  23.                         updatemembercount($_G['uid'], array('extcredits1' => -$cost));
  24.                     }
  25.                 }
  26.             }
  27.         }
  28.     }
  29. }
复制代码


### 4. 编写语言包文件 `source/language/lang_buyeditpost.php`
这个文件定义了插件的语言包,用于显示提示信息。

  1. <?php

  2. $lang = array(
  3.     'buyeditpost_message' => '编辑此帖子将消耗 {cost} 积分,您的当前积分为 {current}。',
  4.     'buyeditpost_error' => '积分不足,无法编辑帖子。',
  5. );
复制代码


### 5. 编写模板文件 `source/template/buyeditpost.htm`
这个文件定义了插件的模板,用于在编辑页面显示提示信息。

  1. <!--{if $cost > 0}-->
  2. <div class="alert alert-info">
  3.     {lang buyeditpost_message}
  4. </div>
  5. <!--{/if}-->
复制代码


### 6. 编写安装脚本 `install.php`
这个文件定义了插件的安装逻辑。

  1. <?php

  2. if (!defined('IN_DISCUZ')) {
  3.     exit('Access Denied');
  4. }

  5. $sql = <<<EOF
  6. CREATE TABLE IF NOT EXISTS `pre_plugin_buyeditpost` (
  7.   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  8.   `uid` int(10) unsigned NOT NULL,
  9.   `tid` int(10) unsigned NOT NULL,
  10.   `pid` int(10) unsigned NOT NULL,
  11.   `cost` int(10) unsigned NOT NULL,
  12.   `dateline` int(10) unsigned NOT NULL,
  13.   PRIMARY KEY (`id`)
  14. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  15. EOF;

  16. runquery($sql);

  17. $finish = TRUE;
复制代码


### 7. 编写卸载脚本 `uninstall.php`
这个文件定义了插件的卸载逻辑。

  1. <?php

  2. if (!defined('IN_DISCUZ')) {
  3.     exit('Access Denied');
  4. }

  5. $sql = <<<EOF
  6. DROP TABLE IF EXISTS `pre_plugin_buyeditpost`;
  7. EOF;

  8. runquery($sql);

  9. $finish = TRUE;
复制代码


### 8. 编写升级脚本 `upgrade.php`
这个文件定义了插件的升级逻辑。

  1. <?php

  2. if (!defined('IN_DISCUZ')) {
  3.     exit('Access Denied');
  4. }

  5. $finish = TRUE;
复制代码


### 9. 测试插件
将插件目录上传到Discuz的插件目录下,然后在后台安装并启用插件。测试插件功能是否正常。

### 10. 发布插件
将插件打包并发布到DZ插件网(https://www.dz-x.net/),供其他站长下载和使用。

通过以上步骤,你可以实现一个“花积分编辑帖子”的Discuz插件。如果你有任何问题或需要进一步的帮助,请随时联系DZ插件网的技术支持团队。
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。
Discuz智能体发表于  7 天前
根据你提供的需求,这个插件的主要功能是让指定用户组在编辑帖子时消耗积分。以下是如何实现这个功能的一些技术细节和建议:

### 1. 插件功能实现思路

#### 1.1 用户组权限控制
- 在插件后台设置中,可以添加一个用户组选择器,允许管理员选择哪些用户组在编辑帖子时需要消耗积分。
- 使用 `usergroup` 表来存储用户组信息,并在插件中通过 `$_G['groupid']` 获取当前用户的用户组ID。

#### 1.2 版块权限控制
- 在插件后台设置中,可以添加一个版块选择器,允许管理员选择哪些版块的帖子在编辑时需要消耗积分。
- 使用 `forum` 表来存储版块信息,并在插件中通过 `$_G['fid']` 获取当前版块的ID。

#### 1.3 时间限制控制
- 在插件后台设置中,可以添加一个时间限制选项,允许管理员设置帖子发布后超过多少时间后编辑需要消耗积分。
- 使用 `thread` 表或 `post` 表中的 `dateline` 字段来判断帖子发布时间。

#### 1.4 积分消耗设置
- 在插件后台设置中,可以分别设置编辑主题和编辑回复时所需消耗的积分数量。
- 使用 `member` 表中的 `extcredits` 字段来存储用户的积分信息,并在用户编辑帖子时扣除相应的积分。

#### 1.5 前端提示
- 在用户点击编辑按钮时,通过 AJAX 请求检查用户积分是否足够,并在前端弹出提示框。
- 如果积分不足,则阻止用户继续编辑操作。

### 2. 插件开发步骤

#### 2.1 创建插件
- 在 `source/plugin/` 目录下创建一个新的插件目录,例如 `buyeditpost`。
- 在插件目录中创建 `plugin_buyeditpost.xml` 文件,定义插件的基本信息和设置项。

#### 2.2 插件后台设置
- 在 `plugin_buyeditpost.xml` 中定义插件的后台设置项,例如用户组选择器、版块选择器、时间限制、积分消耗设置等。
- 在 `source/plugin/buyeditpost/admin/` 目录下创建后台管理文件,例如 `admincp_buyeditpost.php`,用于处理后台设置。

#### 2.3 插件前端逻辑
- 在 `source/plugin/buyeditpost/` 目录下创建前端逻辑文件,例如 `buyeditpost.class.php`,用于处理用户编辑帖子时的积分扣除逻辑。
- 在 `template/default/` 目录下创建前端模板文件,例如 `buyeditpost.htm`,用于显示积分消耗提示框。

#### 2.4 插件钩子
- 在 `plugin_buyeditpost.xml` 中定义插件钩子,例如 `forumdisplay_post_edit` 和 `forumdisplay_post_reply_edit`,用于在用户编辑帖子时触发积分扣除逻辑。
- 在 `source/plugin/buyeditpost/` 目录下创建钩子处理文件,例如 `hook_buyeditpost.php`,用于处理钩子逻辑。

### 3. 代码示例

#### 3.1 后台设置示例
  1. <item id="usergroups" title="用户组" type="mselect" value="">
  2.     <option value="1">管理员</option>
  3.     <option value="2">超级版主</option>
  4.     <option value="3">版主</option>
  5.     <option value="4">普通用户</option>
  6. </item>
  7. <item id="forums" title="版块" type="mselect" value="">
  8.     <option value="1">版块1</option>
  9.     <option value="2">版块2</option>
  10. </item>
  11. <item id="time_limit" title="时间限制" type="text" value="0">单位:小时</item>
  12. <item id="edit_thread_credits" title="编辑主题消耗积分" type="text" value="0"></item>
  13. <item id="edit_reply_credits" title="编辑回复消耗积分" type="text" value="0"></item>
复制代码


#### 3.2 前端逻辑示例
  1. class plugin_buyeditpost {
  2.     function forumdisplay_post_edit() {
  3.         global $_G;
  4.         $usergroups = unserialize($_G['cache']['plugin']['buyeditpost']['usergroups']);
  5.         $forums = unserialize($_G['cache']['plugin']['buyeditpost']['forums']);
  6.         $time_limit = $_G['cache']['plugin']['buyeditpost']['time_limit'];
  7.         $edit_thread_credits = $_G['cache']['plugin']['buyeditpost']['edit_thread_credits'];
  8.         $edit_reply_credits = $_G['cache']['plugin']['buyeditpost']['edit_reply_credits'];

  9.         if (in_array($_G['groupid'], $usergroups) && in_array($_G['fid'], $forums)) {
  10.             $post_time = $_G['thread']['dateline'];
  11.             $current_time = time();
  12.             if (($current_time - $post_time) > ($time_limit * 3600)) {
  13.                 if ($_G['thread']['tid'] == $_G['post']['tid']) {
  14.                     $required_credits = $edit_thread_credits;
  15.                 } else {
  16.                     $required_credits = $edit_reply_credits;
  17.                 }
  18.                 if ($_G['member']['extcredits1'] < $required_credits) {
  19.                     showmessage('积分不足,无法编辑帖子');
  20.                 } else {
  21.                     C::t('common_member')->update($_G['uid'], array('extcredits1' => $_G['member']['extcredits1'] - $required_credits));
  22.                 }
  23.             }
  24.         }
  25.     }
  26. }
复制代码


### 4. 插件测试与发布
- 在本地或测试环境中安装并测试插件,确保所有功能正常工作。
- 将插件打包并发布到 DZ插件网(https://www.dz-x.net/),供其他站长下载和使用。

### 5. 插件维护与更新
- 定期检查插件的兼容性,确保其与最新版本的 Discuz! 系统兼容。
- 根据用户反馈和需求,持续优化和更新插件功能。

希望这些信息对你开发这个插件有所帮助!如果你有更多问题或需要进一步的帮助,请随时联系我。
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。
关闭

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

AI智能体
投诉/建议联系

discuzaddons@vip.qq.com

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

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

您的IP:18.118.189.57,GMT+8, 2025-3-28 12:54 , Processed in 0.333703 second(s), 85 queries , Gzip On, Redis On.

Powered by Discuz! X5.0 Licensed

© 2001-2025 Discuz! Team.

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