diff --git a/admin/settings/security.php b/admin/settings/security.php index 7601c9a673d..270ec07e7ec 100644 --- a/admin/settings/security.php +++ b/admin/settings/security.php @@ -33,6 +33,8 @@ $temp->add(new admin_setting_configselect('bloglevel', get_string('bloglevel', ' 1 => get_string('personalblogs','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_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)); diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 916bee613e9..37bb6c30cc5 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -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['configproxyhost'] = 'If this server 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['configprofilesforenrolledusersonly'] = ' +
@@ -472,6 +477,7 @@ $string['profilemenuoptions'] = 'Menu options (one per line)';
$string['profilemenutoofewoptions'] = 'You must provide at least 2 options';
$string['profilename'] = 'Name';
$string['profilenofieldsdefined'] = 'No fields have been defined';
+$string['profilesforenrolledusersonly'] = 'Profiles for enrolled users only';
$string['profileshortname'] = 'Short name (must be unique)';
$string['profileshortnamenotunique'] = 'This short name is already in use';
$string['profilespecificsettings'] = 'Specific settings';
diff --git a/lang/en_utf8/moodle.php b/lang/en_utf8/moodle.php
index d2cdbf349c8..6e8268e45eb 100644
--- a/lang/en_utf8/moodle.php
+++ b/lang/en_utf8/moodle.php
@@ -1132,6 +1132,7 @@ $string['previous'] = 'Previous';
$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 9eefe7d6bbb..9d2e3c74523 100644
--- a/user/edit_form.php
+++ b/user/edit_form.php
@@ -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
diff --git a/user/editadvanced_form.php b/user/editadvanced_form.php
index 1d04025f711..585a5f6a6a9 100644
--- a/user/editadvanced_form.php
+++ b/user/editadvanced_form.php
@@ -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');
diff --git a/user/view.php b/user/view.php
index 22c52e7754d..c5f2b784df7 100644
--- a/user/view.php
+++ b/user/view.php
@@ -201,7 +201,13 @@
// Print the description
if ($user->description && !isset($hiddenfields['description'])) {
- echo format_text($user->description, FORMAT_MOODLE)."
";
+ $has_courseid = ($course->id != SITEID);
+ if (!$has_courseid && !empty($CFG->profilesforenrolledusersonly)
+ && !record_exists('role_assignments', 'userid', $id)) {
+ echo get_string('profilenotshown', 'moodle').'
';
+ } else {
+ echo format_text($user->description, FORMAT_MOODLE)."
";
+ }
}
// Print all the little details in a list