} else { echo $OUTPUT->header(); lightboxgallery_print_comment($comment, $context); echo '<br />'; $paramsyes = array('id' => $gallery->id, 'delete' => $comment->id, 'sesskey' => sesskey(), 'confirm' => 1); $paramsno = array('id' => $cm->id); echo $OUTPUT->confirm(get_string('commentdelete', 'lightboxgallery'), new moodle_url('/mod/lightboxgallery/comment.php', $paramsyes), new moodle_url('/mod/lightboxgallery/view.php', $paramsno)); echo $OUTPUT->footer(); die; } } require_capability('mod/lightboxgallery:addcomment', $context); if (!$gallery->comments) { print_error('Comments disabled', $galleryurl); } $mform = new mod_lightboxgallery_comment_form(null, $gallery); if ($mform->is_cancelled()) { redirect($galleryurl); } else { if ($formadata = $mform->get_data()) { $newcomment = new object(); $newcomment->gallery = $gallery->id; $newcomment->userid = $USER->id; $newcomment->comment = $formadata->comment['text']; $newcomment->timemodified = time(); if ($DB->insert_record('lightboxgallery_comments', $newcomment)) { add_to_log($course->id, 'lightboxgallery', 'comment', 'view.php?id=' . $cm->id, $gallery->id, $cm->id, $USER->id); redirect($galleryurl, get_string('commentadded', 'lightboxgallery')); } else { print_error('Comment creation failed'); }
delete_records('lightboxgallery_comments', 'id', $comment->id); redirect($galleryurl); } else { print_header(); lightboxgallery_print_comment($comment, $context); echo '<br />'; notice_yesno(get_string('commentdelete', 'lightboxgallery'), $CFG->wwwroot . '/mod/lightboxgallery/comment.php?id=' . $gallery->id . '&cid=' . $comment->id . '&action=delete&confirm=1&sesskey=' . sesskey(), $galleryurl); print_footer(); die; } } require_capability('mod/lightboxgallery:addcomment', $context); if (!$gallery->comments) { error('Comments disabled', $galleryurl); } $mform = new mod_lightboxgallery_comment_form('comment.php'); $mform->set_data(array('id' => $gallery->id)); if ($mform->is_cancelled()) { redirect($galleryurl); } if ($formadata = $mform->get_data()) { $newcomment = new object(); $newcomment->gallery = $gallery->id; $newcomment->userid = $USER->id; $newcomment->comment = $formadata->comment; $newcomment->timemodified = time(); if (insert_record('lightboxgallery_comments', $newcomment)) { add_to_log($course->id, 'lightboxgallery', 'comment', 'view.php?id=' . $cm->id, $gallery->id, $cm->id, $USER->id); redirect($galleryurl, get_string('commentadded', 'lightboxgallery')); } else { error('Comment creation failed');