IndexAction::can_apply_weiba_admin PHP Method

can_apply_weiba_admin() public method

检查是否有申请资格
    public function can_apply_weiba_admin()
    {
        if (!CheckPermission('weiba_normal', 'weiba_apply_manage')) {
            echo -3;
            exit;
        }
        $weiba_id = intval($_POST['weiba_id']);
        if (intval($_POST['type']) == 3) {
            if (D('weiba_follow')->where('weiba_id=' . $weiba_id . ' AND level=3')->find()) {
                //已经有了圈主
                echo 2;
                exit;
            }
        }
        if (D('weiba_apply')->where('weiba_id=' . $weiba_id . ' AND follower_uid=' . $this->mid)->find()) {
            echo -1;
            exit;
        }
        if (D('weiba_follow')->where('weiba_id=' . $weiba_id . ' AND follower_uid=' . $this->mid . ' AND (level=3 OR level=2)')->find()) {
            echo -2;
            exit;
        }
        model('User')->cleanCache($this->mid);
        //关注该微吧
        if (!D('weiba_follow')->where('weiba_id=' . $weiba_id . ' AND follower_uid=' . $this->mid)->find()) {
            echo 0;
            exit;
        }
        $weibaAdminAuditConfig = model('Xdata')->get('weiba_Admin:weibaAdminAuditConfig');
        //粉丝数
        if ($weibaAdminAuditConfig['follower_open'] == 1) {
            $user_data = model('UserData')->getUserData($this->mid);
            if ($user_data['follower_count'] < $weibaAdminAuditConfig['follower']) {
                echo 0;
                exit;
            }
        }
        //等级
        if ($weibaAdminAuditConfig['level_open'] == 1) {
            $user_level = model('Credit')->getUserCredit($this->mid);
            if ($user_level['level']['level'] < $weibaAdminAuditConfig['level']) {
                echo 0;
                exit;
            }
        }
        //发帖数
        if ($weibaAdminAuditConfig['weiba_post_open'] == 1) {
            $user_weiba_post = D('weiba_post')->where('post_uid=' . $this->mid . ' and weiba_id=' . $weiba_id . ' and is_del=0')->count();
            if ($user_weiba_post < $weibaAdminAuditConfig['weiba_post']) {
                echo 0;
                exit;
            }
        }
        echo 1;
    }