MDL-45296 phpdoc: add some missing params
[moodle.git] / tag / coursetags_add.php
blob36573d82b529c472571d9f57703a1ae0e076afda
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/>.
18 /**
19 * coursetags_add.php
21 * @package core_tag
22 * @category tag
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');
29 require_login();
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
56 if ($returnurl) {
57 redirect($returnurl);
58 } else {
59 $myurl = $CFG->wwwroot.'/';
62 redirect($myurl);