discuz updatemembercount,notification_add 解析

来源:互联网 发布:google chrome mac版 编辑:程序博客网 时间:2024/05/18 02:57

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

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 0
原创粉丝点击