3 class block_social_activities
extends block_list
{
5 $this->title
= get_string('blockname','block_social_activities');
6 $this->version
= 2004041800;
9 function applicable_formats() {
10 return array('course-view-social' => true);
13 function get_content() {
16 if ($this->content
!== NULL) {
17 return $this->content
;
20 $this->content
= new stdClass
;
21 $this->content
->items
= array();
22 $this->content
->icons
= array();
23 $this->content
->footer
= '';
25 if (empty($this->instance
)) {
26 return $this->content
;
29 $course = get_record('course', 'id', $this->instance
->pageid
);
30 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
32 // To make our day, we start with an ugly hack
33 global $sections, $mods, $modnames;
35 $section = $sections[0];
36 // That wasn't so bad, was it?
38 $groupbuttons = $course->groupmode
;
39 $groupbuttonslink = (!$course->groupmodeforce
);
40 $viewhiddenactivities = has_capability('moodle/course:viewhiddenactivities', $context);
41 $isediting = isediting($this->instance
->pageid
);
42 $ismoving = ismoving($this->instance
->pageid
);
44 $strmovehere = get_string('movehere');
45 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
46 $strcancel= get_string('cancel');
47 $stractivityclipboard = $USER->activitycopyname
;
49 /// Casting $course->modinfo to string prevents one notice when the field is null
50 $modinfo = unserialize((string)$course->modinfo
);
54 $this->content
->icons
[] = ' <img align="bottom" src="'.$CFG->pixpath
.'/t/move.gif" class="iconsmall" alt="" />';
55 $this->content
->items
[] = $USER->activitycopyname
.' (<a href="'.$CFG->wwwroot
.'/course/mod.php?cancelcopy=true&sesskey='.$USER->sesskey
.'">'.$strcancel.'</a>)';
58 if (!empty($section->sequence
)) {
59 $sectionmods = explode(',', $section->sequence
);
60 foreach ($sectionmods as $modnumber) {
61 if (empty($mods[$modnumber])) {
64 $mod = $mods[$modnumber];
65 if ($isediting && !$ismoving) {
67 if (! $mod->groupmodelink
= $groupbuttonslink) {
68 $mod->groupmode
= $course->groupmode
;
72 $mod->groupmode
= false;
74 $editbuttons = '<br />'.make_editing_buttons($mod, true, true);
78 if ($mod->visible ||
$viewhiddenactivities) {
80 if ($mod->id
== $USER->activitycopy
) {
83 $this->content
->items
[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot
.'/course/mod.php?moveto='.$mod->id
.'&sesskey='.$USER->sesskey
.'">'.
84 '<img height="16" width="80" src="'.$CFG->pixpath
.'/movehere.gif" alt="'.$strmovehere.'" border="0" /></a>';
85 $this->content
->icons
[] = '';
87 $instancename = urldecode($modinfo[$modnumber]->name
);
88 $instancename = format_string($instancename, true, $this->instance
->pageid
);
89 $linkcss = $mod->visible ?
'' : ' class="dimmed" ';
90 if (!empty($modinfo[$modnumber]->extra
)) {
91 $extra = urldecode($modinfo[$modnumber]->extra
);
95 if (!empty($modinfo[$modnumber]->icon
)) {
96 $icon = $CFG->pixpath
.'/'.urldecode($modinfo[$modnumber]->icon
);
98 $icon = $CFG->modpixpath
.'/'.$mod->modname
.'/icon.gif';
101 if ($mod->modname
== 'label') {
102 $this->content
->items
[] = format_text($extra, FORMAT_HTML
).$editbuttons;
103 $this->content
->icons
[] = '';
105 $this->content
->items
[] = '<a title="'.$mod->modfullname
.'" '.$linkcss.' '.$extra.
106 ' href="'.$CFG->wwwroot
.'/mod/'.$mod->modname
.'/view.php?id='.$mod->id
.'">'.$instancename.'</a>'.$editbuttons;
107 $this->content
->icons
[] = '<img src="'.$icon.'" class="icon" alt="'.$mod->modfullname
.'" />';
114 $this->content
->items
[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot
.'/course/mod.php?movetosection='.$section->id
.'&sesskey='.$USER->sesskey
.'">'.
115 '<img height="16" width="80" src="'.$CFG->pixpath
.'/movehere.gif" alt="'.$strmovehere.'" border="0" /></a>';
116 $this->content
->icons
[] = '';
119 if ($isediting && $modnames) {
120 $this->content
->footer
= print_section_add_menus($course, 0, $modnames, true, true);
122 $this->content
->footer
= '';
125 return $this->content
;