From 6d77b23c557fc293e4e102544c695135ebc5e322 Mon Sep 17 00:00:00 2001 From: skodak Date: Wed, 26 Dec 2007 21:33:34 +0000 Subject: [PATCH] MDL-12735 Make AJAX on by default, add option to disable AJAX course editing by default; merged from MOODLE_19_STABLE --- admin/settings/appearance.php | 4 +++- course/view.php | 11 ++++++----- lang/en_utf8/admin.php | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index dcd4c45922..cee6f4e62a 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -78,7 +78,9 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page $ADMIN->add('appearance', $temp); $temp = new admin_settingpage('ajax', get_string('ajaxuse')); - $temp->add(new admin_setting_configcheckbox('enableajax', get_string('enableajax', 'admin'), get_string('configenableajax', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('enableajax', get_string('enableajax', 'admin'), get_string('configenableajax', 'admin'), 1)); + $temp->add(new admin_setting_configcheckbox('disablecourseajax', get_string('disablecourseajax', 'admin'), get_string('configdisablecourseajax', 'admin'), + isset($CFG->disablecourseajax) ? 1 : empty($CFG->enableajax))); $ADMIN->add('appearance', $temp); // link to tag management interface diff --git a/course/view.php b/course/view.php index 6fa94bc1a7..43dac026e6 100644 --- a/course/view.php +++ b/course/view.php @@ -131,12 +131,13 @@ // AJAX-capable course format? - $CFG->useajax = false; + $useajax = false; $ajaxformatfile = $CFG->dirroot.'/course/format/'.$course->format.'/ajax.php'; $bodytags = ''; - if (file_exists($ajaxformatfile)) { // Needs to exist otherwise no AJAX by default + if (empty($CFG->disablecourseajax) and file_exists($ajaxformatfile)) { // Needs to exist otherwise no AJAX by default + // TODO: stop abusing CFG global here $CFG->ajaxcapable = false; // May be overridden later by ajaxformatfile $CFG->ajaxtestedbrowsers = array(); // May be overridden later by ajaxformatfile @@ -173,12 +174,12 @@ // function is called, since that function needs to set some // stuff in the javascriptportal object. $COURSE->javascriptportal = new jsportal(); - $CFG->useajax = true; + $useajax = true; } } } - $CFG->blocksdrag = $CFG->useajax; // this will add a new class to the header so we can style differently + $CFG->blocksdrag = $useajax; // this will add a new class to the header so we can style differently $PAGE->print_header(get_string('course').': %fullname%', NULL, '', $bodytags); @@ -218,7 +219,7 @@ // Use AJAX? - if ($CFG->useajax && has_capability('moodle/course:manageactivities', $context)) { + if ($useajax && has_capability('moodle/course:manageactivities', $context)) { // At the bottom because we want to process sections and activities // after the relevant html has been generated. We're forced to do this // because of the way in which lib/ajax/ajaxcourse.js is written. diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 003bbaa156..d0d274273a 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -96,6 +96,7 @@ $string['configeditorfontlist'] = 'Select the fonts that should appear in the ed $string['configeditordictionary'] = 'This value will be used if aspell doesn\'t have dictionary for users own language.'; $string['configemoticons'] = 'Change the code on the left that relates to the name of the emoticon on the right. To add new emoticons, add a code and a name, then add an image as name.gif in /pix/s.'; $string['configenableajax'] = 'This setting allows you to control the use of AJAX (advanced client/server interfaces using Javascript) across the whole site. With this setting enabled users can still make a choice in their profile, otherwise AJAX is disabled for everybody.'; +$string['configdisablecourseajax'] = 'Do not use AJAX when editing main course pages.'; $string['configenablecourserequests'] = 'This will allow any user to request a course be created.'; $string['configenableglobalsearch'] = 'This setting enables global text searching in resources and activities, it is not compatible with PHP 4.'; $string['configenablegroupings'] = 'This setting enables groupings of groups.'; @@ -276,6 +277,7 @@ $string['deleteuser'] = 'Delete user'; $string['density'] = 'Density'; $string['denyemailaddresses'] = 'Denied email domains'; $string['digestmailtime'] = 'Hour to send digest emails'; +$string['disablecourseajax'] = 'Disable AJAX course editing'; $string['disableuserimages'] = 'Disable User Profile Images'; $string['displayloginfailures'] = 'Display login failures to'; $string['docroot'] = 'Moodle Docs document root'; -- 2.39.5