MDL-69240 tool_moodlenet: Clean MoodleNet profile field
[moodle.git] / mod / lti / request_tool.php
blob14a4062ab6bc7dad56d132499d229a3bec8e56fa
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.
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/>.
17 /**
18 * Submits a request to administrators to add a tool configuration for the requested site.
20 * @package mod_lti
21 * @copyright Copyright (c) 2011 Moodlerooms Inc. (http://www.moodlerooms.com)
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 * @author Chris Scribner
26 require_once('../../config.php');
27 require_once($CFG->dirroot.'/mod/lti/lib.php');
28 require_once($CFG->dirroot.'/mod/lti/locallib.php');
30 $instanceid = required_param('instanceid', PARAM_INT);
32 $lti = $DB->get_record('lti', array('id' => $instanceid));
33 $course = $DB->get_record('course', array('id' => $lti->course));
34 $cm = get_coursemodule_from_instance('lti', $lti->id, $lti->course, false, MUST_EXIST);
35 $context = context_module::instance($cm->id);
37 require_login($course);
39 require_sesskey();
41 require_capability('mod/lti:requesttooladd', context_course::instance($lti->course));
43 $baseurl = lti_get_domain_from_url($lti->toolurl);
45 $url = new moodle_url('/mod/lti/request_tool.php', array('instanceid' => $instanceid));
46 $PAGE->set_url($url);
48 $pagetitle = strip_tags($course->shortname);
49 $PAGE->set_title($pagetitle);
50 $PAGE->set_heading($course->fullname);
52 $PAGE->set_pagelayout('incourse');
54 echo $OUTPUT->header();
55 echo $OUTPUT->heading(format_string($lti->name, true, array('context' => $context)));
57 // Add a tool type if one does not exist already.
58 if (!lti_get_tool_by_url_match($lti->toolurl, $lti->course, LTI_TOOL_STATE_ANY)) {
59 // There are no tools (active, pending, or rejected) for the launch URL. Create a new pending tool.
60 $tooltype = new stdClass();
61 $toolconfig = new stdClass();
63 $toolconfig->lti_toolurl = lti_get_domain_from_url($lti->toolurl);
64 $toolconfig->lti_typename = $toolconfig->lti_toolurl;
66 lti_add_type($tooltype, $toolconfig);
68 echo get_string('lti_tool_request_added', 'lti');
69 } else {
70 echo get_string('lti_tool_request_existing', 'lti');
73 echo $OUTPUT->footer();