Skip to content

Commit

Permalink
BUGFIX Make sure the website URL that the commenter posts has a corre…
Browse files Browse the repository at this point in the history
…ct "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
  • Loading branch information
Sean Harvey authored and Sam Minnee committed Feb 2, 2011
1 parent b4d24d4 commit 6eea8c6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions code/sitefeatures/PageComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,29 @@ function fieldLabels() {
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);
}

}


Expand Down Expand Up @@ -228,6 +251,7 @@ function reportham() {
}
}
}

}

?>

0 comments on commit 6eea8c6

Please sign in to comment.