3 class block_mentees extends block_base {
6 $this->title = get_string('pluginname', 'block_mentees');
7 $this->version = 2007101509;
10 function applicable_formats() {
11 return array('all' => true, 'tag' => false);
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() {
23 global $CFG, $USER, $DB;
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 = $DB->get_records_sql("SELECT c.instanceid, c.instanceid, u.firstname, u.lastname
31 FROM {role_assignments} ra, {context} c, {user} u
33 AND ra.contextid = c.id
34 AND c.instanceid = u.id
35 AND c.contextlevel = ".CONTEXT_USER, array($USER->id))) {
37 $this->content->text = '<ul>';
38 foreach ($usercontexts as $usercontext) {
39 $this->content->text .= '<li><a href="'.$CFG->wwwroot.'/user/view.php?id='.$usercontext->instanceid.'&course='.SITEID.'">'.fullname($usercontext).'</a></li>';
41 $this->content->text .= '</ul>';
44 $this->content->footer = '';
46 return $this->content;