public function get_total_discussion_count_from_forum_id_and_group_id(
        int $forumid,
        array $groupids,
        bool $includehiddendiscussions,
        ?int $includepostsforuser
    ) {
        $alias = $this->get_table_alias();

        $wheresql = "{$alias}.forum = :forumid AND ";
        $groupparams = [];
        if (empty($groupids)) {
            $wheresql .= "{$alias}.groupid = :allgroupsid";
        } else {
            list($insql, $groupparams) = $this->get_db()->get_in_or_equal($groupids, SQL_PARAMS_NAMED, 'gid');
            $wheresql .= "({$alias}.groupid = :allgroupsid OR {$alias}.groupid {$insql})";
        }

        [
            'wheresql' => $hiddensql,
            'params' => $hiddenparams
        ] = $this->get_hidden_post_sql($includehiddendiscussions, $includepostsforuser);
        $wheresql .= $hiddensql;

        $params = array_merge($hiddenparams, $groupparams, [
            'forumid' => $forumid,
            'allgroupsid' => -1,
        ]);

        return $this->get_db()->count_records_sql($this->generate_count_records_sql($wheresql), $params);
    }
public function get_total_discussion_count_from_forum_id_and_group_id(
        int $forumid,
        array $groupids,
        bool $includehiddendiscussions,
        ?int $includepostsforuser
    ) {
        $alias = $this->get_table_alias();

        $wheresql = "{$alias}.forum = :forumid AND ";
        $groupparams = [];
        if (empty($groupids)) {
            $wheresql .= "{$alias}.groupid = :allgroupsid";
        } else {
            list($insql, $groupparams) = $this->get_db()->get_in_or_equal($groupids, SQL_PARAMS_NAMED, 'gid');
            $wheresql .= "({$alias}.groupid = :allgroupsid OR {$alias}.groupid {$insql})";
        }

        [
            'wheresql' => $hiddensql,
            'params' => $hiddenparams
        ] = $this->get_hidden_post_sql($includehiddendiscussions, $includepostsforuser);
        $wheresql .= $hiddensql;

        $params = array_merge($hiddenparams, $groupparams, [
            'forumid' => $forumid,
            'allgroupsid' => -1,
        ]);

        return $this->get_db()->count_records_sql($this->generate_count_records_sql($wheresql), $params);
    }
public function get_total_discussion_count_from_forum_id_and_group_id ( int $ forumid , array $ groupids , bool $ includehiddendiscussions , ? int $ includepostsforuser ) { $ alias = $ this -> get_table_alias ( ) ; $ wheresql = "{$alias}.forum = :forumid AND " ; $ groupparams = [ ] ; if ( empty ( $ groupids ) ) { $ wheresql .= "{$alias}.groupid = :allgroupsid" ; } else { list ( $ insql , $ groupparams ) = $ this -> get_db ( ) -> get_in_or_equal ( $ groupids , SQL_PARAMS_NAMED , 'gid' ) ; $ wheresql .= "({$alias}.groupid = :allgroupsid OR {$alias}.groupid {$insql})" ; } [ 'wheresql' => $ hiddensql , 'params' => $ hiddenparams ] = $ this -> get_hidden_post_sql ( $ includehiddendiscussions , $ includepostsforuser ) ; $ wheresql .= $ hiddensql ; $ params = array_merge ( $ hiddenparams , $ groupparams , [ 'forumid' => $ forumid , 'allgroupsid' => - 1 , ] ) ; return $ this -> get_db ( ) -> count_records_sql ( $ this -> generate_count_records_sql ( $ wheresql ) , $ params ) ; }
Count the number of discussions in all groups and the list of groups provided.

@param int $forumid Id of the forum to count discussions in
@param int[] $groupids List of group ids to include in the count (discussions in all groups will always be counted)
@param bool $includehiddendiscussions Include hidden dicussions in the count?
@param int|null $includepostsforuser Include discussions created by this user in the count
(only works if not including hidden discussions).
@return int
Count the number of discussions in all groups and the list of groups provided .