Shibboleth authentication: Merging fix MDL-18538 and changes from MDL-18116
[moodle.git] / admin / replace.php
CommitLineData
04337d75 1<?php /// $Id$
2 /// Search and replace strings throughout all texts in the whole database
3
a2eaae61 4require_once('../config.php');
c9a49cea 5require_once($CFG->dirroot.'/course/lib.php');
6require_once($CFG->libdir.'/adminlib.php');
1ae083e4 7
8admin_externalpage_setup('replace');
04337d75 9
a2eaae61 10$search = optional_param('search', '', PARAM_RAW);
11$replace = optional_param('replace', '', PARAM_RAW);
04337d75 12
04337d75 13###################################################################
1ae083e4 14admin_externalpage_print_header();
04337d75 15
c9a49cea 16print_heading('Search and replace text throughout the whole database');
04337d75 17
c9a49cea 18
19if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) { /// Print a form
04337d75 20
21 print_simple_box_start('center');
85db96c5 22 echo '<div class="mdl-align">';
c9a49cea 23 echo '<form action="replace.php" method="post">';
d4a1fcaf 24 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
b1b5e868 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 />';
04337d75 28 echo '</form>';
29 echo '</div>';
30 print_simple_box_end();
1ae083e4 31 admin_externalpage_print_footer();
04337d75 32 die;
33}
34
04337d75 35print_simple_box_start('center');
c9a49cea 36
1d8bf5f0 37if (!db_replace($search, $replace)) {
8e9d88f2 38 print_error('erroroccur', debug);
04337d75 39}
3f5edbdf 40
04337d75 41print_simple_box_end();
42
c9a49cea 43/// Rebuild course cache which might be incorrect now
f33e1ed4 44notify('Rebuilding course cache...', 'notifysuccess');
c9a49cea 45rebuild_course_cache();
f33e1ed4 46notify('...finished', 'notifysuccess');
c9a49cea 47
04337d75 48print_continue('index.php');
49
1ae083e4 50admin_externalpage_print_footer();
c9a49cea 51
04337d75 52?>