forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.php
56 lines (45 loc) · 1.54 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
<?php
require_once('../config.php');
require_once('lib.php');
$action = optional_param('action', '', PARAM_ALPHA);
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 (!core_tag_tag::is_enabled('core', 'user')) {
print_error('tagdisabled');
}
$tag = required_param('tag', PARAM_TAG);
core_tag_tag::add_item_tag('core', 'user', $USER->id, $usercontext, $tag);
$tc = core_tag_area::get_collection('core', 'user');
redirect(core_tag_tag::make_url($tc, $tag));
break;
case 'removeinterest':
if (!core_tag_tag::is_enabled('core', 'user')) {
print_error('tagdisabled');
}
$tag = required_param('tag', PARAM_TAG);
core_tag_tag::remove_item_tag('core', 'user', $USER->id, $tag);
$tc = core_tag_area::get_collection('core', 'user');
redirect(core_tag_tag::make_url($tc, $tag));
break;
case 'flaginappropriate':
require_capability('moodle/tag:flag', context_system::instance());
$id = required_param('id', PARAM_INT);
$tagobject = core_tag_tag::get($id, '*', MUST_EXIST);
$tagobject->flag();
redirect($tagobject->get_view_url(), get_string('responsiblewillbenotified', 'tag'));
break;
default:
print_error('unknowaction');
break;
}