--- a/admin/settings/misc.php +++ b/admin/settings/misc.php @@ -18,6 +18,7 @@ $temp->add(new admin_setting_configcheckbox('experimentalsplitrestore', get_string('experimentalsplitrestore', 'admin'), get_string('configexperimentalsplitrestore', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('enableimsccimport', get_string('enable_cc_import', 'imscc'), get_string('enable_cc_import_description', 'imscc'), 0)); $temp->add(new admin_setting_configcheckbox('enablesafebrowserintegration', get_string('enablesafebrowserintegration', 'admin'), get_string('configenablesafebrowserintegration', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('enablegravatar', get_string('enablegravatar', 'admin'), get_string('configenablegravatar', 'admin'), 0)); $ADMIN->add('misc', $temp); --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -113,6 +113,7 @@ $string['configenablecalendarexport'] = 'Enable exporting or subscribing to calendars.'; $string['configenablecourserequests'] = 'This will allow any user to request a course be created.'; $string['configenableglobalsearch'] = 'This setting enables global text searching in resources and activities, it is not compatible with PHP 4.'; +$string['configenablegravatar'] = 'If a user has not uploaded a profile picture, Moodle will try to display a Gravatar image for that user. If no Gravatar image is found, the default profile picture is displayed. See http://www.gravatar.com/ for more information.'; $string['configenablegroupings'] = 'This setting enables groupings of groups.'; $string['configenablehtmlpurifier'] = 'Use HTML Purifier instead of KSES for cleaning of untrusted text. HTML Purifier is actively developed and is believed to be more secure, but it is more resource intensive. Expect minor visual differences in the resulting html code. Please note that embed and object tags can not be enabled, MathML tags and old lang tags are not supported. '; $string['configenablerssfeeds'] = 'This switch will enable RSS feeds from across the site. To actually see any change you will need to enable RSS feeds in the individual modules too - go to the Modules settings under Admin Configuration.'; @@ -356,6 +357,7 @@ $string['enablecalendarexport'] = 'Enable calendar export'; $string['enablecourserequests'] = 'Enable course requests'; $string['enableglobalsearch'] = 'Enable global search'; +$string['enablegravatar'] = 'Enable Gravatar for profile pictures'; $string['enablegroupings'] = 'Enable groupings'; $string['enablehtmlpurifier'] = 'Enable HTML Purifier'; $string['enablerecordcache'] = 'Enable Record Cache'; --- a/lib/weblib.php +++ b/lib/weblib.php @@ -4511,6 +4511,14 @@ } else { // Print default user pictures (use theme version if available) $class .= " defaultuserpic"; $src = "$CFG->pixpath/u/$file.png"; + if (isset($CFG->enablegravatar) && $CFG->enablegravatar == 1) { + if (isset($user->email)) { + $email = $user->email; + } else { + $email = get_field('user', 'email', 'id', $user->id); + } + $src = 'http://www.gravatar.com/avatar.php?gravatar_id='.md5(strtolower($email)).'&default='.urlencode($src).'&size='.$size; + } } $imagealt = ''; if ($alttext) {