Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/blocks/comments/block_comments.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00026 defined('MOODLE_INTERNAL') || die();
00027 
00028 // Obviously required
00029 require_once($CFG->dirroot . '/comment/lib.php');
00030 
00031 class block_comments extends block_base {
00032 
00033     function init() {
00034         $this->title = get_string('pluginname', 'block_comments');
00035     }
00036 
00037     function specialization() {
00038         // require js for commenting
00039         comment::init();
00040     }
00041     function applicable_formats() {
00042         return array('all' => true);
00043     }
00044 
00045     function instance_allow_multiple() {
00046         return false;
00047     }
00048 
00049     function get_content() {
00050         global $CFG, $PAGE;
00051         if ($this->content !== NULL) {
00052             return $this->content;
00053         }
00054         if (!$CFG->usecomments) {
00055             $this->content = new stdClass();
00056             $this->content->text = '';
00057             if ($this->page->user_is_editing()) {
00058                 $this->content->text = get_string('disabledcomments');
00059             }
00060             return $this->content;
00061         }
00062         $this->content = new stdClass();
00063         $this->content->footer = '';
00064         $this->content->text = '';
00065         if (empty($this->instance)) {
00066             return $this->content;
00067         }
00068         list($context, $course, $cm) = get_context_info_array($PAGE->context->id);
00069 
00070         $args = new stdClass;
00071         $args->context   = $PAGE->context;
00072         $args->course    = $course;
00073         $args->area      = 'page_comments';
00074         $args->itemid    = 0;
00075         $args->component = 'block_comments';
00076         $args->linktext  = get_string('showcomments');
00077         $args->notoggle  = true;
00078         $args->autostart = true;
00079         $args->displaycancel = false;
00080         $comment = new comment($args);
00081         $comment->set_view_permission(true);
00082 
00083         $this->content = new stdClass();
00084         $this->content->text = $comment->output(true);
00085         $this->content->footer = '';
00086         return $this->content;
00087     }
00088 }
 All Data Structures Namespaces Files Functions Variables Enumerations