original_string: public function is_favourited(discussion_entity $discussion, \context_module $forumcontext, \stdClass $user) {
          if (!isloggedin()) {
              return false;
          }
  
          $usercontext = \context_user::instance($user->id);
          $ufservice = \core_favourites\service_factory::get_service_for_user_context($usercontext);
          return $ufservice->favourite_exists('mod_forum', 'discussions', $discussion->get_id(), $forumcontext);
      }
code: public function is_favourited(discussion_entity $discussion, \context_module $forumcontext, \stdClass $user) {
          if (!isloggedin()) {
              return false;
          }
  
          $usercontext = \context_user::instance($user->id);
          $ufservice = \core_favourites\service_factory::get_service_for_user_context($usercontext);
          return $ufservice->favourite_exists('mod_forum', 'discussions', $discussion->get_id(), $forumcontext);
      }
code_tokens: public function is_favourited ( discussion_entity $ discussion , \ context_module $ forumcontext , \ stdClass $ user ) { if ( ! isloggedin ( ) ) { return false ; } $ usercontext = \ context_user :: instance ( $ user -> id ) ; $ ufservice = \ core_favourites \ service_factory :: get_service_for_user_context ( $ usercontext ) ; return $ ufservice -> favourite_exists ( 'mod_forum' , 'discussions' , $ discussion -> get_id ( ) , $ forumcontext ) ; }
docstring: Check whether the provided discussion has been favourited by the user.
  
  @param discussion_entity $discussion The discussion record
  @param \context_module $forumcontext Forum context
  @param \stdClass $user The user to check the favourite against
  
  @return bool Whether or not the user has favourited the discussion
docstring_tokens: Check whether the provided discussion has been favourited by the user .