MDL-21695 adding help string
[moodle.git] / mod / wiki / instancecomments.php
blob17456aeedc8642e0206672e6b638eadb0bc702df
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-2.0
22 * @copyrigth 2009 Marc Alier, Jordi Piguillem marc.alier@upc.edu
23 * @copyrigth 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_ACTION);
42 $id = optional_param('id', PARAM_INT);
43 $commentid = optional_param('commentid', PARAM_INT);
44 $newcontent = optional_param('newcontent', '', PARAM_CLEANHTML);
46 if (!$page = wiki_get_page($pageid)) {
47 print_error('incorrectpageid', 'wiki');
50 if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
51 print_error('incorrectsubwikiid', 'wiki');
53 if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) {
54 print_error('invalidcoursemodule');
56 if (!$course = get_course_by_id($cm->course)) {
57 print_error('coursemisconf');
59 if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
60 print_error('incorrectwikiid', 'wiki');
62 require_course_login($course->id, true, $cm);
64 $comm = new page_wiki_handlecomments($wiki, $subwiki, $cm);
65 $comm->set_page($page);
67 if ($action == 'delete') {
68 $comm->set_action($action, $commentid, 0);
69 } else {
70 if (empty($newcontent)) {
71 $form = new mod_wiki_comments_form();
72 $newcomment = $form->get_data();
73 $content = $newcomment->entrycomment_editor['text'];
74 } else {
75 $content = $newcontent;
78 if ($action == 'edit') {
79 $comm->set_action($action, $id, $content);
81 } else {
82 $action = 'add';
83 $comm->set_action($action, 0, $content);
87 $comm->print_header();
88 $comm->print_content();
89 $comm->print_footer();