MDL-25754 improved tag sanitisation and fixed tag autocomplete
[moodle.git] / tag / tag_autocomplete.php
CommitLineData
333abbf1 1<?php
c933a060 2
000ebd5c
DM
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 * @package core
20 * @subpackage tag
21 * @copyright 2007 Luiz Cruz <luiz.laydner@gmail.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
34b93e39
PS
25define('AJAX_SCRIPT', true);
26
9c9d3076 27require_once('../config.php');
c933a060 28require_once('lib.php');
29
9c9d3076 30require_login();
31
32if (empty($CFG->usetags)) {
294ce987 33 print_error('tagsaredisabled', 'tag');
c933a060 34}
35
6f5e0852 36$query = optional_param('query', '', PARAM_RAW);
c933a060 37
db32b054 38if ($similar_tags = tag_autocomplete($query)) {
16803c57 39 foreach ($similar_tags as $tag) {
34b93e39 40 echo clean_param($tag->name, PARAM_TAG) . "\t" . tag_display_name($tag) . "\n";
9c9d3076 41 }
c933a060 42}