From 759a8abbad96fe6cc9936cd18d159661ca43ecf4 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 2 May 2004 23:14:53 +0000 Subject: [PATCH] I suppose that now forum needs current version of Moodle to work (modified cron system...), isn't it? --- mod/forum/restorelib.php | 49 ++++++++++++++++++++++++++++++++++------ mod/forum/version.php | 2 +- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/mod/forum/restorelib.php b/mod/forum/restorelib.php index e530408f5d..922e2716da 100644 --- a/mod/forum/restorelib.php +++ b/mod/forum/restorelib.php @@ -688,7 +688,7 @@ $searchstring='/\$@(FORUMVIEWBYID)\*([0-9]+)@\$/'; //We look for it - preg_match_all($searchstring,$content,$foundset); + preg_match_all($searchstring,$result,$foundset); //If found, then we are going to look for its new id (in backup tables) if ($foundset[0]) { //print_object($foundset); //Debug @@ -709,7 +709,7 @@ $searchstring='/\$@(FORUMVIEWBYF)\*([0-9]+)@\$/'; //We look for it - preg_match_all($searchstring,$content,$foundset); + preg_match_all($searchstring,$result,$foundset); //If found, then we are going to look for its new id (in backup tables) if ($foundset[0]) { //print_object($foundset); //Debug @@ -730,7 +730,7 @@ $searchstring='/\$@(FORUMDISCUSSIONVIEW)\*([0-9]+)@\$/'; //We look for it - preg_match_all($searchstring,$content,$foundset); + preg_match_all($searchstring,$result,$foundset); //If found, then we are going to look for its new id (in backup tables) if ($foundset[0]) { //print_object($foundset); //Debug @@ -751,7 +751,7 @@ $searchstring='/\$@(FORUMDISCUSSIONVIEWPARENT)\*([0-9]+)\*([0-9]+)@\$/'; //We look for it - preg_match_all($searchstring,$content,$foundset); + preg_match_all($searchstring,$result,$foundset); //If found, then we are going to look for its new id (in backup tables) if ($foundset[0]) { //print_object($foundset); //Debug @@ -774,7 +774,7 @@ $searchstring='/\$@(FORUMDISCUSSIONVIEWINSIDE)\*([0-9]+)\*([0-9]+)@\$/'; //We look for it - preg_match_all($searchstring,$content,$foundset); + preg_match_all($searchstring,$result,$foundset); //If found, then we are going to look for its new id (in backup tables) if ($foundset[0]) { //print_object($foundset); //Debug @@ -829,7 +829,7 @@ $result = forum_decode_content_links($content,$restore); if ($result != $content) { //Update record - $post->message = $result; + $post->message = addslashes($result); $status = update_record("forum_posts",$post); if ($CFG->debug>7) { echo "

".$content."
changed to
".$result."

"; @@ -847,6 +847,41 @@ } } + //FORUM: Decode every FORUM (intro) in the coure + + //Check we are restoring forums + if ($restore->mods['forum']->restore == 1) { + //Get all course forums + if ($forums = get_records_sql ("SELECT f.id, f.intro + FROM {$CFG->prefix}forum f + WHERE f.course = $restore->course_id")) { + //Iterate over each forum->intro + $i = 0; //Counter to send some output to the browser to avoid timeouts + foreach ($forums as $forum) { + //Increment counter + $i++; + $content = $forum->intro; + $result = forum_decode_content_links($content,$restore); + if ($result != $content) { + //Update record + $forum->intro = addslashes($result); + $status = update_record("forum",$forum); + if ($CFG->debug>7) { + echo "

".$content."
changed to
".$result."

"; + } + } + //Do some output + if (($i+1) % 5 == 0) { + echo "."; + if (($i+1) % 100 == 0) { + echo "
"; + } + backup_flush(300); + } + } + } + } + //RESOURCE: Decode every RESOURCE (alltext) in the coure //Check we are restoring resources @@ -865,7 +900,7 @@ $result = forum_decode_content_links($content,$restore); if ($result != $content) { //Update record - $resource->alltext = $result; + $resource->alltext = addslashes($result); $status = update_record("resource",$resource); if ($CFG->debug>7) { echo "

".$content."
changed to
".$result."

"; diff --git a/mod/forum/version.php b/mod/forum/version.php index bf44447c06..deeca2dd08 100644 --- a/mod/forum/version.php +++ b/mod/forum/version.php @@ -6,7 +6,7 @@ //////////////////////////////////////////////////////////////////////////////// $module->version = 2004050300; -$module->requires = 2004031000; // Requires this Moodle version +$module->requires = 2004050300; // Requires this Moodle version $module->cron = 60; ?> -- 2.39.5