Commit 406b9a8a authored by Patrick O'Keeffe's avatar Patrick O'Keeffe

patch for forcing search plugin check (bug 1298553)

Change-Id: I001850f421e3520ee17a8afbcfb2811ff213eec4
parent 9cff2a6c
......@@ -828,7 +828,6 @@ function siteoptions_submit(Pieform $form, $values) {
save_notification_settings($values, null, true);
// If they've changed the search plugin, give the new plugin a chance to initialize.
if ($oldsearchplugin != $values['searchplugin']) {
// Call the old search plugin's sitewide cleanup method
safe_require('search', $oldsearchplugin);
......@@ -843,6 +842,15 @@ function siteoptions_submit(Pieform $form, $values) {
));
}
}
// Call the new search plugin's can connect
safe_require('search', $values['searchplugin']);
$connect = call_static_method(generate_class_name('search', $values['searchplugin']), 'can_connect');
if (!$connect) {
$form->reply(PIEFORM_ERR, array(
'message' => get_string('searchconfigerror1', 'admin', $values['searchplugin']),
'goto' => '/admin/site/options.php',
));
}
// submitted sessionlifetime is in minutes; db entry session_timeout is in seconds
if (!set_config('session_timeout', $values['sessionlifetime'] * 60)) {
......
......@@ -147,6 +147,15 @@ abstract class PluginSearch extends Plugin implements IPluginSearch {
return true;
}
/**
* This function gets called everytime the site options are saved. It is used to
* detect whether the search plugin can connect to any servers it requires.
* Defaults to true.
*/
public static function can_connect() {
return true;
}
/**
* This function determines whether the plugin is currently available to be chosen
* as the sitewide search plugin (i.e. get_config('searchplugin'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment