Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
/tag/ -> user.php (source)

Differences Between: [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

   1  <?php
   2  
   3  require_once('../config.php');
   4  require_once ('lib.php');
   5  
   6  $action = optional_param('action', '', PARAM_ALPHA);
   7  
   8  require_login();
   9  
  10  if (empty($CFG->usetags)) {
  11      print_error('tagdisabled');
  12  }
  13  
  14  if (isguestuser()) {
  15      print_error('noguest');
  16  }
  17  
  18  if (!confirm_sesskey()) {
  19      print_error('sesskey');
  20  }
  21  
  22  $usercontext = context_user::instance($USER->id);
  23  
  24  switch ($action) {
  25      case 'addinterest':
  26          if (!core_tag_tag::is_enabled('core', 'user')) {
  27              print_error('tagdisabled');
  28          }
  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));
  33          break;
  34  
  35      case 'removeinterest':
  36          if (!core_tag_tag::is_enabled('core', 'user')) {
  37              print_error('tagdisabled');
  38          }
  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));
  43          break;
  44  
  45      case 'flaginappropriate':
  46          require_capability('moodle/tag:flag', context_system::instance());
  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'));
  51          break;
  52  
  53      default:
  54          print_error('unknowaction');
  55          break;
  56  }