Browse files

MDL-17143

don't display the user description at all when user isn't enrolled in any courses, backported to 1.8
  • Loading branch information...
1 parent 61f34d4 commit 7e62718e7c1465b25ae12eed2c3c8b761f0e3cce dongsheng committed Nov 12, 2008
Showing with 32 additions and 1 deletion.
  1. +2 −0 admin/settings/security.php
  2. +6 −0 lang/en_utf8/admin.php
  3. +1 −0 lang/en_utf8/moodle.php
  4. +7 −0 user/edit_form.php
  5. +9 −0 user/editadvanced_form.php
  6. +7 −1 user/view.php
View
2 admin/settings/security.php
@@ -33,6 +33,8 @@
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));
View
6 lang/en_utf8/admin.php
@@ -150,6 +150,11 @@
$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['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['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>
@@ -472,6 +477,7 @@
$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';
View
1 lang/en_utf8/moodle.php
@@ -1132,6 +1132,7 @@
$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';
View
7 user/edit_form.php
@@ -54,6 +54,13 @@ function definition_after_data() {
}
}
+ // 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
9 user/editadvanced_form.php
@@ -70,6 +70,15 @@ function definition_after_data() {
}
}
+ $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
8 user/view.php
@@ -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

0 comments on commit 7e62718

Please sign in to comment.