3 require_once('../config.php');
4 require_once('lib.php');
6 $action = optional_param('action', '', PARAM_ALPHA
);
7 $id = optional_param('id', 0, PARAM_INT
);
8 $tag = optional_param('tag', '', PARAM_TAG
);
12 if (empty($CFG->usetags
)) {
13 print_error('tagdisabled');
17 print_error('noguest');
20 if (!confirm_sesskey()) {
21 print_error('sesskey');
24 $usercontext = context_user
::instance($USER->id
);
28 if (empty($tag) && $id) { // for backward-compatibility (people saving bookmarks, mostly..)
29 $tag = tag_get_name($id);
32 tag_set_add('user', $USER->id
, $tag, 'core', $usercontext->id
);
34 redirect($CFG->wwwroot
.'/tag/index.php?tag='. rawurlencode($tag));
37 case 'removeinterest':
38 if (empty($tag) && $id) { // for backward-compatibility (people saving bookmarks, mostly..)
39 $tag = tag_get_name($id);
42 tag_set_delete('user', $USER->id
, $tag, 'core', $usercontext->id
);
44 redirect($CFG->wwwroot
.'/tag/index.php?tag='. rawurlencode($tag));
47 case 'flaginappropriate':
48 require_capability('moodle/tag:flag', context_system
::instance());
49 $tagid = tag_get_id($tag);
53 redirect($CFG->wwwroot
.'/tag/index.php?tag='. rawurlencode($tag), get_string('responsiblewillbenotified', 'tag'));
57 print_error('unknowaction');