From 35f0660ab488a31ce3cd40bb573a5617d70bbe58 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Mon, 10 Nov 2008 03:06:27 +0000 Subject: [PATCH] "MDL-17143, don't display the user description at all when user isn't enrolled in any courses, merged and modified from 1.9" --- admin/settings/security.php | 3 +++ lang/en_utf8/admin.php | 6 ++++++ lang/en_utf8/moodle.php | 1 + user/edit_form.php | 6 ++++++ user/editadvanced_form.php | 7 +++++++ user/view.php | 8 +++++++- 6 files changed, 30 insertions(+), 1 deletion(-) diff --git a/admin/settings/security.php b/admin/settings/security.php index 102900ea34..c603abe983 100644 --- a/admin/settings/security.php +++ b/admin/settings/security.php @@ -39,6 +39,9 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page $temp->add(new admin_setting_configcheckbox('extendedusernamechars', get_string('extendedusernamechars', 'admin'), get_string('configextendedusernamechars', 'admin'), 0)); $temp->add(new admin_setting_configtext('sitepolicy', get_string('sitepolicy', 'admin'), get_string('configsitepolicy', 'admin'), '', PARAM_RAW)); $temp->add(new admin_setting_configcheckbox('keeptagnamecase', get_string('keeptagnamecase','admin'),get_string('configkeeptagnamecase', 'admin'),'1')); + + $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_configpasswordunmask('cronremotepassword', get_string('cronremotepassword', 'admin'), get_string('configcronremotepassword', 'admin'), '')); diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index be20575097..68c8e65fef 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -189,6 +189,11 @@ $string['configoverride'] = 'Defined in config.php'; $string['configpathtoclam'] = 'Path to clam AV. Probably something like /usr/bin/clamscan or /usr/bin/clamdscan. You need this in order for clam AV to run.'; $string['configpathtodu'] = 'Path to du. Probably something like /usr/bin/du. If you enter this, pages that display directory contents will run much faster for directories with a lot of files.'; $string['configperfdebug'] = 'If you turn this on, performance info will be printed in the footer of the standard theme'; +$string['configprofilesforenrolledusersonly'] = ' +'; $string['configprotectusernames'] = 'By default forget_password.php does not display any hints that would allow guessing of usernames or email addresses.'; $string['configproxybypass'] = 'Comma separated list of (partial) hostnames or IPs that should bypass proxy (e.g., 192.168., .mydomain.com)'; $string['configproxyhost'] = 'If this server needs to use a proxy computer (eg a firewall) to access the Internet, then provide the proxy hostname here. Otherwise leave it blank.'; @@ -613,6 +618,7 @@ $string['profilefieldtypetextarea'] = 'Text area'; $string['profilefieldmaxlength'] = 'Maximum length'; $string['profilefieldispassword'] = 'Is this a password field?'; $string['profileforceunique'] = 'Should the data be unique?'; +$string['profilesforenrolledusersonly'] = 'Profiles for enrolled users only'; $string['profileinvaliddata'] = 'Invalid value'; $string['profilelocked'] = 'Is this field locked?'; $string['profilemenudefaultnotinoptions'] = 'The default value is not one of the options'; diff --git a/lang/en_utf8/moodle.php b/lang/en_utf8/moodle.php index 4965e7a71f..125fbd868a 100644 --- a/lang/en_utf8/moodle.php +++ b/lang/en_utf8/moodle.php @@ -1220,6 +1220,7 @@ $string['previouslyselectedusers'] = 'Previously selected users not matching \'$ $string['previoussection'] = 'Previous section'; $string['primaryadminsetup'] = 'Setup administrator account'; $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['publicdirectory0'] = 'Please do not publish this site'; $string['publicdirectory1'] = 'Publish the site name only'; diff --git a/user/edit_form.php b/user/edit_form.php index 45282dc41b..920ec7edcf 100644 --- a/user/edit_form.php +++ b/user/edit_form.php @@ -60,8 +60,14 @@ class user_edit_form extends moodleform { } } + if ($user = $DB->get_record('user', array('id'=>$userid))) { + // remove description + if (!$DB->get_record('role_assignments', array('userid'=>$userid)) && empty($user->description) && $CFG->profilesforenrolledusersonly) { + $mform->removeElement('description'); + } + // print picture if (!empty($CFG->gdversion)) { $image_el =& $mform->getElement('currentpicture'); diff --git a/user/editadvanced_form.php b/user/editadvanced_form.php index 9ba149862e..03b3c627c4 100644 --- a/user/editadvanced_form.php +++ b/user/editadvanced_form.php @@ -75,6 +75,13 @@ class user_editadvanced_form extends moodleform { } } + $sitecontext = get_context_instance(CONTEXT_SYSTEM); + $can_edit_user = has_capability('moodle/user:update', $sitecontext); + // remove description + if (!$DB->get_record('role_assignments', array('userid'=>$userid)) && empty($user->description) && $CFG->profilesforenrolledusersonly && !$can_edit_user) { + $mform->removeElement('description'); + } + // user can not change own auth method if ($userid == $USER->id) { $mform->hardFreeze('auth'); diff --git a/user/view.php b/user/view.php index c9dc4784c7..74a37d5fef 100644 --- a/user/view.php +++ b/user/view.php @@ -210,7 +210,13 @@ // Print the description if ($user->description && !isset($hiddenfields['description'])) { - echo format_text($user->description, FORMAT_MOODLE)."
"; + $has_courseid = ($course->id != SITEID); + if (!$DB->get_record('role_assignments', array('userid'=>$id)) + && !$has_courseid && $CFG->profilesforenrolledusersonly) { + echo get_string('profilenotshown', 'moodle').'
'; + } else { + echo format_text($user->description, FORMAT_MOODLE)."
"; + } } // Print all the little details in a list -- 2.39.5