2009-11-01 12:00:47 +00:00
|
|
|
<?php
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2005-03-02 19:22:26 +00:00
|
|
|
class block_social_activities extends block_list {
|
2004-10-19 21:04:28 +00:00
|
|
|
function init(){
|
2010-04-11 11:48:38 +00:00
|
|
|
$this->title = get_string('pluginname', 'block_social_activities');
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function applicable_formats() {
|
2005-02-08 02:59:44 +00:00
|
|
|
return array('course-view-social' => true);
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_content() {
|
2009-07-02 10:53:31 +00:00
|
|
|
global $USER, $CFG, $DB, $OUTPUT;
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-07-29 18:01:32 +00:00
|
|
|
if ($this->content !== NULL) {
|
2004-04-18 23:20:53 +00:00
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
2010-09-21 08:10:17 +00:00
|
|
|
$this->content = new stdClass();
|
2004-04-18 23:20:53 +00:00
|
|
|
$this->content->items = array();
|
|
|
|
$this->content->icons = array();
|
|
|
|
$this->content->footer = '';
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
if (empty($this->instance)) {
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
2009-05-06 09:15:33 +00:00
|
|
|
$course = $this->page->course;
|
2008-01-24 20:33:50 +00:00
|
|
|
|
|
|
|
require_once($CFG->dirroot.'/course/lib.php');
|
|
|
|
|
2012-07-23 15:55:09 +08:00
|
|
|
$context = context_course::instance($course->id);
|
2009-05-06 09:28:26 +00:00
|
|
|
$isediting = $this->page->user_is_editing() && has_capability('moodle/course:manageactivities', $context);
|
2008-01-24 20:33:50 +00:00
|
|
|
$modinfo = get_fast_modinfo($course);
|
|
|
|
|
|
|
|
/// extra fast view mode
|
|
|
|
if (!$isediting) {
|
|
|
|
if (!empty($modinfo->sections[0])) {
|
2010-11-05 02:53:47 +00:00
|
|
|
$options = array('overflowdiv'=>true);
|
2008-01-24 20:33:50 +00:00
|
|
|
foreach($modinfo->sections[0] as $cmid) {
|
|
|
|
$cm = $modinfo->cms[$cmid];
|
|
|
|
if (!$cm->uservisible) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-01-26 10:29:16 +00:00
|
|
|
|
2012-12-11 14:07:42 +08:00
|
|
|
$content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
|
|
|
|
$instancename = $cm->get_formatted_name();
|
2011-01-26 10:29:16 +00:00
|
|
|
|
|
|
|
if (!($url = $cm->get_url())) {
|
|
|
|
$this->content->items[] = $content;
|
2008-01-24 20:33:50 +00:00
|
|
|
$this->content->icons[] = '';
|
|
|
|
} else {
|
|
|
|
$linkcss = $cm->visible ? '' : ' class="dimmed" ';
|
|
|
|
//Accessibility: incidental image - should be empty Alt text
|
2011-01-26 10:29:16 +00:00
|
|
|
$icon = '<img src="' . $cm->get_icon_url() . '" class="icon" alt="" /> ';
|
2010-08-20 06:29:22 +00:00
|
|
|
$this->content->items[] = '<a title="'.$cm->modplural.'" '.$linkcss.' '.$cm->extra.
|
2011-01-26 10:29:16 +00:00
|
|
|
' href="' . $url . '">' . $icon . $instancename . '</a>';
|
2008-01-24 20:33:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-29 09:39:42 +12:00
|
|
|
// Slow & hacky editing mode.
|
|
|
|
/** @var core_course_renderer $courserenderer */
|
2012-12-14 11:32:21 +08:00
|
|
|
$courserenderer = $this->page->get_renderer('core', 'course');
|
2009-05-06 09:15:33 +00:00
|
|
|
$ismoving = ismoving($course->id);
|
2012-09-13 16:18:11 +08:00
|
|
|
$modinfo = get_fast_modinfo($course);
|
|
|
|
$section = $modinfo->get_section_info(0);
|
2004-04-18 23:20:53 +00:00
|
|
|
|
|
|
|
if ($ismoving) {
|
|
|
|
$strmovehere = get_string('movehere');
|
|
|
|
$strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
|
|
|
|
$strcancel= get_string('cancel');
|
|
|
|
$stractivityclipboard = $USER->activitycopyname;
|
|
|
|
}
|
|
|
|
$editbuttons = '';
|
|
|
|
|
|
|
|
if ($ismoving) {
|
2009-12-16 21:50:45 +00:00
|
|
|
$this->content->icons[] = ' <img align="bottom" src="'.$OUTPUT->pix_url('t/move') . '" class="iconsmall" alt="" />';
|
2009-01-02 10:36:25 +00:00
|
|
|
$this->content->items[] = $USER->activitycopyname.' (<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&sesskey='.sesskey().'">'.$strcancel.'</a>)';
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
2012-09-13 16:18:11 +08:00
|
|
|
if (!empty($modinfo->sections[0])) {
|
2010-11-05 02:53:47 +00:00
|
|
|
$options = array('overflowdiv'=>true);
|
2012-09-13 16:18:11 +08:00
|
|
|
foreach ($modinfo->sections[0] as $modnumber) {
|
|
|
|
$mod = $modinfo->cms[$modnumber];
|
|
|
|
if (!$mod->uservisible) {
|
2004-04-18 23:20:53 +00:00
|
|
|
continue;
|
|
|
|
}
|
2008-01-24 20:33:50 +00:00
|
|
|
if (!$ismoving) {
|
2012-12-14 11:32:21 +08:00
|
|
|
$actions = course_get_cm_edit_actions($mod, -1);
|
|
|
|
$editbuttons = '<br />'.
|
2013-07-29 09:39:42 +12:00
|
|
|
$courserenderer->course_section_cm_edit_actions($actions, $mod);
|
2004-04-18 23:20:53 +00:00
|
|
|
} else {
|
|
|
|
$editbuttons = '';
|
|
|
|
}
|
2008-01-24 20:33:50 +00:00
|
|
|
if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $context)) {
|
2004-04-18 23:20:53 +00:00
|
|
|
if ($ismoving) {
|
|
|
|
if ($mod->id == $USER->activitycopy) {
|
|
|
|
continue;
|
|
|
|
}
|
2009-01-02 10:36:25 +00:00
|
|
|
$this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&sesskey='.sesskey().'">'.
|
2009-12-16 21:50:45 +00:00
|
|
|
'<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>';
|
2004-04-18 23:20:53 +00:00
|
|
|
$this->content->icons[] = '';
|
|
|
|
}
|
2012-12-11 14:07:42 +08:00
|
|
|
$content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
|
|
|
|
$instancename = $mod->get_formatted_name();
|
2011-01-26 10:29:16 +00:00
|
|
|
|
2004-04-18 23:20:53 +00:00
|
|
|
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
|
|
|
|
|
2011-01-26 10:29:16 +00:00
|
|
|
if (!($url = $mod->get_url())) {
|
|
|
|
$this->content->items[] = $content . $editbuttons;
|
2004-04-18 23:20:53 +00:00
|
|
|
$this->content->icons[] = '';
|
|
|
|
} else {
|
2008-01-24 20:33:50 +00:00
|
|
|
//Accessibility: incidental image - should be empty Alt text
|
2011-01-26 10:29:16 +00:00
|
|
|
$icon = '<img src="' . $mod->get_icon_url() . '" class="icon" alt="" /> ';
|
|
|
|
$this->content->items[] = '<a title="' . $mod->modfullname . '" ' . $linkcss . ' ' . $mod->extra .
|
|
|
|
' href="' . $url . '">' . $icon . $instancename . '</a>' . $editbuttons;
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($ismoving) {
|
2009-01-02 10:36:25 +00:00
|
|
|
$this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&sesskey='.sesskey().'">'.
|
2009-12-16 21:50:45 +00:00
|
|
|
'<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>';
|
2004-04-18 23:20:53 +00:00
|
|
|
$this->content->icons[] = '';
|
|
|
|
}
|
|
|
|
|
2012-12-14 10:10:45 +08:00
|
|
|
$this->content->footer = $courserenderer->course_section_add_cm_control($course,
|
|
|
|
0, null, array('inblock' => true));
|
2004-04-18 23:20:53 +00:00
|
|
|
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-01 12:00:47 +00:00
|
|
|
|