Skip to content

Commit

Permalink
MDL-17143
Browse files Browse the repository at this point in the history
don't display the user description at all when user isn't enrolled in any courses, backported to 1.7
  • Loading branch information
dongsheng committed Nov 12, 2008
1 parent e37e029 commit 0750703
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions admin/settings/security.php
Expand Up @@ -32,6 +32,7 @@
2 => get_string('groupblogs','blog'),
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'));

$ADMIN->add('security', $temp);

Expand Down
6 changes: 6 additions & 0 deletions lang/en_utf8/admin.php
Expand Up @@ -130,6 +130,11 @@
$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 and port here. Otherwise leave it blank.';
$string['configproxyport'] = 'If this server needs to use a proxy computer, then provide the proxy port here.';
Expand Down Expand Up @@ -373,6 +378,7 @@
$string['php50restricted'] = 'PHP 5.0.x has a number of known problems, please upgrade to 5.1.x or downgrade to 4.3.x or 4.4.x';
$string['pleaseregister'] = 'Please register your site to remove this button';
$string['plugins'] = 'Modules';
$string['profilesforenrolledusersonly'] = 'Profiles for enrolled users only';
$string['protectusernames'] = 'Protect usernames';
$string['proxyhost'] = 'Proxy host';
$string['proxyport'] = 'Proxy port';
Expand Down
1 change: 1 addition & 0 deletions lang/en_utf8/moodle.php
Expand Up @@ -1073,6 +1073,7 @@
$string['previeworchoose'] = 'Preview or choose a theme';
$string['previous'] = 'Previous';
$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';
Expand Down
14 changes: 12 additions & 2 deletions user/edit.html
Expand Up @@ -265,10 +265,16 @@
?>
</td>
</tr>
<?php } ?>
<?php }
$can_edit_user = has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM));
if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !record_exists('role_assignments', 'userid', $userid) && !$can_edit_user) {
// prevent user editing description
} else {
?>
<tr>
<th><?php print_string("userdescription") ?>:</th>
<td><?php
<td>
<?php
if (isset($err["description"])) {
formerr($err["description"]);
echo "<br />";
Expand All @@ -278,6 +284,10 @@
?>
</td>
</tr>
<?php
}

?>
<tr>
<td colspan="2" style="text-align: center;"><input type="submit" value="<?php print_string("updatemyprofile") ?>" /></td>
</tr>
Expand Down
5 changes: 3 additions & 2 deletions user/edit.php
Expand Up @@ -438,8 +438,9 @@ function find_form_errors(&$user, &$usernew, &$err, &$um) {
if (over_bounce_threshold($user) && $user->email == $usernew->email)
$err['email'] = get_string('toomanybounces');

if (empty($usernew->description) and !has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM, SITEID)))
$err["description"] = get_string("missingdescription");
if (empty($usernew->description) and !has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
//$err["description"] = get_string("missingdescription");
}

if (empty($usernew->city))
$err["city"] = get_string("missingcity");
Expand Down
9 changes: 8 additions & 1 deletion user/view.php
Expand Up @@ -185,7 +185,14 @@
// Print the description

if ($user->description && !isset($hiddenfields['description'])) {
echo format_text($user->description, FORMAT_MOODLE)."<hr />";
$has_courseid = ($course->id != SITEID);
$CFG->profilesforenrolledusersonly = true;
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
Expand Down
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)

$version = 2006101060; // YYYYMMDD = date of the 1.7 branch (don't change)
$version = 2006101061; // YYYYMMDD = date of the 1.7 branch (don't change)
// X = release number 1.7.[0,1,2,3...]
// Y = micro-increments between releases

Expand Down

0 comments on commit 0750703

Please sign in to comment.