Merge branch 'wip-MDL-31776-master-alternatenamesfix' of git://github.com/abgreeve/moodle

This commit is contained in:
Marina Glancy 2013-07-10 20:16:21 +10:00
commit 51230ba88e
3 changed files with 34 additions and 10 deletions

View File

@ -262,7 +262,8 @@ class grade_report_grader extends grade_report {
}
}
if ($errorstr) {
$user = $DB->get_record('user', array('id' => $userid), 'id, firstname, lastname');
$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->itemname = $gradeitem->get_name();

View File

@ -2684,7 +2684,11 @@ function forum_get_discussions($cm, $forumsort="d.timemodified DESC", $fullpost=
$umfields = "";
$umtable = "";
} else {
$umfields = ", um.firstname AS umfirstname, um.lastname AS umlastname";
$umfields = '';
$umnames = get_all_user_name_fields();
foreach ($umnames as $umname) {
$umfields .= ', um.' . $umname . ' AS um' . $umname;
}
$umtable = " LEFT JOIN {user} um ON (d.usermodified = um.id)";
}
@ -3810,7 +3814,7 @@ function forum_print_discussion_header(&$post, $forum, $group=-1, $datestring=""
$usermodified->id = $post->usermodified;
foreach (get_all_user_name_fields() as $addname) {
$temp = 'um' . $addname;
$usermodified->$addname = $post->$temp;
$usermodified->$addname = $post->$temp;
}
echo '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$post->usermodified.'&amp;course='.$forum->course.'">'.
fullname($usermodified).'</a><br />';

View File

@ -559,8 +559,13 @@ class question_bank_creator_name_column extends question_bank_column_base {
protected function display_content($question, $rowclasses) {
if (!empty($question->creatorfirstname) && !empty($question->creatorlastname)) {
$u = new stdClass();
$u->firstname = $question->creatorfirstname;
$u->lastname = $question->creatorlastname;
$allnames = get_all_user_name_fields();
foreach ($allnames as $allname) {
$tempname = 'creator' . $allname;
if (isset($question->$tempname)) {
$u->$allname = $question->$tempname;
}
}
echo fullname($u);
}
}
@ -570,7 +575,12 @@ class question_bank_creator_name_column extends question_bank_column_base {
}
public function get_required_fields() {
return array('uc.firstname AS creatorfirstname', 'uc.lastname AS creatorlastname');
$allnames = get_all_user_name_fields();
$requiredfields = array();
foreach ($allnames as $allname) {
$requiredfields[] = 'uc.' . $allname . ' AS creator' . $allname;
}
return $requiredfields;
}
public function is_sortable() {
@ -600,8 +610,13 @@ class question_bank_modifier_name_column extends question_bank_column_base {
protected function display_content($question, $rowclasses) {
if (!empty($question->modifierfirstname) && !empty($question->modifierlastname)) {
$u = new stdClass();
$u->firstname = $question->modifierfirstname;
$u->lastname = $question->modifierlastname;
$allnames = get_all_user_name_fields();
foreach ($allnames as $allname) {
$tempname = 'modifier' . $allname;
if (isset($question->$tempname)) {
$u->$allname = $question->$tempname;
}
}
echo fullname($u);
}
}
@ -611,7 +626,12 @@ class question_bank_modifier_name_column extends question_bank_column_base {
}
public function get_required_fields() {
return array('um.firstname AS modifierfirstname', 'um.lastname AS modifierlastname');
$allnames = get_all_user_name_fields();
$requiredfields = array();
foreach ($allnames as $allname) {
$requiredfields[] = 'um.' . $allname . ' AS modifier' . $allname;
}
return $requiredfields;
}
public function is_sortable() {
@ -1387,7 +1407,6 @@ class question_bank_view {
if ($totalnumber == 0) {
return;
}
$questions = $this->load_page_questions($page, $perpage);
echo '<div class="categorypagingbarcontainer">';