original_string: public static function is_subscribed($userid, $forum, $discussionid = null, $cm = null) {
          // If forum is force subscribed and has allowforcesubscribe, then user is subscribed.
          if (self::is_forcesubscribed($forum)) {
              if (!$cm) {
                  $cm = get_fast_modinfo($forum->course)->instances['forum'][$forum->id];
              }
              if (has_capability('mod/forum:allowforcesubscribe', \context_module::instance($cm->id), $userid)) {
                  return true;
              }
          }
  
          if ($discussionid === null) {
              return self::is_subscribed_to_forum($userid, $forum);
          }
  
          $subscriptions = self::fetch_discussion_subscription($forum->id, $userid);
  
          // Check whether there is a record for this discussion subscription.
          if (isset($subscriptions[$discussionid])) {
              return ($subscriptions[$discussionid] != self::FORUM_DISCUSSION_UNSUBSCRIBED);
          }
  
          return self::is_subscribed_to_forum($userid, $forum);
      }
code: public static function is_subscribed($userid, $forum, $discussionid = null, $cm = null) {
          // If forum is force subscribed and has allowforcesubscribe, then user is subscribed.
          if (self::is_forcesubscribed($forum)) {
              if (!$cm) {
                  $cm = get_fast_modinfo($forum->course)->instances['forum'][$forum->id];
              }
              if (has_capability('mod/forum:allowforcesubscribe', \context_module::instance($cm->id), $userid)) {
                  return true;
              }
          }
  
          if ($discussionid === null) {
              return self::is_subscribed_to_forum($userid, $forum);
          }
  
          $subscriptions = self::fetch_discussion_subscription($forum->id, $userid);
  
          // Check whether there is a record for this discussion subscription.
          if (isset($subscriptions[$discussionid])) {
              return ($subscriptions[$discussionid] != self::FORUM_DISCUSSION_UNSUBSCRIBED);
          }
  
          return self::is_subscribed_to_forum($userid, $forum);
      }
code_tokens: public static function is_subscribed ( $ userid , $ forum , $ discussionid = null , $ cm = null ) { // If forum is force subscribed and has allowforcesubscribe, then user is subscribed. if ( self :: is_forcesubscribed ( $ forum ) ) { if ( ! $ cm ) { $ cm = get_fast_modinfo ( $ forum -> course ) -> instances [ 'forum' ] [ $ forum -> id ] ; } if ( has_capability ( 'mod/forum:allowforcesubscribe' , \ context_module :: instance ( $ cm -> id ) , $ userid ) ) { return true ; } } if ( $ discussionid === null ) { return self :: is_subscribed_to_forum ( $ userid , $ forum ) ; } $ subscriptions = self :: fetch_discussion_subscription ( $ forum -> id , $ userid ) ; // Check whether there is a record for this discussion subscription. if ( isset ( $ subscriptions [ $ discussionid ] ) ) { return ( $ subscriptions [ $ discussionid ] != self :: FORUM_DISCUSSION_UNSUBSCRIBED ) ; } return self :: is_subscribed_to_forum ( $ userid , $ forum ) ; }
docstring: Whether a user is subscribed to this forum, or a discussion within
  the forum.
  
  If a discussion is specified, then report whether the user is
  subscribed to posts to this particular discussion, taking into
  account the forum preference.
  
  If it is not specified then only the forum preference is considered.
  
  @param int $userid The user ID
  @param \stdClass $forum The record of the forum to test
  @param int $discussionid The ID of the discussion to check
  @param $cm The coursemodule record. If not supplied, this will be calculated using get_fast_modinfo instead.
  @return boolean
docstring_tokens: Whether a user is subscribed to this forum or a discussion within the forum .