[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 /** 18 * This file contains the version information for the comments feedback plugin 19 * 20 * @package assignfeedback_editpdf 21 * @copyright 2012 Davo Smith 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * Serves assignment feedback and other files. 29 * 30 * @param mixed $course course or id of the course 31 * @param mixed $cm course module or id of the course module 32 * @param context $context 33 * @param string $filearea 34 * @param array $args 35 * @param bool $forcedownload 36 * @return bool false if file not found, does not return if found - just send the file 37 */ 38 function assignfeedback_editpdf_pluginfile($course, 39 $cm, 40 context $context, 41 $filearea, 42 $args, 43 $forcedownload) { 44 global $USER, $DB, $CFG; 45 46 if ($context->contextlevel == CONTEXT_MODULE) { 47 48 require_login($course, false, $cm); 49 $itemid = (int)array_shift($args); 50 51 if (!$assign = $DB->get_record('assign', array('id'=>$cm->instance))) { 52 return false; 53 } 54 55 $record = $DB->get_record('assign_grades', array('id'=>$itemid), 'userid,assignment', MUST_EXIST); 56 $userid = $record->userid; 57 if ($assign->id != $record->assignment) { 58 return false; 59 } 60 61 // Check is users feedback or has grading permission. 62 if ($USER->id != $userid and !has_capability('mod/assign:grade', $context)) { 63 return false; 64 } 65 66 $relativepath = implode('/', $args); 67 68 $fullpath = "/{$context->id}/assignfeedback_editpdf/$filearea/$itemid/$relativepath"; 69 70 $fs = get_file_storage(); 71 if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { 72 return false; 73 } 74 // Download MUST be forced - security! 75 send_stored_file($file, 0, 0, true);// Check if we want to retrieve the stamps. 76 } 77 78 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |