/** * Perform a search based on the provided filters and return a paginated list of records. * * Requires moodle/competency:competencyview 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 */ public static function count_frameworks($context, $includes) { global $DB; static::require_enabled(); // Get all the relevant contexts. $contexts = self::get_related_contexts($context, $includes, array('moodle/competency:competencyview', 'moodle/competency:competencymanage')); if (empty($contexts)) { throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', ''); } // OK - all set. list($insql, $inparams) = $DB->get_in_or_equal(array_keys($contexts), SQL_PARAMS_NAMED); return competency_framework::count_records_select("contextid {$insql}", $inparams); }