Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'MDL-35669-master-2' of git://github.com/micaherne/moodle

  • Loading branch information...
commit 1203b6ea052d96941f18abd55d36642efa96d51c 2 parents cf45206 + f127b1a
Eloy Lafuente (stronk7) stronk7 authored
1  admin/settings/users.php
@@ -151,6 +151,7 @@
151 151 'institution' => new lang_string('institution'),
152 152 )));
153 153 $temp->add(new admin_setting_configcheckbox('enablegravatar', new lang_string('enablegravatar', 'admin'), new lang_string('enablegravatar_help', 'admin'), 0));
  154 + $temp->add(new admin_setting_configtext('gravatardefaulturl', new lang_string('gravatardefaulturl', 'admin'), new lang_string('gravatardefaulturl_help', 'admin'), 'mm'));
154 155 }
155 156
156 157 $ADMIN->add('roles', $temp);
2  lang/en/admin.php
@@ -553,6 +553,8 @@
553 553 $string['gotofirst'] = 'Go to first missing string';
554 554 $string['gradebook'] = 'Gradebook';
555 555 $string['gradebookroles'] = 'Graded roles';
  556 +$string['gravatardefaulturl'] = 'Gravatar default image URL';
  557 +$string['gravatardefaulturl_help'] = 'Gravatar needs a default image to display if it is unable to find a picture for a given user. Provide a full URL for an image. If you leave this setting empty, Moodle will attempt to use the most appropriate default image for the page you are viewing. Note also that Gravatar has a number of codes which can be used to <a href="https://en.gravatar.com/site/implement/images/#default-image">generate default images</a>.';
556 558 $string['gradeexport'] = 'Primary grade export methods';
557 559 $string['guestroleid'] = 'Role for guest';
558 560 $string['guestroleid_help'] = 'This role is automatically assigned to the guest user. It is also temporarily assigned to not enrolled users that enter the course via guest enrolment plugin.';
17 lib/outputcomponents.php
@@ -384,12 +384,25 @@ public function get_url(moodle_page $page, renderer_base $renderer = null) {
384 384 // Hash the users email address
385 385 $md5 = md5(strtolower(trim($this->user->email)));
386 386 // Build a gravatar URL with what we know.
  387 +
  388 + // Find the best default image URL we can (MDL-35669)
  389 + if (empty($CFG->gravatardefaulturl)) {
  390 + $absoluteimagepath = $page->theme->resolve_image_location('u/'.$filename, 'core');
  391 + if (strpos($absoluteimagepath, $CFG->dirroot) === 0) {
  392 + $gravatardefault = $CFG->wwwroot . substr($absoluteimagepath, strlen($CFG->dirroot));
  393 + } else {
  394 + $gravatardefault = $CFG->wwwroot . '/pix/u/' . $filename . '.png';
  395 + }
  396 + } else {
  397 + $gravatardefault = $CFG->gravatardefaulturl;
  398 + }
  399 +
387 400 // If the currently requested page is https then we'll return an
388 401 // https gravatar page.
389 402 if (strpos($CFG->httpswwwroot, 'https:') === 0) {
390   - return new moodle_url("https://secure.gravatar.com/avatar/{$md5}", array('s' => $size, 'd' => $defaulturl->out(false)));
  403 + return new moodle_url("https://secure.gravatar.com/avatar/{$md5}", array('s' => $size, 'd' => $gravatardefault));
391 404 } else {
392   - return new moodle_url("http://www.gravatar.com/avatar/{$md5}", array('s' => $size, 'd' => $defaulturl->out(false)));
  405 + return new moodle_url("http://www.gravatar.com/avatar/{$md5}", array('s' => $size, 'd' => $gravatardefault));
393 406 }
394 407 }
395 408

0 comments on commit 1203b6e

Please sign in to comment.
Something went wrong with that request. Please try again.