MDL-63660 tool_dataprivacy: Increase expected export file size
[moodle.git] / mod / wiki / instancecomments.php
blobb2466b6b57a8ba89c5c459fc95e0057731aabbbb
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * @TODO: Doc this file
21 * @package mod_wiki
22 * @copyright 2009 Marc Alier, Jordi Piguillem marc.alier@upc.edu
23 * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
25 * @author Jordi Piguillem
26 * @author Marc Alier
27 * @author David Jimenez
28 * @author Josep Arus
29 * @author Daniel Serrano
30 * @author Kenneth Riba
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 require_once('../../config.php');
36 require_once($CFG->dirroot . "/mod/wiki/pagelib.php");
37 require_once($CFG->dirroot . "/mod/wiki/locallib.php");
38 require_once($CFG->dirroot . '/mod/wiki/comments_form.php');
40 $pageid = required_param('pageid', PARAM_TEXT);
41 $action = optional_param('action', '', PARAM_ALPHANUMEXT);
42 $id = optional_param('id', 0, PARAM_INT);
43 $commentid = optional_param('commentid', 0, PARAM_INT);
44 $newcontent = optional_param_array('newcontent', '', PARAM_CLEANHTML);
45 $confirm = optional_param('confirm', 0, PARAM_BOOL);
47 if ($newcontent) {
48 $newcontent = $newcontent['text'];
51 if (!$page = wiki_get_page($pageid)) {
52 print_error('incorrectpageid', 'wiki');
55 if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
56 print_error('incorrectsubwikiid', 'wiki');
58 if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) {
59 print_error('invalidcoursemodule');
61 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
62 if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
63 print_error('incorrectwikiid', 'wiki');
65 require_login($course, true, $cm);
67 if ($action == 'add' || $action == 'edit') {
68 //just check sesskey
69 if (!confirm_sesskey()) {
70 print_error(get_string('invalidsesskey', 'wiki'));
72 $comm = new page_wiki_handlecomments($wiki, $subwiki, $cm);
73 $comm->set_page($page);
74 } else {
75 if(!$confirm) {
76 $comm = new page_wiki_deletecomment($wiki, $subwiki, $cm);
77 $comm->set_page($page);
78 $comm->set_url();
79 } else {
80 $comm = new page_wiki_handlecomments($wiki, $subwiki, $cm);
81 $comm->set_page($page);
82 if (!confirm_sesskey()) {
83 print_error(get_string('invalidsesskey', 'wiki'));
88 if ($action == 'delete') {
89 $comm->set_action($action, $commentid, 0);
90 } else {
91 if (empty($newcontent)) {
92 $form = new mod_wiki_comments_form();
93 $newcomment = $form->get_data();
94 $content = $newcomment->entrycomment_editor['text'];
95 } else {
96 $content = $newcontent;
99 if ($action == 'edit') {
100 $comm->set_action($action, $id, $content);
101 } else {
102 $action = 'add';
103 $comm->set_action($action, 0, $content);
107 $comm->print_header();
108 $comm->print_content();
109 $comm->print_footer();