discuzx2.5 中积分操作函数以及自定义积分
2014-12-12 00:54
176 查看
转:http://www.enjoydiy.com/496.html
添加一条SQL,此 SQL 记录可以在您插件安装的时候内置在里面
PgSQL
添加后站长便可以在积分策略中看到这条记录
此时可让站长自行调整此策略
在代码中进行积分操作时,您只需在插件中添加以下代码,即可执行此积分策略
PHP
单独增减积分可用 updatemembercount() 函数
PHP
积分操作类型:
PHP
里面调用了另一个函数,原始的定义我也发过来吧:
PHP
其中第四个参数和第五个参数在写积分记录的时候有用,如果两者皆不为空,则系统会在积分记录中记录。
第四个参数是记录相关操作的变量,第五个参数看名称应该是记录产生这个积分操作的相关的id值(例如像uid,fid,tid这类的),第六个参数用于当$data数组(即记录积分增减情况的数组)不为空时,重新调用函数并把值传递给第四个变量。
添加一条SQL,此 SQL 记录可以在您插件安装的时候内置在里面
PgSQL
1 2 | INSERT INTO `pre_common_credit_rule` (`rulename`, `action`, `cycletype`, `cycletime`, `rewardnum`, `norepeat`, `extcredits1`, `extcredits2`, `extcredits3`, `extcredits4`, `extcredits5`, `extcredits6`, `extcredits7`, `extcredits8`, `fids`) VALUES (‘宠物购买’, ‘petbuy’, 4, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘0′); |
此时可让站长自行调整此策略
在代码中进行积分操作时,您只需在插件中添加以下代码,即可执行此积分策略
PHP
1 | updatecreditbyaction(‘petbuy’, $_G['uid']); |
PHP
1 2 3 4 5 6 7 8 9 10 | /** * 添加积分 * @param Integer $uids: 用户uid或者uid数组 * @param String $dataarr: member count相关操作数组,例: array(‘extcredits1′ => 1) * @param Boolean $checkgroup: 是否检查用户组 true or false * @param String $operation: 积分记录操作类型(不记录积分日志可忽略) * @param Integer $relatedid: 积分记录相关 ID(不记录积分日志可忽略) * @param String $ruletxt: 动画效果中的积分规则文本(UTF-8格式) */ function updatemembercount($uids, $dataarr = array(), $checkgroup = true, $operation = ”, $relatedid = 0, $ruletxt = ”) |
操作名字 | 关联ID | 说明 |
---|---|---|
ACC | forum_activity.tid | 参与活动扣除积分 |
AFD | common_member.uid | 购买积分即积分充值 |
AGC | common_magic.mid | 获得红包 |
BAC | forum_attachment.aid | 购买附件支出积分 |
BGC | common_magic.mid | 埋下红包 |
BMC | common_magic.mid | 道具购买消耗积分 |
BTC | forum_thread.tid | 购买主题支出积分 |
CDC | 1 | 卡密充值 |
CEC | common_member.uid | 积分兑换 |
ECU | common_member.uid | 通过ucenter兑换积分 |
MRC | common_magic.mid | 道具随机获取积分 |
PRC | forum_post.pid | 帖子被评分所得积分 |
RAC | forum_thread.tid | 最佳答案获取悬赏积分 |
RCA | forum_thread.tid | 回帖中奖 |
RCB | forum_thread.tid | 返还回帖奖励积分 |
RCT | forum_thread.tid | 回帖奖励积分 |
RCV | common_member.uid | 积分转账接收 |
RGC | common_magic.mid | 回收红包 |
RKC | common_member.uid | 竞价排名 |
RPC | common_report.id | 举报功能中的奖惩 |
RSC | forum_thread.tid | 评分帖子扣除自己的积分 |
RTC | forum_thread.tid | 发表悬赏主题扣除积分 |
SAC | forum_attachment.aid | 出售附件获得积分 |
STC | forum_thread.tid | 出售主题获得积分 |
TFR | common_member.uid | 积分转账转出 |
TRC | common_task.taskid | 任务奖励积分 |
UGP | common_usergroup.groupid | 购买扩展用户组支出积分 |
1 2 3 4 5 6 7 | function updatemembercount($uids, $dataarr = array(), $checkgroup = true, $operation = '', $relatedid = 0, $ruletxt = '') { if(!empty($uids) && (is_array($dataarr) && $dataarr)) { require_once libfile('function/credit'); return _updatemembercount($uids, $dataarr, $checkgroup, $operation, $relatedid, $ruletxt); } return true; } |
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | function _updatemembercount($uids, $dataarr = array(), $checkgroup = true, $operation = '', $relatedid = 0, $ruletxt = '') { if(empty($uids)) return; if(!is_array($dataarr) || empty($dataarr)) return; if($operation && $relatedid) { $writelog = true; $log = array( 'uid' => $uids, 'operation' => $operation, 'relatedid' => $relatedid, 'dateline' => time(), ); } else { $writelog = false; } $data = array(); foreach($dataarr as $key => $val) { if(empty($val)) continue; $val = intval($val); $id = intval($key); $id = !$id && substr($key, 0, -1) == 'extcredits' ? intval(substr($key, -1, 1)) : $id; if(0 < $id && $id < 9) { $data['extcredits'.$id] = $val; if($writelog) { $log['extcredits'.$id] = $val; } } else { $data[$key] = $val; } } if($writelog) { DB::insert('common_credit_log', $log); } if($data) { include_once libfile('class/credit'); $credit = & credit::instance(); $credit->updatemembercount($data, $uids, $checkgroup, $ruletxt); } } |
第四个参数是记录相关操作的变量,第五个参数看名称应该是记录产生这个积分操作的相关的id值(例如像uid,fid,tid这类的),第六个参数用于当$data数组(即记录积分增减情况的数组)不为空时,重新调用函数并把值传递给第四个变量。
相关文章推荐
- Discuz!X 中积分操作函数以及自定义积分
- Ext.TextField自定义验证函数以及提示文字
- SQL自定义函数实现字符串截取转化为整型(主要用于对批量数据的操作)
- [MSSQL]日期集合-周、月、季度、年等计算以及自定义函数
- Adobe AIR迷你教程 -- 使用自定义窗口以及对窗口的移动,缩放,关闭操作
- SQL server 使用自定义函数以及游标
- 通知php使用自定义的session处理函数来操作session,而不使用php预置的方法
- 【转】Sqlite3.3.8日期类型字段以及操作函数
- 用 JavaScript 写 ASP,似乎很爽啊,自己封装了一个 操作数据库 分页 以及 文件操作的函数
- mysql常用字符串操作函数大全,以及实例
- Excel操作自定义函数
- 使用自定义窗口以及对窗口的移动,缩放,关闭操作
- 字符串以及内存操作相关函数
- MATLAB 支持的文件格式 以及简单的操作函数
- [MSSQL]日期集合-周、月、季度、年等计算以及自定义函数
- Adobe AIR迷你教程 -- 使用自定义窗口以及对窗口的移动,缩放,关闭操作
- Adobe AIR迷你教程 — 使用自定义窗口以及对窗口的移动,缩放,关闭操作
- js(javascript)自定义的DateAdd和DateDiff函数以及当前日期的取法
- Adobe AIR迷你教程 -- 使用自定义窗口以及对窗口的移动,缩放,关闭操作
- CRecordset类的常用成员函数 成员变量 以及操作实例