Esempio n. 1
0
function quiz_restore_wiki2markdown($restore)
{
    global $CFG;
    $status = true;
    //Convert question->questiontext
    if ($records = get_records_sql("SELECT q.id, q.questiontext, q.questiontextformat\n                                         FROM {$CFG->prefix}question q,\n                                              {$CFG->prefix}backup_ids b\n                                         WHERE b.backup_code = {$restore->backup_unique_code} AND\n                                               b.table_name = 'question' AND\n                                               q.id = b.new_id AND\n                                               q.questiontextformat = " . FORMAT_WIKI)) {
        $i = 0;
        foreach ($records as $record) {
            //Rebuild wiki links
            $record->questiontext = restore_decode_wiki_content($record->questiontext, $restore);
            //Convert to Markdown
            $wtm = new WikiToMarkdown();
            $record->questiontext = $wtm->convert($record->questiontext, $restore->course_id);
            $record->questiontextformat = FORMAT_MARKDOWN;
            $status = update_record('question', addslashes_object($record));
            //Do some output
            $i++;
            if (($i + 1) % 1 == 0) {
                if (!defined('RESTORE_SILENTLY')) {
                    echo ".";
                    if (($i + 1) % 20 == 0) {
                        echo "<br />";
                    }
                }
                backup_flush(300);
            }
        }
    }
    return $status;
}
Esempio n. 2
0
function assignment_restore_wiki2markdown($restore)
{
    global $CFG;
    $status = true;
    //Convert assignment->description
    if ($records = get_records_sql("SELECT a.id, a.description, a.format\n                                         FROM {$CFG->prefix}assignment a,\n                                              {$CFG->prefix}backup_ids b\n                                         WHERE a.course = {$restore->course_id} AND\n                                               a.format = " . FORMAT_WIKI . " AND\n                                               b.backup_code = {$restore->backup_unique_code} AND\n                                               b.table_name = 'assignment' AND\n                                               b.new_id = a.id")) {
        foreach ($records as $record) {
            //Rebuild wiki links
            $record->description = restore_decode_wiki_content($record->description, $restore);
            //Convert to Markdown
            $wtm = new WikiToMarkdown();
            $record->description = $wtm->convert($record->description, $restore->course_id);
            $record->format = FORMAT_MARKDOWN;
            $status = update_record('assignment', addslashes_object($record));
            //Do some output
            $i++;
            if (($i + 1) % 1 == 0) {
                if (!defined('RESTORE_SILENTLY')) {
                    echo ".";
                    if (($i + 1) % 20 == 0) {
                        echo "<br />";
                    }
                }
                backup_flush(300);
            }
        }
    }
    return $status;
}
Esempio n. 3
0
function forum_restore_wiki2markdown($restore)
{
    global $CFG, $DB;
    $status = true;
    //Convert forum_posts->message
    if ($records = $DB->get_records_sql("SELECT p.id, p.message, p.messageformat\n                                               FROM {forum_posts} p,\n                                                    {forum_discussions} d,\n                                                    {forum} f,\n                                                    {backup_ids} b\n                                              WHERE d.id = p.discussion AND\n                                                    f.id = d.forum AND\n                                                    f.course = ? AND\n                                                    p.messageformat = " . FORMAT_WIKI . " AND\n                                                    b.backup_code = ? AND\n                                                    b.table_name = 'forum_posts' AND\n                                                    b.new_id = p.id", array($restore->course_id, $restore->backup_unique_code))) {
        foreach ($records as $record) {
            //Rebuild wiki links
            $record->message = restore_decode_wiki_content($record->message, $restore);
            //Convert to Markdown
            $wtm = new WikiToMarkdown();
            $record->message = $wtm->convert($record->message, $restore->course_id);
            $record->messageformat = FORMAT_MARKDOWN;
            $status = $DB->update_record('forum_posts', $record);
            //Do some output
            $i++;
            if (($i + 1) % 1 == 0) {
                if (!defined('RESTORE_SILENTLY')) {
                    echo ".";
                    if (($i + 1) % 20 == 0) {
                        echo "<br />";
                    }
                }
                backup_flush(300);
            }
        }
    }
    return $status;
}
function kaltura_restore_wiki2markdown($restore)
{
    global $CFG;
    $status = true;
    return $status;
    //Convert resource->alltext
    if ($records = get_records_sql("SELECT r.id, r.alltext, r.options\n                                         FROM {$CFG->prefix}resource r,\n                                              {$CFG->prefix}backup_ids b\n                                         WHERE r.course = {$restore->course_id} AND\n                                               options = " . FORMAT_WIKI . " AND\n                                               b.backup_code = {$restore->backup_unique_code} AND\n                                               b.table_name = 'resource' AND\n                                               b.new_id = r.id")) {
        foreach ($records as $record) {
            //Rebuild wiki links
            $record->alltext = restore_decode_wiki_content($record->alltext, $restore);
            //Convert to Markdown
            $wtm = new WikiToMarkdown();
            $record->alltext = $wtm->convert($record->alltext, $restore->course_id);
            $record->options = FORMAT_MARKDOWN;
            $status = update_record('resource', addslashes_object($record));
            //Do some output
            $i++;
            if (($i + 1) % 1 == 0) {
                if (!defined('RESTORE_SILENTLY')) {
                    echo ".";
                    if (($i + 1) % 20 == 0) {
                        echo "<br />";
                    }
                }
                backup_flush(300);
            }
        }
    }
    return $status;
}
Esempio n. 5
0
function glossary_restore_wiki2markdown($restore)
{
    global $CFG, $DB;
    $status = true;
    //Convert glossary_comments->entrycomment
    if ($records = $DB->get_records_sql("SELECT c.id, c.entrycomment, c.entrycommentformat\n                                               FROM {glossary_comments} c,\n                                                    {glossary_entries} e,\n                                                    {glossary} g,\n                                                    {backup_ids} b\n                                              WHERE e.id = c.entryid AND\n                                                    g.id = e.glossaryid AND\n                                                    g.course = ? AND\n                                                    c.entrycommentformat = " . FORMAT_WIKI . " AND\n                                                    b.backup_code = ? AND\n                                                    b.table_name = 'glossary_comments' AND\n                                                    b.new_id = c.id", array($restore->course_id, $restore->backup_unique_code))) {
        foreach ($records as $record) {
            //Rebuild wiki links
            $record->entrycomment = restore_decode_wiki_content($record->entrycomment, $restore);
            //Convert to Markdown
            $wtm = new WikiToMarkdown();
            $record->entrycomment = $wtm->convert($record->entrycomment, $restore->course_id);
            $record->entrycommentformat = FORMAT_MARKDOWN;
            $status = $DB->update_record('glossary_comments', $record);
            //Do some output
            $i++;
            if (($i + 1) % 1 == 0) {
                if (!defined('RESTORE_SILENTLY')) {
                    echo ".";
                    if (($i + 1) % 20 == 0) {
                        echo "<br />";
                    }
                }
                backup_flush(300);
            }
        }
    }
    //Convert glossary_entries->definition
    if ($records = $DB->get_records_sql("SELECT e.id, e.definition, e.definitionformat\n                                               FROM {glossary_entries} e,\n                                                    {glossary} g,\n                                                    {backup_ids} b\n                                              WHERE g.id = e.glossaryid AND\n                                                    g.course = ? AND\n                                                    e.definitionformat = " . FORMAT_WIKI . " AND\n                                                    b.backup_code = ? AND\n                                                    b.table_name = 'glossary_entries' AND\n                                                    b.new_id = e.id", array($restore->course_id, $restore->backup_unique_code))) {
        foreach ($records as $record) {
            //Rebuild wiki links
            $record->definition = restore_decode_wiki_content($record->definition, $restore);
            //Convert to Markdown
            $wtm = new WikiToMarkdown();
            $record->definition = $wtm->convert($record->definition, $restore->course_id);
            $record->definitionformat = FORMAT_MARKDOWN;
            $status = $DB->update_record('glossary_entries', $record);
            //Do some output
            $i++;
            if (($i + 1) % 1 == 0) {
                if (!defined('RESTORE_SILENTLY')) {
                    echo ".";
                    if (($i + 1) % 20 == 0) {
                        echo "<br />";
                    }
                }
                backup_flush(300);
            }
        }
    }
    return $status;
}
Esempio n. 6
0
function assignment_restore_wiki2markdown($restore)
{
    global $CFG, $DB;
    $status = true;
    //Convert assignment->description
    if ($records = $DB->get_records_sql("SELECT a.id, a.intro, a.introformat\n                                                FROM {assignment} a, {backup_ids} b\n                                               WHERE a.course = ? AND\n                                               a.format = " . FORMAT_WIKI . " AND\n                                               b.backup_code = ? AND\n                                               b.table_name = 'assignment' AND\n                                               b.new_id = a.id", array($restore->course_id, $restore->backup_unique_code))) {
        foreach ($records as $record) {
            //Rebuild wiki links
            $record->intro = restore_decode_wiki_content($record->intro, $restore);
            //Convert to Markdown
            $wtm = new WikiToMarkdown();
            $record->intro = $wtm->convert($record->intro, $restore->course_id);
            $record->introformat = FORMAT_MARKDOWN;
            $status = $DB->update_record('assignment', $record);
            //Do some output
            $i++;
            if (($i + 1) % 1 == 0) {
                if (!defined('RESTORE_SILENTLY')) {
                    echo ".";
                    if (($i + 1) % 20 == 0) {
                        echo "<br />";
                    }
                }
                backup_flush(300);
            }
        }
    }
    return $status;
}
function journal_restore_wiki2markdown($restore)
{
    global $CFG;
    $status = true;
    //Convert journal_entries->text
    if ($records = get_records_sql("SELECT e.id, e.text, e.format\n                                         FROM {$CFG->prefix}journal_entries e,\n                                              {$CFG->prefix}journal j,\n                                              {$CFG->prefix}backup_ids b\n                                         WHERE j.id = e.journal AND\n                                               j.course = {$restore->course_id} AND\n                                               e.format = " . FORMAT_WIKI . " AND\n                                               b.backup_code = {$restore->backup_unique_code} AND\n                                               b.table_name = 'journal_entries' AND\n                                               b.new_id = e.id")) {
        foreach ($records as $record) {
            //Rebuild wiki links
            $record->text = restore_decode_wiki_content($record->text, $restore);
            //Convert to Markdown
            $wtm = new WikiToMarkdown();
            $record->text = $wtm->convert($record->text, $restore->course_id);
            $record->format = FORMAT_MARKDOWN;
            $status = update_record('journal_entries', addslashes_object($record));
            //Do some output
            $i++;
            if (($i + 1) % 1 == 0) {
                if (!defined('RESTORE_SILENTLY')) {
                    echo ".";
                    if (($i + 1) % 20 == 0) {
                        echo "<br />";
                    }
                }
                backup_flush(300);
            }
        }
    }
    //Convert journal->intro
    if ($records = get_records_sql("SELECT j.id, j.intro, j.introformat\n                                         FROM {$CFG->prefix}journal j,\n                                              {$CFG->prefix}backup_ids b\n                                         WHERE j.course = {$restore->course_id} AND\n                                               j.introformat = " . FORMAT_WIKI . " AND\n                                               b.backup_code = {$restore->backup_unique_code} AND\n                                               b.table_name = 'journal' AND\n                                               b.new_id = j.id")) {
        foreach ($records as $record) {
            //Rebuild wiki links
            $record->intro = restore_decode_wiki_content($record->intro, $restore);
            //Convert to Markdown
            $wtm = new WikiToMarkdown();
            $record->intro = $wtm->convert($record->intro, $restore->course_id);
            $record->introformat = FORMAT_MARKDOWN;
            $status = update_record('journal', addslashes_object($record));
            //Do some output
            $i++;
            if (($i + 1) % 1 == 0) {
                if (!defined('RESTORE_SILENTLY')) {
                    echo ".";
                    if (($i + 1) % 20 == 0) {
                        echo "<br />";
                    }
                }
                backup_flush(300);
            }
        }
    }
    return $status;
}