diff --git a/code/sitefeatures/PageComment.php b/code/sitefeatures/PageComment.php index 8bc2f423..70a319ff 100755 --- a/code/sitefeatures/PageComment.php +++ b/code/sitefeatures/PageComment.php @@ -119,6 +119,29 @@ class PageComment extends DataObject { return $labels; } + /** + * This method is called just before this object is + * written to the database. + * + * Specifically, make sure "http://" exists at the start + * of the URL, if it doesn't have https:// or http:// + */ + public function onBeforeWrite() { + parent::onBeforeWrite(); + + $url = $this->CommenterURL; + + if($url) { + if(substr($url, 0, 8) != 'https://') { + if(substr($url, 0, 7) != 'http://') { + $url = $this->CommenterURL = 'http://' . $url; + } + } + } + + $this->CommenterURL = strtolower($url); + } + } @@ -228,6 +251,7 @@ class PageComment_Controller extends Controller { } } } + } ?> \ No newline at end of file