Commit ae8e8e6a authored by Eloy Lafuente's avatar Eloy Lafuente
Browse files

Merge branch 'MDL-55915_master' of https://github.com/rezaies/moodle

parents 03963892 d636015c
...@@ -80,9 +80,10 @@ switch ($action) { ...@@ -80,9 +80,10 @@ switch ($action) {
} else { } else {
$useroptions['link'] = false; $useroptions['link'] = false;
} }
$viewfullnames = has_capability('moodle/site:viewfullnames', $context);
foreach ($outcome->response['users'] as &$user) { foreach ($outcome->response['users'] as &$user) {
$user->picture = $OUTPUT->user_picture($user, $useroptions); $user->picture = $OUTPUT->user_picture($user, $useroptions);
$user->fullname = fullname($user); $user->fullname = fullname($user, $viewfullnames);
$fieldvalues = array(); $fieldvalues = array();
foreach ($extrafields as $field) { foreach ($extrafields as $field) {
$fieldvalues[] = s($user->{$field}); $fieldvalues[] = s($user->{$field});
......
...@@ -37,6 +37,7 @@ $context = context_course::instance($course->id, MUST_EXIST); ...@@ -37,6 +37,7 @@ $context = context_course::instance($course->id, MUST_EXIST);
require_login($course); require_login($course);
$canenrol = has_capability('enrol/manual:enrol', $context); $canenrol = has_capability('enrol/manual:enrol', $context);
$canunenrol = has_capability('enrol/manual:unenrol', $context); $canunenrol = has_capability('enrol/manual:unenrol', $context);
$viewfullnames = has_capability('moodle/site:viewfullnames', $context);
// Note: manage capability not used here because it is used for editing // Note: manage capability not used here because it is used for editing
// of existing enrolments which is not possible here. // of existing enrolments which is not possible here.
...@@ -74,7 +75,9 @@ navigation_node::override_active_url(new moodle_url('/enrol/users.php', array('i ...@@ -74,7 +75,9 @@ navigation_node::override_active_url(new moodle_url('/enrol/users.php', array('i
$options = array('enrolid' => $enrolid, 'accesscontext' => $context); $options = array('enrolid' => $enrolid, 'accesscontext' => $context);
$potentialuserselector = new enrol_manual_potential_participant('addselect', $options); $potentialuserselector = new enrol_manual_potential_participant('addselect', $options);
$potentialuserselector->viewfullnames = $viewfullnames;
$currentuserselector = new enrol_manual_current_participant('removeselect', $options); $currentuserselector = new enrol_manual_current_participant('removeselect', $options);
$currentuserselector->viewfullnames = $viewfullnames;
// Build the list of options for the enrolment period dropdown. // Build the list of options for the enrolment period dropdown.
$unlimitedperiod = get_string('unlimited'); $unlimitedperiod = get_string('unlimited');
......
...@@ -183,6 +183,7 @@ class grade_report_grader extends grade_report { ...@@ -183,6 +183,7 @@ class grade_report_grader extends grade_report {
array_unshift($mygroups, $this->currentgroup); array_unshift($mygroups, $this->currentgroup);
} }
} }
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);
// always initialize all arrays // always initialize all arrays
$queue = array(); $queue = array();
...@@ -288,7 +289,7 @@ class grade_report_grader extends grade_report { ...@@ -288,7 +289,7 @@ class grade_report_grader extends grade_report {
$userfields = 'id, ' . get_all_user_name_fields(true); $userfields = 'id, ' . get_all_user_name_fields(true);
$user = $DB->get_record('user', array('id' => $userid), $userfields); $user = $DB->get_record('user', array('id' => $userid), $userfields);
$gradestr = new stdClass(); $gradestr = new stdClass();
$gradestr->username = fullname($user); $gradestr->username = fullname($user, $viewfullnames);
$gradestr->itemname = $gradeitem->get_name(); $gradestr->itemname = $gradeitem->get_name();
$warnings[] = get_string($errorstr, 'grades', $gradestr); $warnings[] = get_string($errorstr, 'grades', $gradestr);
if ($skip) { if ($skip) {
...@@ -611,6 +612,7 @@ class grade_report_grader extends grade_report { ...@@ -611,6 +612,7 @@ class grade_report_grader extends grade_report {
'moodle/grade:edit'), $this->context); 'moodle/grade:edit'), $this->context);
} }
$hasuserreportcell = $canseeuserreport || $canseesingleview; $hasuserreportcell = $canseeuserreport || $canseesingleview;
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);
$strfeedback = $this->get_lang_string("feedback"); $strfeedback = $this->get_lang_string("feedback");
$strgrade = $this->get_lang_string('grade'); $strgrade = $this->get_lang_string('grade');
...@@ -682,7 +684,7 @@ class grade_report_grader extends grade_report { ...@@ -682,7 +684,7 @@ class grade_report_grader extends grade_report {
$usercell->text = $OUTPUT->user_picture($user, array('visibletoscreenreaders' => false)); $usercell->text = $OUTPUT->user_picture($user, array('visibletoscreenreaders' => false));
} }
$fullname = fullname($user); $fullname = fullname($user, $viewfullnames);
$usercell->text .= html_writer::link(new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $this->course->id)), $fullname, array( $usercell->text .= html_writer::link(new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $this->course->id)), $fullname, array(
'class' => 'username', 'class' => 'username',
)); ));
...@@ -781,6 +783,8 @@ class grade_report_grader extends grade_report { ...@@ -781,6 +783,8 @@ class grade_report_grader extends grade_report {
$strexcludedgrades = get_string('excluded', 'grades'); $strexcludedgrades = get_string('excluded', 'grades');
$strerror = get_string('error'); $strerror = get_string('error');
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);
foreach ($this->gtree->get_levels() as $key => $row) { foreach ($this->gtree->get_levels() as $key => $row) {
$headingrow = new html_table_row(); $headingrow = new html_table_row();
$headingrow->attributes['class'] = 'heading_name_row'; $headingrow->attributes['class'] = 'heading_name_row';
...@@ -942,7 +946,7 @@ class grade_report_grader extends grade_report { ...@@ -942,7 +946,7 @@ class grade_report_grader extends grade_report {
$itemrow = new html_table_row(); $itemrow = new html_table_row();
$itemrow->id = 'user_'.$userid; $itemrow->id = 'user_'.$userid;
$fullname = fullname($user); $fullname = fullname($user, $viewfullnames);
$jsarguments['users'][$userid] = $fullname; $jsarguments['users'][$userid] = $fullname;
foreach ($this->gtree->items as $itemid => $unused) { foreach ($this->gtree->items as $itemid => $unused) {
......
...@@ -652,8 +652,9 @@ class assign_grading_table extends table_sql implements renderable { ...@@ -652,8 +652,9 @@ class assign_grading_table extends table_sql implements renderable {
list($sort, $params) = users_order_by_sql(); list($sort, $params) = users_order_by_sql();
$markers = get_users_by_capability($this->assignment->get_context(), 'mod/assign:grade', '', $sort); $markers = get_users_by_capability($this->assignment->get_context(), 'mod/assign:grade', '', $sort);
$markerlist[0] = get_string('choosemarker', 'assign'); $markerlist[0] = get_string('choosemarker', 'assign');
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->assignment->get_context());
foreach ($markers as $marker) { foreach ($markers as $marker) {
$markerlist[$marker->id] = fullname($marker); $markerlist[$marker->id] = fullname($marker, $viewfullnames);
} }
} }
if (empty($markerlist)) { if (empty($markerlist)) {
...@@ -662,7 +663,8 @@ class assign_grading_table extends table_sql implements renderable { ...@@ -662,7 +663,8 @@ class assign_grading_table extends table_sql implements renderable {
} }
if ($this->is_downloading()) { if ($this->is_downloading()) {
if (isset($markers[$row->allocatedmarker])) { if (isset($markers[$row->allocatedmarker])) {
return fullname($markers[$row->allocatedmarker]); return fullname($markers[$row->allocatedmarker],
has_capability('moodle/site:viewfullnames', $this->assignment->get_context()));
} else { } else {
return ''; return '';
} }
......
...@@ -3548,7 +3548,7 @@ class assign { ...@@ -3548,7 +3548,7 @@ class assign {
$extensionduedate = $flags->extensionduedate; $extensionduedate = $flags->extensionduedate;
} }
$showedit = $this->submissions_open($userid) && ($this->is_any_submission_plugin_enabled()); $showedit = $this->submissions_open($userid) && ($this->is_any_submission_plugin_enabled());
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_course_context()); $viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context());
$usergroups = $this->get_all_groups($user->id); $usergroups = $this->get_all_groups($user->id);
$submissionstatus = new assign_submission_status_compact($instance->allowsubmissionsfromdate, $submissionstatus = new assign_submission_status_compact($instance->allowsubmissionsfromdate,
...@@ -3711,7 +3711,7 @@ class assign { ...@@ -3711,7 +3711,7 @@ class assign {
$user = $DB->get_record('user', array('id' => $userid)); $user = $DB->get_record('user', array('id' => $userid));
if ($user) { if ($user) {
$this->update_effective_access($userid); $this->update_effective_access($userid);
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_course_context()); $viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context());
$usersummary = new assign_user_summary($user, $usersummary = new assign_user_summary($user,
$this->get_course()->id, $this->get_course()->id,
$viewfullnames, $viewfullnames,
...@@ -3746,7 +3746,7 @@ class assign { ...@@ -3746,7 +3746,7 @@ class assign {
$extensionduedate = $flags->extensionduedate; $extensionduedate = $flags->extensionduedate;
} }
$showedit = $this->submissions_open($userid) && ($this->is_any_submission_plugin_enabled()); $showedit = $this->submissions_open($userid) && ($this->is_any_submission_plugin_enabled());
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_course_context()); $viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context());
$usergroups = $this->get_all_groups($user->id); $usergroups = $this->get_all_groups($user->id);
$submissionstatus = new assign_submission_status($instance->allowsubmissionsfromdate, $submissionstatus = new assign_submission_status($instance->allowsubmissionsfromdate,
...@@ -3972,8 +3972,9 @@ class assign { ...@@ -3972,8 +3972,9 @@ class assign {
$markers = get_users_by_capability($this->context, 'mod/assign:grade', '', $sort); $markers = get_users_by_capability($this->context, 'mod/assign:grade', '', $sort);
$markingallocationoptions[''] = get_string('filternone', 'assign'); $markingallocationoptions[''] = get_string('filternone', 'assign');
$markingallocationoptions[ASSIGN_MARKER_FILTER_NO_MARKER] = get_string('markerfilternomarker', 'assign'); $markingallocationoptions[ASSIGN_MARKER_FILTER_NO_MARKER] = get_string('markerfilternomarker', 'assign');
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);
foreach ($markers as $marker) { foreach ($markers as $marker) {
$markingallocationoptions[$marker->id] = fullname($marker); $markingallocationoptions[$marker->id] = fullname($marker, $viewfullnames);
} }
} }
...@@ -4219,12 +4220,13 @@ class assign { ...@@ -4219,12 +4220,13 @@ class assign {
$uniqueid = $user->recordid; $uniqueid = $user->recordid;
} }
if ($hasviewblind) { if ($hasviewblind) {
return get_string('participant', 'assign') . ' ' . $uniqueid . ' (' . fullname($user) . ')'; return get_string('participant', 'assign') . ' ' . $uniqueid . ' (' .
fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context())) . ')';
} else { } else {
return get_string('participant', 'assign') . ' ' . $uniqueid; return get_string('participant', 'assign') . ' ' . $uniqueid;
} }
} else { } else {
return fullname($user); return fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context()));
} }
} }
...@@ -4487,6 +4489,7 @@ class assign { ...@@ -4487,6 +4489,7 @@ class assign {
$usercount = 0; $usercount = 0;
$extrauserfields = get_extra_user_fields($this->get_context()); $extrauserfields = get_extra_user_fields($this->get_context());
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context());
foreach ($userlist as $userid) { foreach ($userlist as $userid) {
if ($usercount >= 5) { if ($usercount >= 5) {
$usershtml .= get_string('moreusers', 'assign', count($userlist) - 5); $usershtml .= get_string('moreusers', 'assign', count($userlist) - 5);
...@@ -4496,8 +4499,7 @@ class assign { ...@@ -4496,8 +4499,7 @@ class assign {
$usershtml .= $this->get_renderer()->render(new assign_user_summary($user, $usershtml .= $this->get_renderer()->render(new assign_user_summary($user,
$this->get_course()->id, $this->get_course()->id,
has_capability('moodle/site:viewfullnames', $viewfullnames,
$this->get_course_context()),
$this->is_blind_marking(), $this->is_blind_marking(),
$this->get_uniqueid_for_user($user->id), $this->get_uniqueid_for_user($user->id),
$extrauserfields, $extrauserfields,
...@@ -4551,6 +4553,7 @@ class assign { ...@@ -4551,6 +4553,7 @@ class assign {
$usercount = 0; $usercount = 0;
$extrauserfields = get_extra_user_fields($this->get_context()); $extrauserfields = get_extra_user_fields($this->get_context());
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context());
foreach ($userlist as $userid) { foreach ($userlist as $userid) {
if ($usercount >= 5) { if ($usercount >= 5) {
$usershtml .= get_string('moreusers', 'assign', count($userlist) - 5); $usershtml .= get_string('moreusers', 'assign', count($userlist) - 5);
...@@ -4560,8 +4563,7 @@ class assign { ...@@ -4560,8 +4563,7 @@ class assign {
$usershtml .= $this->get_renderer()->render(new assign_user_summary($user, $usershtml .= $this->get_renderer()->render(new assign_user_summary($user,
$this->get_course()->id, $this->get_course()->id,
has_capability('moodle/site:viewfullnames', $viewfullnames,
$this->get_course_context()),
$this->is_blind_marking(), $this->is_blind_marking(),
$this->get_uniqueid_for_user($user->id), $this->get_uniqueid_for_user($user->id),
$extrauserfields, $extrauserfields,
...@@ -4708,7 +4710,7 @@ class assign { ...@@ -4708,7 +4710,7 @@ class assign {
if ($flags) { if ($flags) {
$extensionduedate = $flags->extensionduedate; $extensionduedate = $flags->extensionduedate;
} }
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_course_context()); $viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context());
$gradingstatus = $this->get_grading_status($user->id); $gradingstatus = $this->get_grading_status($user->id);
$usergroups = $this->get_all_groups($user->id); $usergroups = $this->get_all_groups($user->id);
...@@ -4820,6 +4822,8 @@ class assign { ...@@ -4820,6 +4822,8 @@ class assign {
} }
} }
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context());
$feedbackstatus = new assign_feedback_status($gradefordisplay, $feedbackstatus = new assign_feedback_status($gradefordisplay,
$gradeddate, $gradeddate,
$grader, $grader,
...@@ -4827,7 +4831,8 @@ class assign { ...@@ -4827,7 +4831,8 @@ class assign {
$grade, $grade,
$this->get_course_module()->id, $this->get_course_module()->id,
$this->get_return_action(), $this->get_return_action(),
$this->get_return_params()); $this->get_return_params(),
$viewfullnames);
return $feedbackstatus; return $feedbackstatus;
} }
return; return;
...@@ -7097,8 +7102,9 @@ class assign { ...@@ -7097,8 +7102,9 @@ class assign {
list($sort, $params) = users_order_by_sql(); list($sort, $params) = users_order_by_sql();
$markers = get_users_by_capability($this->context, 'mod/assign:grade', '', $sort); $markers = get_users_by_capability($this->context, 'mod/assign:grade', '', $sort);
$markerlist = array('' => get_string('choosemarker', 'assign')); $markerlist = array('' => get_string('choosemarker', 'assign'));
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);
foreach ($markers as $marker) { foreach ($markers as $marker) {
$markerlist[$marker->id] = fullname($marker); $markerlist[$marker->id] = fullname($marker, $viewfullnames);
} }
$mform->addElement('select', 'allocatedmarker', get_string('allocatedmarker', 'assign'), $markerlist); $mform->addElement('select', 'allocatedmarker', get_string('allocatedmarker', 'assign'), $markerlist);
$mform->addHelpButton('allocatedmarker', 'allocatedmarker', 'assign'); $mform->addHelpButton('allocatedmarker', 'allocatedmarker', 'assign');
......
...@@ -287,6 +287,8 @@ class assign_feedback_status implements renderable { ...@@ -287,6 +287,8 @@ class assign_feedback_status implements renderable {
public $returnaction = ''; public $returnaction = '';
/** @var array returnparams */ /** @var array returnparams */
public $returnparams = array(); public $returnparams = array();
/** @var bool canviewfullnames */
public $canviewfullnames = false;
/** /**
* Constructor * Constructor
...@@ -298,6 +300,7 @@ class assign_feedback_status implements renderable { ...@@ -298,6 +300,7 @@ class assign_feedback_status implements renderable {
* @param int $coursemoduleid * @param int $coursemoduleid
* @param string $returnaction The action required to return to this page * @param string $returnaction The action required to return to this page
* @param array $returnparams The list of params required to return to this page * @param array $returnparams The list of params required to return to this page
* @param bool $canviewfullnames
*/ */
public function __construct($gradefordisplay, public function __construct($gradefordisplay,
$gradeddate, $gradeddate,
...@@ -306,7 +309,8 @@ class assign_feedback_status implements renderable { ...@@ -306,7 +309,8 @@ class assign_feedback_status implements renderable {
$grade, $grade,
$coursemoduleid, $coursemoduleid,
$returnaction, $returnaction,
$returnparams) { $returnparams,
$canviewfullnames) {
$this->gradefordisplay = $gradefordisplay; $this->gradefordisplay = $gradefordisplay;
$this->gradeddate = $gradeddate; $this->gradeddate = $gradeddate;
$this->grader = $grader; $this->grader = $grader;
...@@ -315,6 +319,7 @@ class assign_feedback_status implements renderable { ...@@ -315,6 +319,7 @@ class assign_feedback_status implements renderable {
$this->coursemoduleid = $coursemoduleid; $this->coursemoduleid = $coursemoduleid;
$this->returnaction = $returnaction; $this->returnaction = $returnaction;
$this->returnparams = $returnparams; $this->returnparams = $returnparams;
$this->canviewfullnames = $canviewfullnames;
} }
} }
......
...@@ -389,7 +389,7 @@ class mod_assign_renderer extends plugin_renderer_base { ...@@ -389,7 +389,7 @@ class mod_assign_renderer extends plugin_renderer_base {
$cell1 = new html_table_cell(get_string('gradedby', 'assign')); $cell1 = new html_table_cell(get_string('gradedby', 'assign'));
$userdescription = $this->output->user_picture($status->grader) . $userdescription = $this->output->user_picture($status->grader) .
$this->output->spacer(array('width'=>30)) . $this->output->spacer(array('width'=>30)) .
fullname($status->grader); fullname($status->grader, $status->canviewfullnames);
$cell2 = new html_table_cell($userdescription); $cell2 = new html_table_cell($userdescription);
$row->cells = array($cell1, $cell2); $row->cells = array($cell1, $cell2);
$t->data[] = $row; $t->data[] = $row;
......
...@@ -82,6 +82,9 @@ abstract class user_selector_base { ...@@ -82,6 +82,9 @@ abstract class user_selector_base {
/** @var int this is used to define maximum number of users visible in list */ /** @var int this is used to define maximum number of users visible in list */
public $maxusersperpage = 100; public $maxusersperpage = 100;
/** @var boolean Whether to override fullname() */
public $viewfullnames = false;
/** /**
* Constructor. Each subclass must have a constructor with this signature. * Constructor. Each subclass must have a constructor with this signature.
* *
...@@ -571,7 +574,7 @@ abstract class user_selector_base { ...@@ -571,7 +574,7 @@ abstract class user_selector_base {
* @return string a string representation of the user. * @return string a string representation of the user.
*/ */
public function output_user($user) { public function output_user($user) {
$out = fullname($user); $out = fullname($user, $this->viewfullnames);
if ($this->extrafields) { if ($this->extrafields) {
$displayfields = array(); $displayfields = array();
foreach ($this->extrafields as $field) { foreach ($this->extrafields as $field) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment