public static function count_templates($context, $includes) {
        global $DB;
        static::require_enabled();

        // First we do a permissions check.
        $contexts = self::get_related_contexts($context, $includes,
            array('moodle/competency:templateview', 'moodle/competency:templatemanage'));

        if (empty($contexts)) {
             throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
        }

        // OK - all set.
        $template = new template();
        list($insql, $inparams) = $DB->get_in_or_equal(array_keys($contexts), SQL_PARAMS_NAMED);
        return $template->count_records_select("contextid $insql", $inparams);
    }
public static function count_templates($context, $includes) {
        global $DB;
        static::require_enabled();

        // First we do a permissions check.
        $contexts = self::get_related_contexts($context, $includes,
            array('moodle/competency:templateview', 'moodle/competency:templatemanage'));

        if (empty($contexts)) {
             throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
        }

        // OK - all set.
        $template = new template();
        list($insql, $inparams) = $DB->get_in_or_equal(array_keys($contexts), SQL_PARAMS_NAMED);
        return $template->count_records_select("contextid $insql", $inparams);
    }
public static function count_templates ( $ context , $ includes ) { global $ DB ; static :: require_enabled ( ) ; // First we do a permissions check. $ contexts = self :: get_related_contexts ( $ context , $ includes , array ( 'moodle/competency:templateview' , 'moodle/competency:templatemanage' ) ) ; if ( empty ( $ contexts ) ) { throw new required_capability_exception ( $ context , 'moodle/competency:templateview' , 'nopermissions' , '' ) ; } // OK - all set. $ template = new template ( ) ; list ( $ insql , $ inparams ) = $ DB -> get_in_or_equal ( array_keys ( $ contexts ) , SQL_PARAMS_NAMED ) ; return $ template -> count_records_select ( "contextid $insql" , $ inparams ) ; }
Perform a search based on the provided filters and return how many results there are.

Requires moodle/competency:templateview capability at the system context.

@param context $context The parent context of the frameworks.
@param string $includes Defines what other contexts to fetch frameworks from.
Accepted values are:
- children: All descendants
- parents: All parents, grand parents, etc...
- self: Context passed only.
@return int
Perform a search based on the provided filters and return how many results there are .