Moodle plugin, allowing collaborative annotations in PDF files
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

83 lines
3.0 KiB

  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * @package mod_pdfannotator
  18. * @author Ahmad Obeid (ahmad.obeid@rwth-aachen.de), Anna Heynkes
  19. * @copyright 2018 RWTH Aachen
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  21. */
  22. require('../../config.php');
  23. require_once($CFG->dirroot . '/mod/pdfannotator/locallib.php'); // Requires lib.php in turn.
  24. require_once($CFG->libdir . '/completionlib.php');
  25. require_once($CFG->dirroot . '/mod/pdfannotator/model/pdfannotator.php');
  26. require_once('renderable.php');
  27. $id = optional_param('id', 0, PARAM_INT); // Course Module ID.
  28. $r = optional_param('r', 0, PARAM_INT); // Pdfannotator instance ID.
  29. $redirect = optional_param('redirect', 0, PARAM_BOOL);
  30. $page = optional_param('page', 1, PARAM_INT);
  31. $annoid = optional_param('annoid', null, PARAM_INT);
  32. $commid = optional_param('commid', null, PARAM_INT);
  33. if ($r) {
  34. if (!$pdfannotator = $DB->get_record('pdfannotator', array('id' => $r))) {
  35. print_error('invalidaccessparameter');
  36. }
  37. $cm = get_coursemodule_from_instance('pdfannotator', $pdfannotator->id, $pdfannotator->course, false, MUST_EXIST);
  38. } else {
  39. if (!$cm = get_coursemodule_from_id('pdfannotator', $id)) {
  40. print_error('invalidcoursemodule');
  41. }
  42. $pdfannotator = $DB->get_record('pdfannotator', array('id' => $cm->instance), '*', MUST_EXIST);
  43. }
  44. $course = get_course($cm->course); // Get course by id.
  45. require_course_login($course, true, $cm);
  46. $context = context_module::instance($cm->id);
  47. require_capability('mod/pdfannotator:view', $context);
  48. // Completion and trigger events.
  49. pdfannotator_view($pdfannotator, $course, $cm, $context);
  50. $PAGE->set_url('/mod/pdfannotator/view.php', array('id' => $cm->id));
  51. $fs = get_file_storage();
  52. $files = $fs->get_area_files($context->id, 'mod_pdfannotator', 'content', 0, 'sortorder DESC, id ASC', false);// TODO Not efficient!
  53. if (count($files) < 1) {
  54. pdfannotator_print_filenotfound($pdfannotator, $cm, $course);
  55. die;
  56. } else {
  57. $file = reset($files);
  58. unset($files);
  59. }
  60. $pdfannotator->mainfile = $file->get_filename();
  61. // Set course name for display.
  62. $PAGE->set_heading($course->fullname);
  63. // Display course name, navigation bar at the very top and "Dashboard->...->..." bar.
  64. echo $OUTPUT->header();
  65. require_once($CFG->dirroot . '/mod/pdfannotator/controller.php');
  66. // Display navigation and settings bars on the left as well as the footer.
  67. echo $OUTPUT->footer();