function restore_decode_content_links($restore) { global $CFG; $status = true; if (!defined('RESTORE_SILENTLY')) { echo "<ul>"; } // Recode links in the course summary. if (!defined('RESTORE_SILENTLY')) { echo '<li>' . get_string('from') . ' ' . get_string('course'); } $course = get_record('course', 'id', $restore->course_id, '', '', '', '', 'id,summary'); $coursesummary = backup_todb($course->summary, false); // Exception: Process FILEPHP (not available when restored) MDL-18222 $coursesummary = restore_decode_content_links_worker($coursesummary, $restore); if ($coursesummary != $course->summary) { $course->summary = addslashes($coursesummary); if (!update_record('course', $course)) { $status = false; } } if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } // Recode links in section summaries. $sections = get_records('course_sections', 'course', $restore->course_id, 'id', 'id,summary'); if ($sections) { if (!defined('RESTORE_SILENTLY')) { echo '<li>' . get_string('from') . ' ' . get_string('sections'); } foreach ($sections as $section) { $sectionsummary = restore_decode_content_links_worker($section->summary, $restore); if ($sectionsummary != $section->summary) { $section->summary = addslashes($sectionsummary); if (!update_record('course_sections', $section)) { $status = false; } } } if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } } // Restore links in modules. foreach ($restore->mods as $name => $info) { //If the module is being restored if (isset($info->restore) && $info->restore == 1) { //Check if the xxxx_decode_content_links_caller exists include_once "{$CFG->dirroot}/mod/{$name}/restorelib.php"; $function_name = $name . "_decode_content_links_caller"; if (function_exists($function_name)) { if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("from") . " " . get_string("modulenameplural", $name); } $status = $function_name($restore) && $status; if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } } } } // For the course format call its decode_content_links method (if it exists) $format = get_field('course', 'format', 'id', $restore->course_id); if (file_exists("{$CFG->dirroot}/course/format/{$format}/restorelib.php")) { include_once "{$CFG->dirroot}/course/format/{$format}/restorelib.php"; $function_name = $format . '_decode_format_content_links_caller'; if (function_exists($function_name)) { if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("from") . " " . get_string("format") . ' ' . $format; } $status = $function_name($restore); if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } } } // Process all html text also in blocks too if (!defined('RESTORE_SILENTLY')) { echo '<li>' . get_string('from') . ' ' . get_string('blocks'); } if ($blocks = get_records('block', 'visible', 1)) { foreach ($blocks as $block) { if ($blockobject = block_instance($block->name)) { $blockobject->decode_content_links_caller($restore); } } } if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } // Restore links in questions. require_once "{$CFG->dirroot}/question/restorelib.php"; if (!defined('RESTORE_SILENTLY')) { echo '<li>' . get_string('from') . ' ' . get_string('questions', 'quiz'); } $status = question_decode_content_links_caller($restore) && $status; if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } if (!defined('RESTORE_SILENTLY')) { echo "</ul>"; } return $status; }
function restore_decode_content_links($restore) { global $CFG, $DB; $status = true; if (!defined('RESTORE_SILENTLY')) { echo "<ul>"; } // Recode links in the course summary. if (!defined('RESTORE_SILENTLY')) { echo '<li>' . get_string('from') . ' ' . get_string('course'); } $course = $DB->get_record('course', array('id' => $restore->course_id), 'id,summary'); $coursesummary = restore_decode_content_links_worker($course->summary, $restore); if ($coursesummary != $course->summary) { $course->summary = addslashes($coursesummary); if (!update_record('course', $course)) { $status = false; } } if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } // Recode links in section summaries. $sections = $DB->get_records('course_sections', array('course', $restore->course_id), 'id,summary'); if ($sections) { if (!defined('RESTORE_SILENTLY')) { echo '<li>' . get_string('from') . ' ' . get_string('sections'); } foreach ($sections as $section) { $sectionsummary = restore_decode_content_links_worker($section->summary, $restore); if ($sectionsummary != $section->summary) { $section->summary = addslashes($sectionsummary); if (!update_record('course_sections', $section)) { $status = false; } } } if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } } // Restore links in modules. foreach ($restore->mods as $name => $info) { //If the module is being restored if (isset($info->restore) && $info->restore == 1) { //Check if the xxxx_decode_content_links_caller exists include_once "{$CFG->dirroot}/mod/{$name}/restorelib.php"; $function_name = $name . "_decode_content_links_caller"; if (function_exists($function_name)) { if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("from") . " " . get_string("modulenameplural", $name); } $status = $function_name($restore) && $status; if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } } } } // Process all html text also in blocks too if (!defined('RESTORE_SILENTLY')) { echo '<li>' . get_string('from') . ' ' . get_string('blocks'); } if ($blocks = $DB->get_records('block', array('visible' => 1))) { foreach ($blocks as $block) { if ($blockobject = block_instance($block->name)) { $blockobject->decode_content_links_caller($restore); } } } if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } // Restore links in questions. require_once "{$CFG->dirroot}/question/restorelib.php"; if (!defined('RESTORE_SILENTLY')) { echo '<li>' . get_string('from') . ' ' . get_string('questions', 'quiz'); } $status = question_decode_content_links_caller($restore) && $status; if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } if (!defined('RESTORE_SILENTLY')) { echo "</ul>"; } return $status; }
function restore_decode_content_links($restore) { global $CFG; $status = true; if (!defined('RESTORE_SILENTLY')) { echo "<ul>"; } // Restore links in modules. foreach ($restore->mods as $name => $info) { //If the module is being restored if (isset($info->restore) && $info->restore == 1) { //Check if the xxxx_decode_content_links_caller exists include_once "{$CFG->dirroot}/mod/{$name}/restorelib.php"; $function_name = $name . "_decode_content_links_caller"; if (function_exists($function_name)) { if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("from") . " " . get_string("modulenameplural", $name); } $status = $function_name($restore); if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } } } } // TODO: process all html text also in blocks too // Restore links in questions. require_once "{$CFG->dirroot}/question/restorelib.php"; if (!defined('RESTORE_SILENTLY')) { echo '<li>' . get_string('from') . ' ' . get_string('questions', 'quiz'); } $status = question_decode_content_links_caller($restore); if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } if (!defined('RESTORE_SILENTLY')) { echo "</ul>"; } return $status; }
function restore_decode_content_links($restore) { global $CFG; $status = true; if (!defined('RESTORE_SILENTLY')) { echo "<ul>"; } // Restore links in modules. foreach ($restore->mods as $name => $info) { //If the module is being restored if (isset($info->restore) && $info->restore == 1) { //Check if the xxxx_decode_content_links_caller exists include_once "{$CFG->dirroot}/mod/{$name}/restorelib.php"; $function_name = $name . "_decode_content_links_caller"; if (function_exists($function_name)) { if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("from") . " " . get_string("modulenameplural", $name); } $status = $function_name($restore); if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } } } } // Process all html text also in blocks too if (!defined('RESTORE_SILENTLY')) { echo '<li>' . get_string('from') . ' ' . get_string('blocks'); } if (!empty($restore->blockinstanceids)) { $blocks = blocks_get_record(); $instances = get_records_list('block_instance', 'id', implode(',', $restore->blockinstanceids), '', 'id,blockid,configdata'); foreach ($instances as $instance) { if (!isset($blocks[$instance->blockid]->blockobject)) { $blocks[$instance->blockid]->blockobject = block_instance($blocks[$instance->blockid]->name); } $config = unserialize(base64_decode($instance->configdata)); if ($blocks[$instance->blockid]->blockobject->restore_decode_absolute_links_in_config($config)) { $instance->configdata = base64_encode(serialize($config)); $status = $status && update_record('block_instance', $instance); } } } if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } // Restore links in questions. require_once "{$CFG->dirroot}/question/restorelib.php"; if (!defined('RESTORE_SILENTLY')) { echo '<li>' . get_string('from') . ' ' . get_string('questions', 'quiz'); } $status = question_decode_content_links_caller($restore); if (!defined('RESTORE_SILENTLY')) { echo '</li>'; } if (!defined('RESTORE_SILENTLY')) { echo "</ul>"; } return $status; }