2 /// Search and replace strings throughout all texts in the whole database
4 require_once('../config.php');
5 require_once($CFG->dirroot
.'/course/lib.php');
6 require_once($CFG->libdir
.'/adminlib.php');
8 admin_externalpage_setup('replace');
10 $search = optional_param('search', '', PARAM_RAW
);
11 $replace = optional_param('replace', '', PARAM_RAW
);
13 ###################################################################
14 admin_externalpage_print_header();
16 print_heading('Search and replace text throughout the whole database');
19 if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) { /// Print a form
21 print_simple_box_start('center');
22 echo '<div align="center">';
23 echo '<form action="replace.php" method="post">';
24 echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey
.'" />';
25 echo 'Search whole database for: <input type="text" name="search" /><br />';
26 echo 'Replace with this string: <input type="text" name="replace" /><br />';
27 echo '<input type="submit" value="Yes, do it now" /><br />';
30 print_simple_box_end();
31 admin_externalpage_print_footer();
35 print_simple_box_start('center');
37 if (!db_replace($search, $replace)) {
38 error('An error has occured during this process');
41 print_simple_box_end();
43 /// Rebuild course cache which might be incorrect now
44 notify('Rebuilding course cache...');
45 rebuild_course_cache();
46 notify('...finished');
48 print_continue('index.php');
50 admin_externalpage_print_footer();