|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00035 require_once('../../config.php'); 00036 require_once($CFG->dirroot . "/mod/wiki/pagelib.php"); 00037 require_once($CFG->dirroot . "/mod/wiki/locallib.php"); 00038 require_once($CFG->dirroot . '/mod/wiki/comments_form.php'); 00039 00040 $pageid = required_param('pageid', PARAM_TEXT); 00041 $action = optional_param('action', '', PARAM_ACTION); 00042 $id = optional_param('id', 0, PARAM_INT); 00043 $commentid = optional_param('commentid', 0, PARAM_INT); 00044 $newcontent = optional_param('newcontent', '', PARAM_CLEANHTML); 00045 $confirm = optional_param('confirm', 0, PARAM_BOOL); 00046 00047 if (!$page = wiki_get_page($pageid)) { 00048 print_error('incorrectpageid', 'wiki'); 00049 } 00050 00051 if (!$subwiki = wiki_get_subwiki($page->subwikiid)) { 00052 print_error('incorrectsubwikiid', 'wiki'); 00053 } 00054 if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) { 00055 print_error('invalidcoursemodule'); 00056 } 00057 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); 00058 if (!$wiki = wiki_get_wiki($subwiki->wikiid)) { 00059 print_error('incorrectwikiid', 'wiki'); 00060 } 00061 require_login($course->id, true, $cm); 00062 00063 if ($action == 'add' || $action == 'edit') { 00064 //just check sesskey 00065 if (!confirm_sesskey()) { 00066 print_error(get_string('invalidsesskey', 'wiki')); 00067 } 00068 $comm = new page_wiki_handlecomments($wiki, $subwiki, $cm); 00069 $comm->set_page($page); 00070 } else { 00071 if(!$confirm) { 00072 $comm = new page_wiki_deletecomment($wiki, $subwiki, $cm); 00073 $comm->set_page($page); 00074 $comm->set_url(); 00075 } else { 00076 $comm = new page_wiki_handlecomments($wiki, $subwiki, $cm); 00077 $comm->set_page($page); 00078 if (!confirm_sesskey()) { 00079 print_error(get_string('invalidsesskey', 'wiki')); 00080 } 00081 } 00082 } 00083 00084 if ($action == 'delete') { 00085 $comm->set_action($action, $commentid, 0); 00086 } else { 00087 if (empty($newcontent)) { 00088 $form = new mod_wiki_comments_form(); 00089 $newcomment = $form->get_data(); 00090 $content = $newcomment->entrycomment_editor['text']; 00091 } else { 00092 $content = $newcontent; 00093 } 00094 00095 if ($action == 'edit') { 00096 $comm->set_action($action, $id, $content); 00097 00098 } else { 00099 $action = 'add'; 00100 $comm->set_action($action, 0, $content); 00101 } 00102 } 00103 00104 $comm->print_header(); 00105 $comm->print_content(); 00106 $comm->print_footer();