|
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 00018 /* 00019 * Comments management interface 00020 */ 00021 require_once('../config.php'); 00022 require_once($CFG->libdir.'/adminlib.php'); 00023 require_once($CFG->dirroot.'/comment/locallib.php'); 00024 00025 require_login(); 00026 admin_externalpage_setup('comments', '', null, '', array('pagelayout'=>'report')); 00027 00028 $context = get_context_instance(CONTEXT_SYSTEM); 00029 require_capability('moodle/comment:delete', $context); 00030 00031 $PAGE->requires->js_init_call('M.core_comment.init_admin', null, true); 00032 00033 $action = optional_param('action', '', PARAM_ALPHA); 00034 $commentid = optional_param('commentid', 0, PARAM_INT); 00035 $commentids = optional_param('commentids', '', PARAM_ALPHANUMEXT); 00036 $page = optional_param('page', 0, PARAM_INT); 00037 $confirm = optional_param('confirm', 0, PARAM_INT); 00038 00039 $manager = new comment_manager(); 00040 00041 if ($action and !confirm_sesskey()) { 00042 // no action if sesskey not confirmed 00043 $action = ''; 00044 } 00045 00046 if ($action === 'delete') { 00047 // delete a single comment 00048 if (!empty($commentid)) { 00049 if (!$confirm) { 00050 echo $OUTPUT->header(); 00051 $optionsyes = array('action'=>'delete', 'commentid'=>$commentid, 'confirm'=>1, 'sesskey'=>sesskey()); 00052 $optionsno = array('sesskey'=>sesskey()); 00053 $buttoncontinue = new single_button(new moodle_url('/comment/index.php', $optionsyes), get_string('delete')); 00054 $buttoncancel = new single_button(new moodle_url('/comment/index.php', $optionsno), get_string('cancel')); 00055 echo $OUTPUT->confirm(get_string('confirmdeletecomments', 'admin'), $buttoncontinue, $buttoncancel); 00056 echo $OUTPUT->footer(); 00057 die; 00058 } else { 00059 if ($manager->delete_comment($commentid)) { 00060 redirect($CFG->httpswwwroot.'/comment/'); 00061 } else { 00062 $err = 'cannotdeletecomment'; 00063 } 00064 } 00065 } 00066 // delete a list of comments 00067 if (!empty($commentids)) { 00068 if ($manager->delete_comments($commentids)) { 00069 die('yes'); 00070 } else { 00071 die('no'); 00072 } 00073 } 00074 } 00075 00076 echo $OUTPUT->header(); 00077 echo $OUTPUT->heading(get_string('comments')); 00078 echo $OUTPUT->box_start('generalbox commentsreport'); 00079 if (!empty($err)) { 00080 print_error($err, 'error', $CFG->httpswwwroot.'/comment/'); 00081 } 00082 if (empty($action)) { 00083 echo '<form method="post">'; 00084 $return = $manager->print_comments($page); 00085 // if no comments available, $return will be false 00086 if ($return) { 00087 echo '<input type="submit" id="comments_delete" name="batchdelete" value="'.get_string('delete').'" />'; 00088 } 00089 echo '</form>'; 00090 } 00091 00092 echo $OUTPUT->box_end(); 00093 echo $OUTPUT->footer();