|
phpwind[插件开发辅助函数,积分控制类
开发过程中经常会遇到针对积分的控制应用,pw积分操作统一入口credit.php文件,介绍一下这个文件和调用实例本篇说到的文件大家可以到程序里去查看,
复制代码[ol,var $cType = array();//积分名称 var $cUnit = array();//积分单位 var $Field = array();//积分的使用范围 var $cLog = array();//积分日志数组 var $setUser = array();//积分处理缓存数组,即分步积分操作结果缓存起来 var $getUser = array();//用户积分提前缓存数组//构造函数,定义了系统默认积分以及自定义积分的名称和单位 function PwCredit() { //默认的积分类型 $this->cType = array( 'money' => $GLOBALS['db_moneyname',, 'rvrc' => $GLOBALS['db_rvrcname',, 'credit' => $GLOBALS['db_creditname',, 'currency' => $GLOBALS['db_currencyname', ); $this->cUnit = array( 'money' => $GLOBALS['db_moneyunit',, 'rvrc' => $GLOBALS['db_rvrcunit',, 'credit' => $GLOBALS['db_creditunit',, 'currency' => $GLOBALS['db_currencyunit', ); //自定义的积分类型 foreach ($GLOBALS['_CREDITDB', as $key => $value) { $this->cType[$key, = $value[0]; $this->cUnit[$key, = $value[1,; } //与积分加减有关的发帖和精品贴 $this->Field = array('postnum', 'digests'); }[/ol,
复制代码[ol,//主要针对帖子相关系统使用的积分处理function creditset($f_set,$d_set) { if (!is_array($f_set)) $f_set = unserialize($f_set); if (!is_array($d_set)) $d_set = unserialize($d_set); foreach ($d_set as $key => $value) { foreach ($value as $k => $v) { isset($f_set[$key,[$k,) && $f_set[$key,[$k, !== '' && $v = $f_set[$key,[$k,; if (!in_array($key,array('Digest','Post','Reply'))) { $v = -$v; } $d_set[$key,[$k, = $v; } } return $d_set; }[/ol, |
|