2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * The comments block helper functions and callbacks
21 * @subpackage comments
22 * @copyright 2011 Dongsheng Cai <dongsheng@moodle.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') ||
die();
29 * Validate comment parameter before perform other comments actions
31 * @package block_comments
34 * @param stdClass $comment_param {
35 * context => context the context object
36 * courseid => int course id
37 * cm => stdClass course module object
38 * commentarea => string comment area
39 * itemid => int itemid
43 function block_comments_comment_validate($comment_param) {
44 if ($comment_param->commentarea
!= 'page_comments') {
45 throw new comment_exception('invalidcommentarea');
47 if ($comment_param->itemid
!= 0) {
48 throw new comment_exception('invalidcommentitemid');
54 * Running addtional permission check on plugins
56 * @package block_comments
59 * @param stdClass $args
62 function block_comments_comment_permissions($args) {
63 return array('post'=>true, 'view'=>true);
67 * Validate comment data before displaying comments
69 * @package block_comments
72 * @param stdClass $comment
73 * @param stdClass $args
76 function block_comments_comment_display($comments, $args) {
77 if ($args->commentarea
!= 'page_comments') {
78 throw new comment_exception('invalidcommentarea');
80 if ($args->itemid
!= 0) {
81 throw new comment_exception('invalidcommentitemid');