3 require_once($CFG->dirroot . '/comment/lib.php');
5 class block_comments extends block_base {
8 $this->title = get_string('pluginname', 'block_comments');
9 $this->version = 2009072000;
12 function specialization() {
13 // require js for commenting
16 function applicable_formats() {
17 return array('all' => true);
20 function instance_allow_multiple() {
24 function get_content() {
26 if (!$CFG->usecomments) {
27 $this->content->text = '';
28 if ($this->page->user_is_editing()) {
29 $this->content->text = get_string('disabledcomments');
31 return $this->content;
33 if ($this->content !== NULL) {
34 return $this->content;
36 if (empty($this->instance)) {
39 $this->content->footer = '';
40 $this->content->text = '';
41 //TODO: guest and not-logged-in shoudl be able to read comments, right?
42 if (isloggedin() && !isguestuser()) { // Show the block
43 list($context, $course, $cm) = get_context_info_array($this->context->id);
45 $cmt->context = $context;
46 $cmt->course = $course;
47 $cmt->area = 'block_comments';
48 $cmt->itemid = $this->instance->id;
49 // this is a hack to adjust commenting UI in block_comments
50 $cmt->env = 'block_comments';
51 $cmt->linktext = get_string('showcomments');
52 $comment = new comment($cmt);
54 $this->content = new stdClass;
55 $this->content->text = $comment->output(true);
56 $this->content->footer = '';
58 return $this->content;