Skip to content

Commit

Permalink
Improved override instance capability.
Browse files Browse the repository at this point in the history
  • Loading branch information
raja-lmsace committed Mar 30, 2024
1 parent 58f1300 commit eacbadb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions classes/forms/automation_instance_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ public function after_definition() {
$mform->insertElementBefore($referenceprefix, 'insreference');

$this->load_default_override_elements(['insreference']);

// Add element to disable instance override options.
$hasinstanceeditcapability = has_capability('mod/pulse:overridetemplateinstance', \context_course::instance($course));
$mform->addElement('hidden', 'hasinstanceeditcapability', $hasinstanceeditcapability);
$mform->setType('hasinstanceeditcapability', PARAM_INT);

if (!empty($elements)) {
// List of element type don't need to add the override option.
Expand All @@ -176,9 +181,15 @@ public function after_definition() {
foreach ($elements as $element) {

if (!in_array($element->getType(), $dontoverride) && $element->getName() !== 'buttonar') {
// if (has_capability('mod/pulse:overridetemplateinstance', \context_course::instance($course))) {

if ($hasinstanceeditcapability) {
// Has capability add override element.
$this->add_override_element($element, $course);
// }
} else {
$elementname = $element->getName();
$orgelementname = $elementname;
$mform->disabledIf($orgelementname, 'hasinstanceeditcapability', 'neq', 1);
}
}
}
}
Expand Down

0 comments on commit eacbadb

Please sign in to comment.