weekly release 4.0dev
[moodle.git] / tag / user.php
CommitLineData
6bfe7aac 1<?php
c933a060 2
3require_once('../config.php');
3627b0e3 4require_once('lib.php');
c933a060 5
6$action = optional_param('action', '', PARAM_ALPHA);
6bfe7aac 7
c933a060 8require_login();
9
10if (empty($CFG->usetags)) {
aad67397 11 print_error('tagdisabled');
c933a060 12}
13
d3d1fe07 14if (isguestuser()) {
cb1e9c74 15 print_error('noguest');
16}
17
18if (!confirm_sesskey()) {
19 print_error('sesskey');
20}
21
cc033d48 22$usercontext = context_user::instance($USER->id);
cb1e9c74 23
c933a060 24switch ($action) {
25 case 'addinterest':
c4e868d5
MG
26 if (!core_tag_tag::is_enabled('core', 'user')) {
27 print_error('tagdisabled');
6bfe7aac 28 }
c4e868d5
MG
29 $tag = required_param('tag', PARAM_TAG);
30 core_tag_tag::add_item_tag('core', 'user', $USER->id, $usercontext, $tag);
31 $tc = core_tag_area::get_collection('core', 'user');
32 redirect(core_tag_tag::make_url($tc, $tag));
c933a060 33 break;
34
3627b0e3 35 case 'removeinterest':
c4e868d5
MG
36 if (!core_tag_tag::is_enabled('core', 'user')) {
37 print_error('tagdisabled');
6bfe7aac 38 }
c4e868d5
MG
39 $tag = required_param('tag', PARAM_TAG);
40 core_tag_tag::remove_item_tag('core', 'user', $USER->id, $tag);
41 $tc = core_tag_area::get_collection('core', 'user');
42 redirect(core_tag_tag::make_url($tc, $tag));
3627b0e3 43 break;
44
c933a060 45 case 'flaginappropriate':
b771b31e 46 require_capability('moodle/tag:flag', context_system::instance());
c4e868d5
MG
47 $id = required_param('id', PARAM_INT);
48 $tagobject = core_tag_tag::get($id, '*', MUST_EXIST);
49 $tagobject->flag();
50 redirect($tagobject->get_view_url(), get_string('responsiblewillbenotified', 'tag'));
c933a060 51 break;
3627b0e3 52
53 default:
aad67397 54 print_error('unknowaction');
3627b0e3 55 break;
c933a060 56}