diff --git a/code/Commenting.php b/code/Commenting.php index d2528c7..d7974ad 100644 --- a/code/Commenting.php +++ b/code/Commenting.php @@ -26,6 +26,8 @@ class Commenting { 'require_login' => false, // boolean, whether a user needs to login 'required_permission' => false, // required permission to comment (or array of permissions) 'use_ajax_commenting' => true, // use ajax to post comments. + 'use_gravatar' => false, // set to true to show gravatar icons, + 'gravatar_size' => 80, // size of gravatar in pixels. This is the same as the standard default 'show_comments_when_disabled' => false, // when comments are disabled should we show older comments (if available) 'order_comments_by' => "\"Created\" DESC", 'comments_per_page' => 10, diff --git a/code/dataobjects/Comment.php b/code/dataobjects/Comment.php index 518403f..0e6327f 100755 --- a/code/dataobjects/Comment.php +++ b/code/dataobjects/Comment.php @@ -394,4 +394,19 @@ 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))); + $gravatarsize = Commenting::get_config_value($this->BaseClass, 'gravatar_size'); + $gravatar.= "?s=".$gravatarsize."&d=mm"; + } + + return $gravatar; + } } diff --git a/docs/en/Configuration.md b/docs/en/Configuration.md index d97b4e9..686130d 100644 --- a/docs/en/Configuration.md +++ b/docs/en/Configuration.md @@ -18,7 +18,9 @@ The module provides a number of built in configuration settings below are the de 'require_moderation' => false, 'html_allowed' => false, // allow for sanitized HTML in comments 'html_allowed_elements' => array('a', 'img', 'i', 'b'), - 'use_preview' => false, // preview formatted comment (when allowing HTML) + 'use_preview' => false, // preview formatted comment (when allowing HTML), + 'use_gravatar' => false, + 'gravatar_size' => 80 ); If you want to customize any of the configuration options after you have added the extension (or @@ -48,3 +50,13 @@ The easiest way to do this is through [Composer](http://getcomposer.org). **Important**: Rendering user-provided HTML on your website always risks exposing your users to cross-site scripting (XSS) attacks, if the HTML isn't properly sanitized. Don't allow tags like `