2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
23 * @copyright 2007 j.beedell@open.ac.uk
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require_once('../config.php');
31 $systemcontext = context_system
::instance();
32 require_capability('moodle/tag:create', $systemcontext);
34 if (empty($CFG->usetags
)) {
35 print_error('tagsaredisabled', 'tag');
38 $returnurl = optional_param('returnurl', null, PARAM_LOCALURL
);
39 $keyword = optional_param('coursetag_new_tag', '', PARAM_TEXT
);
40 $courseid = optional_param('entryid', 0, PARAM_INT
);
41 $userid = optional_param('userid', 0, PARAM_INT
);
43 $keyword = trim(strip_tags($keyword));
44 if ($keyword and confirm_sesskey()) {
46 require_once($CFG->dirroot
.'/tag/coursetagslib.php');
48 if ($courseid > 0 and $userid > 0) {
49 $myurl = 'tag/search.php';
50 $keywords = explode(',', $keyword);
51 coursetag_store_keywords($keywords, $courseid, $userid, 'default', $myurl);
55 // send back to originating page, where the new tag will be visible in the block
59 $myurl = $CFG->wwwroot
.'/';