From fab6f7b78e9a08130c36b5818888acaf35fb69d7 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 25 Sep 2011 15:29:17 +0200 Subject: [PATCH] MDL-29509 migrate DB replace to admin tools --- admin/settings/unsupported.php | 10 ------ admin/{replace.php => tool/replace/index.php} | 32 ++++++++++++++++--- admin/tool/replace/lang/en/tool_replace.php | 26 +++++++++++++++ admin/tool/replace/settings.php | 30 +++++++++++++++++ admin/tool/replace/version.php | 32 +++++++++++++++++++ lib/pluginlib.php | 2 +- 6 files changed, 116 insertions(+), 16 deletions(-) delete mode 100644 admin/settings/unsupported.php rename admin/{replace.php => tool/replace/index.php} (65%) create mode 100644 admin/tool/replace/lang/en/tool_replace.php create mode 100644 admin/tool/replace/settings.php create mode 100644 admin/tool/replace/version.php diff --git a/admin/settings/unsupported.php b/admin/settings/unsupported.php deleted file mode 100644 index f618f91cfa3..00000000000 --- a/admin/settings/unsupported.php +++ /dev/null @@ -1,10 +0,0 @@ -add('unsupported', new admin_externalpage('purgemoodledata', 'Purge moodledata', $CFG->wwwroot.'/'.$CFG->admin.'/delete.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/replace.php b/admin/tool/replace/index.php similarity index 65% rename from admin/replace.php rename to admin/tool/replace/index.php index 8217876de04..6f3c89fcb0e 100644 --- a/admin/replace.php +++ b/admin/tool/replace/index.php @@ -1,13 +1,35 @@ . + +/** + * Search and replace strings throughout all texts in the whole database + * + * @package tool + * @subpackage replace + * @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('../../../config.php'); require_once($CFG->dirroot.'/course/lib.php'); require_once($CFG->libdir.'/adminlib.php'); -admin_externalpage_setup('replace'); +admin_externalpage_setup('toolreplace'); $search = optional_param('search', '', PARAM_RAW); $replace = optional_param('replace', '', PARAM_RAW); @@ -30,7 +52,7 @@ if (!data_submitted() or !$search or !$replace or !confirm_sesskey() or !$sure) echo $OUTPUT->box_start(); echo '
'; - echo '
'; + echo '
'; echo ''; echo '
(usually previous server URL)
'; echo '
(usually new server URL)
'; @@ -52,7 +74,7 @@ echo $OUTPUT->notification('Rebuilding course cache...', 'notifysuccess'); rebuild_course_cache(); echo $OUTPUT->notification('...finished', 'notifysuccess'); -echo $OUTPUT->continue_button('index.php'); +echo $OUTPUT->continue_button(new moodle_url('/admin/index.php')); echo $OUTPUT->footer(); diff --git a/admin/tool/replace/lang/en/tool_replace.php b/admin/tool/replace/lang/en/tool_replace.php new file mode 100644 index 00000000000..f967fad8766 --- /dev/null +++ b/admin/tool/replace/lang/en/tool_replace.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'tool_replace', language 'en', branch 'MOODLE_22_STABLE' + * + * @package tool + * @subpackage replace + * @copyright 2011 Petr Skoda {@link http://skodak.org} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'DB search and replace'; diff --git a/admin/tool/replace/settings.php b/admin/tool/replace/settings.php new file mode 100644 index 00000000000..44087e3f6fd --- /dev/null +++ b/admin/tool/replace/settings.php @@ -0,0 +1,30 @@ +. + +/** + * Link to unsupported db replace script. + * + * @package tool + * @subpackage replace + * @copyright 2011 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('toolreplace', get_string('pluginname', 'tool_replace'), $CFG->wwwroot.'/'.$CFG->admin.'/tool/replace/index.php', 'moodle/site:config', true)); +} diff --git a/admin/tool/replace/version.php b/admin/tool/replace/version.php new file mode 100644 index 00000000000..f67bf1dde39 --- /dev/null +++ b/admin/tool/replace/version.php @@ -0,0 +1,32 @@ +. + +/** + * Version details. + * + * @package tool + * @subpackage replace + * @copyright 2011 Petr Skoda {@link http://skodak.org} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die; + +$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX) +$plugin->requires = 2011092100; // Requires this Moodle version +$plugin->component = 'tool_replace'; // Full name of the plugin (used for diagnostics) + +$maturity = MATURITY_ALPHA; // this version's maturity level diff --git a/lib/pluginlib.php b/lib/pluginlib.php index adfb85e9949..9cdc83a4f04 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -367,7 +367,7 @@ class plugin_manager { 'tool' => array( 'bloglevelupgrade', 'capability', 'customlang', 'dbtransfer', 'generator', 'health', 'innodb', 'langimport', 'multilangupgrade', 'profiling', - 'qeupgradehelper', 'spamcleaner', 'timezoneimport', 'unittest', + 'qeupgradehelper', 'replace', 'spamcleaner', 'timezoneimport', 'unittest', 'uploaduser', 'unsuproles', 'xmldb' ), -- 2.43.0