original_string: public static function export_item_tags(
          int $userid,
          \context $context,
          array $subcontext,
          string $component,
          string $itemtype,
          int $itemid,
          bool $onlyuser = false
      ) {
          global $DB;
  
          // Ignore mdl_tag.userid here because it only reflects the user who originally created the tag.
          $sql = "SELECT
                      t.rawname
                    FROM {tag} t
              INNER JOIN {tag_instance} ti ON ti.tagid = t.id
                   WHERE ti.component = :component
                     AND ti.itemtype = :itemtype
                     AND ti.itemid = :itemid
                     ";
  
          if ($onlyuser) {
              $sql .= "AND ti.tiuserid = :userid";
          } else {
              $sql .= "AND (ti.tiuserid = 0 OR ti.tiuserid = :userid)";
          }
  
          $params = [
              'component' => $component,
              'itemtype' => $itemtype,
              'itemid' => $itemid,
              'userid' => $userid,
          ];
  
          if ($tags = $DB->get_fieldset_sql($sql, $params)) {
              $writer = \core_privacy\local\request\writer::with_context($context)
                  ->export_related_data($subcontext, 'tags', $tags);
          }
      }
code: public static function export_item_tags(
          int $userid,
          \context $context,
          array $subcontext,
          string $component,
          string $itemtype,
          int $itemid,
          bool $onlyuser = false
      ) {
          global $DB;
  
          // Ignore mdl_tag.userid here because it only reflects the user who originally created the tag.
          $sql = "SELECT
                      t.rawname
                    FROM {tag} t
              INNER JOIN {tag_instance} ti ON ti.tagid = t.id
                   WHERE ti.component = :component
                     AND ti.itemtype = :itemtype
                     AND ti.itemid = :itemid
                     ";
  
          if ($onlyuser) {
              $sql .= "AND ti.tiuserid = :userid";
          } else {
              $sql .= "AND (ti.tiuserid = 0 OR ti.tiuserid = :userid)";
          }
  
          $params = [
              'component' => $component,
              'itemtype' => $itemtype,
              'itemid' => $itemid,
              'userid' => $userid,
          ];
  
          if ($tags = $DB->get_fieldset_sql($sql, $params)) {
              $writer = \core_privacy\local\request\writer::with_context($context)
                  ->export_related_data($subcontext, 'tags', $tags);
          }
      }
code_tokens: public static function export_item_tags ( int $ userid , \ context $ context , array $ subcontext , string $ component , string $ itemtype , int $ itemid , bool $ onlyuser = false ) { global $ DB ; // Ignore mdl_tag.userid here because it only reflects the user who originally created the tag. $ sql = "SELECT
                      t.rawname
                    FROM {tag} t
              INNER JOIN {tag_instance} ti ON ti.tagid = t.id
                   WHERE ti.component = :component
                     AND ti.itemtype = :itemtype
                     AND ti.itemid = :itemid
                     " ; if ( $ onlyuser ) { $ sql .= "AND ti.tiuserid = :userid" ; } else { $ sql .= "AND (ti.tiuserid = 0 OR ti.tiuserid = :userid)" ; } $ params = [ 'component' => $ component , 'itemtype' => $ itemtype , 'itemid' => $ itemid , 'userid' => $ userid , ] ; if ( $ tags = $ DB -> get_fieldset_sql ( $ sql , $ params ) ) { $ writer = \ core_privacy \ local \ request \ writer :: with_context ( $ context ) -> export_related_data ( $ subcontext , 'tags' , $ tags ) ; } }
docstring: Store all tags which match the specified component, itemtype, and itemid.
  
  In most situations you will want to specify $onlyuser as false.
  This will fetch only tags where the user themselves set the tag, or where tags are a shared resource.
  
  If you specify $onlyuser as true, only the tags created by that user will be included.
  
  @param   int         $userid The user whose information is to be exported
  @param   \context    $context The context to export for
  @param   array       $subcontext The subcontext within the context to export this information
  @param   string      $component The component to fetch data from
  @param   string      $itemtype The itemtype that the data was exported in within the component
  @param   int         $itemid The itemid within that tag
  @param   bool        $onlyuser Whether to only export ratings that the current user has made, or all tags
docstring_tokens: Store all tags which match the specified component itemtype and itemid .