Commit | Line | Data |
---|---|---|
07ab0c80 | 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 | * @package blocks | |
19 | * @subpackage community | |
20 | * @author Jerome Mouneyrac <jerome@mouneyrac.com> | |
21 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL | |
22 | * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com | |
23 | * | |
24 | * The community block | |
25 | */ | |
26 | ||
276f590e | 27 | require_once($CFG->dirroot . '/blocks/community/locallib.php'); |
07ab0c80 | 28 | |
29 | class block_community extends block_list { | |
30 | function init() { | |
31 | $this->title = get_string('pluginname', 'block_community'); | |
32 | $this->version = 2010042701; | |
33 | } | |
34 | ||
35 | function get_content() { | |
36 | ||
37 | global $CFG, $OUTPUT, $USER; | |
38 | ||
39 | $this->content = new stdClass(); | |
40 | $this->content->items = array(); | |
41 | $this->content->icons = array(); | |
42 | $this->content->footer = ''; | |
43 | ||
276f590e | 44 | |
45 | ||
07ab0c80 | 46 | $this->content->items[] = '<a href='.$CFG->wwwroot.'/blocks/community/communitycourse.php?add=true>'.get_string('addcourse', 'block_community').'</a>'; |
47 | $this->content->icons[] = '<img src="'.$OUTPUT->pix_url('i/group') . '" class="icon" alt="" />'; | |
48 | ||
49 | $community = new community(); | |
50 | $courses = $community->get_community_courses($USER->id); | |
bfe600c3 MD |
51 | if ($courses) { |
52 | $this->content->items[] = '<hr />'; | |
53 | $this->content->icons[] = ''; | |
54 | $this->content->items[] = get_string('mycommunities', 'block_community'); | |
55 | $this->content->icons[] = ''; | |
56 | foreach ($courses as $course) { | |
57 | //delete link | |
58 | $deleteicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/cross_red_small'))); | |
59 | $deleteurl = new moodle_url($CFG->wwwroot.'/blocks/community/communitycourse.php', | |
60 | array('remove'=>true, 'communityid'=> $course->id, 'sesskey' => sesskey())); | |
61 | $deleteatag = html_writer::tag('a', $deleteicon, array('href' => $deleteurl)); | |
276f590e | 62 | |
bfe600c3 | 63 | $this->content->items[] = '<a href='.$course->courseurl.'>'.$course->coursename.'</a> ' . |
276f590e | 64 | $deleteatag; |
bfe600c3 MD |
65 | $this->content->icons[] = ''; |
66 | } | |
07ab0c80 | 67 | } |
68 | ||
69 | return $this->content; | |
70 | } | |
71 | ||
72 | function applicable_formats() { | |
73 | return array('all' => true); | |
74 | } | |
75 | ||
76 | } | |
77 |