original_string: public static function get_contexts_for_group_member(int $userid, string $component, int $itemid = 0) {
          $contextlist = new contextlist();
  
          $sql = "SELECT ctx.id
                    FROM {groups_members} gm
                    JOIN {groups} g ON gm.groupid = g.id
                    JOIN {context} ctx ON g.courseid = ctx.instanceid AND ctx.contextlevel = :contextcourse
                   WHERE gm.userid = :userid AND gm.component = :component";
  
          $params = [
              'contextcourse' => CONTEXT_COURSE,
              'userid'        => $userid,
              'component'     => $component
          ];
  
          if ($itemid) {
              $sql .= ' AND gm.itemid = :itemid';
              $params['itemid'] = $itemid;
          }
  
          $contextlist->add_from_sql($sql, $params);
  
          // Get the contexts where the userid has group conversations.
          \core_message\privacy\provider::add_contexts_for_conversations($contextlist, $userid, 'core_group', 'groups', $itemid);
  
          return $contextlist;
      }
code: public static function get_contexts_for_group_member(int $userid, string $component, int $itemid = 0) {
          $contextlist = new contextlist();
  
          $sql = "SELECT ctx.id
                    FROM {groups_members} gm
                    JOIN {groups} g ON gm.groupid = g.id
                    JOIN {context} ctx ON g.courseid = ctx.instanceid AND ctx.contextlevel = :contextcourse
                   WHERE gm.userid = :userid AND gm.component = :component";
  
          $params = [
              'contextcourse' => CONTEXT_COURSE,
              'userid'        => $userid,
              'component'     => $component
          ];
  
          if ($itemid) {
              $sql .= ' AND gm.itemid = :itemid';
              $params['itemid'] = $itemid;
          }
  
          $contextlist->add_from_sql($sql, $params);
  
          // Get the contexts where the userid has group conversations.
          \core_message\privacy\provider::add_contexts_for_conversations($contextlist, $userid, 'core_group', 'groups', $itemid);
  
          return $contextlist;
      }
code_tokens: public static function get_contexts_for_group_member ( int $ userid , string $ component , int $ itemid = 0 ) { $ contextlist = new contextlist ( ) ; $ sql = "SELECT ctx.id
                    FROM {groups_members} gm
                    JOIN {groups} g ON gm.groupid = g.id
                    JOIN {context} ctx ON g.courseid = ctx.instanceid AND ctx.contextlevel = :contextcourse
                   WHERE gm.userid = :userid AND gm.component = :component" ; $ params = [ 'contextcourse' => CONTEXT_COURSE , 'userid' => $ userid , 'component' => $ component ] ; if ( $ itemid ) { $ sql .= ' AND gm.itemid = :itemid' ; $ params [ 'itemid' ] = $ itemid ; } $ contextlist -> add_from_sql ( $ sql , $ params ) ; // Get the contexts where the userid has group conversations. \ core_message \ privacy \ provider :: add_contexts_for_conversations ( $ contextlist , $ userid , 'core_group' , 'groups' , $ itemid ) ; return $ contextlist ; }
docstring: Get the list of contexts that contain group membership for the specified user.
  
  @param   int     $userid     The user to search.
  @param   string  $component  The component to check.
  @param   int     $itemid     Optional itemid associated with component.
  @return  contextlist         The contextlist containing the list of contexts.
docstring_tokens: Get the list of contexts that contain group membership for the specified user .