|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 class block_social_activities extends block_list { 00004 function init(){ 00005 $this->title = get_string('pluginname', 'block_social_activities'); 00006 } 00007 00008 function applicable_formats() { 00009 return array('course-view-social' => true); 00010 } 00011 00012 function get_content() { 00013 global $USER, $CFG, $DB, $OUTPUT; 00014 00015 if ($this->content !== NULL) { 00016 return $this->content; 00017 } 00018 00019 $this->content = new stdClass(); 00020 $this->content->items = array(); 00021 $this->content->icons = array(); 00022 $this->content->footer = ''; 00023 00024 if (empty($this->instance)) { 00025 return $this->content; 00026 } 00027 00028 $course = $this->page->course; 00029 00030 require_once($CFG->dirroot.'/course/lib.php'); 00031 00032 $context = get_context_instance(CONTEXT_COURSE, $course->id); 00033 $isediting = $this->page->user_is_editing() && has_capability('moodle/course:manageactivities', $context); 00034 $modinfo = get_fast_modinfo($course); 00035 00037 if (!$isediting) { 00038 if (!empty($modinfo->sections[0])) { 00039 $options = array('overflowdiv'=>true); 00040 foreach($modinfo->sections[0] as $cmid) { 00041 $cm = $modinfo->cms[$cmid]; 00042 if (!$cm->uservisible) { 00043 continue; 00044 } 00045 00046 list($content, $instancename) = 00047 get_print_section_cm_text($cm, $course); 00048 00049 if (!($url = $cm->get_url())) { 00050 $this->content->items[] = $content; 00051 $this->content->icons[] = ''; 00052 } else { 00053 $linkcss = $cm->visible ? '' : ' class="dimmed" '; 00054 //Accessibility: incidental image - should be empty Alt text 00055 $icon = '<img src="' . $cm->get_icon_url() . '" class="icon" alt="" /> '; 00056 $this->content->items[] = '<a title="'.$cm->modplural.'" '.$linkcss.' '.$cm->extra. 00057 ' href="' . $url . '">' . $icon . $instancename . '</a>'; 00058 } 00059 } 00060 } 00061 return $this->content; 00062 } 00063 00064 00066 $ismoving = ismoving($course->id); 00067 $sections = get_all_sections($course->id); 00068 00069 if(!empty($sections) && isset($sections[0])) { 00070 $section = $sections[0]; 00071 } 00072 00073 if (!empty($section)) { 00074 get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); 00075 } 00076 00077 $groupbuttons = $course->groupmode; 00078 $groupbuttonslink = (!$course->groupmodeforce); 00079 00080 if ($ismoving) { 00081 $strmovehere = get_string('movehere'); 00082 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'")); 00083 $strcancel= get_string('cancel'); 00084 $stractivityclipboard = $USER->activitycopyname; 00085 } 00087 $editbuttons = ''; 00088 00089 if ($ismoving) { 00090 $this->content->icons[] = ' <img align="bottom" src="'.$OUTPUT->pix_url('t/move') . '" class="iconsmall" alt="" />'; 00091 $this->content->items[] = $USER->activitycopyname.' (<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&sesskey='.sesskey().'">'.$strcancel.'</a>)'; 00092 } 00093 00094 if (!empty($section) && !empty($section->sequence)) { 00095 $sectionmods = explode(',', $section->sequence); 00096 $options = array('overflowdiv'=>true); 00097 foreach ($sectionmods as $modnumber) { 00098 if (empty($mods[$modnumber])) { 00099 continue; 00100 } 00101 $mod = $mods[$modnumber]; 00102 if (!$ismoving) { 00103 if ($groupbuttons) { 00104 if (! $mod->groupmodelink = $groupbuttonslink) { 00105 $mod->groupmode = $course->groupmode; 00106 } 00107 00108 } else { 00109 $mod->groupmode = false; 00110 } 00111 $editbuttons = '<br />'.make_editing_buttons($mod, true, true); 00112 } else { 00113 $editbuttons = ''; 00114 } 00115 if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $context)) { 00116 if ($ismoving) { 00117 if ($mod->id == $USER->activitycopy) { 00118 continue; 00119 } 00120 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&sesskey='.sesskey().'">'. 00121 '<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>'; 00122 $this->content->icons[] = ''; 00123 } 00124 list($content, $instancename) = 00125 get_print_section_cm_text($modinfo->cms[$modnumber], $course); 00126 00127 $linkcss = $mod->visible ? '' : ' class="dimmed" '; 00128 00129 if (!($url = $mod->get_url())) { 00130 $this->content->items[] = $content . $editbuttons; 00131 $this->content->icons[] = ''; 00132 } else { 00133 //Accessibility: incidental image - should be empty Alt text 00134 $icon = '<img src="' . $mod->get_icon_url() . '" class="icon" alt="" /> '; 00135 $this->content->items[] = '<a title="' . $mod->modfullname . '" ' . $linkcss . ' ' . $mod->extra . 00136 ' href="' . $url . '">' . $icon . $instancename . '</a>' . $editbuttons; 00137 } 00138 } 00139 } 00140 } 00141 00142 if ($ismoving) { 00143 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&sesskey='.sesskey().'">'. 00144 '<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>'; 00145 $this->content->icons[] = ''; 00146 } 00147 00148 if ($modnames) { 00149 $this->content->footer = print_section_add_menus($course, 0, $modnames, true, true); 00150 } else { 00151 $this->content->footer = ''; 00152 } 00153 00154 return $this->content; 00155 } 00156 } 00157 00158