# The following patch is used to fix database URL activity
# sample page: http://qa.moodle.net/mod/data/edit.php?d=2

Index: moodle/mod/data/field/url/field.class.php
--- moodle/mod/data/field/url/field.class.php Base (1.20)
+++ moodle/mod/data/field/url/field.class.php Locally Modified (Based On 1.20)
@@ -36,7 +36,6 @@
                 $text = $content->content1;
             }
         }
-        $url = empty($url) ? 'http://' : $url;
         $str = '<div title="'.s($this->field->description).'">';
         if (!empty($this->field->param1) and empty($this->field->param2)) {
             $str .= '<table><tr><td align="right">';
@@ -105,6 +104,7 @@
         $content->fieldid = $this->field->id;
         $content->recordid = $recordid;
         $names = explode('_', $name);
+        
         switch ($names[2]) {
             case 0:
                 // update link
@@ -118,6 +118,10 @@
                 break;
         }
 
+        if (!empty($content->content) && strpos($content->content, '://') === false) {
+            $content->content = 'http://' . $content->content;
+        }        
+        
         if ($oldcontent = $DB->get_record('data_content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid))) {
             $content->id = $oldcontent->id;
             return $DB->update_record('data_content', $content);


# the patch below is used to fix resources URL (external URL)
# sample page: http://qa.moodle.net/course/modedit.php?update=7&return=0

Index: moodle/mod/url/lib.php
--- moodle/mod/url/lib.php Base (1.5)
+++ moodle/mod/url/lib.php Locally Modified (Based On 1.5)
@@ -107,7 +107,7 @@
     }
     $data->displayoptions = serialize($displayoptions);

-    if (strpos($data->externalurl, '://') === false) {
+    if (!empty($data->externalurl) && strpos($data->externalurl, '://') === false) {
         $data->externalurl = 'http://'.$data->externalurl;
     }

@@ -148,7 +148,7 @@
     }
     $data->displayoptions = serialize($displayoptions);

-    if (strpos($data->externalurl, '://') === false) {
+    if (!empty($data->externalurl) && strpos($data->externalurl, '://') === false) {
         $data->externalurl = 'http://'.$data->externalurl;
     }
