discuz 修改积分策略( 在周期中添加"每周" )

在  source/admincp/admincp_credits.php 文件中, ctrl+f 搜索  $lang['setting_credits_policy_cycletype_1'] 处,  在后面添加一行:

array(5, $lang['setting_credits_policy_cycletype_5'], array('cycletimetd' => 'none', 'rewardnumtd' => '')),

我把"每周" 的表单值设置为5 , 在语言包 lang_admincp.php 中添加一行 

'setting_credits_policy_cycletype_5' => '每周',

然后去, source/class/class_credit.php  ctrl+f搜索 if($rule['cycletype'] == 1)  在下面添加

if($rule['cycletype'] == 5) {//奖励周期1次
    $this_week = this_monday($_G['timestamp']);//本周一, 时间戳形式
    if($rulelog['dateline'] < $this_week && $rule['rewardnum']) {
        $rulelog['cyclenum'] =  0;
        $newcycle = true;
    }
}    

this_monday函数如下, 自己去function中定义去

//这个星期的星期一  
// @$timestamp ,某个星期的某一个时间戳,默认为当前时间  
// @is_return_timestamp ,是否返回时间戳,否则返回时间格式  
function this_monday($timestamp = 0, $is_return_timestamp = true) {
    static $cache;
    $id = $timestamp . $is_return_timestamp;
    if (!isset($cache[$id])) {
        if (!$timestamp)
            $timestamp = time();
        $monday_date = date('Y-m-d', $timestamp - 86400 * date('w', $timestamp) + (date('w', $timestamp) > 0 ? 86400 : -/* 6*86400 */518400));
        if ($is_return_timestamp) {
            $cache[$id] = strtotime($monday_date);
        } else {
            $cache[$id] = $monday_date;
        }
    }
    return $cache[$id];
}

  

  

原文地址:https://www.cnblogs.com/freespider/p/3672947.html