[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * URL module main user interface 20 * 21 * @package mod_url 22 * @copyright 2009 Petr Skoda {@link http://skodak.org} 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 require('../../config.php'); 27 require_once("$CFG->dirroot/mod/url/lib.php"); 28 require_once("$CFG->dirroot/mod/url/locallib.php"); 29 require_once($CFG->libdir . '/completionlib.php'); 30 31 $id = optional_param('id', 0, PARAM_INT); // Course module ID 32 $u = optional_param('u', 0, PARAM_INT); // URL instance id 33 $redirect = optional_param('redirect', 0, PARAM_BOOL); 34 35 if ($u) { // Two ways to specify the module 36 $url = $DB->get_record('url', array('id'=>$u), '*', MUST_EXIST); 37 $cm = get_coursemodule_from_instance('url', $url->id, $url->course, false, MUST_EXIST); 38 39 } else { 40 $cm = get_coursemodule_from_id('url', $id, 0, false, MUST_EXIST); 41 $url = $DB->get_record('url', array('id'=>$cm->instance), '*', MUST_EXIST); 42 } 43 44 $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); 45 46 require_course_login($course, true, $cm); 47 $context = context_module::instance($cm->id); 48 require_capability('mod/url:view', $context); 49 50 // Completion and trigger events. 51 url_view($url, $course, $cm, $context); 52 53 $PAGE->set_url('/mod/url/view.php', array('id' => $cm->id)); 54 55 // Make sure URL exists before generating output - some older sites may contain empty urls 56 // Do not use PARAM_URL here, it is too strict and does not support general URIs! 57 $exturl = trim($url->externalurl); 58 if (empty($exturl) or $exturl === 'http://') { 59 url_print_header($url, $cm, $course); 60 url_print_heading($url, $cm, $course); 61 url_print_intro($url, $cm, $course); 62 notice(get_string('invalidstoredurl', 'url'), new moodle_url('/course/view.php', array('id'=>$cm->course))); 63 die; 64 } 65 unset($exturl); 66 67 $displaytype = url_get_final_display_type($url); 68 if ($displaytype == RESOURCELIB_DISPLAY_OPEN) { 69 // For 'open' links, we always redirect to the content - except if the user 70 // just chose 'save and display' from the form then that would be confusing 71 if (strpos(get_local_referer(false), 'modedit.php') === false) { 72 $redirect = true; 73 } 74 } 75 76 if ($redirect) { 77 // coming from course page or url index page, 78 // the redirection is needed for completion tracking and logging 79 $fullurl = str_replace('&', '&', url_get_full_url($url, $cm, $course)); 80 81 if (!course_get_format($course)->has_view_page()) { 82 // If course format does not have a view page, add redirection delay with a link to the edit page. 83 // Otherwise teacher is redirected to the external URL without any possibility to edit activity or course settings. 84 $editurl = null; 85 if (has_capability('moodle/course:manageactivities', $context)) { 86 $editurl = new moodle_url('/course/modedit.php', array('update' => $cm->id)); 87 $edittext = get_string('editthisactivity'); 88 } else if (has_capability('moodle/course:update', $context->get_course_context())) { 89 $editurl = new moodle_url('/course/edit.php', array('id' => $course->id)); 90 $edittext = get_string('editcoursesettings'); 91 } 92 if ($editurl) { 93 redirect($fullurl, html_writer::link($editurl, $edittext)."<br/>". 94 get_string('pageshouldredirect'), 10); 95 } 96 } 97 redirect($fullurl); 98 } 99 100 switch ($displaytype) { 101 case RESOURCELIB_DISPLAY_EMBED: 102 url_display_embed($url, $cm, $course); 103 break; 104 case RESOURCELIB_DISPLAY_FRAME: 105 url_display_frame($url, $cm, $course); 106 break; 107 default: 108 url_print_workaround($url, $cm, $course); 109 break; 110 }
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 |