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');
27 if (empty($tag) && $id) { // for backward-compatibility (people saving bookmarks, mostly..)
28 $tag = tag_get_name($id);
31 tag_set_add('user', $USER->id
, $tag);
33 redirect($CFG->wwwroot
.'/tag/index.php?tag='. rawurlencode($tag));
36 case 'removeinterest':
37 if (empty($tag) && $id) { // for backward-compatibility (people saving bookmarks, mostly..)
38 $tag = tag_get_name($id);
41 tag_set_delete('user', $USER->id
, $tag);
43 redirect($CFG->wwwroot
.'/tag/index.php?tag='. rawurlencode($tag));
46 case 'flaginappropriate':
48 $tagid = tag_get_id($tag);
49 // Add flaging action to logs
50 add_to_log(SITEID
, 'tag', 'flag', 'index.php?id='. $tagid, $tagid, '', $USER->id
);
54 redirect($CFG->wwwroot
.'/tag/index.php?tag='. rawurlencode($tag), get_string('responsiblewillbenotified', 'tag'));
58 print_error('unknowaction');