|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 class block_activity_modules extends block_list { 00004 function init() { 00005 $this->title = get_string('pluginname', 'block_activity_modules'); 00006 } 00007 00008 function get_content() { 00009 global $CFG, $DB, $OUTPUT; 00010 00011 if($this->content !== NULL) { 00012 return $this->content; 00013 } 00014 00015 $this->content = new stdClass; 00016 $this->content->items = array(); 00017 $this->content->icons = array(); 00018 $this->content->footer = ''; 00019 00020 $course = $this->page->course; 00021 00022 require_once($CFG->dirroot.'/course/lib.php'); 00023 00024 $modinfo = get_fast_modinfo($course); 00025 $modfullnames = array(); 00026 00027 $archetypes = array(); 00028 00029 foreach($modinfo->cms as $cm) { 00030 // Exclude activities which are not visible or have no link (=label) 00031 if (!$cm->uservisible or !$cm->has_view()) { 00032 continue; 00033 } 00034 if (array_key_exists($cm->modname, $modfullnames)) { 00035 continue; 00036 } 00037 if (!array_key_exists($cm->modname, $archetypes)) { 00038 $archetypes[$cm->modname] = plugin_supports('mod', $cm->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER); 00039 } 00040 if ($archetypes[$cm->modname] == MOD_ARCHETYPE_RESOURCE) { 00041 if (!array_key_exists('resources', $modfullnames)) { 00042 $modfullnames['resources'] = get_string('resources'); 00043 } 00044 } else { 00045 $modfullnames[$cm->modname] = $cm->modplural; 00046 } 00047 } 00048 00049 collatorlib::asort($modfullnames); 00050 00051 foreach ($modfullnames as $modname => $modfullname) { 00052 if ($modname === 'resources') { 00053 $icon = '<img src="'.$OUTPUT->pix_url('f/html') . '" class="icon" alt="" /> '; 00054 $this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/resources.php?id='.$course->id.'">'.$icon.$modfullname.'</a>'; 00055 } else { 00056 $icon = '<img src="'.$OUTPUT->pix_url('icon', $modname) . '" class="icon" alt="" /> '; 00057 $this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$course->id.'">'.$icon.$modfullname.'</a>'; 00058 } 00059 } 00060 00061 return $this->content; 00062 } 00063 00064 function applicable_formats() { 00065 return array('all' => true, 'mod' => false, 'my' => false, 'admin' => false, 00066 'tag' => false); 00067 } 00068 } 00069 00070