$PAGE->set_context($systemcontext); $PAGE->set_blocks_editing_capability('moodle/tag:editblocks'); $PAGE->set_pagelayout('base'); $tagname = tag_display_name($tag); // set the relatedtags field of the $tag object that will be passed to the form $tag->relatedtags = tag_get_related_tags_csv(tag_get_related_tags($tag->id, TAG_RELATED_MANUAL), TAG_RETURN_TEXT); $options = new stdClass(); $options->smiley = false; $options->filter = false; // convert and remove any XSS $tag->description = format_text($tag->description, $tag->descriptionformat, $options); $tag->descriptionformat = FORMAT_HTML; $errorstring = ''; $editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'context' => $systemcontext, 'subdirs' => file_area_contains_subdirs($systemcontext, 'tag', 'description', $tag->id)); $tag = file_prepare_standard_editor($tag, 'description', $editoroptions, $systemcontext, 'tag', 'description', $tag->id); $tagform = new tag_edit_form(null, compact('editoroptions')); if ($tag->tagtype == 'official') { $tag->tagtype = '1'; } else { $tag->tagtype = '0'; } $tagform->set_data($tag); // If new data has been sent, update the tag record if ($tagnew = $tagform->get_data()) { if (has_capability('moodle/tag:manage', $systemcontext)) { if ($tag->tagtype != 'default' && (!isset($tagnew->tagtype) || $tagnew->tagtype != '1')) { tag_type_set($tag->id, 'default'); } elseif ($tag->tagtype != 'official' && $tagnew->tagtype == '1') { tag_type_set($tag->id, 'official'); } }
$PAGE->set_context($systemcontext); $PAGE->set_blocks_editing_capability('moodle/tag:editblocks'); $PAGE->set_pagelayout('standard'); $tagname = tag_display_name($tag); // set the relatedtags field of the $tag object that will be passed to the form $tag->relatedtags = tag_get_tags_array('tag', $tag->id); $options = new stdClass(); $options->smiley = false; $options->filter = false; // convert and remove any XSS $tag->description = format_text($tag->description, $tag->descriptionformat, $options); $tag->descriptionformat = FORMAT_HTML; $errorstring = ''; $editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'context' => $systemcontext, 'subdirs' => file_area_contains_subdirs($systemcontext, 'tag', 'description', $tag->id)); $tag = file_prepare_standard_editor($tag, 'description', $editoroptions, $systemcontext, 'tag', 'description', $tag->id); $tagform = new tag_edit_form(null, compact('editoroptions')); if ($tag->tagtype == 'official') { $tag->tagtype = '1'; } else { $tag->tagtype = '0'; } $tag->returnurl = $returnurl; $tagform->set_data($tag); // If new data has been sent, update the tag record if ($tagform->is_cancelled()) { redirect($returnurl ? new moodle_url($returnurl) : new moodle_url('/tag/index.php', array('tag' => $tag->name))); } else { if ($tagnew = $tagform->get_data()) { if (has_capability('moodle/tag:manage', $systemcontext)) { if ($tag->tagtype != 'default' && (!isset($tagnew->tagtype) || $tagnew->tagtype != '1')) { tag_type_set($tag->id, 'default');