MDL-17143

don't display the user description at all when user isn't enrolled in any courses, backported to 1.8
This commit is contained in:
dongsheng 2008-11-12 02:21:54 +00:00
parent 61f34d4260
commit 7e62718e7c
6 changed files with 32 additions and 1 deletions

View file

@ -54,6 +54,13 @@ class user_edit_form extends moodleform {
}
}
// remove description
if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !record_exists('role_assignments', 'userid', $userid)) {
if ($mform->elementExists('description')) {
$mform->removeElement('description');
}
}
if ($user = get_record('user', 'id', $userid)) {
// print picture

View file

@ -70,6 +70,15 @@ class user_editadvanced_form extends moodleform {
}
}
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
$can_edit_user = has_capability('moodle/user:update', $sitecontext);
if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !$can_edit_user && !record_exists('role_assignments', 'userid', $userid)) {
// remove description
if ($mform->elementExists('description')) {
$mform->removeElement('description');
}
}
// user can not change own auth method
if ($userid == $USER->id) {
$mform->hardFreeze('auth');

View file

@ -201,7 +201,13 @@
// Print the description
if ($user->description && !isset($hiddenfields['description'])) {
echo format_text($user->description, FORMAT_MOODLE)."<hr />";
$has_courseid = ($course->id != SITEID);
if (!$has_courseid && !empty($CFG->profilesforenrolledusersonly)
&& !record_exists('role_assignments', 'userid', $id)) {
echo get_string('profilenotshown', 'moodle').'<hr />';
} else {
echo format_text($user->description, FORMAT_MOODLE)."<hr />";
}
}
// Print all the little details in a list