Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/blocks/mentees/block_mentees.php
Go to the documentation of this file.
00001 <?php
00002 
00003 class block_mentees extends block_base {
00004 
00005     function init() {
00006         $this->title = get_string('pluginname', 'block_mentees');
00007     }
00008 
00009     function applicable_formats() {
00010         return array('all' => true, 'tag' => false);
00011     }
00012 
00013     function specialization() {
00014         $this->title = isset($this->config->title) ? $this->config->title : get_string('newmenteesblock', 'block_mentees');
00015     }
00016 
00017     function instance_allow_multiple() {
00018         return true;
00019     }
00020 
00021     function get_content() {
00022         global $CFG, $USER, $DB;
00023 
00024         if ($this->content !== NULL) {
00025             return $this->content;
00026         }
00027 
00028         $this->content = new stdClass();
00029 
00030         // get all the mentees, i.e. users you have a direct assignment to
00031         if ($usercontexts = $DB->get_records_sql("SELECT c.instanceid, c.instanceid, u.firstname, u.lastname
00032                                                     FROM {role_assignments} ra, {context} c, {user} u
00033                                                    WHERE ra.userid = ?
00034                                                          AND ra.contextid = c.id
00035                                                          AND c.instanceid = u.id
00036                                                          AND c.contextlevel = ".CONTEXT_USER, array($USER->id))) {
00037 
00038             $this->content->text = '<ul>';
00039             foreach ($usercontexts as $usercontext) {
00040                 $this->content->text .= '<li><a href="'.$CFG->wwwroot.'/user/view.php?id='.$usercontext->instanceid.'&amp;course='.SITEID.'">'.fullname($usercontext).'</a></li>';
00041             }
00042             $this->content->text .= '</ul>';
00043         }
00044 
00045         $this->content->footer = '';
00046 
00047         return $this->content;
00048     }
00049 }
00050 
 All Data Structures Namespaces Files Functions Variables Enumerations