From 48e43c12e6cc63f10f4296d5746e3c3bcf301cbf Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Thu, 22 Mar 2012 10:09:39 +0800 Subject: [PATCH 1/2] MDL-32150 Libraries: checkall and uncheckall will not select disabled or readonly checkboxes --- lib/javascript-static.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/javascript-static.js b/lib/javascript-static.js index d5f249961ec..95ed06127b8 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -796,6 +796,9 @@ function checkall() { var inputs = document.getElementsByTagName('input'); for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == 'checkbox') { + if (inputs[i].disabled || inputs[i].readOnly) { + continue; + } inputs[i].checked = true; } } @@ -805,6 +808,9 @@ function checknone() { var inputs = document.getElementsByTagName('input'); for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == 'checkbox') { + if (inputs[i].disabled || inputs[i].readOnly) { + continue; + } inputs[i].checked = false; } } From a99a9a163efcda8130b0334462d441d026c7d507 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Thu, 22 Mar 2012 10:28:39 +0800 Subject: [PATCH 2/2] MDL-32150 Libraries: checkbox controller will not check or uncheck freezed checkboxes --- lib/form/yui/checkboxcontroller/checkboxcontroller.js | 6 +++++- lib/formslib.php | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/form/yui/checkboxcontroller/checkboxcontroller.js b/lib/form/yui/checkboxcontroller/checkboxcontroller.js index abcbbbd8476..7543eb57eb1 100644 --- a/lib/form/yui/checkboxcontroller/checkboxcontroller.js +++ b/lib/form/yui/checkboxcontroller/checkboxcontroller.js @@ -100,7 +100,11 @@ YUI.add('moodle-form-checkboxcontroller', function(Y) { controllervaluenode.set('value', '1'); newvalue = 'checked'; } - checkboxes.set('checked', newvalue); + checkboxes.each(function(checkbox){ + if (!checkbox.get('disabled')) { + checkbox.set('checked', newvalue); + } + }); } } }); diff --git a/lib/formslib.php b/lib/formslib.php index 78f1fc305be..5ca5bd1a83f 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -1084,7 +1084,8 @@ abstract class moodleform { if (!is_null($contollerbutton) || is_null($select_value)) { foreach ($mform->_elements as $element) { if (($element instanceof MoodleQuickForm_advcheckbox) && - $element->getAttribute('class') == $checkboxgroupclass) { + $element->getAttribute('class') == $checkboxgroupclass && + !$element->isFrozen()) { $mform->setConstants(array($element->getName() => $new_select_value)); } }