global search MDL-25099 setting global search block to 'hidden' when feature is disabled in experimental settings.

This commit is contained in:
Aparup Banerjee 2010-11-11 03:37:54 +00:00
parent 2031735b1b
commit 693fc4a29f
5 changed files with 31 additions and 2 deletions

View File

@ -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));

View File

@ -0,0 +1,10 @@
<?php
function xmldb_block_search_install() {
global $DB;
// Disable this block by default as its experimental.
$DB->set_field('block', 'visible', 0, array('name'=>'search'));
}

View File

@ -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;
}

View File

@ -15,5 +15,5 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
$plugin->version = 2010110900;
$plugin->version = 2010111100;
$plugin->cron = 1;

View File

@ -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
}
}
?>