'; - $output .= print_user_picture($userfrom, $course->id, $userfrom->picture, false, true); + $output .= $post->anonymous ? $anonpicture : print_user_picture($userfrom, $course->id, $userfrom->picture, false, true); $output .= ' | '; if ($post->parent) { @@ -2700,7 +2717,7 @@ $fullname = fullname($userfrom, $viewfullnames); $by = new object(); - $by->name = ''.$fullname.''; + $by->name = $post->anonymous ? $CFG->forum_anonymousname : ''.$fullname.''; $by->date = userdate($post->modified, '', $userto->timezone); $output .= ' '; @@ -2795,8 +2812,9 @@ static $strpruneheading, $displaymode; static $strmarkread, $strmarkunread; - $post->course = $course->id; - $post->forum = $forum->id; + $post->course = $course->id; + $post->forum = $forum->id; + $post->anonymous = $forum->anonymous == 1 ? true : ($forum->anonymous == 2 ? $post->anonymous : false); // caching if (!isset($cm->cache)) { @@ -2888,9 +2906,10 @@ $postuser->lastname = $post->lastname; $postuser->imagealt = $post->imagealt; $postuser->picture = $post->picture; + $anonpicture = ''; echo '|
'; - print_user_picture($postuser, $course->id); + $post->anonymous ? print($anonpicture) : print_user_picture($postuser, $course->id); echo ' | '; if ($post->parent) { @@ -2908,8 +2927,14 @@ echo ''; - print_user_picture($postuser, $forum->course); + $post->anonymous ? print($anonpicture) : print_user_picture($postuser, $forum->course); echo " | \n"; // User name $fullname = fullname($post, has_capability('moodle/site:viewfullnames', $modcontext)); echo ''; - echo ''.$fullname.''; + + if ($post->anonymous) { + echo $CFG->forum_anonymousname; + } else { + echo ''.$fullname.''; + } + echo " | \n"; // Group picture @@ -3242,8 +3284,13 @@ $usermodified->id = $post->usermodified; $usermodified->firstname = $post->umfirstname; $usermodified->lastname = $post->umlastname; - echo ''. - fullname($usermodified).'
"; - print_user_picture($activity->user, $courseid); + if($activity->user->anonymous) { + echo ''; + } else { + print_user_picture($activity->user, $courseid); + } echo " | ";
echo ' ';
@@ -5385,7 +5446,7 @@
echo ' ';
echo '';
- $fullname = fullname($activity->user, $viewfullnames);
+ $fullname = $activity->user->anonymous ? $CFG->forum_anonymousname : fullname($activity->user, $viewfullnames);
echo "wwwroot/user/view.php?id={$activity->user->id}&course=$courseid\">"
."{$fullname} - ".userdate($activity->timestamp);
echo ' ';
Index: mod/forum/post_form.php
===================================================================
--- a/mod/forum/post_form.php (revision 242)
+++ b/mod/forum/post_form.php (revision 243)
@@ -66,6 +66,11 @@
$mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'forum'));
}
+ // MDL-1071
+ if ($forum->anonymous == 2) {
+ $mform->addElement('checkbox', 'anonymous', get_string('anonymouspost', 'forum'));
+ }
+
if (!empty($CFG->forum_enabletimedposts) && !$post->parent && has_capability('mod/forum:viewhiddentimedposts', $coursecontext)) { // hack alert
$mform->addElement('header', '', get_string('displayperiod', 'forum'));
Index: mod/forum/user.php
===================================================================
--- a/mod/forum/user.php (revision 242)
+++ b/mod/forum/user.php (revision 243)
@@ -69,12 +69,12 @@
switch ($mode) {
case 'posts' :
$searchterms = array('userid:'.$user->id);
- $extrasql = '';
+ $extrasql = 'AND anonymous = 0';
break;
default:
$searchterms = array('userid:'.$user->id);
- $extrasql = 'AND p.parent = 0';
+ $extrasql = 'AND p.parent = 0 AND anonymous = 0';
break;
}
@@ -93,12 +93,9 @@
}
// Get the posts.
- if ($posts = forum_search_posts($searchterms, $searchcourse, $page*$perpage, $perpage,
- $totalcount, $extrasql)) {
+ if ($posts = forum_search_posts($searchterms, $searchcourse, $page*$perpage, $perpage, $totalcount, $extrasql)) {
+ print_paging_bar($totalcount, $page, $perpage, "user.php?id=$user->id&course=$course->id&mode=$mode&perpage=$perpage&");
- print_paging_bar($totalcount, $page, $perpage,
- "user.php?id=$user->id&course=$course->id&mode=$mode&perpage=$perpage&");
-
$discussions = array();
$forums = array();
$cms = array();
Index: mod/forum/post.php
===================================================================
--- a/mod/forum/post.php (revision 242)
+++ b/mod/forum/post.php (revision 243)
@@ -13,6 +13,7 @@
$name = optional_param('name', '', PARAM_CLEAN);
$confirm = optional_param('confirm', 0, PARAM_INT);
$groupid = optional_param('groupid', null, PARAM_INT);
+ $isanon = optional_param('anonymous', 0, PARAM_INT) ? true : false;
//these page_params will be passed as hidden variables later in the form.
@@ -111,6 +112,7 @@
$post->subject = '';
$post->userid = $USER->id;
$post->message = '';
+ $post->anonymous = $isanon;
if (isset($groupid)) {
$post->groupid = $groupid;
@@ -179,6 +181,7 @@
$post->subject = $parent->subject;
$post->userid = $USER->id;
$post->message = '';
+ $post->anonymous = $isanon;
$post->groupid = ($discussion->groupid == -1) ? 0 : $discussion->groupid;
@@ -391,6 +394,7 @@
$newpost->id = $post->id;
$newpost->parent = 0;
$newpost->subject = $name;
+ $newpost->anonymous = $isanon;
if (!update_record("forum_posts", $newpost)) {
error('Could not update the original post');
@@ -754,6 +758,7 @@
'message'=>$post->message,
'subscribe'=>$subscribe?1:0,
'mailnow'=>!empty($post->mailnow),
+ 'anonymous'=>($post->anonymous)?1:0,
'userid'=>$post->userid,
'parent'=>$post->parent,
'discussion'=>$post->discussion,
Index: lang/en_utf8/forum.php
===================================================================
--- a/lang/en_utf8/forum.php (revision 242)
+++ b/lang/en_utf8/forum.php (revision 243)
@@ -15,6 +15,7 @@
$string['aggregatetype'] = 'Aggregate type';
$string['ajaxrating'] = 'Enable AJAX rating';
$string['allforums'] = 'All forums';
+$string['allowanonymous'] = 'Anonymize posts?';
$string['allowchoice'] = 'Allow everyone to choose';
$string['allowdiscussions'] = 'Can a $a post to this forum?';
$string['allowratings'] = 'Allow posts to be rated?';
@@ -22,6 +23,11 @@
$string['allowsdiscussions'] = 'This forum allows each person to start one discussion topic.';
$string['allsubscribe'] = 'Subscribe to all forums';
$string['allunsubscribe'] = 'Unsubscribe from all forums';
+$string['anonno'] = 'No, never';
+$string['anonoptional'] = 'Optional (let the user decide)';
+$string['anonyes'] = 'Yes, all posts';
+$string['anonymouspost'] = 'Post anonymously';
+$string['anonymousname'] = 'Anonymous user name';
$string['anyfile'] = 'Any file';
$string['attachment'] = 'Attachment';
$string['blockafter'] = 'Post threshold for blocking';
@@ -33,6 +39,7 @@
$string['cannotadddiscussionall'] = 'You do not have permission to add a new discussion topic for all participants.';
$string['cleanreadtime'] = 'Mark old posts as read hour';
$string['configajaxrating'] = 'AJAX rating is a forum rating usability improvement. If enabled, users can rate forum posts almost instantly without needing to scroll to the bottom of the page and click the \'Send in my latest ratings\' button. This setting also requires AJAX to be enabled for the site and in user profiles.';
+$string['configanonymousname'] = 'The user name to display on anonymous forum posts.';
$string['configcleanreadtime'] = 'The hour of the day to clean old posts from the \'read\' table.';
$string['configdisplaymode'] = 'The default display mode for discussions if one isn\'t set.';
$string['configenablerssfeeds'] = 'This switch will enable the possibility of RSS feeds for all forums. You will still need to turn feeds on manually in the settings for each forum.';
Index: lang/en_utf8/help/forum/anonymous.html
===================================================================
--- a/lang/en_utf8/help/forum/anonymous.html (revision 0)
+++ b/lang/en_utf8/help/forum/anonymous.html (revision 243)
@@ -0,0 +1,17 @@
+Make posts anonymous?+ +There are three options available: + +
+Even though anonymous posts will indeed show up as anonymous within Moodle for both instructors +and students, the "export forum" function available to instructors will unmask anonymous posts, +revealing the identity of the authors. In addition, course instructors can change this forum option +at anytime, and when changed from "Yes" or "Optional" to "No, never", all previously anonymous posts +will be unmasked. + |