diff --git a/admin/innodb.php b/admin/innodb.php deleted file mode 100644 index 47fcf09ae5c..00000000000 --- a/admin/innodb.php +++ /dev/null @@ -1,45 +0,0 @@ -libdir.'/adminlib.php'); - - admin_externalpage_setup('toinodb'); - - $confirm = optional_param('confirm', 0, PARAM_BOOL); - - require_login(); - - require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); - - echo $OUTPUT->header(); - echo $OUTPUT->heading('Convert all MySQL tables from MYISAM to InnoDB'); - - if ($DB->get_dbfamily() != 'mysql') { - notice('This function is for MySQL databases only!', 'index.php'); - } - - if (data_submitted() and $confirm and confirm_sesskey()) { - - echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess'); - - if ($tables = $DB->get_tables()) { - $DB->set_debug(true); - foreach ($tables as $table) { - $fulltable = $DB->get_prefix().$table; - $DB->change_database_structure("ALTER TABLE $fulltable TYPE=INNODB"); - } - $DB->set_debug(false); - } - echo $OUTPUT->notification('... done.', 'notifysuccess'); - echo $OUTPUT->continue_button('index.php'); - echo $OUTPUT->footer(); - - } else { - $optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey()); - $formcontinue = new single_button(new moodle_url('/admin/innodb.php', $optionsyes), get_string('yes')); - $formcancel = new single_button(new moodle_url('/admin/index.php'), get_string('no'), 'get'); - echo $OUTPUT->confirm('Are you sure you want convert all your tables to the InnoDB format?', $formcontinue, $formcancel); - echo $OUTPUT->footer(); - } - - diff --git a/admin/settings/unsupported.php b/admin/settings/unsupported.php index c800de1eb42..f618f91cfa3 100644 --- a/admin/settings/unsupported.php +++ b/admin/settings/unsupported.php @@ -5,7 +5,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page $ADMIN->add('unsupported', new admin_externalpage('purgemoodledata', 'Purge moodledata', $CFG->wwwroot.'/'.$CFG->admin.'/delete.php', 'moodle/site:config', true)); - $ADMIN->add('unsupported', new admin_externalpage('toinodb', 'Convert to InnoDB', $CFG->wwwroot.'/'.$CFG->admin.'/innodb.php', 'moodle/site:config', true)); $ADMIN->add('unsupported', new admin_externalpage('replace', 'Search and replace', $CFG->wwwroot.'/'.$CFG->admin.'/replace.php', 'moodle/site:config', true)); } // end of speedup diff --git a/admin/tool/innodb/index.php b/admin/tool/innodb/index.php new file mode 100644 index 00000000000..faaea89f0e8 --- /dev/null +++ b/admin/tool/innodb/index.php @@ -0,0 +1,69 @@ +. + +/** + * InnoDB conversion tool. + * + * @package tool + * @subpackage innodb + * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +define('NO_OUTPUT_BUFFERING', true); + +require_once('../../../config.php'); +require_once($CFG->libdir.'/adminlib.php'); + +admin_externalpage_setup('toolinnodb'); + +$confirm = optional_param('confirm', 0, PARAM_BOOL); + +require_login(); +require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); + +echo $OUTPUT->header(); +echo $OUTPUT->heading('Convert all MySQL tables from MYISAM to InnoDB'); + +if ($DB->get_dbfamily() != 'mysql') { + notice('This function is for MySQL databases only!', new moodle_url('/admin/')); +} + +if (data_submitted() and $confirm and confirm_sesskey()) { + + echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess'); + + if ($tables = $DB->get_tables()) { + $DB->set_debug(true); + foreach ($tables as $table) { + $fulltable = $DB->get_prefix().$table; + $DB->change_database_structure("ALTER TABLE $fulltable TYPE=INNODB"); + } + $DB->set_debug(false); + } + echo $OUTPUT->notification('... done.', 'notifysuccess'); + echo $OUTPUT->continue_button(new moodle_url('/admin/')); + echo $OUTPUT->footer(); + +} else { + $optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey()); + $formcontinue = new single_button(new moodle_url('/admin/tool/innodb/index.php', $optionsyes), get_string('yes')); + $formcancel = new single_button(new moodle_url('/admin/'), get_string('no'), 'get'); + echo $OUTPUT->confirm('Are you sure you want convert all your tables to the InnoDB format?', $formcontinue, $formcancel); + echo $OUTPUT->footer(); +} + + diff --git a/admin/tool/innodb/lang/en/tool_innodb.php b/admin/tool/innodb/lang/en/tool_innodb.php new file mode 100644 index 00000000000..3edcd392759 --- /dev/null +++ b/admin/tool/innodb/lang/en/tool_innodb.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'tool_generator', language 'en', branch 'MOODLE_22_STABLE' + * + * @package tool + * @subpackage innodb + * @copyright 2011 petr Skoda + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Convert to InnoDB'; diff --git a/admin/tool/innodb/settings.php b/admin/tool/innodb/settings.php new file mode 100644 index 00000000000..254f8f041ad --- /dev/null +++ b/admin/tool/innodb/settings.php @@ -0,0 +1,30 @@ +. + +/** + * Link to InnoDB conversion tool + * + * @package tool + * @subpackage innodb + * @copyright 2010 Petr Skoda {@link http://skodak.org} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die; + +if ($hassiteconfig) { + $ADMIN->add('unsupported', new admin_externalpage('toolinnodb', 'Convert to InnoDB', $CFG->wwwroot.'/'.$CFG->admin.'/tool/innodb/index.php', 'moodle/site:config', true)); +} diff --git a/admin/tool/innodb/version.php b/admin/tool/innodb/version.php new file mode 100644 index 00000000000..8732ea34427 --- /dev/null +++ b/admin/tool/innodb/version.php @@ -0,0 +1,30 @@ +. + +/** + * Version details. + * + * @package tool + * @subpackage innodb + * @copyright 2011 Petr Skoda + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die; + +$plugin->version = 2011091700; // The current plugin version (Date: YYYYMMDDXX) +$plugin->requires = 2011091600; // Requires this Moodle version +$plugin->component = 'tool_innodb'; // Full name of the plugin (used for diagnostics) diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 7e07e690d85..96f1e13ac80 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -368,7 +368,7 @@ class plugin_manager { 'tool' => array( 'bloglevelupgrade', 'capability', 'generator', 'health', - 'langimport', 'profiling', 'unittest', 'unsuproles' + 'innodb', 'langimport', 'profiling', 'unittest', 'unsuproles' ), 'webservice' => array(