Delete one unused table when grading online assignment submissions.
[moodle.git] / tag / edit.php
CommitLineData
c933a060 1<?php // $Id$
2
3require_once('../config.php');
4require_once('lib.php');
5require_once('edit_form.php');
6require_once($CFG->dirroot.'/lib/weblib.php');
7
8require_login();
9
10if( empty($CFG->usetags)) {
11 error(get_string('tagsaredisabled', 'tag'));
12}
13
14$tagid = required_param('id', PARAM_INT); // user id
15$tag = tag_by_id($tagid);
4f81c51d 16$tagname = tag_display_name($tag);
c933a060 17
4f81c51d 18//Editing a tag requires moodle/tag:edit capability
c933a060 19$systemcontext = get_context_instance(CONTEXT_SYSTEM);
4f81c51d 20require_capability('moodle/tag:edit', $systemcontext);
c933a060 21
22// set the relatedtags field of the $tag object that will be passed to the form
23$tag->relatedtags = tag_names_csv( get_item_tags('tag',$tagid) );
24
25$tagform = new tag_edit_form();
26$tagform->set_data($tag);
27
28// if new data has been sent, update the tag record
29if ($tagnew = $tagform->get_data()) {
30
31 $tagnew->timemodified = time();
32
33 if (!update_record('tag', $tagnew)) {
34 error('Error updating tag record');
35 }
36
37 //updated related tags
38 update_item_tags('tag', $tagnew->id, $tagnew->relatedtags);
39
40 redirect($CFG->wwwroot.'/tag/index.php?id='.$tagnew->id);
41}
42
43
44$navlinks = array();
45$navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
46$navlinks[] = array('name' => $tagname, 'link' => '', 'type' => '');
47
48$navigation = build_navigation($navlinks);
49print_header_simple(get_string('tag', 'tag') . ' - '. $tagname, '', $navigation);
50
51print_heading($tagname, '', 2);
52
53$tagform->display();
54
55
9ee998a5 56echo require_js('yui_dom-event');
57echo require_js('yui_connection');
58echo require_js('yui_animation');
59echo require_js('yui_autocomplete');
c933a060 60
9ee998a5 61?>
c933a060 62
63<script type="text/javascript">
64
65// An XHR DataSource
66var myServer = "./tag_autocomplete.php";
67var myDataSource = new YAHOO.widget.DS_XHR(myServer, ["\n", "\t"]);
68myDataSource.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
69myDataSource.maxCacheEntries = 60;
70myDataSource.queryMatchSubset = true;
71
72var myAutoComp = new YAHOO.widget.AutoComplete("id_relatedtags","relatedtags-autocomplete", myDataSource);
73myAutoComp.delimChar = ",";
74myAutoComp.maxResultsDisplayed = 20;
75myAutoComp.minQueryLength = 2;
76myAutoComp.allowBrowserAutocomplete = false;
77</script>
78
79<?php
80
81print_footer();
82
83?>