MDL-69559 course: Add course content download UI and execution page
[moodle.git] / blocks / comments / lib.php
blob454d1cde56deef04459f33444016fa6e0de2a014
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.
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/>.
17 /**
18 * The comments block helper functions and callbacks
20 * @package block_comments
21 * @copyright 2011 Dongsheng Cai <dongsheng@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
27 /**
28 * Validate comment parameter before perform other comments actions
30 * @package block_comments
31 * @category comment
33 * @param stdClass $comment_param {
34 * context => context the context object
35 * courseid => int course id
36 * cm => stdClass course module object
37 * commentarea => string comment area
38 * itemid => int itemid
39 * }
40 * @return boolean
42 function block_comments_comment_validate($comment_param) {
43 if ($comment_param->commentarea != 'page_comments') {
44 throw new comment_exception('invalidcommentarea');
46 if ($comment_param->itemid != 0) {
47 throw new comment_exception('invalidcommentitemid');
49 return true;
52 /**
53 * Running addtional permission check on plugins
55 * @package block_comments
56 * @category comment
58 * @param stdClass $args
59 * @return array
61 function block_comments_comment_permissions($args) {
62 return array('post'=>true, 'view'=>true);
65 /**
66 * Validate comment data before displaying comments
68 * @package block_comments
69 * @category comment
71 * @param stdClass $comment
72 * @param stdClass $args
73 * @return boolean
75 function block_comments_comment_display($comments, $args) {
76 if ($args->commentarea != 'page_comments') {
77 throw new comment_exception('invalidcommentarea');
79 if ($args->itemid != 0) {
80 throw new comment_exception('invalidcommentitemid');
82 return $comments;