dirroot.'/tag/coursetagslib.php'); require_once($CFG->dirroot.'/tag/lib.php'); $courseid = optional_param('courseid', 0, PARAM_INT); $keyword = optional_param('coursetag_new_tag', '', PARAM_TEXT); $deltag = optional_param('del_tag', 0, PARAM_INT); $url = new moodle_url('/tag/coursetags_edit.php'); if ($courseid !== 0) { $url->param('courseid', $courseid); } if ($keyword !== '') { $url->param('coursetag_new_tag', $keyword); } if ($deltag !== 0) { $url->param('del_tag', $deltag); } $PAGE->set_url($url); require_login(); if (empty($CFG->usetags)) { print_error('tagsaredisabled', 'tag'); } if ($courseid != SITEID) { if (! ($course = $DB->get_record('course', array('id' => $courseid), '*')) ) { print_error('invalidcourse'); } } else { print_error('errortagfrontpage', 'tag'); } // Permissions $sitecontext = get_context_instance(CONTEXT_SYSTEM); require_login($course->id); $canedit = has_capability('moodle/tag:create', $sitecontext); // Language strings $tagslang = 'block_tags'; // Store data if ($data = data_submitted()) { if (confirm_sesskey() and $courseid > 0 and $USER->id > 0 and $canedit) { // store personal tag if (trim(strip_tags($keyword))) { $myurl = 'tag/search.php'; $keywords = explode(',', $keyword); coursetag_store_keywords($keywords, $courseid, $USER->id, 'default', $myurl); } // delete personal tag if ($deltag > 0) { coursetag_delete_keyword($deltag, $USER->id, $courseid); } } } // The title and breadcrumb $title = get_string('edittitle', $tagslang); $coursefullname = format_string($course->fullname); $courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); $PAGE->navbar->add($title); $PAGE->set_title($title); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(false); echo $OUTPUT->header(); // Print personal tags for all courses $title = get_string('edittitle', $tagslang); echo $OUTPUT->heading($title, 2, 'mdl-align'); $mytags = coursetag_print_cloud(coursetag_get_tags(0, $USER->id, 'default'), true); $outstr = '
'.get_string('editmytags', $tagslang).'
'; if ($mytags) { $outstr .= $mytags; } else { $outstr .= get_string('editnopersonaltags', $tagslang); } $outstr .= '
'; echo $outstr; // Personal tag editing if ($canedit) { $title = get_string('editmytagsfor', $tagslang, '"'.$coursefullname.' ('.$courseshortname.')"'); echo $OUTPUT->heading($title, 2, 'main mdl-align'); // Deletion here is open to the users own tags for this course only $selectoptions = ''; $coursetabs = ''; if ($options = coursetag_get_records($courseid, $USER->id)) { $coursetabs = '"'; foreach ($options as $option) { $selectoptions .= ''; $coursetabs .= $option->rawname . ', '; } $coursetabs = rtrim($coursetabs, ', '); $coursetabs .= '"'; } if ($coursetabs) { $outstr = '
'.get_string('editthiscoursetags', $tagslang, $coursetabs).'
'; } else { $outstr = '
'.get_string('editnopersonaltags', $tagslang).'
'; } // Print the add and delete form coursetag_get_jscript(); $edittagthisunit = get_string('edittagthisunit', $tagslang); $suggestedtagthisunit = get_string('suggestedtagthisunit', $tagslang); $arrowtitle = get_string('arrowtitle', $tagslang); $sesskey = sesskey(); $leftarrow = $OUTPUT->pix_url('t/arrow_left'); $outstr .= <<
EOT; if ($coursetabs) { $editdeletemytag = get_string('editdeletemytag', $tagslang); $outstr .= <<
EOT1; } $submitstr = get_string('submit'); $outstr .= <<
EOT2; echo $outstr; } echo $OUTPUT->footer();