Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * Social activities block.
19
 *
20
 * @package    block_social_activities
21
 * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
1441 ariadna 24
class block_social_activities extends block_base {
1 efrain 25
    function init(){
26
        $this->title = get_string('pluginname', 'block_social_activities');
27
    }
28
 
29
    function applicable_formats() {
30
        return array('course-view-social' => true);
31
    }
32
 
33
    function get_content() {
34
        if ($this->content !== NULL) {
35
            return $this->content;
36
        }
37
 
38
        $this->content = new stdClass();
1441 ariadna 39
        $this->content->text = '';
1 efrain 40
        $this->content->footer = '';
41
 
42
        if (empty($this->instance)) {
43
            return $this->content;
44
        }
45
 
46
        $course = $this->page->course;
1441 ariadna 47
 
48
        course_create_sections_if_missing($course, 0);
1 efrain 49
        $format = course_get_format($course);
1441 ariadna 50
        $modinfo = $format->get_modinfo();
1 efrain 51
        $section = $modinfo->get_section_info(0);
52
 
1441 ariadna 53
        if ($format->supports_ajax()) {
54
            include_course_ajax($course);
1 efrain 55
        }
56
 
1441 ariadna 57
        $courserenderer = $format->get_renderer($this->page);
1 efrain 58
 
1441 ariadna 59
        $output = new block_social_activities\output\blocksection($format, $section);
1 efrain 60
 
1441 ariadna 61
        $this->content->text = $courserenderer->render($output);
1 efrain 62
 
1441 ariadna 63
        $this->content->footer = $courserenderer->course_section_add_cm_control(
64
            course: $course,
65
            section: 0,
66
            sectionreturn: null,
67
            displayoptions: ['inblock' => true],
68
        );
1 efrain 69
        return $this->content;
70
    }
71
}