Skip to content
Snippets Groups Projects
Select Git revision
  • e29a5bb6bc981fc13300ed13e01fc25176aac809
  • main default
  • hsh-MOODLE_404+
  • hsh_3.10
  • master protected
  • v1.4.7
  • v1.4.6
  • v1.4.5
  • v1.4.3
  • v1.4.1
  • v1.4
  • v1.3r2
  • v1.3
  • v1.2
14 results

controller.php

Blame
  • controller.php 25.35 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
     * @copyright 2018 RWTH Aachen (see README.md)
     * @author   Anna Heynkes, Friederike Schwager
     * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
     */
    
    use mod_pdfannotator\output\statistics;
    
    defined('MOODLE_INTERNAL') || die();
    
    $action = optional_param('action', 'view', PARAM_ALPHA); // The default action is 'view'.
    
    $taburl = new moodle_url('/mod/pdfannotator/view.php', array('id' => $id));
    
    $myrenderer = $PAGE->get_renderer('mod_pdfannotator');
    
    require_course_login($pdfannotator->course, true, $cm);
    
    /* * ********************************************** Display overview page *********************************************** */
    
    if ($action === 'overview') {
        // Go to question-overview by default.
        $action = 'overviewquestions';
    }
    
    if ($action === 'forwardquestion') {
        require_sesskey();
        require_capability('mod/pdfannotator:forwardquestions', $context);
        require_once($CFG->dirroot . '/mod/pdfannotator/forward_form.php');
        global $USER;
    
        $commentid = required_param('commentid', PARAM_INT);
        $fromoverview = optional_param('fromoverview', 0, PARAM_INT);
        $cminfo = pdfannotator_instance::get_cm_info($cm->course);
        // Make sure user is allowed to see cm with the question. (Might happen if user changes commentid in url).
        list($insql, $inparams) = $DB->get_in_or_equal(array_keys($cminfo));
        $sql = "SELECT c.*, a.page, cm.id AS cmid "
            . "FROM {pdfannotator_comments} c "
            . "JOIN {pdfannotator_annotations} a ON c.annotationid = a.id "
            . "JOIN {pdfannotator} p ON a.pdfannotatorid = p.id "
            . "JOIN {course_modules} cm ON p.id = cm.instance "
            . "WHERE c.isdeleted = 0 AND c.id = ? AND cm.id $insql";
        $params = array_merge([$commentid], $inparams);
        $comments = $DB->get_records_sql($sql, $params);
        $error = false;
        if (!$comments) {
            $error = true;
        } else {
            $comment = $comments[$commentid];
            if (!$error && $comment->ishidden && !has_capability('mod/pdfannotator:seehiddencomments', $context)) {
                $error = true;
            }
        }