public static function count_rule_subscriptions($ruleid) {
        global $DB;
        $sql = self::get_subscription_join_rule_sql(true);
        $sql .= "WHERE s.ruleid = :ruleid";

        return $DB->count_records_sql($sql, array('ruleid' => $ruleid));
    }