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

@ -33,6 +33,8 @@ $temp->add(new admin_setting_configselect('bloglevel', get_string('bloglevel', '
1 => get_string('personalblogs','blog'), 1 => get_string('personalblogs','blog'),
0 => get_string('disableblogs','blog')))); 0 => get_string('disableblogs','blog'))));
$temp->add(new admin_setting_configcheckbox('profilesforenrolledusersonly', get_string('profilesforenrolledusersonly','admin'),get_string('configprofilesforenrolledusersonly', 'admin'),'1'));
$temp->add(new admin_setting_configcheckbox('cronclionly', get_string('cronclionly', 'admin'), get_string('configcronclionly', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('cronclionly', get_string('cronclionly', 'admin'), get_string('configcronclionly', 'admin'), 0));
$temp->add(new admin_setting_configtext('cronremotepassword', get_string('cronremotepassword', 'admin'), get_string('configcronremotepassword', 'admin'), '', PARAM_RAW)); $temp->add(new admin_setting_configtext('cronremotepassword', get_string('cronremotepassword', 'admin'), get_string('configcronremotepassword', 'admin'), '', PARAM_RAW));
$temp->add(new admin_setting_configcheckbox('emailchangeconfirmation', get_string('emailchangeconfirmation', 'admin'), get_string('configemailchangeconfirmation', 'admin'), 1)); $temp->add(new admin_setting_configcheckbox('emailchangeconfirmation', get_string('emailchangeconfirmation', 'admin'), get_string('configemailchangeconfirmation', 'admin'), 1));

View file

@ -150,6 +150,11 @@ $string['configperfdebug'] = 'If you turn this on, performance info will be prin
$string['configprotectusernames'] = 'By default forget_password.php does not display any hints that would allow guessing of usernames or email addresses.'; $string['configprotectusernames'] = 'By default forget_password.php does not display any hints that would allow guessing of usernames or email addresses.';
$string['configproxyhost'] = 'If this <b>server</b> needs to use a proxy computer (eg a firewall) to access the Internet, then provide the proxy hostname and port here. Otherwise leave it blank.'; $string['configproxyhost'] = 'If this <b>server</b> needs to use a proxy computer (eg a firewall) to access the Internet, then provide the proxy hostname and port here. Otherwise leave it blank.';
$string['configproxyport'] = 'If this server needs to use a proxy computer, then provide the proxy port here.'; $string['configproxyport'] = 'If this server needs to use a proxy computer, then provide the proxy port here.';
$string['configprofilesforenrolledusersonly'] = '
<ul>
<li>When showing the profile page, if a courseid isn\'t defined (this is the public view) AND the user is not enrolled in any courses AND this setting is set as true then replace the profile description won\'t display.</li>
<li>When editing the profile page, if the description is blank AND the user is not enrolled in any courses AND this setting is set as true then completely hide the description field from the editing page.</li>
</ul>';
$string['configquarantinedir'] = 'If you want clam AV to move infected files to a quarantine directory, enter it here. It must be writable by the webserver. If you leave this blank, or if you enter a directory that doesn\'t exist or isn\'t writable, infected files will be deleted. Do not include a trailing slash.'; $string['configquarantinedir'] = 'If you want clam AV to move infected files to a quarantine directory, enter it here. It must be writable by the webserver. If you leave this blank, or if you enter a directory that doesn\'t exist or isn\'t writable, infected files will be deleted. Do not include a trailing slash.';
$string['configcronclionly'] = 'If this is set, then the cron script can only be run from the commandline instead of via the web. This overrides the cron password setting below.'; $string['configcronclionly'] = 'If this is set, then the cron script can only be run from the commandline instead of via the web. This overrides the cron password setting below.';
$string['configcronremotepassword'] = 'This means that the cron.php script cannot be run from a web browser without supplying the password using the following form of URL:<pre> $string['configcronremotepassword'] = 'This means that the cron.php script cannot be run from a web browser without supplying the password using the following form of URL:<pre>
@ -472,6 +477,7 @@ $string['profilemenuoptions'] = 'Menu options (one per line)';
$string['profilemenutoofewoptions'] = 'You must provide at least 2 options'; $string['profilemenutoofewoptions'] = 'You must provide at least 2 options';
$string['profilename'] = 'Name'; $string['profilename'] = 'Name';
$string['profilenofieldsdefined'] = 'No fields have been defined'; $string['profilenofieldsdefined'] = 'No fields have been defined';
$string['profilesforenrolledusersonly'] = 'Profiles for enrolled users only';
$string['profileshortname'] = 'Short name (must be unique)'; $string['profileshortname'] = 'Short name (must be unique)';
$string['profileshortnamenotunique'] = 'This short name is already in use'; $string['profileshortnamenotunique'] = 'This short name is already in use';
$string['profilespecificsettings'] = 'Specific settings'; $string['profilespecificsettings'] = 'Specific settings';

View file

@ -1132,6 +1132,7 @@ $string['previous'] = 'Previous';
$string['previoussection'] = 'Previous section'; $string['previoussection'] = 'Previous section';
$string['primaryadminsetup'] = 'Setup administrator account'; $string['primaryadminsetup'] = 'Setup administrator account';
$string['profile'] = 'Profile'; $string['profile'] = 'Profile';
$string['profilenotshown'] = 'This profile description will not be shown until this person is enrolled in at least one course.';
$string['publicdirectory'] = 'Public directory'; $string['publicdirectory'] = 'Public directory';
$string['publicdirectory0'] = 'Please do not publish this site'; $string['publicdirectory0'] = 'Please do not publish this site';
$string['publicdirectory1'] = 'Publish the site name only'; $string['publicdirectory1'] = 'Publish the site name only';

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)) { if ($user = get_record('user', 'id', $userid)) {
// print picture // 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 // user can not change own auth method
if ($userid == $USER->id) { if ($userid == $USER->id) {
$mform->hardFreeze('auth'); $mform->hardFreeze('auth');

View file

@ -201,7 +201,13 @@
// Print the description // Print the description
if ($user->description && !isset($hiddenfields['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 // Print all the little details in a list