MDL-22054 converting block name strings to pluginname
[moodle.git] / blocks / mentees / block_mentees.php
CommitLineData
521296f5 1<?php
2
3class block_mentees extends block_base {
4
5 function init() {
2c4d7e2c 6 $this->title = get_string('pluginname', 'block_mentees');
433c242f 7 $this->version = 2007101509;
521296f5 8 }
9
10 function applicable_formats() {
1d2c7142 11 return array('all' => true, 'tag' => false);
521296f5 12 }
13
14 function specialization() {
15 $this->title = isset($this->config->title) ? $this->config->title : get_string('newmenteesblock', 'block_mentees');
16 }
17
18 function instance_allow_multiple() {
19 return true;
20 }
21
22 function get_content() {
f28f2d90 23 global $CFG, $USER, $DB;
24
521296f5 25 if ($this->content !== NULL) {
26 return $this->content;
27 }
28
29 // get all the mentees, i.e. users you have a direct assignment to
f28f2d90 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
32 WHERE ra.userid = ?
33 AND ra.contextid = c.id
34 AND c.instanceid = u.id
35 AND c.contextlevel = ".CONTEXT_USER, array($USER->id))) {
4ca6cfbf 36
521296f5 37 $this->content->text = '<ul>';
38 foreach ($usercontexts as $usercontext) {
cd44c2b7 39 $this->content->text .= '<li><a href="'.$CFG->wwwroot.'/user/view.php?id='.$usercontext->instanceid.'&amp;course='.SITEID.'">'.fullname($usercontext).'</a></li>';
521296f5 40 }
e92c286c 41 $this->content->text .= '</ul>';
521296f5 42 }
e92c286c 43
521296f5 44 $this->content->footer = '';
45
46 return $this->content;
47 }
48}
4ca6cfbf 49