Index: admin/settings/security.php
===================================================================
RCS file: /cvsroot/moodle/moodle/admin/settings/security.php,v
retrieving revision 1.21.2.6
diff -u -p -r1.21.2.6 security.php
--- admin/settings/security.php	11 Jul 2008 07:49:54 -0000	1.21.2.6
+++ admin/settings/security.php	10 Nov 2008 02:49:01 -0000
@@ -40,6 +40,9 @@ if ($hassiteconfig) { // speedup for non
                                                                                                                                               0 => get_string('disableblogs','blog'))));
     $temp->add(new admin_setting_configcheckbox('usetags', get_string('usetags','admin'),get_string('configusetags', 'admin'),'1'));
     $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'), ''));
 
Index: lang/en_utf8/moodle.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/moodle.php,v
retrieving revision 1.141.2.45
diff -u -p -r1.141.2.45 moodle.php
--- lang/en_utf8/moodle.php	7 Nov 2008 05:51:54 -0000	1.141.2.45
+++ lang/en_utf8/moodle.php	10 Nov 2008 02:49:02 -0000
@@ -1204,6 +1204,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';
Index: lang/en_utf8/admin.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/admin.php,v
retrieving revision 1.154.2.62
diff -u -p -r1.154.2.62 admin.php
--- lang/en_utf8/admin.php	1 Nov 2008 19:30:56 -0000	1.154.2.62
+++ lang/en_utf8/admin.php	10 Nov 2008 02:49:03 -0000
@@ -179,6 +179,11 @@ $string['configoverride'] = 'Defined in 
 $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'] = '
+<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['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 here.  Otherwise leave it blank.';
 $string['configproxypassword'] = 'Password needed to access internet through proxy if required, empty if none (PHP cURL extension required).';
@@ -581,6 +586,7 @@ $string['profilefieldtypetextarea'] = 'T
 $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';
Index: user/editadvanced_form.php
===================================================================
RCS file: /cvsroot/moodle/moodle/user/editadvanced_form.php,v
retrieving revision 1.14.2.5
diff -u -p -r1.14.2.5 editadvanced_form.php
--- user/editadvanced_form.php	10 Oct 2008 21:27:42 -0000	1.14.2.5
+++ user/editadvanced_form.php	10 Nov 2008 02:49:04 -0000
@@ -76,6 +76,13 @@ class user_editadvanced_form extends moo
             }
         }
 
+        $sitecontext = get_context_instance(CONTEXT_SYSTEM);
+        $can_edit_user = has_capability('moodle/user:update', $sitecontext);
+        // remove description
+        if (!get_record('role_assignments', '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');
Index: user/edit_form.php
===================================================================
RCS file: /cvsroot/moodle/moodle/user/edit_form.php,v
retrieving revision 1.24.2.5
diff -u -p -r1.24.2.5 edit_form.php
--- user/edit_form.php	13 Oct 2008 19:38:49 -0000	1.24.2.5
+++ user/edit_form.php	10 Nov 2008 02:49:04 -0000
@@ -61,6 +61,11 @@ class user_edit_form extends moodleform 
             }
         }
 
+        // remove description
+        if (!get_record('role_assignments', 'userid', $userid) && empty($user->description) && $CFG->profilesforenrolledusersonly) {
+            $mform->removeElement('description');
+        }
+
         if ($user = get_record('user', 'id', $userid)) {
 
             // print picture
Index: user/view.php
===================================================================
RCS file: /cvsroot/moodle/moodle/user/view.php,v
retrieving revision 1.168.2.19
diff -u -p -r1.168.2.19 view.php
--- user/view.php	10 Sep 2008 03:21:04 -0000	1.168.2.19
+++ user/view.php	10 Nov 2008 02:49:04 -0000
@@ -220,7 +220,13 @@
     // Print the description
 
     if ($user->description && !isset($hiddenfields['description'])) {
-        echo format_text($user->description, FORMAT_MOODLE)."<hr />";
+        $has_courseid = ($course->id != SITEID);
+        if (!get_record('role_assignments', 'userid', $id)
+            && !$has_courseid && $CFG->profilesforenrolledusersonly) {
+            echo get_string('profilenotshown', 'moodle').'<hr />';
+        } else {
+            echo format_text($user->description, FORMAT_MOODLE)."<hr />";
+        }
     }
 
     // Print all the little details in a list
