Skip to content

Commit

Permalink
Merge branch 'MDL-55915_master' of https://github.com/rezaies/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Jan 24, 2017
2 parents 0396389 + d636015 commit ae8e8e6
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 22 deletions.
3 changes: 2 additions & 1 deletion enrol/manual/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@
} else {
$useroptions['link'] = false;
}
$viewfullnames = has_capability('moodle/site:viewfullnames', $context);
foreach ($outcome->response['users'] as &$user) {
$user->picture = $OUTPUT->user_picture($user, $useroptions);
$user->fullname = fullname($user);
$user->fullname = fullname($user, $viewfullnames);
$fieldvalues = array();
foreach ($extrafields as $field) {
$fieldvalues[] = s($user->{$field});
Expand Down
3 changes: 3 additions & 0 deletions enrol/manual/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
require_login($course);
$canenrol = has_capability('enrol/manual:enrol', $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
// of existing enrolments which is not possible here.
Expand Down Expand Up @@ -74,7 +75,9 @@
$options = array('enrolid' => $enrolid, 'accesscontext' => $context);

$potentialuserselector = new enrol_manual_potential_participant('addselect', $options);
$potentialuserselector->viewfullnames = $viewfullnames;
$currentuserselector = new enrol_manual_current_participant('removeselect', $options);
$currentuserselector->viewfullnames = $viewfullnames;

// Build the list of options for the enrolment period dropdown.
$unlimitedperiod = get_string('unlimited');
Expand Down
10 changes: 7 additions & 3 deletions grade/report/grader/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function process_data($data) {
array_unshift($mygroups, $this->currentgroup);
}
}
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);

// always initialize all arrays
$queue = array();
Expand Down Expand Up @@ -288,7 +289,7 @@ public function process_data($data) {
$userfields = 'id, ' . get_all_user_name_fields(true);
$user = $DB->get_record('user', array('id' => $userid), $userfields);
$gradestr = new stdClass();
$gradestr->username = fullname($user);
$gradestr->username = fullname($user, $viewfullnames);
$gradestr->itemname = $gradeitem->get_name();
$warnings[] = get_string($errorstr, 'grades', $gradestr);
if ($skip) {
Expand Down Expand Up @@ -611,6 +612,7 @@ public function get_left_rows($displayaverages) {
'moodle/grade:edit'), $this->context);
}
$hasuserreportcell = $canseeuserreport || $canseesingleview;
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);

$strfeedback = $this->get_lang_string("feedback");
$strgrade = $this->get_lang_string('grade');
Expand Down Expand Up @@ -682,7 +684,7 @@ public function get_left_rows($displayaverages) {
$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(
'class' => 'username',
));
Expand Down Expand Up @@ -781,6 +783,8 @@ public function get_right_rows($displayaverages) {
$strexcludedgrades = get_string('excluded', 'grades');
$strerror = get_string('error');

$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);

foreach ($this->gtree->get_levels() as $key => $row) {
$headingrow = new html_table_row();
$headingrow->attributes['class'] = 'heading_name_row';
Expand Down Expand Up @@ -942,7 +946,7 @@ public function get_right_rows($displayaverages) {
$itemrow = new html_table_row();
$itemrow->id = 'user_'.$userid;

$fullname = fullname($user);
$fullname = fullname($user, $viewfullnames);
$jsarguments['users'][$userid] = $fullname;

foreach ($this->gtree->items as $itemid => $unused) {
Expand Down
6 changes: 4 additions & 2 deletions mod/assign/gradingtable.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,9 @@ public function col_allocatedmarker(stdClass $row) {
list($sort, $params) = users_order_by_sql();
$markers = get_users_by_capability($this->assignment->get_context(), 'mod/assign:grade', '', $sort);
$markerlist[0] = get_string('choosemarker', 'assign');
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->assignment->get_context());
foreach ($markers as $marker) {
$markerlist[$marker->id] = fullname($marker);
$markerlist[$marker->id] = fullname($marker, $viewfullnames);
}
}
if (empty($markerlist)) {
Expand All @@ -662,7 +663,8 @@ public function col_allocatedmarker(stdClass $row) {
}
if ($this->is_downloading()) {
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 {
return '';
}
Expand Down
32 changes: 19 additions & 13 deletions mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3548,7 +3548,7 @@ protected function view_single_grading_panel($args) {
$extensionduedate = $flags->extensionduedate;
}
$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);

$submissionstatus = new assign_submission_status_compact($instance->allowsubmissionsfromdate,
Expand Down Expand Up @@ -3711,7 +3711,7 @@ protected function view_single_grade_page($mform) {
$user = $DB->get_record('user', array('id' => $userid));
if ($user) {
$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,
$this->get_course()->id,
$viewfullnames,
Expand Down Expand Up @@ -3746,7 +3746,7 @@ protected function view_single_grade_page($mform) {
$extensionduedate = $flags->extensionduedate;
}
$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);

$submissionstatus = new assign_submission_status($instance->allowsubmissionsfromdate,
Expand Down Expand Up @@ -3972,8 +3972,9 @@ protected function view_grading_table() {
$markers = get_users_by_capability($this->context, 'mod/assign:grade', '', $sort);
$markingallocationoptions[''] = get_string('filternone', 'assign');
$markingallocationoptions[ASSIGN_MARKER_FILTER_NO_MARKER] = get_string('markerfilternomarker', 'assign');
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);
foreach ($markers as $marker) {
$markingallocationoptions[$marker->id] = fullname($marker);
$markingallocationoptions[$marker->id] = fullname($marker, $viewfullnames);
}
}

Expand Down Expand Up @@ -4219,12 +4220,13 @@ public function fullname($user) {
$uniqueid = $user->recordid;
}
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 {
return get_string('participant', 'assign') . ' ' . $uniqueid;
}
} else {
return fullname($user);
return fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context()));
}
}

Expand Down Expand Up @@ -4487,6 +4489,7 @@ protected function view_batch_set_workflow_state($mform) {

$usercount = 0;
$extrauserfields = get_extra_user_fields($this->get_context());
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context());
foreach ($userlist as $userid) {
if ($usercount >= 5) {
$usershtml .= get_string('moreusers', 'assign', count($userlist) - 5);
Expand All @@ -4496,8 +4499,7 @@ protected function view_batch_set_workflow_state($mform) {

$usershtml .= $this->get_renderer()->render(new assign_user_summary($user,
$this->get_course()->id,
has_capability('moodle/site:viewfullnames',
$this->get_course_context()),
$viewfullnames,
$this->is_blind_marking(),
$this->get_uniqueid_for_user($user->id),
$extrauserfields,
Expand Down Expand Up @@ -4551,6 +4553,7 @@ public function view_batch_markingallocation($mform) {

$usercount = 0;
$extrauserfields = get_extra_user_fields($this->get_context());
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context());
foreach ($userlist as $userid) {
if ($usercount >= 5) {
$usershtml .= get_string('moreusers', 'assign', count($userlist) - 5);
Expand All @@ -4560,8 +4563,7 @@ public function view_batch_markingallocation($mform) {

$usershtml .= $this->get_renderer()->render(new assign_user_summary($user,
$this->get_course()->id,
has_capability('moodle/site:viewfullnames',
$this->get_course_context()),
$viewfullnames,
$this->is_blind_marking(),
$this->get_uniqueid_for_user($user->id),
$extrauserfields,
Expand Down Expand Up @@ -4708,7 +4710,7 @@ public function get_assign_submission_status_renderable($user, $showlinks) {
if ($flags) {
$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);
$usergroups = $this->get_all_groups($user->id);
Expand Down Expand Up @@ -4820,14 +4822,17 @@ public function get_assign_feedback_status_renderable($user) {
}
}

$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context());

$feedbackstatus = new assign_feedback_status($gradefordisplay,
$gradeddate,
$grader,
$this->get_feedback_plugins(),
$grade,
$this->get_course_module()->id,
$this->get_return_action(),
$this->get_return_params());
$this->get_return_params(),
$viewfullnames);
return $feedbackstatus;
}
return;
Expand Down Expand Up @@ -7097,8 +7102,9 @@ public function add_grade_form_elements(MoodleQuickForm $mform, stdClass $data,
list($sort, $params) = users_order_by_sql();
$markers = get_users_by_capability($this->context, 'mod/assign:grade', '', $sort);
$markerlist = array('' => get_string('choosemarker', 'assign'));
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);
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->addHelpButton('allocatedmarker', 'allocatedmarker', 'assign');
Expand Down
7 changes: 6 additions & 1 deletion mod/assign/renderable.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ class assign_feedback_status implements renderable {
public $returnaction = '';
/** @var array returnparams */
public $returnparams = array();
/** @var bool canviewfullnames */
public $canviewfullnames = false;

/**
* Constructor
Expand All @@ -298,6 +300,7 @@ class assign_feedback_status implements renderable {
* @param int $coursemoduleid
* @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 bool $canviewfullnames
*/
public function __construct($gradefordisplay,
$gradeddate,
Expand All @@ -306,7 +309,8 @@ public function __construct($gradefordisplay,
$grade,
$coursemoduleid,
$returnaction,
$returnparams) {
$returnparams,
$canviewfullnames) {
$this->gradefordisplay = $gradefordisplay;
$this->gradeddate = $gradeddate;
$this->grader = $grader;
Expand All @@ -315,6 +319,7 @@ public function __construct($gradefordisplay,
$this->coursemoduleid = $coursemoduleid;
$this->returnaction = $returnaction;
$this->returnparams = $returnparams;
$this->canviewfullnames = $canviewfullnames;
}
}

Expand Down
2 changes: 1 addition & 1 deletion mod/assign/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public function render_assign_feedback_status(assign_feedback_status $status) {
$cell1 = new html_table_cell(get_string('gradedby', 'assign'));
$userdescription = $this->output->user_picture($status->grader) .
$this->output->spacer(array('width'=>30)) .
fullname($status->grader);
fullname($status->grader, $status->canviewfullnames);
$cell2 = new html_table_cell($userdescription);
$row->cells = array($cell1, $cell2);
$t->data[] = $row;
Expand Down
5 changes: 4 additions & 1 deletion user/selector/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ abstract class user_selector_base {
/** @var int this is used to define maximum number of users visible in list */
public $maxusersperpage = 100;

/** @var boolean Whether to override fullname() */
public $viewfullnames = false;

/**
* Constructor. Each subclass must have a constructor with this signature.
*
Expand Down Expand Up @@ -571,7 +574,7 @@ protected function output_optgroup($groupname, $users, $select) {
* @return string a string representation of the user.
*/
public function output_user($user) {
$out = fullname($user);
$out = fullname($user, $this->viewfullnames);
if ($this->extrafields) {
$displayfields = array();
foreach ($this->extrafields as $field) {
Expand Down

0 comments on commit ae8e8e6

Please sign in to comment.