3 require_once('../config.php');
4 require_once('lib.php');
5 require_once('edit_form.php');
7 require_js(array('yui_dom-event', 'yui_connection', 'yui_animation', 'yui_autocomplete'));
11 if (empty($CFG->usetags
)) {
12 error(get_string('tagsaredisabled', 'tag'));
15 $tagid = required_param('id', PARAM_INT
); // user id
17 $tag = tag_by_id($tagid);
18 $tagname = tag_display_name($tag);
20 //Editing a tag requires moodle/tag:edit capability
21 $systemcontext = get_context_instance(CONTEXT_SYSTEM
);
22 require_capability('moodle/tag:edit', $systemcontext);
24 // set the relatedtags field of the $tag object that will be passed to the form
25 $tag->relatedtags
= tag_names_csv(get_item_tags('tag',$tagid));
27 if (can_use_html_editor()) {
28 $options = new object();
29 $options->smiley
= false;
30 $options->filter
= false;
32 // convert and remove any XSS
33 $tag->description
= format_text($tag->description
, $tag->descriptionformat
, $options);
34 $tag->descriptionformat
= FORMAT_HTML
;
37 $tagform = new tag_edit_form();
38 $tagform->set_data($tag);
40 // if new data has been sent, update the tag record
41 if ($tagnew = $tagform->get_data()) {
43 $tagnew->timemodified
= time();
45 if (!update_record('tag', $tagnew)) {
46 error('Error updating tag record');
49 //updated related tags
50 update_item_tags('tag', $tagnew->id
, $tagnew->relatedtags
);
52 redirect($CFG->wwwroot
.'/tag/index.php?id='.$tagnew->id
);
57 $navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
58 $navlinks[] = array('name' => $tagname, 'link' => '', 'type' => '');
60 $navigation = build_navigation($navlinks);
61 print_header_simple(get_string('tag', 'tag') . ' - '. $tagname, '', $navigation);
63 print_heading($tagname, '', 2);
70 <script type
="text/javascript">
73 var myServer
= "./tag_autocomplete.php";
74 var myDataSource
= new YAHOO
.widget
.DS_XHR(myServer
, ["\n", "\t"]);
75 myDataSource
.responseType
= YAHOO
.widget
.DS_XHR
.TYPE_FLAT
;
76 myDataSource
.maxCacheEntries
= 60;
77 myDataSource
.queryMatchSubset
= true;
79 var myAutoComp
= new YAHOO
.widget
.AutoComplete("id_relatedtags","relatedtags-autocomplete", myDataSource
);
80 myAutoComp
.delimChar
= ",";
81 myAutoComp
.maxResultsDisplayed
= 20;
82 myAutoComp
.minQueryLength
= 2;
83 myAutoComp
.allowBrowserAutocomplete
= false;