BUGFIX Make sure the website URL that the commenter posts has a correct "http://" or "http://" bit at the start of the string

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@68999 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2008-12-15 07:04:58 +00:00 committed by Sam Minnee
parent b4d24d441d
commit 6eea8c657f

View File

@ -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 {
}
}
}
}
?>