3 class block_social_activities extends block_list {
5 $this->title = get_string('pluginname', 'block_social_activities');
8 function applicable_formats() {
9 return array('course-view-social' => true);
12 function get_content() {
13 global $USER, $CFG, $DB, $OUTPUT;
15 if ($this->content !== NULL) {
16 return $this->content;
19 $this->content = new stdClass();
20 $this->content->items = array();
21 $this->content->icons = array();
22 $this->content->footer = '';
24 if (empty($this->instance)) {
25 return $this->content;
28 $course = $this->page->course;
30 require_once($CFG->dirroot.'/course/lib.php');
32 $context = context_course::instance($course->id);
33 $isediting = $this->page->user_is_editing() && has_capability('moodle/course:manageactivities', $context);
34 $modinfo = get_fast_modinfo($course);
36 /// extra fast view mode
38 if (!empty($modinfo->sections[0])) {
39 $options = array('overflowdiv'=>true);
40 foreach($modinfo->sections[0] as $cmid) {
41 $cm = $modinfo->cms[$cmid];
42 if (!$cm->uservisible) {
46 $content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
47 $instancename = $cm->get_formatted_name();
49 if (!($url = $cm->get_url())) {
50 $this->content->items[] = $content;
51 $this->content->icons[] = '';
53 $linkcss = $cm->visible ? '' : ' class="dimmed" ';
54 //Accessibility: incidental image - should be empty Alt text
55 $icon = '<img src="' . $cm->get_icon_url() . '" class="icon" alt="" /> ';
56 $this->content->items[] = '<a title="'.$cm->modplural.'" '.$linkcss.' '.$cm->extra.
57 ' href="' . $url . '">' . $icon . $instancename . '</a>';
61 return $this->content;
65 /// slow & hacky editing mode
66 $ismoving = ismoving($course->id);
67 $modinfo = get_fast_modinfo($course);
68 $section = $modinfo->get_section_info(0);
70 $groupbuttons = $course->groupmode;
71 $groupbuttonslink = (!$course->groupmodeforce);
74 $strmovehere = get_string('movehere');
75 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
76 $strcancel= get_string('cancel');
77 $stractivityclipboard = $USER->activitycopyname;
79 /// Casting $course->modinfo to string prevents one notice when the field is null
83 $this->content->icons[] = ' <img align="bottom" src="'.$OUTPUT->pix_url('t/move') . '" class="iconsmall" alt="" />';
84 $this->content->items[] = $USER->activitycopyname.' (<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&sesskey='.sesskey().'">'.$strcancel.'</a>)';
87 if (!empty($modinfo->sections[0])) {
88 $options = array('overflowdiv'=>true);
89 foreach ($modinfo->sections[0] as $modnumber) {
90 $mod = $modinfo->cms[$modnumber];
91 if (!$mod->uservisible) {
96 if (! $mod->groupmodelink = $groupbuttonslink) {
97 $mod->groupmode = $course->groupmode;
101 $mod->groupmode = false;
103 $editbuttons = '<br />'.make_editing_buttons($mod, true, true);
107 if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $context)) {
109 if ($mod->id == $USER->activitycopy) {
112 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&sesskey='.sesskey().'">'.
113 '<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>';
114 $this->content->icons[] = '';
116 $content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
117 $instancename = $mod->get_formatted_name();
119 $linkcss = $mod->visible ? '' : ' class="dimmed" ';
121 if (!($url = $mod->get_url())) {
122 $this->content->items[] = $content . $editbuttons;
123 $this->content->icons[] = '';
125 //Accessibility: incidental image - should be empty Alt text
126 $icon = '<img src="' . $mod->get_icon_url() . '" class="icon" alt="" /> ';
127 $this->content->items[] = '<a title="' . $mod->modfullname . '" ' . $linkcss . ' ' . $mod->extra .
128 ' href="' . $url . '">' . $icon . $instancename . '</a>' . $editbuttons;
135 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&sesskey='.sesskey().'">'.
136 '<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>';
137 $this->content->icons[] = '';
140 $this->content->footer = print_section_add_menus($course, 0, null, true, true);
142 return $this->content;