MDL-31794 theme_formalwhite: Fixed up tabs
[moodle.git] / blocks / social_activities / block_social_activities.php
blob886e888395133da7fc3f524e0cf5a66ca2d17901
1 <?php
3 class block_social_activities extends block_list {
4 function init(){
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 = get_context_instance(CONTEXT_COURSE, $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
37 if (!$isediting) {
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) {
43 continue;
46 list($content, $instancename) =
47 get_print_section_cm_text($cm, $course);
49 if (!($url = $cm->get_url())) {
50 $this->content->items[] = $content;
51 $this->content->icons[] = '';
52 } else {
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="" />&nbsp;';
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 $sections = get_all_sections($course->id);
69 if(!empty($sections) && isset($sections[0])) {
70 $section = $sections[0];
73 if (!empty($section)) {
74 get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
77 $groupbuttons = $course->groupmode;
78 $groupbuttonslink = (!$course->groupmodeforce);
80 if ($ismoving) {
81 $strmovehere = get_string('movehere');
82 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
83 $strcancel= get_string('cancel');
84 $stractivityclipboard = $USER->activitycopyname;
86 /// Casting $course->modinfo to string prevents one notice when the field is null
87 $editbuttons = '';
89 if ($ismoving) {
90 $this->content->icons[] = '&nbsp;<img align="bottom" src="'.$OUTPUT->pix_url('t/move') . '" class="iconsmall" alt="" />';
91 $this->content->items[] = $USER->activitycopyname.'&nbsp;(<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&amp;sesskey='.sesskey().'">'.$strcancel.'</a>)';
94 if (!empty($section) && !empty($section->sequence)) {
95 $sectionmods = explode(',', $section->sequence);
96 $options = array('overflowdiv'=>true);
97 foreach ($sectionmods as $modnumber) {
98 if (empty($mods[$modnumber])) {
99 continue;
101 $mod = $mods[$modnumber];
102 if (!$ismoving) {
103 if ($groupbuttons) {
104 if (! $mod->groupmodelink = $groupbuttonslink) {
105 $mod->groupmode = $course->groupmode;
108 } else {
109 $mod->groupmode = false;
111 $editbuttons = '<br />'.make_editing_buttons($mod, true, true);
112 } else {
113 $editbuttons = '';
115 if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $context)) {
116 if ($ismoving) {
117 if ($mod->id == $USER->activitycopy) {
118 continue;
120 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&amp;sesskey='.sesskey().'">'.
121 '<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>';
122 $this->content->icons[] = '';
124 list($content, $instancename) =
125 get_print_section_cm_text($modinfo->cms[$modnumber], $course);
127 $linkcss = $mod->visible ? '' : ' class="dimmed" ';
129 if (!($url = $mod->get_url())) {
130 $this->content->items[] = $content . $editbuttons;
131 $this->content->icons[] = '';
132 } else {
133 //Accessibility: incidental image - should be empty Alt text
134 $icon = '<img src="' . $mod->get_icon_url() . '" class="icon" alt="" />&nbsp;';
135 $this->content->items[] = '<a title="' . $mod->modfullname . '" ' . $linkcss . ' ' . $mod->extra .
136 ' href="' . $url . '">' . $icon . $instancename . '</a>' . $editbuttons;
142 if ($ismoving) {
143 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&amp;sesskey='.sesskey().'">'.
144 '<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>';
145 $this->content->icons[] = '';
148 if ($modnames) {
149 $this->content->footer = print_section_add_menus($course, 0, $modnames, true, true);
150 } else {
151 $this->content->footer = '';
154 return $this->content;