From d4cc737878c3e9c17697de37eb2c9c19bf382b80 Mon Sep 17 00:00:00 2001 From: Gordon Anderson Date: Wed, 6 Mar 2013 15:50:41 +0700 Subject: [PATCH] ENHANCEMENT: Added gravatar method to get the URL for the gravatar from the email address submitted with the comment --- code/dataobjects/Comment.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/code/dataobjects/Comment.php b/code/dataobjects/Comment.php index 518403f..582e3ee 100755 --- a/code/dataobjects/Comment.php +++ b/code/dataobjects/Comment.php @@ -394,4 +394,17 @@ class Comment extends DataObject { $config->set('URI.DisableExternalResources', true); return new HTMLPurifier($config); } + + /* + Calcualate the gravatar link from the email address + */ + public function Gravatar() { + $gravatar = ''; + $use_gravatar = Commenting::get_config_value($this->BaseClass, 'use_gravatar'); + if ($use_gravatar) { + $gravatar = "http://www.gravatar.com/avatar/" . md5( strtolower(trim($this->Email))); + } + + return $gravatar; + } }