예제 #1
0
$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');
        }
    }
    if (!has_capability('moodle/tag:manage', $systemcontext)) {
        unset($tagnew->name);
        unset($tagnew->rawname);
    } else {
        // They might be trying to change the rawname, make sure it's a change that doesn't affect name
        $norm = tag_normalize($tagnew->rawname, TAG_CASE_LOWER);
예제 #2
0
파일: edit.php 프로젝트: bewanyk/moodle
// set the relatedtags field of the $tag object that will be passed to the form
$data = $tag->to_object();
$data->relatedtags = core_tag_tag::get_item_tags_array('core', 'tag', $tag->id);
$options = new stdClass();
$options->smiley = false;
$options->filter = false;
// convert and remove any XSS
$data->description = format_text($tag->description, $tag->descriptionformat, $options);
$data->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));
$data = file_prepare_standard_editor($data, 'description', $editoroptions, $systemcontext, 'tag', 'description', $data->id);
$tagform = new tag_edit_form(null, array('editoroptions' => $editoroptions, 'tag' => $tag));
$data->tagtype = $data->tagtype === 'official' ? '1' : '0';
$data->returnurl = $returnurl;
$tagform->set_data($data);
if ($tagform->is_cancelled()) {
    redirect($returnurl ? new moodle_url($returnurl) : $tag->get_view_url());
} else {
    if ($tagnew = $tagform->get_data()) {
        // If new data has been sent, update the tag record.
        $updatedata = array();
        if (has_capability('moodle/tag:manage', $systemcontext)) {
            $updatedata['tagtype'] = empty($tagnew->tagtype) ? 'default' : 'official';
            $updatedata['rawname'] = $tagnew->rawname;
        }
        $tagnew = file_postupdate_standard_editor($tagnew, 'description', $editoroptions, $systemcontext, 'tag', 'description', $tag->id);
        $updatedata['description'] = $tagnew->description;
        $updatedata['descriptionformat'] = $tagnew->descriptionformat;
        // Update name, description and official type.
        $tag->update($updatedata);