Browse files

MDL-20307 - add view fullname capabilities to display fullname in gra…

…debook and participant list
  • Loading branch information...
1 parent df9fe21 commit edef4cd2e15998dd9c0655a604ac474a25c3b0d2 Rossiani Wijaya committed Feb 4, 2010
Showing with 24 additions and 15 deletions.
  1. +9 −8 grade/report/grader/lib.php
  2. +1 −1 mod/assignment/lib.php
  3. +2 −2 mod/quiz/report/overview/report.php
  4. +12 −4 user/index.php
View
17 grade/report/grader/lib.php
@@ -657,7 +657,7 @@ function get_headerhtml() {
$hidden = ' hidden ';
}
- $headerlink = $this->gtree->get_element_header($element, true, $this->get_pref('showactivityicons'), false);
+ $headerlink = $this->gtree->get_element_header($element, true, $this->get_pref('showactivityicons'), false);
//MDL-21088 - IE 7 ignores nowraps on tds or ths so we this in a span with a nowrap on it.
$headerhtml .= '<th class=" '.$columnclass.' '.$type.$catlevel.$hidden.'" scope="col" onclick="set_col(this.cellIndex)"><span>'
.shorten_text($headerlink) . $arrow;
@@ -687,6 +687,7 @@ function get_studentshtml() {
$showuserimage = $this->get_pref('showuserimage');
$showuseridnumber = $this->get_pref('showuseridnumber');
$fixedstudents = $this->is_fixed_students();
+ $canviewfullname = has_capability('moodle/site:viewfullnames', $this->context);
// Preload scale objects for items with a scaleid
$scales_list = '';
@@ -736,19 +737,18 @@ function get_studentshtml() {
$userreportcell = '';
$userreportcellcolspan = '';
if (has_capability('gradereport/'.$CFG->grade_profilereport.':view', $this->context)) {
- $a->user = fullname($user);
+ $a->user = fullname($user, $canviewfullname);
$strgradesforuser = get_string('gradesforuser', 'grades', $a);
$userreportcell = '<th class="header userreport"><a href="'.$CFG->wwwroot.'/grade/report/'.$CFG->grade_profilereport.'/index.php?id='.$this->courseid.'&amp;userid='.$user->id.'">'
.'<img src="'.$CFG->pixpath.'/t/grades.gif" alt="'.$strgradesforuser.'" title="'.$strgradesforuser.'" /></a></th>';
- }
- else {
+ } else {
$userreportcellcolspan = 'colspan=2';
}
$studentshtml .= '<tr class="r'.$this->rowcount++ . $row_classes[$this->rowcount % 2] . '">'
.'<th class="c'.$columncount++.' user" scope="row" onclick="set_row(this.parentNode.rowIndex);" '.$userreportcellcolspan.' >'.$user_pic
.'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$this->course->id.'">'
- .fullname($user)."</a></th>$userreportcell\n";
+ .fullname($user, $canviewfullname)."</a></th>$userreportcell\n";
if ($showuseridnumber) {
$studentshtml .= '<th class="c'.$columncount++.' useridnumber" onclick="set_row(this.parentNode.rowIndex);">'.
@@ -944,7 +944,8 @@ function get_studentnameshtml() {
$strsortdesc = $this->get_lang_string('sortdesc', 'grades');
$strfirstname = $this->get_lang_string('firstname');
$strlastname = $this->get_lang_string('lastname');
-
+ $canviewfullname = has_capability('moodle/site:viewfullnames', $this->context);
+
if ($this->sortitemid === 'lastname') {
if ($this->sortorder == 'ASC') {
$lastarrow = print_arrow('up', $strsortasc, true);
@@ -1023,7 +1024,7 @@ function get_studentnameshtml() {
$userreportcell = '';
$userreportcellcolspan = '';
if (has_capability('gradereport/'.$CFG->grade_profilereport.':view', $this->context)) {
- $a->user = fullname($user);
+ $a->user = fullname($user, $canviewfullname);
$strgradesforuser = get_string('gradesforuser', 'grades', $a);
$userreportcell = '<th class="userreport"><a href="'.$CFG->wwwroot.'/grade/report/'.$CFG->grade_profilereport.'/index.php?id='.$this->courseid.'&amp;userid='.$user->id.'">'
.'<img src="'.$CFG->pixpath.'/t/grades.gif" alt="'.$strgradesforuser.'" title="'.$strgradesforuser.'" /></a></th>';
@@ -1035,7 +1036,7 @@ function get_studentnameshtml() {
$studentshtml .= '<tr class="r'.$this->rowcount++ . $row_classes[$this->rowcount % 2] . '">'
.'<th class="c0 user" scope="row" onclick="set_row(this.parentNode.rowIndex);" '.$userreportcellcolspan.' >'.$user_pic
.'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$this->course->id.'">'
- .fullname($user)."</a></th>$userreportcell\n";
+ .fullname($user, $canviewfullname)."</a></th>$userreportcell\n";
if ($showuseridnumber) {
$studentshtml .= '<th class="c0 useridnumber" onclick="set_row(this.parentNode.rowIndex);">'. $user->idnumber."</th>\n";
View
2 mod/assignment/lib.php
@@ -1300,7 +1300,7 @@ function display_submissions($message='') {
}
}
- $userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&amp;course=' . $course->id . '">' . fullname($auser) . '</a>';
+ $userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&amp;course=' . $course->id . '">' . fullname($auser, has_capability('moodle/site:viewfullnames', $this->context)) . '</a>';
$row = array($picture, $userlink, $grade, $comment, $studentmodified, $teachermodified, $status, $finalgrade);
if ($uses_outcomes) {
$row[] = $outcomes;
View
4 mod/quiz/report/overview/report.php
@@ -466,10 +466,10 @@ function display($quiz, $cm, $course) {
}
if (!$download){
$userlink = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$attempt->userid.
- '&amp;course='.$course->id.'">'.fullname($attempt).'</a>';
+ '&amp;course='.$course->id.'">'.fullname($attempt,has_capability('moodle/site:viewfullnames', $context)).'</a>';
$row[] = $userlink;
} else {
- $row[] = fullname($attempt);
+ $row[] = fullname($attempt, has_capability('moodle/site:viewfullnames', $context));
}
if (in_array('idnumber', $columns)){
View
16 user/index.php
@@ -679,7 +679,7 @@ function checkchecked(form) {
if ($userlist) {
- $usersprinted = array();
+ $usersprinted = array();
while ($user = rs_fetch_next_record($userlist)) {
if (in_array($user->id, $usersprinted)) { /// Prevent duplicates by r.hidden - MDL-13935
continue;
@@ -717,11 +717,19 @@ function checkchecked(form) {
} else {
$usercontext = $user->context;
}
+
+ $contextcanviewdetails = has_capability('moodle/user:viewdetails', $context);
+ $usercontextcanviewdetails = has_capability('moodle/user:viewdetails', $usercontext);
- if ($piclink = ($USER->id == $user->id || has_capability('moodle/user:viewdetails', $context) || has_capability('moodle/user:viewdetails', $usercontext))) {
- $profilelink = '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id.'">'.fullname($user).'</a></strong>';
+ if ($piclink = ($USER->id == $user->id || $contextcanviewdetails || $usercontextcanviewdetails)) {
+ if ($usercontextcanviewdetails) {
+ $canviewfullname = has_capability('moodle/site:viewfullnames', $usercontext);
+ } else {
+ $canviewfullname = has_capability('moodle/site:viewfullnames', $context);
+ }
+ $profilelink = '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id.'">'.fullname($user, $canviewfullname).'</a></strong>';
} else {
- $profilelink = '<strong>'.fullname($user).'</strong>';
+ $profilelink = '<strong>'.fullname($user, has_capability('moodle/site:viewfullnames', $context)).'</strong>';
}
$data = array (

0 comments on commit edef4cd

Please sign in to comment.