forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.php
59 lines (41 loc) · 1.42 KB
/
user.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
require_once('../config.php');
require_once('lib.php');
$action = optional_param('action', '', PARAM_ALPHA);
$id = optional_param('id', 0, PARAM_INT);
$tag = optional_param('tag', '', PARAM_TAG);
require_login();
if (empty($CFG->usetags)) {
print_error('tagdisabled');
}
if (isguestuser()) {
print_error('noguest');
}
if (!confirm_sesskey()) {
print_error('sesskey');
}
$usercontext = context_user::instance($USER->id);
switch ($action) {
case 'addinterest':
if (empty($tag) && $id) { // for backward-compatibility (people saving bookmarks, mostly..)
$tag = tag_get_name($id);
}
tag_set_add('user', $USER->id, $tag, 'core', $usercontext->id);
redirect($CFG->wwwroot.'/tag/index.php?tag='. rawurlencode($tag));
break;
case 'removeinterest':
if (empty($tag) && $id) { // for backward-compatibility (people saving bookmarks, mostly..)
$tag = tag_get_name($id);
}
tag_set_delete('user', $USER->id, $tag, 'core', $usercontext->id);
redirect($CFG->wwwroot.'/tag/index.php?tag='. rawurlencode($tag));
break;
case 'flaginappropriate':
$tagid = tag_get_id($tag);
tag_set_flag($tagid);
redirect($CFG->wwwroot.'/tag/index.php?tag='. rawurlencode($tag), get_string('responsiblewillbenotified', 'tag'));
break;
default:
print_error('unknowaction');
break;
}