navigation MDL-14632 Added fuzzy matching as a worst case scenario to find the active...
[moodle.git] / blocks / community / block_community.php
CommitLineData
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 27require_once($CFG->dirroot . '/blocks/community/locallib.php');
07ab0c80 28
29class 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);
51 $this->content->items[] = '';
52 $this->content->icons[] = '';
53 $this->content->items[] = get_string('mycommunities', 'block_community');
54 $this->content->icons[] = '';
55 foreach ($courses as $course) {
276f590e 56 //delete link
57 $deleteicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/cross_red_small')));
58 $deleteurl = new moodle_url($CFG->wwwroot.'/blocks/community/communitycourse.php',
59 array('remove'=>true, 'communityid'=> $course->id, 'sesskey' => sesskey()));
60 $deleteatag = html_writer::tag('a', $deleteicon, array('href' => $deleteurl));
61
62 $this->content->items[] = '<a href='.$course->courseurl.'>'.$course->coursename.'</a> ' .
63 $deleteatag;
07ab0c80 64 $this->content->icons[] = '';
65 }
66
67 return $this->content;
68 }
69
70 function applicable_formats() {
71 return array('all' => true);
72 }
73
74}
75