diff --git a/admin/settings/development.php b/admin/settings/development.php index b7ac470620d..46f92bcfaf1 100644 --- a/admin/settings/development.php +++ b/admin/settings/development.php @@ -7,8 +7,12 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page // Experimental settings page $ADMIN->add('development', new admin_category('experimental', get_string('experimental','admin'))); + require_once($CFG->dirroot .'/search/lib.php'); $temp = new admin_settingpage('experimentalsettings', get_string('experimentalsettings', 'admin')); - $temp->add(new admin_setting_configcheckbox('enableglobalsearch', get_string('enableglobalsearch', 'admin'), get_string('configenableglobalsearch', 'admin'), 0)); + $englobalsearch = new admin_setting_configcheckbox('enableglobalsearch', get_string('enableglobalsearch', 'admin'), get_string('configenableglobalsearch', 'admin'), 0); + $englobalsearch->set_updatedcallback('search_updatedcallback'); + $temp->add($englobalsearch); + $temp->add(new admin_setting_configcheckbox('experimentalsplitrestore', get_string('experimentalsplitrestore', 'admin'), get_string('configexperimentalsplitrestore', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('enableimsccimport', get_string('enable_cc_import', 'imscc'), get_string('enable_cc_import_description', 'imscc'), 0)); $temp->add(new admin_setting_configcheckbox('enablesafebrowserintegration', get_string('enablesafebrowserintegration', 'admin'), get_string('configenablesafebrowserintegration', 'admin'), 0)); diff --git a/blocks/search/db/install.php b/blocks/search/db/install.php new file mode 100644 index 00000000000..f8a13cf7f20 --- /dev/null +++ b/blocks/search/db/install.php @@ -0,0 +1,10 @@ +set_field('block', 'visible', 0, array('name'=>'search')); + +} + diff --git a/blocks/search/db/upgrade.php b/blocks/search/db/upgrade.php index ee8b4848646..952a1297e59 100644 --- a/blocks/search/db/upgrade.php +++ b/blocks/search/db/upgrade.php @@ -83,5 +83,12 @@ function xmldb_block_search_upgrade($oldversion) { upgrade_block_savepoint(true, 2010110900, 'search'); } + if ($oldversion < 2010111100) { + // set block to hidden if global search is disabled. + if ($CFG->enableglobalsearch != 1) { + $DB->set_field('block', 'visible', 0, array('name'=>'search')); // Hide block + } + upgrade_block_savepoint(true, 2010111100, 'search'); + } return $result; } diff --git a/blocks/search/version.php b/blocks/search/version.php index 77f60501e83..b7456820a7b 100644 --- a/blocks/search/version.php +++ b/blocks/search/version.php @@ -15,5 +15,5 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -$plugin->version = 2010110900; +$plugin->version = 2010111100; $plugin->cron = 1; diff --git a/search/lib.php b/search/lib.php index 8484981379a..d93a633f810 100644 --- a/search/lib.php +++ b/search/lib.php @@ -186,4 +186,12 @@ function search_pexit($str = "") { exit(0); } +function search_updatedcallback($name) { + global $CFG, $DB; + // set block to hidden when global search is disabled. + if ($CFG->enableglobalsearch != 1) { + $DB->set_field('block', 'visible', 0, array('name'=>'search')); // Hide block + } +} + ?>