Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
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. 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 * Edit course tags 19 * 20 * @package core_course 21 * @copyright 2015 Marina Glancy 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 require_once("../config.php"); 26 require_once($CFG->dirroot . '/course/tags_form.php'); 27 28 $id = required_param('id', PARAM_INT); // Course id. 29 $returnurl = optional_param('return', null, PARAM_LOCALURL); 30 $course = get_course($id); 31 32 require_login(); 33 34 // Check capabilities but do not call require_login($course) - the user does not have to be enrolled. 35 $context = context_course::instance($course->id); 36 if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) { 37 print_error('coursehidden', '', $CFG->wwwroot .'/'); 38 } 39 require_capability('moodle/course:tag', $context); 40 if (!core_tag_tag::is_enabled('core', 'course')) { 41 print_error('tagsaredisabled', 'tag'); 42 } 43 44 $PAGE->set_course($course); 45 $PAGE->set_pagelayout('incourse'); 46 $PAGE->set_url('/course/tags.php', array('id' => $course->id)); 47 $PAGE->set_title(get_string('coursetags', 'tag')); 48 $PAGE->set_heading($course->fullname); 49 50 $form = new coursetags_form(); 51 $data = array('id' => $course->id, 'tags' => core_tag_tag::get_item_tags_array('core', 'course', $course->id)); 52 $form->set_data($data); 53 54 $redirecturl = $returnurl ? new moodle_url($returnurl) : course_get_url($course); 55 if ($form->is_cancelled()) { 56 redirect($redirecturl); 57 } else if ($data = $form->get_data()) { 58 core_tag_tag::set_item_tags('core', 'course', $course->id, context_course::instance($course->id), $data->tags); 59 redirect($redirecturl); 60 } 61 62 echo $OUTPUT->header(); 63 echo $OUTPUT->heading(get_string('coursetags', 'tag')); 64 65 $form->display(); 66 67 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body