Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/lti/request_tool.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00027 require_once('../../config.php');
00028 require_once($CFG->dirroot.'/mod/lti/lib.php');
00029 require_once($CFG->dirroot.'/mod/lti/locallib.php');
00030 
00031 $instanceid = required_param('instanceid', PARAM_INT);
00032 
00033 $lti = $DB->get_record('lti', array('id' => $instanceid));
00034 $course = $DB->get_record('course', array('id' => $lti->course));
00035 
00036 require_login($course);
00037 
00038 require_capability('mod/lti:requesttooladd', get_context_instance(CONTEXT_COURSE, $lti->course));
00039 
00040 $baseurl = lti_get_domain_from_url($lti->toolurl);
00041 
00042 $url = new moodle_url('/mod/lti/request_tool.php', array('instanceid' => $instanceid));
00043 $PAGE->set_url($url);
00044 
00045 $pagetitle = strip_tags($course->shortname);
00046 $PAGE->set_title($pagetitle);
00047 $PAGE->set_heading($course->fullname);
00048 
00049 $PAGE->set_pagelayout('incourse');
00050 
00051 echo $OUTPUT->header();
00052 
00053 //Add a tool type if one does not exist already
00054 if (!lti_get_tool_by_url_match($lti->toolurl, $lti->course, LTI_TOOL_STATE_ANY)) {
00055     //There are no tools (active, pending, or rejected) for the launch URL. Create a new pending tool
00056     $tooltype = new stdClass();
00057     $toolconfig = new stdClass();
00058 
00059     $toolconfig->lti_toolurl = lti_get_domain_from_url($lti->toolurl);
00060     $toolconfig->lti_typename = $toolconfig->lti_toolurl;
00061 
00062     lti_add_type($tooltype, $toolconfig);
00063 
00064     echo get_string('lti_tool_request_added', 'lti');
00065 } else {
00066     echo get_string('lti_tool_request_existing', 'lti');
00067 }
00068 
00069 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations