I inherited this code and have very little php coding experience. I want to be able to sort by fullname or lastname. Can anyone point me in the right direction? I’ve spent the past couple hours trying things and only coming up with errors.
[php]
function get_content() {
global $CFG, $USER, $DB;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
// get all the mentees, i.e. users you have a direct assignment to
$allusernames = get_all_user_name_fields(true, 'u');
if ($usercontexts = $DB->get_records_sql("SELECT c.instanceid, c.instanceid, $allusernames
FROM {role_assignments} ra, {context} c, {user} u
WHERE ra.userid = ?
AND ra.contextid = c.id
AND c.instanceid = u.id
AND c.contextlevel = ".CONTEXT_USER, array($USER->id))) {
$this->content->text = '<ul>';
foreach ($usercontexts as $usercontext) {
$this->content->text .= '<li><a href="'.$CFG->wwwroot.'/blocks/mentees_report/view.php?id='.$usercontext->instanceid.'">'.fullname($usercontext).'</a></li>';
}
$this->content->text .= '</ul>';
}
$this->content->footer = '';
return $this->content;
}
[/php]