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.
 
 
 
 

82 lines
3.0 KiB

<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package mod_pdfannotator
* @author Ahmad Obeid (ahmad.obeid@rwth-aachen.de), Anna Heynkes
* @copyright 2018 RWTH Aachen
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../config.php');
require_once($CFG->dirroot . '/mod/pdfannotator/locallib.php'); // Requires lib.php in turn.
require_once($CFG->libdir . '/completionlib.php');
require_once($CFG->dirroot . '/mod/pdfannotator/model/pdfannotator.php');
require_once('renderable.php');
$id = optional_param('id', 0, PARAM_INT); // Course Module ID.
$r = optional_param('r', 0, PARAM_INT); // Pdfannotator instance ID.
$redirect = optional_param('redirect', 0, PARAM_BOOL);
$page = optional_param('page', 1, PARAM_INT);
$annoid = optional_param('annoid', null, PARAM_INT);
$commid = optional_param('commid', null, PARAM_INT);
if ($r) {
if (!$pdfannotator = $DB->get_record('pdfannotator', array('id' => $r))) {
print_error('invalidaccessparameter');
}
$cm = get_coursemodule_from_instance('pdfannotator', $pdfannotator->id, $pdfannotator->course, false, MUST_EXIST);
} else {
if (!$cm = get_coursemodule_from_id('pdfannotator', $id)) {
print_error('invalidcoursemodule');
}
$pdfannotator = $DB->get_record('pdfannotator', array('id' => $cm->instance), '*', MUST_EXIST);
}
$course = get_course($cm->course); // Get course by id.
require_course_login($course, true, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/pdfannotator:view', $context);
// Completion and trigger events.
pdfannotator_view($pdfannotator, $course, $cm, $context);
$PAGE->set_url('/mod/pdfannotator/view.php', array('id' => $cm->id));
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, 'mod_pdfannotator', 'content', 0, 'sortorder DESC, id ASC', false);// TODO Not efficient!
if (count($files) < 1) {
pdfannotator_print_filenotfound($pdfannotator, $cm, $course);
die;
} else {
$file = reset($files);
unset($files);
}
$pdfannotator->mainfile = $file->get_filename();
// Set course name for display.
$PAGE->set_heading($course->fullname);
// Display course name, navigation bar at the very top and "Dashboard->...->..." bar.
echo $OUTPUT->header();
require_once($CFG->dirroot . '/mod/pdfannotator/controller.php');
// Display navigation and settings bars on the left as well as the footer.
echo $OUTPUT->footer();