From: dongsheng Date: Fri, 24 Jul 2009 02:52:09 +0000 (+0000) Subject: "MDL-19839, comments block" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=346ac86b1011b393149c1e7582ab1b544dee389a;p=moodle.git "MDL-19839, comments block" --- diff --git a/blocks/comments/block_comments.php b/blocks/comments/block_comments.php new file mode 100644 index 0000000000..8f107b695c --- /dev/null +++ b/blocks/comments/block_comments.php @@ -0,0 +1,51 @@ +libdir . '/commentlib.php'); + +class block_comments extends block_base { + + function init() { + $this->title = get_string('comments'); + $this->version = 2009072000; + } + + function specialization() { + // require js for commenting + comment::js(); + } + function applicable_formats() { + return array('all' => true); + } + + function instance_allow_multiple() { + return false; + } + + function get_content() { + if ($this->content !== NULL) { + return $this->content; + } + if (empty($this->instance)) { + return null; + } + $this->content->footer = ''; + $this->content->text = ''; + if (isloggedin() && !isguestuser()) { // Show the block + $cmt = new stdclass; + $cmt->context = $this->instance->context; + $cmt->area = 'block_comments'; + $cmt->itemid = $this->instance->id; + $cmt->course = $this->page->course; + // this is a hack to adjust commenting UI + // in block_comments + $cmt->env = 'block_comments'; + $cmt->linktext = get_string('showcomments'); + $comment = new comment($cmt); + $this->content = new stdClass; + $this->content->text = $comment->init(true); + $this->content->footer = ''; + + } + return $this->content; + } +}