3 class block_mentees
extends block_base
{
6 $this->title
= get_string('blockname', 'block_mentees');
7 $this->version
= 2007030900;
10 function applicable_formats() {
11 return array('all' => true);
14 function specialization() {
15 $this->title
= isset($this->config
->title
) ?
$this->config
->title
: get_string('newmenteesblock', 'block_mentees');
18 function instance_allow_multiple() {
22 function get_content() {
25 if ($this->content
!== NULL) {
26 return $this->content
;
29 // get all the mentees, i.e. users you have a direct assignment to
30 if ($usercontexts = get_records_sql("SELECT c.instanceid, c.instanceid, u.firstname, u.lastname
31 FROM {$CFG->prefix}role_assignments ra,
32 {$CFG->prefix}context c,
34 WHERE ra.userid = $USER->id
35 AND ra.contextid = c.id
36 AND c.instanceid = u.id
37 AND c.contextlevel = ".CONTEXT_USER
)) {
39 $this->content
->text
= '<ul>';
40 foreach ($usercontexts as $usercontext) {
41 $this->content
->text
.= '<li><a href="'.$CFG->wwwroot
.'/user/view.php?id='.$usercontext->instanceid
.'&course=1">'.fullname($usercontext).'</a></li>';
43 $this->content
->text
.= '</ul>';
47 $this->content
->footer
= '';
49 return $this->content
;