mirror of
https://github.com/moodle/moodle.git
synced 2025-04-19 07:25:30 +02:00
MDL-78597 mod_lti: add category restriction support to course tools list
This commit is contained in:
parent
7cb2a78626
commit
c497672778
@ -65,12 +65,20 @@ class course_external_tools_list extends system_report {
|
||||
FROM {lti} $ti
|
||||
WHERE $ti.typeid = {$entitymainalias}.id) AS toolusage");
|
||||
|
||||
// Scope the report to the course context only.
|
||||
// Join the types_categories table, to include only tools available to the current course's category.
|
||||
$cattablealias = database::generate_alias();
|
||||
$joinsql = "LEFT JOIN {lti_types_categories} {$cattablealias}
|
||||
ON ({$cattablealias}.typeid = {$entitymainalias}.id)";
|
||||
$this->add_join($joinsql);
|
||||
|
||||
// Scope the report to the course context and include only those tools available to the category.
|
||||
$paramprefix = database::generate_param_name();
|
||||
$coursevisibleparam = database::generate_param_name();
|
||||
$categoryparam = database::generate_param_name();
|
||||
[$insql, $params] = $DB->get_in_or_equal([get_site()->id, $this->course->id], SQL_PARAMS_NAMED, "{$paramprefix}_");
|
||||
$wheresql = "{$entitymainalias}.course {$insql} AND {$entitymainalias}.coursevisible NOT IN (:{$coursevisibleparam})";
|
||||
$params = array_merge($params, [$coursevisibleparam => LTI_COURSEVISIBLE_NO]);
|
||||
$wheresql = "{$entitymainalias}.course {$insql} AND {$entitymainalias}.coursevisible NOT IN (:{$coursevisibleparam}) ".
|
||||
"AND ({$cattablealias}.id IS NULL OR {$cattablealias}.categoryid = :{$categoryparam})";
|
||||
$params = array_merge($params, [$coursevisibleparam => LTI_COURSEVISIBLE_NO, $categoryparam => $this->course->category]);
|
||||
$this->add_base_condition_sql($wheresql, $params);
|
||||
|
||||
$this->set_downloadable(false, get_string('pluginname', 'mod_lti'));
|
||||
|
Loading…
x
Reference in New Issue
Block a user