RegisterModel::activate PHP Method

activate() public method

激活指定用户
public activate ( integer $uid, string $code ) : boolean
$uid integer 用户UID
$code string 激活码
return boolean 是否激活成功
    public function activate($uid, $code)
    {
        $map['uid'] = $uid;
        $user_info = $this->_user_model->where($map)->find();
        $res = $code == $this->getActivationCode($user_info);
        if ($res && !$user_info['is_active']) {
            $res = $this->_user_model->where($map)->save(array('is_active' => 1));
            $this->_user_model->cleanCache($uid);
        }
        if ($res) {
            $this->_error = L('PUBLIC_ACCOUNT_ACTIVATED_SUCCESSFULLY');
            // 恭喜,帐号已成功激活
            return true;
        } else {
            $this->_error = L('PUBLIC_ACTIVATE_USER_FAIL');
            // 激活用户失败
            return false;
        }
    }