discuz updatemembercount,notification_add 解析

这个函数的原始定义如下:

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;
}
里面调用了另一个函数:

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);
        }
}

其中第四个参数和第五个参数在写积分记录的时候有用,如果两者皆不为空,则系统会在积分记录中记录。

第一个参数用户 用户数组,

第二个参数操作规则,如扣减第二个积分3分:array ('extcredits2' => -3);

第三个参数是否检查用户组升级,通常为true

第四个参数是记录相关操作的变量,

第五个参数看名称应该是记录产生这个积分操作的相关的id值(例如像uid,fid,tid这类的),

第六个参数用于当$data数组(即记录积分增减情况的数组)不为空时,重新调用函数并把值传递给第四个变量.

示例:updatemembercount('10', array('extcredits2' => "-1"), true, '', 0, '');   将uid为10的用户第二个积分-1



notification_add($touid, $type, $note, $notevars = array(), $system = 0)
$touid : 发送给谁?
$type : 方式? 常用的是post
$note : 可以自己编辑内容
$notevars = 一些内容参数
$system = 默认情况下为0

示例:notification_add(10,'post','欢迎来我的网站');    给用户id为10的用户发送一条"欢迎来我的网站"的讯息

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值