diff --git a/admin/qbehaviours.php b/admin/qbehaviours.php index cb59976e6b6..85f0c8ef905 100644 --- a/admin/qbehaviours.php +++ b/admin/qbehaviours.php @@ -143,7 +143,7 @@ if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) print_error('cannotdeletemissingbehaviour', 'question', $thispageurl); } - if (!isset($behaviours[$delete])) { + if (!isset($behaviours[$delete]) && !get_config('qbehaviour_' . $delete, 'version')) { print_error('unknownbehaviour', 'question', $thispageurl, $delete); } @@ -171,10 +171,7 @@ if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('deletingbehaviour', 'question', $behaviourname)); - // Delete any configuration records. - if (!unset_all_config_for_plugin('qbehaviour_' . $delete)) { - echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qbehaviour_' . $delete)); - } + // Remove this behaviour from configurations where it might appear. if (($key = array_search($delete, $disabledbehaviours)) !== false) { unset($disabledbehaviours[$key]); set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question'); @@ -185,12 +182,10 @@ if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) set_config('behavioursortorder', implode(',', $behaviourorder), 'question'); } - // Then the tables themselves - drop_plugin_tables($delete, core_component::get_plugin_directory('qbehaviour', $delete) . '/db/install.xml', false); - - // Remove event handlers and dequeue pending events - events_uninstall('qbehaviour_' . $delete); + // Then uninstall the plugin. + uninstall_plugin('qbehaviour', $delete); + // Display a message. $a = new stdClass(); $a->behaviour = $behaviourname; $a->directory = core_component::get_plugin_directory('qbehaviour', $delete); diff --git a/admin/qtypes.php b/admin/qtypes.php index e12d3cc4fa3..3e865d14160 100644 --- a/admin/qtypes.php +++ b/admin/qtypes.php @@ -129,7 +129,7 @@ if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) print_error('cannotdeletemissingqtype', 'question', $thispageurl); } - if (!isset($qtypes[$delete])) { + if (!isset($qtypes[$delete]) && !get_config('qtype_' . $delete, 'version')) { print_error('unknownquestiontype', 'question', $thispageurl, $delete); } @@ -158,18 +158,12 @@ if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('deletingqtype', 'question', $qtypename)); - // Delete any configuration records. - if (!unset_all_config_for_plugin('qtype_' . $delete)) { - echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qtype_' . $delete)); - } + // Delete any questoin configuration records mentioning this plugin. unset_config($delete . '_disabled', 'question'); unset_config($delete . '_sortorder', 'question'); - // Then the tables themselves - drop_plugin_tables($delete, $qtypes[$delete]->plugin_dir() . '/db/install.xml', false); - - // Remove event handlers and dequeue pending events - events_uninstall('qtype_' . $delete); + // Then uninstall the plugin. + uninstall_plugin('qtype', $delete); $a = new stdClass(); $a->qtype = $qtypename;