Moodle release 2.2beta
[moodle.git] / mod / lti / ajax.php
CommitLineData
6831c7cd 1<?php
61eb12d4
CS
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 * MRTODO: Brief description of this file
19 *
20 * @package mod
21 * @subpackage xml
22 * @copyright 2011 onwards MRTODO
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
6831c7cd
CS
25
26require_once(dirname(__FILE__) . "/../../config.php");
27require_once($CFG->dirroot . '/mod/lti/locallib.php');
28
29$courseid = required_param('course', PARAM_INT);
30
31require_login($courseid, false);
32
33$action = required_param('action', PARAM_TEXT);
34
35$response = new stdClass();
36
ea04a9f9 37switch ($action) {
6831c7cd
CS
38 case 'find_tool_config':
39 $toolurl = required_param('toolurl', PARAM_RAW);
e27cb316 40
6831c7cd 41 $tool = lti_get_tool_by_url_match($toolurl, $courseid);
e27cb316 42
ea04a9f9 43 if (!empty($tool)) {
6831c7cd
CS
44 $response->toolid = $tool->id;
45 $response->toolname = htmlspecialchars($tool->name);
16e8f130 46 $response->tooldomain = htmlspecialchars($tool->tooldomain);
6831c7cd 47 }
6831c7cd
CS
48 break;
49}
50
51echo json_encode($response);
52
61eb12d4 53die;