MDL-56285 competency: fix move competencies capabilities

In learning plan templates, cannot move competencies
around even if capability templatemanage is given
to the role because of bad context check
This commit is contained in:
Issam Taboubi
2016-10-06 10:33:32 -04:00
parent f73f938469
commit fd8043b2de
2 changed files with 71 additions and 3 deletions
+6 -3
View File
@@ -2196,10 +2196,13 @@ class api {
*/
public static function reorder_template_competency($templateid, $competencyidfrom, $competencyidto) {
static::require_enabled();
// First we do a permissions check.
$context = context_system::instance();
$template = new template($templateid);
require_capability('moodle/competency:templatemanage', $context);
// First we do a permissions check.
if (!$template->can_manage()) {
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage',
'nopermissions', '');
}
$down = true;
$matches = template_competency::get_records(array('templateid' => $templateid, 'competencyid' => $competencyidfrom));