MDL-10496:
[moodle-linuxchix.git] / blocks / mentees / block_mentees.php
blob7ea3e91f9c3514bca8f3a1aca2f64858d7222c6d
1 <?php
3 class block_mentees extends block_base {
5 function init() {
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() {
19 return true;
22 function get_content() {
24 global $CFG, $USER;
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,
33 {$CFG->prefix}user u
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.'&amp;course=1">'.fullname($usercontext).'</a></li>';
43 $this->content->text .= '</ul>';
47 $this->content->footer = '';
49 return $this->content;