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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user