First Official realease of the "Blocks System".
[moodle.git] / blocks / social_activities / block_social_activities.php
CommitLineData
0f3fe4b6 1<?php //$Id$
2
3class CourseBlock_social_activities extends MoodleBlock {
4 function CourseBlock_social_activities ($course) {
5 $this->title = get_string('blockname','block_social_activities');
6 $this->content_type = BLOCK_TYPE_LIST;
7 $this->course = $course;
8 $this->version = 2004041800;
9 }
10
11 function applicable_formats() {
12 return COURSE_FORMAT_SOCIAL;
13 }
14
15 function get_content() {
16 global $USER, $CFG;
17
18 if($this->content !== NULL) {
19 return $this->content;
20 }
21
22 $this->content = New object;
23 $this->content->items = array();
24 $this->content->icons = array();
25 $this->content->footer = '';
26
27 // To make our day, we start with an ugly hack
28 global $sections, $mods, $modnames;
29
30 $section = $sections[0];
31 // That wasn't so bad, was it?
32
33 $groupbuttons = $this->course->groupmode;
34 $groupbuttonslink = (!$this->course->groupmodeforce);
35 $isteacher = isteacher($this->course->id);
36 $isediting = isediting($this->course->id);
37 $ismoving = ismoving($this->course->id);
38 if ($ismoving) {
39 $strmovehere = get_string('movehere');
40 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
41 $strcancel= get_string('cancel');
42 $stractivityclipboard = $USER->activitycopyname;
43 }
44
45 $modinfo = unserialize($this->course->modinfo);
46 $editbuttons = '';
47
48 if ($ismoving) {
49 $this->content->items[] = '&nbsp;<img align="bottom" src="'.$CFG->pixpath.'/t/move.gif" height="11" width="11">';
50 $this->content->icons[] = $USER->activitycopyname.'&nbsp;(<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true">'.$strcancel.'</a>)';
51 }
52
53 if (!empty($section->sequence)) {
54 $sectionmods = explode(',', $section->sequence);
55 foreach ($sectionmods as $modnumber) {
56 if (empty($mods[$modnumber])) {
57 continue;
58 }
59 $mod = $mods[$modnumber];
60 if ($isediting && !$ismoving) {
61 if ($groupbuttons) {
62 if (! $mod->groupmodelink = $groupbuttonslink) {
63 $mod->groupmode = $this->course->groupmode;
64 }
65
66 } else {
67 $mod->groupmode = false;
68 }
69 $editbuttons = '<br />'.make_editing_buttons($mod, true, true);
70 } else {
71 $editbuttons = '';
72 }
73 if ($mod->visible || $isteacher) {
74 if ($ismoving) {
75 if ($mod->id == $USER->activitycopy) {
76 continue;
77 }
78 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'">'.
79 '<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" border="0"></a>';
80 $this->content->icons[] = '';
81 }
82 $instancename = urldecode($modinfo[$modnumber]->name);
83 if (!empty($CFG->filterall)) {
84 $instancename = filter_text('<nolink>'.$instancename.'</nolink>', $this->course->id);
85 }
86 $linkcss = $mod->visible ? '' : ' class="dimmed" ';
87 if (!empty($modinfo[$modnumber]->extra)) {
88 $extra = urldecode($modinfo[$modnumber]->extra);
89 } else {
90 $extra = '';
91 }
92
93 if ($mod->modname == 'label') {
94 $this->content->items[] = format_text($extra, FORMAT_HTML).$editbuttons;
95 $this->content->icons[] = '';
96 } else {
97 $this->content->items[] = '<a title="'.$mod->modfullname.'" '.$linkcss.' '.$extra.
98 ' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.$instancename.'</a>'.$editbuttons;
99 $this->content->icons[] = '<img src="'.$CFG->modpixpath.'/'.$mod->modname.'/icon.gif" height="16" width="16" alt="'.$mod->modfullname.'">';
100 }
101 }
102 }
103 }
104
105 if ($ismoving) {
106 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'">'.
107 '<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" border="0"></a>';
108 $this->content->icons[] = '';
109 }
110
111 if ($isediting && $modnames) {
112 $this->content->footer = '<div style="text-align: right;">'.
113 popup_form($CFG->wwwroot.'/course/mod.php?id='.$this->course->id.'&amp;section='.$section->section.'&amp;add=',
114 $modnames, 'section0', '', get_string('add').'...', 'mods', get_string('activities'), true) . '</div>';
115 } else {
116 $this->content->footer = '';
117 }
118
119 return $this->content;
120 }
121}
122
123?>