]> git.mjollnir.org Git - moodle.git/commitdiff
Adding data_encode_content_links() to backup, so data module
authorstronk7 <stronk7>
Mon, 17 Sep 2007 17:59:54 +0000 (17:59 +0000)
committerstronk7 <stronk7>
Mon, 17 Sep 2007 17:59:54 +0000 (17:59 +0000)
links are encoded to be transported in backup files. Part of MDL-11268.

mod/data/backuplib.php

index 12d9fbe4b06936051c9ff3aed1113e1e243b698e..7536293dab5c8596efa3a02885265bbd13fb0093 100644 (file)
@@ -387,6 +387,39 @@ function data_check_backup_mods($course,$user_data=false,$backup_unique_code,$in
 
 }
 
+/**
+ * Returns a content encoded to support interactivities linking. Every module
+ * should have its own. They are called automatically from the backup procedure.
+ *
+ * @param string $content content to be encoded
+ * @param object $preferences backup preferences in use
+ * @return string the content encoded
+ */
+function data_encode_content_links ($content,$preferences) {
+
+    global $CFG;
+
+    $base = preg_quote($CFG->wwwroot,"/");
+
+/// Link to one "record" of the database
+    $search="/(".$base."\/mod\/data\/view.php\?d\=)([0-9]+)\&rid\=([0-9]+)/";
+    $result= preg_replace($search,'$@DATAVIEWRECORD*$2*$3@$',$content);
+
+/// Link to the list of databases
+    $search="/(".$base."\/mod\/data\/index.php\?id\=)([0-9]+)/";
+    $result= preg_replace($search,'$@DATAINDEX*$2@$',$result);
+
+/// Link to database view by moduleid
+    $search="/(".$base."\/mod\/data\/view.php\?id\=)([0-9]+)/";
+    $result= preg_replace($search,'$@DATAVIEWBYID*$2@$',$result);
+
+/// Link to database view by databaseid
+    $search="/(".$base."\/mod\/data\/view.php\?d\=)([0-9]+)/";
+    $result= preg_replace($search,'$@DATAVIEWBYD*$2@$',$result);
+
+    return $result;
+}
+
 function data_ids($course) {
     // stub function, return number of modules
     return 1;