original_string: private function get_read_receipts_from_posts(stdClass $user, array $groupedposts) {
          $forumdatamapper = $this->legacydatamapperfactory->get_forum_data_mapper();
          $trackedforums = [];
          $trackedpostids = [];
  
          foreach ($groupedposts as $group) {
              ['forum' => $forum, 'posts' => $posts] = $group;
              $forumid = $forum->get_id();
  
              if (!isset($trackedforums[$forumid])) {
                  $forumrecord = $forumdatamapper->to_legacy_object($forum);
                  $trackedforums[$forumid] = forum_tp_is_tracked($forumrecord, $user);
              }
  
              if ($trackedforums[$forumid]) {
                  foreach ($posts as $post) {
                      $trackedpostids[] = $post->get_id();
                  }
              }
          }
  
          if (empty($trackedpostids)) {
              return [];
          }
  
          // We can just load a single receipt collection for all tracked posts.
          $receiptvault = $this->vaultfactory->get_post_read_receipt_collection_vault();
          $readreceiptcollection = $receiptvault->get_from_user_id_and_post_ids($user->id, $trackedpostids);
          $receiptsbyforumid = [];
  
          // Assign the collection to all forums that are tracked.
          foreach ($trackedforums as $forumid => $tracked) {
              if ($tracked) {
                  $receiptsbyforumid[$forumid] = $readreceiptcollection;
              }
          }
  
          return $receiptsbyforumid;
      }
code: private function get_read_receipts_from_posts(stdClass $user, array $groupedposts) {
          $forumdatamapper = $this->legacydatamapperfactory->get_forum_data_mapper();
          $trackedforums = [];
          $trackedpostids = [];
  
          foreach ($groupedposts as $group) {
              ['forum' => $forum, 'posts' => $posts] = $group;
              $forumid = $forum->get_id();
  
              if (!isset($trackedforums[$forumid])) {
                  $forumrecord = $forumdatamapper->to_legacy_object($forum);
                  $trackedforums[$forumid] = forum_tp_is_tracked($forumrecord, $user);
              }
  
              if ($trackedforums[$forumid]) {
                  foreach ($posts as $post) {
                      $trackedpostids[] = $post->get_id();
                  }
              }
          }
  
          if (empty($trackedpostids)) {
              return [];
          }
  
          // We can just load a single receipt collection for all tracked posts.
          $receiptvault = $this->vaultfactory->get_post_read_receipt_collection_vault();
          $readreceiptcollection = $receiptvault->get_from_user_id_and_post_ids($user->id, $trackedpostids);
          $receiptsbyforumid = [];
  
          // Assign the collection to all forums that are tracked.
          foreach ($trackedforums as $forumid => $tracked) {
              if ($tracked) {
                  $receiptsbyforumid[$forumid] = $readreceiptcollection;
              }
          }
  
          return $receiptsbyforumid;
      }
code_tokens: private function get_read_receipts_from_posts ( stdClass $ user , array $ groupedposts ) { $ forumdatamapper = $ this -> legacydatamapperfactory -> get_forum_data_mapper ( ) ; $ trackedforums = [ ] ; $ trackedpostids = [ ] ; foreach ( $ groupedposts as $ group ) { [ 'forum' => $ forum , 'posts' => $ posts ] = $ group ; $ forumid = $ forum -> get_id ( ) ; if ( ! isset ( $ trackedforums [ $ forumid ] ) ) { $ forumrecord = $ forumdatamapper -> to_legacy_object ( $ forum ) ; $ trackedforums [ $ forumid ] = forum_tp_is_tracked ( $ forumrecord , $ user ) ; } if ( $ trackedforums [ $ forumid ] ) { foreach ( $ posts as $ post ) { $ trackedpostids [ ] = $ post -> get_id ( ) ; } } } if ( empty ( $ trackedpostids ) ) { return [ ] ; } // We can just load a single receipt collection for all tracked posts. $ receiptvault = $ this -> vaultfactory -> get_post_read_receipt_collection_vault ( ) ; $ readreceiptcollection = $ receiptvault -> get_from_user_id_and_post_ids ( $ user -> id , $ trackedpostids ) ; $ receiptsbyforumid = [ ] ; // Assign the collection to all forums that are tracked. foreach ( $ trackedforums as $ forumid => $ tracked ) { if ( $ tracked ) { $ receiptsbyforumid [ $ forumid ] = $ readreceiptcollection ; } } return $ receiptsbyforumid ; }
docstring: Get the read receipt collections for the given viewing user and each forum. The
  receipt collections will only be loaded for posts in forums that the user is tracking.
  
  The receipt collections are returned in an array indexed by the forum ids.
  
  @param stdClass $user The user viewing the posts.
  @param array $groupedposts List of posts grouped by discussions.
docstring_tokens: Get the read receipt collections for the given viewing user and each forum . The receipt collections will only be loaded for posts in forums that the user is tracking .