From 29e2fecb44227fbcf3a274d839bf6bec0dff885f Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Fri, 19 Apr 2013 13:05:12 +0800 Subject: [PATCH] MDL-39173 Assign - Remove permissions check and OUTPUT from previous patch The permissions check is not correct (even users with grade capability should not see user identities) and $assignment->get_renderer() is preferred over $OUTPUT. --- mod/assign/submission/comments/lib.php | 44 ++++++++++++-------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/mod/assign/submission/comments/lib.php b/mod/assign/submission/comments/lib.php index 9a2e97c432b..6bdb6edb36e 100644 --- a/mod/assign/submission/comments/lib.php +++ b/mod/assign/submission/comments/lib.php @@ -115,7 +115,7 @@ function assignsubmission_comments_comment_permissions(stdClass $options) { * @throws comment_exception */ function assignsubmission_comments_comment_display($comments, $options) { - global $CFG, $DB, $USER, $OUTPUT; + global $CFG, $DB, $USER; if ($options->commentarea != 'submission_comments' && $options->commentarea != 'submission_comments_upgrade') { @@ -142,30 +142,28 @@ function assignsubmission_comments_comment_display($comments, $options) { $guestuser = guest_user(); foreach ($comments as $comment) { - if (($USER->id != $comment->userid) && !has_capability('mod/assign:grade', $assignment->get_context(), $comment->userid)) { - // Anonymize if the logged in user is not the commenter and the commenter does not have the grading capability. - if (empty($usermappings[$comment->userid])) { - // The blind-marking information for this commenter has not been generated; do so now. - $anonid = $assignment->get_uniqueid_for_user($comment->userid); - $commenter = new stdClass(); - $commenter->firstname = $hiddenuserstr; - $commenter->lastname = $anonid; - $commenter->picture = 0; - $commenter->id = $guestuser->id; - $commenter->email = $guestuser->email; - $commenter->imagealt = $guestuser->imagealt; + // Anonymize the comments. + if (empty($usermappings[$comment->userid])) { + // The blind-marking information for this commenter has not been generated; do so now. + $anonid = $assignment->get_uniqueid_for_user($comment->userid); + $commenter = new stdClass(); + $commenter->firstname = $hiddenuserstr; + $commenter->lastname = $anonid; + $commenter->picture = 0; + $commenter->id = $guestuser->id; + $commenter->email = $guestuser->email; + $commenter->imagealt = $guestuser->imagealt; - // Temporarily store blind-marking information for use in later comments if necessary. - $usermappings[$comment->userid]->fullname = fullname($commenter); - $usermappings[$comment->userid]->avatar = $OUTPUT->user_picture($commenter, - array('size'=>18, 'link' => false)); - } - - // Set blind-marking information for this comment. - $comment->fullname = $usermappings[$comment->userid]->fullname; - $comment->avatar = $usermappings[$comment->userid]->avatar; - $comment->profileurl = null; + // Temporarily store blind-marking information for use in later comments if necessary. + $usermappings[$comment->userid]->fullname = fullname($commenter); + $usermappings[$comment->userid]->avatar = $assignment->get_renderer()->user_picture($commenter, + array('size'=>18, 'link' => false)); } + + // Set blind-marking information for this comment. + $comment->fullname = $usermappings[$comment->userid]->fullname; + $comment->avatar = $usermappings[$comment->userid]->avatar; + $comment->profileurl = null; } }