Browse files

"MDL-17143, don't display the user description at all when user isn't…

… enrolled in any courses, backported to 1.6"
  • Loading branch information...
1 parent ebad401 commit e45607b4912c7e6b462840516580eebdd67a544c dongsheng committed Nov 18, 2008
Showing with 27 additions and 4 deletions.
  1. +3 −0 admin/configvars.php
  2. +1 −0 lang/en_utf8/admin.php
  3. +1 −0 lang/en_utf8/moodle.php
  4. +9 −0 user/edit.html
  5. +3 −2 user/edit.php
  6. +9 −1 user/view.php
  7. +1 −1 version.php
View
3 admin/configvars.php
@@ -461,6 +461,9 @@ function togglemodules(index) {
$security['loginhttps'] = new configvar (get_string('configloginhttps', 'admin'),
choose_from_menu ($noyesoptions, 'loginhttps', $config->loginhttps, '', '', '', true) );
+/// profilesforenrolledusersonly
+ $security['profilesforenrolledusersonly'] = new configvar (get_string('configprofilesforenrolledusersonly', 'admin'), choose_from_menu ($noyesoptions, 'profilesforenrolledusersonly', $CFG->profilesforenrolledusersonly, '', '', '', true) );
+
/// runclamonupload
$security['runclamonupload'] = new configvar (get_string('configrunclamonupload', 'admin'),
choose_from_menu($noyesoptions, 'runclamonupload', $config->runclamonupload, '', '', '', true) );
View
1 lang/en_utf8/admin.php
@@ -221,6 +221,7 @@
$string['pgcluster'] = 'PostgreSQL Cluster';
$string['pgclusterdescription'] = 'PostgreSQL version/cluster parameter for command line operations. If you only have one postgresql on your system or you are not sure what this is, leave this blank.';
$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['configprofilesforenrolledusersonly'] = 'To prevent misuse by spammers, profile descriptions of users who are not yet enrolled in any course are hidden. New users must enrol in at least one course before they can add a profile description.';
$string['remotelangnotavailable'] = 'Because Moodle can not connect to download.moodle.org, we are unable to do language pack installation automatically. Please download the appropriate zip file(s) from the list below, copy them to your $a directory and unzip them manually.';
$string['serverchecks'] = 'Server Checks';
$string['sitelangchanged'] = 'Site language setting changed successfully';
View
1 lang/en_utf8/moodle.php
@@ -1028,6 +1028,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';
View
9 user/edit.html
@@ -251,6 +251,12 @@
</td>
</tr>
<?php } ?>
+<?php
+$can_edit_user = isadmin();
+if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !record_exists('user_students', 'userid', $userid)&& !record_exists('user_teachers', 'userid', $userid) && !$can_edit_user) {
+ // prevent user editing description
+} else {
+?>
<tr>
<th><?php print_string("userdescription") ?>:</th>
<td><?php
@@ -263,6 +269,9 @@
?>
</td>
</tr>
+<?php
+}
+?>
<tr>
<td colspan="2" style="text-align: center;"><input type="submit" value="<?php print_string("updatemyprofile") ?>" /></td>
</tr>
View
5 user/edit.php
@@ -427,8 +427,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 !isadmin())
- $err["description"] = get_string("missingdescription");
+ if (empty($usernew->description) and !isadmin()) {
+ //$err["description"] = get_string("missingdescription");
+ }
if (empty($usernew->city))
$err["city"] = get_string("missingcity");
View
10 user/view.php
@@ -136,8 +136,16 @@
// Print the description
+ var_dump($CFG->profilesforenrolledusersonly);
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('user_students', 'userid', $id)
+ && !record_exists('user_teachers', '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
View
2 version.php
@@ -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 = 2006050580; // YYYYMMDD = date of the 1.6 branch (don't change)
+ $version = 2006050581; // YYYYMMDD = date of the 1.6 branch (don't change)
// X = release number 1.6.[0,1,2,3...]
// Y = micro-increments between releases

0 comments on commit e45607b

Please sign in to comment.