MDL-35669 gravatar Provide default image URL to Gravatar
Conflicts: admin/settings/users.php lib/outputcomponents.php
This commit is contained in:
committed by
Eloy Lafuente (stronk7)
parent
7697512a90
commit
60bbf98971
@@ -150,6 +150,7 @@ if ($hassiteconfig
|
||||
'institution' => get_string('institution'),
|
||||
)));
|
||||
$temp->add(new admin_setting_configcheckbox('enablegravatar', get_string('enablegravatar', 'admin'), get_string('enablegravatar_help', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configtext('gravatardefaulturl', get_string('gravatardefaulturl', 'admin'), get_string('gravatardefaulturl_help', 'admin'), 'mm'));
|
||||
}
|
||||
|
||||
$ADMIN->add('roles', $temp);
|
||||
|
||||
@@ -550,6 +550,8 @@ $string['googlemapkey'] = 'Google Maps API V2 key';
|
||||
$string['gotofirst'] = 'Go to first missing string';
|
||||
$string['gradebook'] = 'Gradebook';
|
||||
$string['gradebookroles'] = 'Graded roles';
|
||||
$string['gravatardefaulturl'] = 'Gravatar default image URL';
|
||||
$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>.';
|
||||
$string['gradeexport'] = 'Primary grade export methods';
|
||||
$string['guestroleid'] = 'Role for guest';
|
||||
$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.';
|
||||
|
||||
@@ -329,12 +329,25 @@ class user_picture implements renderable {
|
||||
// Hash the users email address
|
||||
$md5 = md5(strtolower(trim($this->user->email)));
|
||||
// Build a gravatar URL with what we know.
|
||||
|
||||
// Find the best default image URL we can (MDL-35669)
|
||||
if (empty($CFG->gravatardefaulturl)) {
|
||||
$absoluteimagepath = $page->theme->resolve_image_location('u/'.$filename, 'core');
|
||||
if (strpos($absoluteimagepath, $CFG->dirroot) === 0) {
|
||||
$gravatardefault = $CFG->wwwroot . substr($absoluteimagepath, strlen($CFG->dirroot));
|
||||
} else {
|
||||
$gravatardefault = $CFG->wwwroot . '/pix/u/' . $filename . '.png';
|
||||
}
|
||||
} else {
|
||||
$gravatardefault = $CFG->gravatardefaulturl;
|
||||
}
|
||||
|
||||
// If the currently requested page is https then we'll return an
|
||||
// https gravatar page.
|
||||
if (strpos($CFG->httpswwwroot, 'https:') === 0) {
|
||||
$imageurl = new moodle_url("https://secure.gravatar.com/avatar/{$md5}", array('s' => $size, 'd' => $imageurl->out(false)));
|
||||
$imageurl = new moodle_url("https://secure.gravatar.com/avatar/{$md5}", array('s' => $size, 'd' => $gravatardefault));
|
||||
} else {
|
||||
$imageurl = new moodle_url("http://www.gravatar.com/avatar/{$md5}", array('s' => $size, 'd' => $imageurl->out(false)));
|
||||
$imageurl = new moodle_url("http://www.gravatar.com/avatar/{$md5}", array('s' => $size, 'd' => $gravatardefault));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user