]> git.mjollnir.org Git - moodle.git/commitdiff
Included one more translation of links from
authorstronk7 <stronk7>
Fri, 1 Oct 2004 11:33:26 +0000 (11:33 +0000)
committerstronk7 <stronk7>
Fri, 1 Oct 2004 11:33:26 +0000 (11:33 +0000)
assignments to resources. Required in bug 2027.
Easy and not risky.

Merged from MOODLE_14_STABLE

mod/resource/restorelib.php

index 100d3a927a5b23fe6a06cf188e399fc2097d0272..c063b1068c84275fc7e6250a34f4857de6f76ea3 100644 (file)
         $status = true;
 
         echo "<ul>";
+
+        //ASSIGNMENT: Decode every ASSIGNMENT (description) in the coure
+
+        //Check we are restoring assignments
+        if ($restore->mods['assignment']->restore == 1) {
+            echo "<li>".get_string("from")." ".get_string("modulenameplural","assignment");
+            //Get all course assignments
+            if ($assignments = get_records_sql ("SELECT a.id, a.description
+                                       FROM {$CFG->prefix}assignment a
+                                       WHERE a.course = $restore->course_id")) {
+                //Iterate over each assignment->description
+                $i = 0;   //Counter to send some output to the browser to avoid timeouts
+                foreach ($assignments as $assignment) {
+                    //Increment counter
+                    $i++;
+                    $content = $assignment->description;
+                    $result = resource_decode_content_links($content,$restore);
+                    if ($result != $content) {
+                        //Update record
+                        $assignment->description = addslashes($result);
+                        $status = update_record("assignment",$assignment);
+                        if ($CFG->debug>7) {
+                            echo "<br><hr>".$content."<br>changed to</br>".$result."<hr><br>";
+                        }
+                    }
+                    //Do some output
+                    if (($i+1) % 5 == 0) {
+                        echo ".";
+                        if (($i+1) % 100 == 0) {
+                            echo "<br>";
+                        }
+                        backup_flush(300);
+                    }
+                }
+            }
+        }
  
         //FORUM: Decode every POST (message) in the coure