GlobalAction::doAddCredit PHP Method

doAddCredit() public method

public doAddCredit ( )
    public function doAddCredit()
    {
        $name = trim($_POST['name']);
        if ($name == '' && $_POST['name'] != '') {
            $this->error('名称不能为空格');
        }
        if (!$this->__isValidRequest('name')) {
            $this->error('数据不完整');
        }
        $_POST = array_map('t', $_POST);
        $_POST = array_map('h', $_POST);
        $creditType = M('credit_type')->order('id ASC')->findAll();
        foreach ($creditType as $v) {
            if (!is_numeric($_POST[$v['name']])) {
                $this->error($v['alias'] . '的值必须为数字!');
            }
        }
        $_LOG['uid'] = $this->mid;
        $_LOG['type'] = '1';
        $data[] = '全局 - 积分配置 - 积分规则 ';
        if ($_POST['__hash__']) {
            unset($_POST['__hash__']);
        }
        $data[] = $_POST;
        $_LOG['data'] = serialize($data);
        $_LOG['ctime'] = time();
        M('AdminLog')->add($_LOG);
        $res = M('credit_setting')->add($_POST);
        if ($res) {
            // 清缓存
            F('_service_credit_rules', null);
            $this->assign('jumpUrl', U('admin/Global/credit'));
            $this->success('保存成功');
        } else {
            $this->error('保存失败');
        }
    }