Exemple #1
0
if ($action === 'delete') {
    // delete a single comment
    if (!empty($commentid)) {
        if ($manager->delete_comment($commentid)) {
            redirect($CFG->httpswwwroot . '/comment/', get_string('deleted'));
        } else {
            $err = 'cannotdeletecomment';
        }
    }
    // delete a list of comments
    if (!empty($commentids)) {
        if ($manager->delete_comments($commentids)) {
            die('yes');
        } else {
            die('no');
        }
    }
}
admin_externalpage_setup('comments');
admin_externalpage_print_header();
echo $OUTPUT->heading(get_string('comments'));
if (!empty($err)) {
    print_error($err, 'error', $CFG->httpswwwroot . '/comment/');
}
if (empty($action)) {
    $manager->print_comments($page);
    echo '<div class="mdl-align">';
    echo '<button id="comments_delete">' . get_string('delete') . '</button>';
    echo '<div>';
}
echo $OUTPUT->footer();
            } else {
                $err = 'cannotdeletecomment';
            }
        }
    }
    // delete a list of comments
    if (!empty($commentids)) {
        if ($manager->delete_comments($commentids)) {
            die('yes');
        } else {
            die('no');
        }
    }
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('comments'));
echo $OUTPUT->box_start('generalbox commentsreport');
if (!empty($err)) {
    print_error($err, 'error', $CFG->httpswwwroot . '/comment/');
}
if (empty($action)) {
    echo '<form method="post">';
    $return = $manager->print_comments($page);
    // if no comments available, $return will be false
    if ($return) {
        echo '<input type="submit" id="comments_delete" name="batchdelete" value="' . get_string('delete') . '" />';
    }
    echo '</form>';
}
echo $OUTPUT->box_end();
echo $OUTPUT->footer();