/**
 * Migrate legacy files in intro and chapters
 * @return void
 */
function mod_book_migrate_all_areas()
{
    global $DB;
    $rsbooks = $DB->get_recordset('book');
    foreach ($rsbooks as $book) {
        upgrade_set_timeout(360);
        // set up timeout, may also abort execution
        $cm = get_coursemodule_from_instance('book', $book->id);
        $context = context_module::instance($cm->id);
        mod_book_migrate_area($book, 'intro', 'book', $book->course, $context, 'mod_book', 'intro', 0);
        $rschapters = $DB->get_recordset('book_chapters', array('bookid' => $book->id));
        foreach ($rschapters as $chapter) {
            mod_book_migrate_area($chapter, 'content', 'book_chapters', $book->course, $context, 'mod_book', 'chapter', $chapter->id);
        }
        $rschapters->close();
    }
    $rsbooks->close();
}
Beispiel #2
0
/**
 * Migrate legacy files in intro and chapters
 * @return void
 */
function mod_book_migrate_all_areas()
{
    global $DB, $OUTPUT;
    $rsbooks = $DB->get_recordset('book');
    foreach ($rsbooks as $book) {
        upgrade_set_timeout(360);
        // set up timeout, may also abort execution
        $cm = get_coursemodule_from_instance('book', $book->id);
        if (empty($cm) || empty($cm->id)) {
            echo $OUTPUT->notification("Course module not found, skipping: {$book->name}");
            continue;
        }
        $context = context_module::instance($cm->id);
        mod_book_migrate_area($book, 'intro', 'book', $book->course, $context, 'mod_book', 'intro', 0);
        $rschapters = $DB->get_recordset('book_chapters', array('bookid' => $book->id));
        foreach ($rschapters as $chapter) {
            mod_book_migrate_area($chapter, 'content', 'book_chapters', $book->course, $context, 'mod_book', 'chapter', $chapter->id);
        }
        $rschapters->close();
    }
    $rsbooks->close();
}