From 88c5092a5042127e3a0bfd6cf08cccb969bb48d9 Mon Sep 17 00:00:00 2001 From: vyshane Date: Fri, 17 Nov 2006 05:54:21 +0000 Subject: [PATCH] Merged from 1.7. --- course/format/weeks/format.php | 4 +++- lib/ajax/ajaxlib.php | 27 +++++++++++++++++++++++---- lib/ajax/section_classes.js | 8 ++++---- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/course/format/weeks/format.php b/course/format/weeks/format.php index bf89224032..beab3a5469 100644 --- a/course/format/weeks/format.php +++ b/course/format/weeks/format.php @@ -173,7 +173,8 @@ echo ''; echo ' '; - if (!empty($USER->ajax) && $editing) { + + if (ajaxenabled() && $editing) { // Temporarily hide the dates for the weeks. We do it this way // for now. Eventually, we'll have to modify the javascript code // to handle re-calculation of dates when sections are moved @@ -183,6 +184,7 @@ $weekperiod = $weekday.' '.$endweekday; } + echo ''; if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) { // Hidden for students echo '
'.$weekperiod.' ('.get_string('notavailable').')
'; diff --git a/lib/ajax/ajaxlib.php b/lib/ajax/ajaxlib.php index 19812cadce..b261f38ddd 100644 --- a/lib/ajax/ajaxlib.php +++ b/lib/ajax/ajaxlib.php @@ -9,10 +9,7 @@ function require_js($list) { global $CFG; $output = ''; - if (!check_browser_version('MSIE', 6.0) - && !check_browser_version('Firefox', 1.5) - && !check_browser_version('Camino', '1.0.2')) { - // We still have issues with AJAX in other browsers. + if (!ajaxenabled()) { return; } @@ -45,6 +42,28 @@ function require_js($list) { } +/** + * Returns whether ajax is enabled/allowed or not. + */ +function ajaxenabled() { + + global $CFG, $USER; + + if (!check_browser_version('MSIE', 6.0) + && !check_browser_version('Firefox', 1.5) + && !check_browser_version('Camino', '1.0.2')) { + // We still have issues with AJAX in other browsers. + return false; + } + + if (!empty($CFG->enableajax) && !empty($USER->ajax)) { + return true; + } else { + return false; + } +} + + /** * Used to create view of document to be passed to JavaScript on pageload. * We use this class to pass data from PHP to JavaScript. diff --git a/lib/ajax/section_classes.js b/lib/ajax/section_classes.js index 18f8e3630f..f4b64df504 100755 --- a/lib/ajax/section_classes.js +++ b/lib/ajax/section_classes.js @@ -306,16 +306,16 @@ section_class.prototype.mk_marker = function() { main.connect('POST', 'class=course&field=marker', null, 'value=0'); this.toggle_highlight(); } -} +} section_class.prototype.changeId = function(newId) { this.sectionId = newId; - this.numberDisplay.firstChild.data = newId; + this.numberDisplay.firstChild.data = newId; //main.connectQueue_add('POST','class=section&field=all',null,'id='+newId+"&summary="+main.mk_safe_for_transport(this.summary)+"&sequence="+this.write_sequence_list(true)+'&visible='+(this.hidden?0:1)) if (main.marker == this) { - main.update_marker(this); + main.update_marker(this); } } @@ -392,7 +392,7 @@ section_class.prototype.insert_resource = function(el, targetel) { } else { if (el.hiddenStored != null) { el.toggle_hide(null, null, true, el.hiddenStored); - el.hiddenStored = null; + el.hiddenStored = null; } } //update model -- 2.39.5